This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 770
/
ISyntaxHighlighter.cs
73 lines (63 loc) · 2.44 KB
/
ISyntaxHighlighter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.SharpDevelop.Editor
{
/// <summary>
/// Represents the syntax highlighter inside the text editor.
/// </summary>
public interface ISyntaxHighlighter
{
/// <summary>
/// Retrieves the names of the spans that are active at the start of the specified line.
/// Nested spans are returned in inside-out order (first element of result enumerable is the innermost span).
/// </summary>
IEnumerable<string> GetSpanColorNamesFromLineStart(int lineNumber);
/// <summary>
/// Gets the highlighting definition that is being used.
/// </summary>
IHighlightingDefinition HighlightingDefinition { get; }
/// <summary>
/// Adds an additional highlighting engine that runs in addition to the XSHD-based highlighting.
/// </summary>
void AddAdditionalHighlighter(IHighlighter highlighter);
/// <summary>
/// Removes an additional highlighting engine.
/// </summary>
void RemoveAdditionalHighlighter(IHighlighter highlighter);
/// <summary>
/// Invalidates a line, causing it to be re-highlighted.
/// </summary>
/// <remarks>
/// This method is intended to be called by additional highlighters that process external information
/// (e.g. semantic highlighting).
/// </remarks>
void InvalidateLine(IDocumentLine line);
/// <summary>
/// Invalidates all lines, causing-them to be re-highlighted.
/// </summary>
/// <remarks>
/// This method is intended to be called by additional highlighters that process external information
/// (e.g. semantic highlighting).
/// </remarks>
void InvalidateAll();
}
public static class SyntaxHighligherKnownSpanNames
{
public const string Comment = "Comment";
public const string String = "String";
public const string Char = "Char";
public static bool IsLineStartInsideComment(this ISyntaxHighlighter highligher, int lineNumber)
{
return highligher.GetSpanColorNamesFromLineStart(lineNumber).Contains(Comment);
}
public static bool IsLineStartInsideString(this ISyntaxHighlighter highligher, int lineNumber)
{
return highligher.GetSpanColorNamesFromLineStart(lineNumber).Contains(String);
}
}
}