added some development tools
[windows-sources.git] / developer / VSSDK / VisualStudioIntegration / Common / Source / CSharp / LanguageService100 / Scanner.cs
blob1254e2337c1b0450f2ab9f438b8858ea2aaba525
1 using System;
3 namespace Microsoft.VisualStudio.Package {
4 /// <include file='doc\Scanner.uex' path='docs/doc[@for="IScanner"]/*' />
5 /// <summary>
6 /// Scans individual source lines and provides coloring and trigger information about tokens.
7 /// </summary>
8 public interface IScanner {
9 /// <include file='doc\Scanner.uex' path='docs/doc[@for="IScanner.SetSource"]/*' />
10 /// <summary>
11 /// Used to (re)initialize the scanner before scanning a small portion of text, such as single source line for syntax coloring purposes
12 /// </summary>
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"]/*' />
18 /// <summary>
19 /// Scan the next token and fill in syntax coloring details about it in tokenInfo.
20 /// </summary>
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"]/*' />
29 Text,
30 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.Keyword"]/*' />
31 Keyword,
32 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.Comment"]/*' />
33 Comment,
34 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.Identifier"]/*' />
35 Identifier,
36 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.String"]/*' />
37 String,
38 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenColor.Number"]/*' />
39 Number
41 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenInfo"]/*' />
42 public class TokenInfo {
43 int startIndex;
44 int endIndex;
45 TokenColor color;
46 TokenType type;
47 TokenTriggers trigger;
48 int token;
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;"]/*' />
56 public int 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>
78 public int Token {
79 get { return token; }
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"]/*' />
90 /// <summary>
91 /// 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
98 ///
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)
105 /// </summary>
106 [FlagsAttribute]
107 public enum TokenTriggers {
108 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.None"]/*' />
109 None = 0x00,
110 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.MemberSelect"]/*' />
111 MemberSelect = 0x01,
112 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.MatchBraces"]/*' />
113 MatchBraces = 0x02,
114 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.MethodTip"]/*' />
115 MethodTip = 0xF0,
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"]/*' />
121 ParameterEnd = 0x40,
122 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenTriggers.Param"]/*' />
123 Parameter = 0x80
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"]/*' />
129 Unknown,
130 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Text"]/*' />
131 Text,
132 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Keyword"]/*' />
133 Keyword,
134 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Identifier"]/*' />
135 Identifier,
136 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.String"]/*' />
137 String,
138 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Literal"]/*' />
139 Literal,
140 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Operator"]/*' />
141 Operator,
142 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Delimiter"]/*' />
143 Delimiter,
144 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.WhiteSpace"]/*' />
145 WhiteSpace,
146 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.LineComment"]/*' />
147 LineComment,
148 /// <include file='doc\Scanner.uex' path='docs/doc[@for="TokenType.Comment"]/*' />
149 Comment,