~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/AspNetSyntaxMode.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
{
38
38
        public class AspNetSyntaxMode : Mono.TextEditor.Highlighting.SyntaxMode
39
39
        {
40
 
                SyntaxMode charpMode;
 
40
        //      SyntaxMode charpMode;
41
41
                
42
42
                public AspNetSyntaxMode ()
43
43
                {
54
54
                        }
55
55
                }
56
56
                
57
 
                public override SpanParser CreateSpanParser (Mono.TextEditor.Document doc, SyntaxMode mode, LineSegment line, Stack<Span> spanStack)
 
57
                public override SpanParser CreateSpanParser (Mono.TextEditor.Document doc, SyntaxMode mode, LineSegment line, CloneableStack<Span> spanStack)
58
58
                {
59
 
                        return new ASPNetSpanParser (doc, mode, line, spanStack);
 
59
                        return new ASPNetSpanParser (doc, mode, spanStack ?? line.StartSpan.Clone ());
60
60
                }
61
61
 
62
62
                protected class ASPNetSpanParser : SpanParser
63
63
                {
64
 
                        public ASPNetSpanParser (Mono.TextEditor.Document doc, SyntaxMode mode, LineSegment line, Stack<Span> spanStack) : base (doc, mode, line, spanStack)
 
64
                        public ASPNetSpanParser (Mono.TextEditor.Document doc, SyntaxMode mode, CloneableStack<Span> spanStack) : base (doc, mode, spanStack)
65
65
                        {}
66
66
                        
67
67
                        class CodeExpressionSpan : Span
71
71
                                        Rule = "mode:" + language;
72
72
                                        Begin = new Regex ("<%");
73
73
                                        End = new Regex ("<%");
74
 
                                        Color = "text";
75
 
                                        TagColor = "text.markup.tag";
 
74
                                        Color = "template";
 
75
                                        TagColor = "template.tag";
76
76
                                }
77
77
                        }
78
78
                        
139
139
                        {
140
140
                                if (!spanStack.Any (s => s is CodeDeclarationSpan || s is CodeExpressionSpan) &&  i + 3 < doc.Length && doc.GetTextAt (i, 2) == "<%" && doc.GetCharAt (i + 2) != '@') {
141
141
                                        var span = new CodeExpressionSpan (GetDefaultMime ());
142
 
                                        spanStack.Push (span);
143
 
                                        ruleStack.Push (GetRule (span));
144
 
                                        OnFoundSpanBegin (span, i, doc.GetCharAt (i + 2) == '=' ? 3 : 2);
 
142
                                        FoundSpanBegin (span, i, "#$=:".IndexOf (doc.GetCharAt (i + 2)) >= 0? 3 : 2);
145
143
                                        return;
146
144
                                }
147
145
                                
176
174
                                                
177
175
                                                if (mime != null) {
178
176
                                                        CodeDeclarationSpan span = new CodeDeclarationSpan (mime);
179
 
                                                        spanStack.Push (span);
180
 
                                                        ruleStack.Push (GetRule (span));
181
 
                                                        OnFoundSpanBegin (span, i, 0);
 
177
                                                        FoundSpanBegin (span, i, 0);
182
178
                                                        return;
183
179
                                                }
184
180
                                        }
191
187
                        {
192
188
                                if (spanStack.Any (s => s is CodeDeclarationSpan) && i + 9 <= doc.Length && doc.GetTextAt (i, 9) == "</script>") {
193
189
                                        while (!(spanStack.Peek () is CodeDeclarationSpan)) {
194
 
                                                OnFoundSpanEnd (spanStack.Peek (), i, 0);
195
 
                                                spanStack.Pop ();
196
 
                                                if (ruleStack.Count > 1)
197
 
                                                        ruleStack.Pop ();
 
190
                                                FoundSpanEnd (spanStack.Peek (), i, 0);
198
191
                                        }
199
192
                                        cur = spanStack.Peek ();
200
 
                                        OnFoundSpanEnd (cur, i, "</script>".Length);
201
193
                                        i += "</script>".Length;
202
 
                                        spanStack.Pop ();
203
 
                                        if (ruleStack.Count > 1)
204
 
                                                ruleStack.Pop ();
 
194
                                        FoundSpanEnd (cur, i, "</script>".Length);
205
195
                                        return true;
206
196
                                }
207
197
                                
208
198
                                if (spanStack.Any (s => s is CodeExpressionSpan) && i + 2 < doc.Length && doc.GetTextAt (i, 2) == "%>") {
209
199
                                        while (!(spanStack.Peek () is CodeExpressionSpan)) {
210
 
                                                OnFoundSpanEnd (spanStack.Peek (), i, 0);
211
 
                                                spanStack.Pop ();
212
 
                                                if (ruleStack.Count > 1)
213
 
                                                        ruleStack.Pop ();
 
200
                                                FoundSpanEnd (spanStack.Peek (), i, 0);
214
201
                                        }
215
202
                                        cur = spanStack.Peek ();
216
 
                                        OnFoundSpanEnd (cur, i, 2);
217
 
                                        spanStack.Pop ();
218
 
                                        if (ruleStack.Count > 1)
219
 
                                                ruleStack.Pop ();
 
203
                                        FoundSpanEnd (cur, i, 2);
220
204
                                        return true;
221
205
                                }
222
206
                                return base.ScanSpanEnd (cur, ref i);