Browse Source

- added keywords to CC

- added some snippets

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@6068 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
8671ab60c2
  1. 39
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetManager.cs
  2. 2
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg
  3. 7
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt
  4. 12
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs
  5. 7
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs
  6. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs
  7. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/VBNetExpressionFinder.cs

39
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetManager.cs

@ -84,8 +84,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets
Description = "Switch statement", Description = "Switch statement",
// dynamic switch snippet (inserts switch body dependent on condition) // dynamic switch snippet (inserts switch body dependent on condition)
Text = "switch (${condition}) {\n\t${refactoring:switchbody}\n}" Text = "switch (${condition}) {\n\t${refactoring:switchbody}\n}"
// static switch snippet (always inserts the same, independent of condition) // static switch snippet (always inserts the same, independent of condition)
//Text = "switch (${condition}) {\n\tcase ${firstcase=0}:\n\t\t${Caret}\n\t\tbreak;\n\tdefault:\n\t\t${Selection}\n\t\tbreak;\n}" //Text = "switch (${condition}) {\n\tcase ${firstcase=0}:\n\t\t${Caret}\n\t\tbreak;\n\tdefault:\n\t\t${Selection}\n\t\tbreak;\n}"
}, },
new CodeSnippet { new CodeSnippet {
Name = "try", Name = "try",
@ -103,6 +103,41 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets
Text = "try {\n\t${Selection}\n} finally {\n\t${Caret}\n}" Text = "try {\n\t${Selection}\n} finally {\n\t${Caret}\n}"
}, },
} }
},
new CodeSnippetGroup {
Extensions = ".vb",
Snippets = {
new CodeSnippet {
Name = "If",
Description = "If statement",
Text = "If ${condition} Then\n" +
"\t${Selection}\n" +
"End If"
},
new CodeSnippet {
Name = "IfElse",
Description = "If-Else statement",
Text = "If ${condition} Then\n" +
"\t${Selection}\n" +
"Else\n" +
"\t${Caret}\n" +
"End If"
},
new CodeSnippet {
Name = "For",
Description = "For loop",
Text = "For ${counter=i} As ${type=Integer} = ${start=0} To ${end}\n" +
"\t${Selection}\n" +
"Next ${counter}"
},
new CodeSnippet {
Name = "ForStep",
Description = "For loop with Step",
Text = "For ${counter=i} As ${type=Integer} = ${start=0} To ${end} Step ${step=1}\n" +
"\t${Selection}\n" +
"Next ${counter}"
}
}
} }
}; };

2
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg

@ -296,7 +296,7 @@ NamespaceMemberDeclaration =
. .
NamespaceDeclaration = NamespaceDeclaration =
"Namespace" { ANY } StatementTerminator "Namespace" (. PushContext(Context.IdentifierExpected, la, t); .) { ANY } (. PopContext(); .) StatementTerminator
{ NamespaceMemberDeclaration } { NamespaceMemberDeclaration }
"End" "Namespace" StatementTerminator "End" "Namespace" StatementTerminator
. .

7
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt

@ -274,6 +274,11 @@ TypeLevel("Sub", "Function", "Property")
# List of keywords that are valid identifiers, must be the same as the "Identifier" production in VBNET.ATG # List of keywords that are valid identifiers, must be the same as the "Identifier" production in VBNET.ATG
IdentifierTokens("Text", "Binary", "Compare", "Assembly", "Ansi", "Auto", "Preserve", "Unicode", "Until", "Off", "Out", "Key", "Explicit", "Infer", "From", "Join", "Equals", "Distinct", "Where", "Take", "Skip", "Order", "By", "Ascending", "Descending", "Group", "Into", "Aggregate") IdentifierTokens("Text", "Binary", "Compare", "Assembly", "Ansi", "Auto", "Preserve", "Unicode", "Until", "Off", "Out", "Key", "Explicit", "Infer", "From", "Join", "Equals", "Distinct", "Where", "Take", "Skip", "Order", "By", "Ascending", "Descending", "Group", "Into", "Aggregate")
ExpressionStart("Me", "MyBase", "MyClass", "False", "New", "Nothing", "True", "GetType") ExpressionStart("Me", "MyBase", "MyClass", @BooleanExpressions, @OperatorsAtStart, "New", @Null, "AddressOf", "GetType", "TypeOf", "GetXmlNamespace", "Global", @TypeKW, @LambdaStart, @CastExpressions)
StatementStart(@Null, @ExpressionStart, "Dim", "Const", "Static", "For", "While", "Do", "Select")
SimpleTypeName(@TypeKW, @IdentifierTokens) SimpleTypeName(@TypeKW, @IdentifierTokens)
CastExpressions("DirectCast", "TryCast", "CType", "CBool", "CByte", "CChar", "CDate", "CDec", "CDbl", "CInt", "CLng", "CObj", "CSByte", "CShort", "CSng", "CStr", "CUInt", "CULng", "CUShort")
BooleanExpressions("True", "False")
LambdaStart("Sub", "Function")
OperatorsAtStart("Not", "From", "Aggregate")
TypeKW("Boolean", "Date", "Char", "String", "Decimal", "Byte", "Short", "Integer", "Long", "Single", "Double", "UInteger", "ULong", "UShort", "SByte") TypeKW("Boolean", "Date", "Char", "String", "Decimal", "Byte", "Short", "Integer", "Long", "Single", "Double", "UInteger", "ULong", "UShort", "SByte")

12
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs

@ -104,7 +104,8 @@ partial class ExpressionFinder {
case 5: { case 5: {
if (la == null) { currentState = 5; break; } if (la == null) { currentState = 5; break; }
if (la.kind == 160) { if (la.kind == 160) {
goto case 446; currentState = 446;
break;
} else { } else {
if (set[1, la.kind]) { if (set[1, la.kind]) {
goto case 7; goto case 7;
@ -3475,15 +3476,16 @@ partial class ExpressionFinder {
} }
} }
case 446: { case 446: {
if (la == null) { currentState = 446; break; } PushContext(Context.IdentifierExpected, la, t);
currentState = 447; goto case 447;
break;
} }
case 447: { case 447: {
if (la == null) { currentState = 447; break; } if (la == null) { currentState = 447; break; }
if (set[26, la.kind]) { if (set[26, la.kind]) {
goto case 446; currentState = 447;
break;
} else { } else {
PopContext();
stateStack.Push(448); stateStack.Push(448);
goto case 15; goto case 15;
} }

7
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs

@ -264,8 +264,13 @@ namespace ICSharpCode.NRefactory.Parser.VB
public static BitArray GlobalLevel = NewSet(Namespace, Module, Class, Structure, Imports, Option); public static BitArray GlobalLevel = NewSet(Namespace, Module, Class, Structure, Imports, Option);
public static BitArray TypeLevel = NewSet(Sub, Function, Property); public static BitArray TypeLevel = NewSet(Sub, Function, Property);
public static BitArray IdentifierTokens = NewSet(Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate); public static BitArray IdentifierTokens = NewSet(Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate);
public static BitArray ExpressionStart = NewSet(Me, MyBase, MyClass, False, New, Nothing, True, GetType); public static BitArray ExpressionStart = NewSet(Me, MyBase, MyClass, True, False, Not, From, Aggregate, New, Nothing, AddressOf, GetType, TypeOf, GetXmlNamespace, Global, Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Sub, Function, DirectCast, TryCast, CType, CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CSByte, CShort, CSng, CStr, CUInt, CULng, CUShort);
public static BitArray StatementStart = NewSet(Nothing, Me, MyBase, MyClass, True, False, Not, From, Aggregate, New, Nothing, AddressOf, GetType, TypeOf, GetXmlNamespace, Global, Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Sub, Function, DirectCast, TryCast, CType, CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CSByte, CShort, CSng, CStr, CUInt, CULng, CUShort, Dim, Const, Static, For, While, Do, Select);
public static BitArray SimpleTypeName = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate); public static BitArray SimpleTypeName = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate);
public static BitArray CastExpressions = NewSet(DirectCast, TryCast, CType, CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CSByte, CShort, CSng, CStr, CUInt, CULng, CUShort);
public static BitArray BooleanExpressions = NewSet(True, False);
public static BitArray LambdaStart = NewSet(Sub, Function);
public static BitArray OperatorsAtStart = NewSet(Not, From, Aggregate);
public static BitArray TypeKW = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte); public static BitArray TypeKW = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte);
static string[] tokenList = new string[] { static string[] tokenList = new string[] {

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

@ -1153,6 +1153,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
AddVBNetKeywords(result, NR.Parser.VB.Tokens.TypeLevel); AddVBNetKeywords(result, NR.Parser.VB.Tokens.TypeLevel);
} else if (context == ExpressionContext.Global) { } else if (context == ExpressionContext.Global) {
AddVBNetKeywords(result, NR.Parser.VB.Tokens.GlobalLevel); AddVBNetKeywords(result, NR.Parser.VB.Tokens.GlobalLevel);
} else if (context == ExpressionContext.MethodBody) {
AddVBNetKeywords(result, NR.Parser.VB.Tokens.StatementStart);
} else { } else {
AddVBNetPrimitiveTypes(result); AddVBNetPrimitiveTypes(result);
CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces);

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/VBNetExpressionFinder.cs

@ -129,6 +129,8 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
return ExpressionContext.IdentifierExpected; return ExpressionContext.IdentifierExpected;
case Context.Type: case Context.Type:
return ExpressionContext.TypeDeclaration; return ExpressionContext.TypeDeclaration;
case Context.Body:
return ExpressionContext.MethodBody;
} }
return ExpressionContext.Default; return ExpressionContext.Default;

Loading…
Cancel
Save