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>
Statement block = null; Statement block = null;
.) .)
{ {
(.List<CaseLabel> caseClauses = null; .) (.List<CaseLabel> caseClauses = null; Location caseLocation = la.Location; .)
"Case" CaseClauses<out caseClauses> [ IF(IsNotStatementSeparator()) ":" ] EndOfStmt "Case" CaseClauses<out caseClauses> [ IF(IsNotStatementSeparator()) ":" ] EndOfStmt
(. (.
SwitchSection selectSection = new SwitchSection(caseClauses); SwitchSection selectSection = new SwitchSection(caseClauses);
selectSection.StartLocation = caseLocation;
.) .)
Block<out block> Block<out block>
(. (.
selectSection.Children = block.Children; selectSection.Children = block.Children;
selectSection.EndLocation = t.EndLocation;
selectSections.Add(selectSection); selectSections.Add(selectSection);
.) .)
} }

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

@ -53,6 +53,7 @@ namespace ICSharpCode.NRefactory.Visitors
public class LookupTableVisitor : AbstractAstVisitor public class LookupTableVisitor : AbstractAstVisitor
{ {
Dictionary<string, List<LocalLookupVariable>> variables; Dictionary<string, List<LocalLookupVariable>> variables;
SupportedLanguage language;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public Dictionary<string, List<LocalLookupVariable>> Variables { public Dictionary<string, List<LocalLookupVariable>> Variables {
@ -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) public void AddVariable(TypeReference typeRef, string name, Location startPos, Location endPos, bool isConst)
@ -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) public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
{ {
AddVariable(foreachStatement.TypeReference, AddVariable(foreachStatement.TypeReference,

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

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

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

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

Loading…
Cancel
Save