diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index fded6415f2..2f50255f32 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -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 } return DefaultControlSpaceItems(); } + + var attribute = syntaxTree.GetNodeAt(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; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs index 07b800c631..8fd0642be0 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs @@ -539,7 +539,7 @@ namespace ICSharpCode.NRefactory.CSharp typeStack.Push (newType); base.Visit (c); AddAttributeSection (newType, c.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole); - + if (location != null && curLoc < location.Count) { newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++]), Roles.RBrace), Roles.RBrace); @@ -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); } diff --git a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs index 777ff1cb18..b18c8912f7 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs @@ -5264,7 +5264,6 @@ public class Test /// /// Bug 4624 - [AutoComplete] Attribute autocomplete inserts entire attribute class name. /// - [Ignore("MCS BUG")] [Test] public void TestBug4624() {