Browse Source

Fixed completion bug.

pull/32/merge
Mike Krüger 13 years ago
parent
commit
f4daf2631e
  1. 26
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
  2. 2
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  3. 1
      ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs

26
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs

@ -657,13 +657,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -657,13 +657,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
AddKeywords(dataList, linqKeywords);
return dataList.Result;
}
if (currentType != null && currentType.Kind == TypeKind.Enum) {
var contextList = new CompletionDataWrapper(this);
var identifierStart = GetExpressionAtCursor();
if (currentType != null && currentType.Kind == TypeKind.Enum && identifierStart == null) {
if (!char.IsLetter(completionChar))
return null;
return HandleEnumContext();
}
var contextList = new CompletionDataWrapper(this);
var identifierStart = GetExpressionAtCursor();
if (!(char.IsLetter(completionChar) || completionChar == '_') && (!controlSpace || identifierStart == null)) {
return controlSpace ? HandleAccessorContext() ?? DefaultControlSpaceItems(identifierStart) : null;
}
@ -1076,6 +1078,24 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -1076,6 +1078,24 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
}
return DefaultControlSpaceItems();
}
var attribute = syntaxTree.GetNodeAt<Attribute>(location);
Console.WriteLine(syntaxTree.GetText ());
Console.WriteLine("---");
Console.WriteLine("attr:"+attribute);
if (attribute != null) {
var contextList = new CompletionDataWrapper(this);
var astResolver = CompletionContextProvider.GetResolver(GetState (), syntaxTree);
var csResolver = astResolver.GetResolverStateBefore(attribute);
AddContextCompletion(
contextList,
csResolver,
attribute
);
return contextList.Result;
}
return null;
}

2
ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs

@ -733,6 +733,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -733,6 +733,8 @@ namespace ICSharpCode.NRefactory.CSharp
// parser error, set end node to max value.
newType.AddChild (new ErrorNode (), Roles.Error);
}
AddAttributeSection (newType, e.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
typeStack.Pop ();
AddType (newType);
}

1
ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs

@ -5264,7 +5264,6 @@ public class Test @@ -5264,7 +5264,6 @@ public class Test
/// <summary>
/// Bug 4624 - [AutoComplete] Attribute autocomplete inserts entire attribute class name.
/// </summary>
[Ignore("MCS BUG")]
[Test]
public void TestBug4624()
{

Loading…
Cancel
Save