diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-11-03 15:40:18 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-11-03 15:40:18 +0400 |
commit | f9babc5210289ee4f4fbf7b81fa98e04660d24ee (patch) | |
tree | f6771e6f62555420f67639a1c3c6039aada9afcb /main/contrib | |
parent | 4730ba6d8d8d3fa0877b8212db19abfe5b3f69bd (diff) |
Fixed "Bug 1795 - [New Resolver] Public keyword not shown sometimes
when adding a new member".
Diffstat (limited to 'main/contrib')
-rw-r--r-- | main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs | 4 | ||||
-rw-r--r-- | main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs | 20 |
2 files changed, 20 insertions, 4 deletions
diff --git a/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index 7388055c1b..8882cdd848 100644 --- a/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -1974,8 +1974,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion { var state = new CSharpResolver (ctx, System.Threading.CancellationToken.None); - state.CurrentMember = CSharpParsedFile.GetMember (location); - state.CurrentTypeDefinition = CSharpParsedFile.GetInnermostTypeDefinition (location); + state.CurrentMember = currentMember; + state.CurrentTypeDefinition = currentType; state.CurrentUsingScope = CSharpParsedFile.GetUsingScope (location); if (state.CurrentMember != null) { var node = Unit.GetNodeAt (location); diff --git a/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs b/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs index 767826ba8a..17c77582d1 100644 --- a/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs +++ b/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs @@ -63,7 +63,17 @@ namespace ICSharpCode.NRefactory.CSharp.Completion this.location = document.GetLocation (offset); this.currentType = CSharpParsedFile.GetInnermostTypeDefinition (location); - this.currentMember = CSharpParsedFile.GetMember (location); + this.currentMember = null; + if (this.currentType != null) { + foreach (var member in currentType.Members) { + if (member.Region.Begin < location && (currentMember == null || currentMember.Region.Begin < member.Region.Begin)) + currentMember = member; + } + } + + var stack = GetBracketStack (GetMemberTextToCaret ().Item1); + if (stack.Count == 0) + currentMember = null; } #region Context helper methods @@ -160,7 +170,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion #endregion #region Basic parsing/resolving functions - protected void AppendMissingClosingBrackets (StringBuilder wrapper, string memberText, bool appendSemicolon) + Stack<Tuple<char, int>> GetBracketStack (string memberText) { var bracketStack = new Stack<Tuple<char, int>> (); @@ -211,6 +221,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion break; } } + return bracketStack; + } + + protected void AppendMissingClosingBrackets (StringBuilder wrapper, string memberText, bool appendSemicolon) + { + var bracketStack = GetBracketStack (memberText); bool didAppendSemicolon = !appendSemicolon; char lastBracket = '\0'; |