3 namespace Microsoft
.VisualStudio
.Package
{
4 /// <include file='doc\Scanner.uex' path='docs/doc[@for="IScanner"]/*' />
6 /// Scans individual source lines and provides coloring and trigger information about tokens.
8 public interface IScanner
{
9 /// <include file='doc\Scanner.uex' path='docs/doc[@for="IScanner.SetSource"]/*' />
11 /// Used to (re)initialize the scanner before scanning a small portion of text, such as single source line for syntax coloring purposes
13 /// <param name="source">The source text portion to be scanned</param>
14 /// <param name="offset">The index of the first character to be scanned</param>
15 void SetSource(string source
, int offset
);
17 /// <include file='doc\Scanner.uex' path='docs/doc[@for="IScanner.ScanTokenAndProvideInfoAboutIt"]/*' />
19 /// Scan the next token and fill in syntax coloring details about it in tokenInfo.
21 /// <param name="tokenInfo">Keeps information about token.</param>
22 /// <param name="state">Keeps track of scanner state. In: state after last token. Out: state after current token.</param>
23 /// <returns></returns>
24 bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo
, ref int state
);
26 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor"]/*' />
27 public enum TokenColor
{
28 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.Text"]/*' />
30 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.Keyword"]/*' />
32 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.Comment"]/*' />
34 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.Identifier"]/*' />
36 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.String"]/*' />
38 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.Number"]/*' />
41 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo"]/*' />
42 public class TokenInfo
{
47 TokenTriggers trigger
;
50 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo.StartIndex;"]/*' />
51 public int StartIndex
{
52 get { return this.startIndex; }
53 set { this.startIndex = value; }
55 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo.EndIndex;"]/*' />
57 get { return this.endIndex; }
58 set { this.endIndex = value; }
60 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo.Color;"]/*' />
61 public TokenColor Color
{
62 get { return this.color; }
63 set { this.color = value; }
65 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo.Type;"]/*' />
66 public TokenType Type
{
67 get { return this.type; }
68 set { this.type = value; }
70 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo.Trigger;"]/*' />
71 public TokenTriggers Trigger
{
72 get { return this.trigger; }
73 set { this.trigger = value; }
76 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo.StartIndex;"]/*' />
77 /// <summary>Language Specific</summary>
80 set { token = value; }
83 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo.TokenInfo"]/*' />
84 public TokenInfo() { }
85 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo.TokenInfo1"]/*' />
86 public TokenInfo(int startIndex
, int endIndex
, TokenType type
) { this.startIndex = startIndex; this.endIndex = endIndex; this.type = type; }
89 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers"]/*' />
92 /// If a character has (a) trigger(s) associated with it, it may
93 /// fire one or both of the following triggers:
94 /// MemberSelect - a member selection tip window
95 /// MatchBraces - highlight matching braces
96 /// or the following trigger:
97 /// MethodTip - a method tip window
99 /// The following triggers exist for speed reasons: the (fast) lexer
100 /// determines when a (slow) parse might be needed.
101 /// The Trigger.MethodTip trigger is subdivided in 4
102 /// other triggers. It is the best to be as specific as possible;
103 /// it is better to return Trigger.ParamStart than Trigger.Param
104 /// (or Trigger.MethodTip)
107 public enum TokenTriggers
{
108 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.None"]/*' />
110 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.MemberSelect"]/*' />
112 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.MatchBraces"]/*' />
114 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.MethodTip"]/*' />
116 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.ParamStart"]/*' />
117 ParameterStart
= 0x10,
118 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.ParamNext"]/*' />
119 ParameterNext
= 0x20,
120 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.ParamEnd"]/*' />
122 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.Param"]/*' />
126 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType"]/*' />
127 public enum TokenType
{
128 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Unknown"]/*' />
130 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Text"]/*' />
132 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Keyword"]/*' />
134 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Identifier"]/*' />
136 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.String"]/*' />
138 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Literal"]/*' />
140 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Operator"]/*' />
142 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Delimiter"]/*' />
144 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.WhiteSpace"]/*' />
146 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.LineComment"]/*' />
148 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Comment"]/*' />