Browse Source

Fixed SD2-1282: Completion inside Select Case statement

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2337 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
e6bdcac3ae
  1. 368
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  2. 4
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  3. 19
      src/Libraries/NRefactory/Project/Src/Visitors/LookupTableVisitor.cs
  4. 18
      src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/EqualsCodeGenerator.cs
  5. 6
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

368
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

4
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -2475,14 +2475,16 @@ EmbeddedStatement<out Statement statement> @@ -2475,14 +2475,16 @@ EmbeddedStatement<out Statement statement>
Statement block = null;
.)
{
(.List<CaseLabel> caseClauses = null; .)
(.List<CaseLabel> caseClauses = null; Location caseLocation = la.Location; .)
"Case" CaseClauses<out caseClauses> [ IF(IsNotStatementSeparator()) ":" ] EndOfStmt
(.
SwitchSection selectSection = new SwitchSection(caseClauses);
selectSection.StartLocation = caseLocation;
.)
Block<out block>
(.
selectSection.Children = block.Children;
selectSection.EndLocation = t.EndLocation;
selectSections.Add(selectSection);
.)
}

19
src/Libraries/NRefactory/Project/Src/Visitors/LookupTableVisitor.cs

@ -53,6 +53,7 @@ namespace ICSharpCode.NRefactory.Visitors @@ -53,6 +53,7 @@ namespace ICSharpCode.NRefactory.Visitors
public class LookupTableVisitor : AbstractAstVisitor
{
Dictionary<string, List<LocalLookupVariable>> variables;
SupportedLanguage language;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public Dictionary<string, List<LocalLookupVariable>> Variables {
@ -69,9 +70,14 @@ namespace ICSharpCode.NRefactory.Visitors @@ -69,9 +70,14 @@ namespace ICSharpCode.NRefactory.Visitors
}
}
public LookupTableVisitor(StringComparer nameComparer)
public LookupTableVisitor(SupportedLanguage language)
{
variables = new Dictionary<string, List<LocalLookupVariable>>(nameComparer);
this.language = language;
if (language == SupportedLanguage.VBNet) {
variables = new Dictionary<string, List<LocalLookupVariable>>(StringComparer.InvariantCultureIgnoreCase);
} else {
variables = new Dictionary<string, List<LocalLookupVariable>>(StringComparer.InvariantCulture);
}
}
public void AddVariable(TypeReference typeRef, string name, Location startPos, Location endPos, bool isConst)
@ -171,6 +177,15 @@ namespace ICSharpCode.NRefactory.Visitors @@ -171,6 +177,15 @@ namespace ICSharpCode.NRefactory.Visitors
}
}
public override object VisitSwitchSection(SwitchSection switchSection, object data)
{
if (language == SupportedLanguage.VBNet) {
return VisitBlockStatement(switchSection, data);
} else {
return base.VisitSwitchSection(switchSection, data);
}
}
public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
{
AddVariable(foreachStatement.TypeReference,

18
src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/EqualsCodeGenerator.cs

@ -35,6 +35,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -35,6 +35,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
Expression expr;
foreach (IField field in currentClass.Fields) {
if (field.IsStatic) continue;
expr = new AssignmentExpression(new IdentifierExpression(var.Name),
AssignmentOperatorType.ExclusiveOr,
new InvocationExpression(new FieldReferenceExpression(new IdentifierExpression(field.Name), "GetHashCode")));
@ -75,13 +77,19 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -75,13 +77,19 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
currentType);
method.Body.AddChild(new LocalVariableDeclaration(var));
expr = TestEquality(var.Name, currentClass.Fields[0]);
for (int i = 1; i < currentClass.Fields.Count; i++) {
expr = new BinaryOperatorExpression(expr, BinaryOperatorType.LogicalAnd,
TestEquality(var.Name, currentClass.Fields[i]));
expr = null;
foreach (IField field in currentClass.Fields) {
if (field.IsStatic) continue;
if (expr == null) {
expr = TestEquality(var.Name, field);
} else {
expr = new BinaryOperatorExpression(expr, BinaryOperatorType.LogicalAnd,
TestEquality(var.Name, field));
}
}
method.Body.AddChild(new ReturnStatement(expr));
method.Body.AddChild(new ReturnStatement(expr ?? new PrimitiveExpression(true, "true")));
nodes.Add(method);
}

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

@ -266,7 +266,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -266,7 +266,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
void RunLookupTableVisitor(string fileContent)
{
lookupTableVisitor = new LookupTableVisitor(languageProperties.NameComparer);
lookupTableVisitor = new LookupTableVisitor(language);
if (callingMember != null) {
CompilationUnit cu = ParseCurrentMemberAsCompilationUnit(fileContent);
@ -278,7 +278,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -278,7 +278,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public void RunLookupTableVisitor(INode currentMemberNode)
{
lookupTableVisitor = new LookupTableVisitor(languageProperties.NameComparer);
lookupTableVisitor = new LookupTableVisitor(language);
currentMemberNode.AcceptVisitor(lookupTableVisitor, null);
}
@ -1017,7 +1017,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -1017,7 +1017,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
this.caretLine = caretLine;
this.caretColumn = caretColumn;
lookupTableVisitor = new LookupTableVisitor(languageProperties.NameComparer);
lookupTableVisitor = new LookupTableVisitor(language);
cu = parseInfo.MostRecentCompilationUnit;

Loading…
Cancel
Save