protected override void ScanSpan(ref int i) { if (!spanStack.Any(s => s is CodeDeclarationSpan || s is CodeExpressionSpan) && i + 3 < doc.Length && doc.GetTextAt(i, 2) == "<%" && doc.GetCharAt(i + 2) != '@') { var span = new CodeExpressionSpan(GetDefaultMime()); spanStack.Push(span); ruleStack.Push(GetRule(span)); OnFoundSpanBegin(span, i, doc.GetCharAt(i + 2) == '=' ? 3 : 2); return; } if (i > 0 && doc.GetCharAt(i - 1) == '>') { int k = i - 1; while (k > 0 && doc.GetCharAt(k) != '<') { k--; } if (k + 7 < doc.Length && doc.GetTextAt(k, 7) == "<script") { int j = k + 7; string mime = "application/javascript"; while (j < doc.Length && doc.GetCharAt(j) != '>') { if (j + 8 < doc.Length && doc.GetTextAt(j, 8) == "language") { j += 8; mime = GetMimeForLanguage(GetAttributeValue(ref j)); break; } if (j + 5 < doc.Length && doc.GetTextAt(j, 5) == "runat") { j += 5; GetAttributeValue(ref j); mime = GetDefaultMime(); break; } if (j + 4 < doc.Length && doc.GetTextAt(j, 4) == "type") { j += 4; mime = GetAttributeValue(ref j); break; } j++; } if (mime != null) { CodeDeclarationSpan span = new CodeDeclarationSpan(mime); spanStack.Push(span); ruleStack.Push(GetRule(span)); OnFoundSpanBegin(span, i, 0); return; } } } base.ScanSpan(ref i); }
protected override bool ScanSpan(ref int i) { if (!spanStack.Any(s => s is CodeDeclarationSpan || s is CodeExpressionSpan) && i + 4 < doc.TextLength && doc.GetTextAt(i, 2) == "<%" && doc.GetTextAt(i, 4) != "<%--" && doc.GetCharAt(i + 2) != '@') { var span = new CodeExpressionSpan(GetDefaultMime()); FoundSpanBegin(span, i, 2); return(true); } if (i > 0 && doc.GetCharAt(i) == '>') { int k = i; while (k > 0 && doc.GetCharAt(k) != '<') { k--; } if (k + 7 < doc.TextLength && doc.GetTextAt(k, 7) == "<script") { int j = k + "<script".Length; string mime = "application/javascript"; while (j < doc.TextLength && doc.GetCharAt(j) != '>') { if (j + 8 < doc.TextLength && doc.GetTextAt(j, 8) == "language") { j += 8; mime = GetMimeForLanguage(GetAttributeValue(ref j)); break; } if (j + 5 < doc.TextLength && doc.GetTextAt(j, 5) == "runat") { j += 5; GetAttributeValue(ref j); mime = GetDefaultMime(); break; } if (j + 4 < doc.TextLength && doc.GetTextAt(j, 4) == "type") { j += 4; mime = GetAttributeValue(ref j); break; } j++; } if (mime != null) { CodeDeclarationSpan span = new CodeDeclarationSpan(mime); try { FoundSpanBegin(span, i, 0); return(true); } catch (Exception ex) { LoggingService.LogInternalError(ex); } } } } return(base.ScanSpan(ref i)); }
protected override bool ScanSpanEnd (Mono.TextEditor.Highlighting.Span cur, int i) { if (doc.GetCharAt (i) == '>') { int j = i - 1; while (j > 0) { char ch = doc.GetCharAt (j); if (ch == '<') break; if (ch == '>') break; j--; } if (j + 7 < doc.Length && doc.GetTextAt (j, 7) == "<script") { StringBuilder langBuilder = new StringBuilder (); j += 7; while (j < doc.Length && doc.GetCharAt (j) != '>') { if (j + 8 < doc.Length && doc.GetTextAt (j, 8) == "language") { j += 8; bool inString = false; while (j < doc.Length) { char ch = doc.GetCharAt (j); if (ch == '"' || ch == '\'') { if (inString) break; inString = true; j++; continue; } if (inString) langBuilder.Append (ch); j++; } break; } j++; } string mime = langBuilder.Length != 0 ? GetMimeForLanguage (langBuilder.ToString ()) : GetDefaultMime (); if (mime != null) { bool result = base.ScanSpanEnd (cur, i); CodeDeclarationSpan span = new CodeDeclarationSpan (mime); spanStack.Push (span); ruleStack.Push (GetRule (span)); OnFoundSpanBegin (span, i + 1, 0); return result; } } } if (spanStack.Any (s => s is CodeDeclarationSpan) && i + 10 < doc.Length && doc.GetTextAt (i + 1, 9) == "</script>") { while (!(spanStack.Peek () is CodeDeclarationSpan)) { OnFoundSpanEnd (spanStack.Peek (), i, 0); spanStack.Pop (); if (ruleStack.Count > 1) ruleStack.Pop (); } cur = spanStack.Peek (); OnFoundSpanEnd (cur, i, 0); spanStack.Pop (); if (ruleStack.Count > 1) ruleStack.Pop (); return true; } if (spanStack.Any (s => s is CodeExpressionSpan) && i + 2 < doc.Length && doc.GetTextAt (i, 2) == "%>") { while (!(spanStack.Peek () is CodeExpressionSpan)) { OnFoundSpanEnd (spanStack.Peek (), i, 0); spanStack.Pop (); if (ruleStack.Count > 1) ruleStack.Pop (); } cur = spanStack.Peek (); OnFoundSpanEnd (cur, i, 0); spanStack.Pop (); if (ruleStack.Count > 1) ruleStack.Pop (); return true; } return base.ScanSpanEnd (cur, i); }
protected override void ScanSpan (ref int i) { if (!spanStack.Any (s => s is CodeDeclarationSpan || s is CodeExpressionSpan) && i + 3 < doc.Length && doc.GetTextAt (i, 2) == "<%" && doc.GetCharAt (i + 2) != '@') { var span = new CodeExpressionSpan (GetDefaultMime ()); spanStack.Push (span); ruleStack.Push (GetRule (span)); OnFoundSpanBegin (span, i, doc.GetCharAt (i + 2) == '=' ? 3 : 2); return; } if (i > 0 && doc.GetCharAt (i - 1) == '>') { int k = i - 1; while (k > 0 && doc.GetCharAt (k) != '<') { k--; } if (k + 7 < doc.Length && doc.GetTextAt (k, 7) == "<script") { int j = k + 7; string mime = "application/javascript"; while (j < doc.Length && doc.GetCharAt (j) != '>') { if (j + 8 < doc.Length && doc.GetTextAt (j, 8) == "language") { j += 8; mime = GetMimeForLanguage (GetAttributeValue (ref j)); break; } if (j + 5 < doc.Length && doc.GetTextAt (j, 5) == "runat") { j += 5; GetAttributeValue (ref j); mime = GetDefaultMime (); break; } if (j + 4 < doc.Length && doc.GetTextAt (j, 4) == "type") { j += 4; mime = GetAttributeValue (ref j); break; } j++; } if (mime != null) { CodeDeclarationSpan span = new CodeDeclarationSpan (mime); spanStack.Push (span); ruleStack.Push (GetRule (span)); OnFoundSpanBegin (span, i, 0); return; } } } base.ScanSpan (ref i); }
protected override bool ScanSpan (ref int i) { if (!spanStack.Any (s => s is CodeDeclarationSpan || s is CodeExpressionSpan) && i + 4 < doc.TextLength && doc.GetTextAt (i, 2) == "<%" && doc.GetTextAt (i, 4) != "<%--" && doc.GetCharAt (i + 2) != '@') { var span = new CodeExpressionSpan (GetDefaultMime ()); FoundSpanBegin (span, i, 2); return true; } if (i > 0 && doc.GetCharAt (i) == '>') { int k = i; while (k > 0 && doc.GetCharAt (k) != '<') { k--; } if (k + 7 < doc.TextLength && doc.GetTextAt (k, 7) == "<script") { int j = k + "<script".Length; string mime = "application/javascript"; while (j < doc.TextLength && doc.GetCharAt (j) != '>') { if (j + 8 < doc.TextLength && doc.GetTextAt (j, 8) == "language") { j += 8; mime = GetMimeForLanguage (GetAttributeValue (ref j)); break; } if (j + 5 < doc.TextLength && doc.GetTextAt (j, 5) == "runat") { j += 5; GetAttributeValue (ref j); mime = GetDefaultMime (); break; } if (j + 4 < doc.TextLength && doc.GetTextAt (j, 4) == "type") { j += 4; mime = GetAttributeValue (ref j); break; } j++; } if (mime != null) { CodeDeclarationSpan span = new CodeDeclarationSpan (mime); try { FoundSpanBegin (span, i, 0); return true; } catch (Exception ex) { LoggingService.LogInternalError (ex); } } } } return base.ScanSpan (ref i); }