diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2017-04-10 15:07:22 +0300 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2017-04-10 15:09:18 +0300 |
commit | 3526bebe66c584798446cb8edd4ccf20bc8bf12c (patch) | |
tree | e3b04deaa00a3ca25ce57eebba4843539108558f /main/src/addins/MonoDevelop.DocFood | |
parent | c2937efec269d135a5a459b0e98d167109061d84 (diff) |
Fixed 'Bug 54936 - Unable to type in third '/' when gathering class
information'
Diffstat (limited to 'main/src/addins/MonoDevelop.DocFood')
-rw-r--r-- | main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs index 1faa165d06..36b5a03950 100644 --- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs +++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs @@ -33,6 +33,7 @@ using MonoDevelop.Ide.Editor; using MonoDevelop.Ide.Editor.Extension; using System.Threading; using Microsoft.CodeAnalysis.CSharp; +using MonoDevelop.Core; namespace MonoDevelop.DocFood { @@ -167,42 +168,50 @@ namespace MonoDevelop.DocFood if (parsedDocument == null) return null; - var partialDoc = await CSharpCompletionTextEditorExtension.WithFrozenPartialSemanticsAsync (DocumentContext.AnalysisDocument, cancellationToken).ConfigureAwait (false); - var semanticModel = await partialDoc.GetSemanticModelAsync (); - if (semanticModel == null) - return null; - var caretOffset = Editor.CaretOffset; - var offset = caretOffset; - var root = semanticModel.SyntaxTree.GetRoot (); - var tokenAtCaret = root.FindTrivia (offset - 1, true); - if (!tokenAtCaret.IsKind (SyntaxKind.SingleLineCommentTrivia)) - return null; - while (offset < Editor.Length) { - var node = root.FindNode (TextSpan.FromBounds (offset, offset)); + try { + var analysisDoc = DocumentContext.AnalysisDocument; + if (analysisDoc == null) + return null; + var partialDoc = await CSharpCompletionTextEditorExtension.WithFrozenPartialSemanticsAsync (analysisDoc, cancellationToken).ConfigureAwait (false); + var semanticModel = await partialDoc.GetSemanticModelAsync (); + if (semanticModel == null) + return null; + var caretOffset = Editor.CaretOffset; + var offset = caretOffset; + var root = semanticModel.SyntaxTree.GetRoot (); + var tokenAtCaret = root.FindTrivia (offset - 1, true); + if (!tokenAtCaret.IsKind (SyntaxKind.SingleLineCommentTrivia)) + return null; + while (offset < Editor.Length) { + var node = root.FindNode (TextSpan.FromBounds (offset, offset)); - if (node == null || node.GetLastToken ().SpanStart < caretOffset) { - offset++; - continue; - } - var fieldDeclarationSyntax = node as FieldDeclarationSyntax; - if (fieldDeclarationSyntax != null) { - node = fieldDeclarationSyntax.Declaration.Variables.First (); - } + if (node == null || node.GetLastToken ().SpanStart < caretOffset) { + offset++; + continue; + } + var fieldDeclarationSyntax = node as FieldDeclarationSyntax; + if (fieldDeclarationSyntax != null) { + node = fieldDeclarationSyntax.Declaration.Variables.First (); + } - var eventDeclaration = node as EventFieldDeclarationSyntax; - if (eventDeclaration != null) { - node = eventDeclaration.Declaration.Variables.First (); - } + var eventDeclaration = node as EventFieldDeclarationSyntax; + if (eventDeclaration != null) { + node = eventDeclaration.Declaration.Variables.First (); + } - if (node.Span.Contains (caretOffset)) - return null; + if (node.Span.Contains (caretOffset)) + return null; - var declaredSymbol = semanticModel.GetDeclaredSymbol (node); - if (declaredSymbol != null) - return declaredSymbol; - offset = node.FullSpan.End + 1; + var declaredSymbol = semanticModel.GetDeclaredSymbol (node); + if (declaredSymbol != null) + return declaredSymbol; + offset = node.FullSpan.End + 1; + } + return null; + } catch (Exception e) { + LoggingService.LogError("Error wihle getting member to document.", e); + return null; } - return null; } } } |