diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2016-08-01 12:21:12 +0300 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2016-08-01 12:21:12 +0300 |
commit | 5f255f4283a31a29cd94582080dd15590539e616 (patch) | |
tree | a6675a3f7155be3401bb714ab506202d8c6c94c1 /main/src/addins/MonoDevelop.DocFood | |
parent | 25dcd78ef88a647de5251a8466ffe4022be4b6a7 (diff) | |
parent | b46436808d73749244a3be546db625e9a3653d92 (diff) |
Merge branch 'master' into maceditor
Diffstat (limited to 'main/src/addins/MonoDevelop.DocFood')
4 files changed, 27 insertions, 12 deletions
diff --git a/main/src/addins/MonoDevelop.DocFood/DocFood.config.xml b/main/src/addins/MonoDevelop.DocFood/DocFood.config.xml index 7402d5ba8c..8f99de3c5a 100644 --- a/main/src/addins/MonoDevelop.DocFood/DocFood.config.xml +++ b/main/src/addins/MonoDevelop.DocFood/DocFood.config.xml @@ -346,10 +346,16 @@ </Case> <Case wordCount="1"> <If paramCount="0"> - <Section name="summary">${FirstAsVerb} this instance.</Section> + <Section name="summary">${FirstAsVerb} this instance.</Section> + <IfNot returns="void"> + <Section name="returns">The ${AllWords}.</Section> + </IfNot> </If> <IfNot paramCount="0"> <Section name="summary">${FirstAsVerb} the specified ${ParameterList}.</Section> + <IfNot returns="void"> + <Section name="returns">The ${AllWords}.</Section> + </IfNot> </IfNot> </Case> <Case endsWith="At,Between"> diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj index 519c95dc95..05ea3916e8 100644 --- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj +++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj @@ -20,11 +20,6 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <Externalconsole>True</Externalconsole> - <CustomCommands> - <CustomCommands> - <Command type="Execute" command="../../../main/build/bin/MonoDevelop.exe" /> - </CustomCommands> - </CustomCommands> <NoWarn>1591;1573</NoWarn> <DocumentationFile>..\..\..\build\AddIns\BackendBindings\MonoDevelop.DocFood.xml</DocumentationFile> </PropertyGroup> @@ -69,6 +64,10 @@ <HintPath>..\..\..\external\roslyn\Binaries\Release\Microsoft.CodeAnalysis.CSharp.dll</HintPath> <Private>False</Private> </Reference> + <Reference Include="Microsoft.CodeAnalysis.Workspaces"> + <HintPath>..\..\..\build\bin\Microsoft.CodeAnalysis.Workspaces.dll</HintPath> + <Private>False</Private> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="AssemblyInfo.cs" /> diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs index 7ccb5b775d..16a4d01097 100644 --- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs +++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs @@ -24,11 +24,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Text; +using MonoDevelop.CSharp.Completion; using MonoDevelop.Ide.Editor; using MonoDevelop.Ide.Editor.Extension; +using System.Threading; namespace MonoDevelop.DocFood { @@ -72,9 +75,10 @@ namespace MonoDevelop.DocFood if (l != null && Editor.GetTextAt (l).TrimStart ().StartsWith ("///", StringComparison.Ordinal)) return base.KeyPress (descriptor); - var member = GetMemberToDocument (); - if (member == null) + var memberTask = GetMemberToDocument (); + if (!memberTask.Wait (250) || memberTask.Result == null) return base.KeyPress (descriptor); + var member = memberTask.Result; string documentation = GenerateDocumentation (member, Editor.GetLineIndent (line)); if (string.IsNullOrEmpty (documentation)) @@ -156,12 +160,14 @@ namespace MonoDevelop.DocFood return true; } - ISymbol GetMemberToDocument () + async Task<ISymbol> GetMemberToDocument (CancellationToken cancellationToken = default(CancellationToken)) { var parsedDocument = DocumentContext.ParsedDocument; if (parsedDocument == null) return null; - var semanticModel = parsedDocument.GetAst<SemanticModel> (); + + var partialDoc = await CSharpCompletionTextEditorExtension.WithFrozenPartialSemanticsAsync (DocumentContext.AnalysisDocument, cancellationToken).ConfigureAwait (false); + var semanticModel = await partialDoc.GetSemanticModelAsync (); if (semanticModel == null) return null; var caretOffset = Editor.CaretOffset; @@ -182,6 +188,10 @@ namespace MonoDevelop.DocFood if (eventDeclaration != null) { node = eventDeclaration.Declaration.Variables.First (); } + + if (node.Span.Contains (caretOffset)) + return null; + var declaredSymbol = semanticModel.GetDeclaredSymbol (node); if (declaredSymbol != null) return declaredSymbol; diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs index 22dfccc500..00fa6eca7f 100644 --- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs +++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs @@ -961,9 +961,9 @@ namespace MonoDevelop.DocFood continue; } if (i != j) - result.Append (name.Substring (j, i - j)); + result.Append (name, j, i - j); if (i + 1 < name.Length) { - result.Append (" "); + result.Append (' '); result.Append (char.ToLower (name [i])); } continue; |