提交 7c59fbfb 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #18373 from CyrusNajmabadi/improveDocCommentCollapsing

Improve doc comment collapsing (for outlining).
......@@ -144,7 +144,7 @@ class Class3
}";
await VerifyBlockSpansAsync(code,
Region("span", "/// <summary> Hello C#!", autoCollapse: true));
Region("span", "/// <summary>Hello C#!", autoCollapse: true));
}
[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
......@@ -157,7 +157,7 @@ class Class3
}";
await VerifyBlockSpansAsync(code,
Region("span", "/** <summary> Hello C#!", autoCollapse: true));
Region("span", "/** <summary>Hello C#!", autoCollapse: true));
}
[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
......@@ -170,7 +170,7 @@ class Class3
}";
await VerifyBlockSpansAsync(code,
Region("span", "/// <summary> Hello C#!", autoCollapse: true));
Region("span", "/// <summary>Hello C#!", autoCollapse: true));
}
[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
......@@ -183,7 +183,7 @@ class Class3
}";
await VerifyBlockSpansAsync(code,
Region("span", "/** <summary> Hello C#!", autoCollapse: true));
Region("span", "/** <summary>Hello C#!", autoCollapse: true));
}
[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
......@@ -234,7 +234,27 @@ class C
}";
await VerifyBlockSpansAsync(code,
Region("span", "/// <summary> Summary with SeeClass , SeeAlsoClass , null , T , t , and not-supported .", autoCollapse: true));
Region("span", "/// <summary> Summary with SeeClass, SeeAlsoClass, null, T, t, and not-supported.", autoCollapse: true));
}
[WorkItem(402822, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=402822")]
[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
public async Task TestSummaryWithPunctuation()
{
const string code = @"
class C
{
{|span:/// $$<summary>
/// The main entrypoint for <see cref=""Program""/>.
/// </summary>
/// <param name=""args""></param>|}
void Main()
{
}
}";
await VerifyBlockSpansAsync(code,
Region("span", "/// <summary> The main entrypoint for Program.", autoCollapse: true));
}
}
}
......@@ -90,7 +90,7 @@ End Class
"
Await VerifyBlockSpansAsync(code,
Region("span", "''' <summary> Hello VB!", autoCollapse:=True))
Region("span", "''' <summary>Hello VB!", autoCollapse:=True))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Outlining)>
......@@ -102,7 +102,7 @@ End Class
"
Await VerifyBlockSpansAsync(code,
Region("span", "''' <summary> Hello VB!", autoCollapse:=True))
Region("span", "''' <summary>Hello VB!", autoCollapse:=True))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Outlining)>
......@@ -151,7 +151,24 @@ End Class
"
Await VerifyBlockSpansAsync(code,
Region("span", "''' <summary> Summary with SeeClass , SeeAlsoClass , Nothing , T , t , and not-supported .", autoCollapse:=True))
Region("span", "''' <summary> Summary with SeeClass, SeeAlsoClass, Nothing, T, t, and not-supported.", autoCollapse:=True))
End Function
<WorkItem(402822, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=402822")>
<Fact, Trait(Traits.Feature, Traits.Features.Outlining)>
Public Async Function TestSummaryWithPunctuation() As Task
Const code = "
class C
{|span:''' $$<summary>
''' The main entrypoint for <see cref=""Program""/>.
''' </summary>
''' <param name=""args""></param>|}
Sub Main()
End Sub
end class"
Await VerifyBlockSpansAsync(code,
Region("span", "''' <summary> The main entrypoint for Program.", autoCollapse:=True))
End Function
End Class
End Namespace
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Text;
......@@ -15,95 +14,8 @@ namespace Microsoft.CodeAnalysis.CSharp.Structure
{
internal class DocumentationCommentStructureProvider : AbstractSyntaxNodeStructureProvider<DocumentationCommentTriviaSyntax>
{
private static string GetDocumentationCommentPrefix(DocumentationCommentTriviaSyntax documentationComment)
{
Contract.ThrowIfNull(documentationComment);
var leadingTrivia = documentationComment.GetLeadingTrivia();
var exteriorTrivia = leadingTrivia.Where(t => t.Kind() == SyntaxKind.DocumentationCommentExteriorTrivia)
.FirstOrNullable();
return exteriorTrivia != null ? exteriorTrivia.Value.ToString() : string.Empty;
}
private static string GetBannerText(DocumentationCommentTriviaSyntax documentationComment, CancellationToken cancellationToken)
{
// TODO: Consider unifying code to extract text from an Xml Documentation Comment (https://github.com/dotnet/roslyn/issues/2290)
var summaryElement = documentationComment.ChildNodes().OfType<XmlElementSyntax>()
.FirstOrDefault(e => e.StartTag.Name.ToString() == "summary");
var prefix = GetDocumentationCommentPrefix(documentationComment);
string text;
if (summaryElement != null)
{
var sb = new StringBuilder(summaryElement.Span.Length);
sb.Append(prefix);
sb.Append(" <summary>");
foreach (var node in summaryElement.ChildNodes())
{
if (node is XmlTextSyntax xmlText)
{
var textTokens = xmlText.TextTokens;
AppendTextTokens(sb, textTokens);
}
else if (node is XmlEmptyElementSyntax xmlEmpty)
{
foreach (var attribute in xmlEmpty.Attributes)
{
if (attribute is XmlCrefAttributeSyntax xmlCref)
{
sb.Append(" ");
sb.Append(xmlCref.Cref.ToString());
}
else if (attribute is XmlNameAttributeSyntax xmlName)
{
sb.Append(" ");
sb.Append(xmlName.Identifier.Identifier.Text);
}
else if (attribute is XmlTextAttributeSyntax xmlTextAttribute)
{
AppendTextTokens(sb, xmlTextAttribute.TextTokens);
}
else
{
Debug.Assert(false, $"Unexpected XML syntax kind {attribute.Kind()}");
}
}
}
}
text = sb.ToString();
}
else
{
// If a summary element isn't found, use the first line of the XML doc comment.
var syntaxTree = documentationComment.SyntaxTree;
var spanStart = documentationComment.SpanStart;
var line = syntaxTree.GetText(cancellationToken).Lines.GetLineFromPosition(spanStart);
text = prefix + " " + line.ToString().Substring(spanStart - line.Start).Trim() + " " + CSharpStructureHelpers.Ellipsis;
}
if (text.Length > CSharpStructureHelpers.MaxXmlDocCommentBannerLength)
{
text = text.Substring(0, CSharpStructureHelpers.MaxXmlDocCommentBannerLength) + " " + CSharpStructureHelpers.Ellipsis;
}
return text;
}
private static void AppendTextTokens(StringBuilder sb, SyntaxTokenList textTokens)
{
foreach (var tk in textTokens)
{
var s = tk.ToString().Trim();
if (s.Length > 0)
{
sb.Append(" ");
sb.Append(s);
}
}
}
=> CSharpSyntaxFactsService.Instance.GetBannerText(documentationComment, cancellationToken);
protected override void CollectBlockSpans(
DocumentationCommentTriviaSyntax documentationComment,
......
......@@ -12,64 +12,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Structure
Inherits AbstractSyntaxNodeStructureProvider(Of DocumentationCommentTriviaSyntax)
Private Shared Function GetBannerText(documentationComment As DocumentationCommentTriviaSyntax, cancellationToken As CancellationToken) As String
' TODO: Consider unifying code to extract text from an Xml Documentation Comment (https://github.com/dotnet/roslyn/issues/2290)
Dim summaryElement = documentationComment.Content _
.OfType(Of XmlElementSyntax)() _
.FirstOrDefault(Function(e) e.StartTag.Name.ToString = "summary")
Dim text As String
If summaryElement IsNot Nothing Then
Dim sb As New StringBuilder(summaryElement.Span.Length)
sb.Append("''' <summary>")
For Each node In summaryElement.ChildNodes()
If node.Kind() = SyntaxKind.XmlText Then
Dim textNode = DirectCast(node, XmlTextSyntax)
Dim textTokens As SyntaxTokenList = textNode.TextTokens
AppendTextTokens(sb, textTokens)
ElseIf node.Kind() = SyntaxKind.XmlEmptyElement Then
Dim elementNode = DirectCast(node, XmlEmptyElementSyntax)
For Each attribute In elementNode.Attributes
If TypeOf attribute Is XmlCrefAttributeSyntax Then
sb.Append(" ")
sb.Append(DirectCast(attribute, XmlCrefAttributeSyntax).Reference.ToString())
ElseIf TypeOf attribute Is XmlNameAttributeSyntax Then
sb.Append(" ")
sb.Append(DirectCast(attribute, XmlNameAttributeSyntax).Reference.ToString())
ElseIf TypeOf attribute Is XmlAttributeSyntax Then
AppendTextTokens(sb, DirectCast(DirectCast(attribute, XmlAttributeSyntax).Value, XmlStringSyntax).TextTokens)
Else
Debug.Assert(False, $"Unexpected XML syntax kind {attribute.Kind()}")
End If
Next
End If
Next
text = sb.ToString()
Else
' If a summary element isn't found, use the first line of the XML doc comment.
Dim span = documentationComment.Span
Dim syntaxTree = documentationComment.SyntaxTree
Dim line = syntaxTree.GetText(cancellationToken).Lines.GetLineFromPosition(span.Start)
text = "''' " & line.ToString().Substring(span.Start - line.Start).Trim() & SpaceEllipsis
End If
If text.Length > MaxXmlDocCommentBannerLength Then
text = text.Substring(0, MaxXmlDocCommentBannerLength) & SpaceEllipsis
End If
Return text
Return VisualBasicSyntaxFactsService.Instance.GetBannerText(documentationComment, cancellationToken)
End Function
Private Shared Sub AppendTextTokens(sb As StringBuilder, textTokens As SyntaxTokenList)
For Each token In textTokens.Where(Function(t) t.Kind = SyntaxKind.XmlTextLiteralToken)
Dim s = token.ToString().Trim()
If s.Length <> 0 Then
sb.Append(" ")
sb.Append(s)
End If
Next
End Sub
Protected Overrides Sub CollectBlockSpans(documentationComment As DocumentationCommentTriviaSyntax,
spans As ArrayBuilder(Of BlockSpan),
options As OptionSet,
......
......@@ -190,6 +190,7 @@
<Compile Include="Formatting\Rules\TokenBasedFormattingRule.cs" />
<Compile Include="Formatting\Rules\WrappingFormattingRule.cs" />
<Compile Include="LanguageServices\CSharpCompilationFactoryService.cs" />
<Compile Include="LanguageServices\CSharpDocumentationCommentService.cs" />
<Compile Include="LanguageServices\CSharpParseOptionsService.cs" />
<Compile Include="LanguageServices\CSharpSemanticFactsService.cs" />
<Compile Include="LanguageServices\CSharpSemanticFactsServiceFactory.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.LanguageServices;
namespace Microsoft.CodeAnalysis.CSharp
{
internal class CSharpDocumentationCommentService : AbstractDocumentationCommentService<
DocumentationCommentTriviaSyntax,
XmlNodeSyntax,
XmlAttributeSyntax,
CrefSyntax,
XmlElementSyntax,
XmlTextSyntax,
XmlEmptyElementSyntax,
XmlCrefAttributeSyntax,
XmlNameAttributeSyntax,
XmlTextAttributeSyntax>
{
private CSharpDocumentationCommentService()
: base(CSharpSyntaxFactsService.Instance)
{
}
public static readonly IDocumentationCommentService Instance = new CSharpDocumentationCommentService();
protected override SyntaxList<XmlAttributeSyntax> GetAttributes(XmlEmptyElementSyntax xmlEmpty)
=> xmlEmpty.Attributes;
protected override CrefSyntax GetCref(XmlCrefAttributeSyntax xmlCref)
=> xmlCref.Cref;
protected override SyntaxToken GetIdentifier(XmlNameAttributeSyntax xmlName)
=> xmlName.Identifier.Identifier;
protected override SyntaxNode GetName(XmlElementSyntax xmlElement)
=> xmlElement.StartTag.Name;
protected override SyntaxTokenList GetTextTokens(XmlTextAttributeSyntax xmlTextAttribute)
=> xmlTextAttribute.TextTokens;
protected override SyntaxTokenList GetTextTokens(XmlTextSyntax xmlText)
=> xmlText.TextTokens;
}
}
\ No newline at end of file
......@@ -30,6 +30,9 @@ private CSharpSyntaxFactsService()
public bool IsCaseSensitive => true;
protected override IDocumentationCommentService DocumentationCommentService
=> CSharpDocumentationCommentService.Instance;
public bool SupportsIndexingInitializer(ParseOptions options)
=> ((CSharpParseOptions)options).LanguageVersion >= LanguageVersion.CSharp6;
......@@ -1622,6 +1625,9 @@ public bool IsRegularComment(SyntaxTrivia trivia)
public bool IsDocumentationComment(SyntaxTrivia trivia)
=> trivia.IsDocComment();
public bool IsDocumentationCommentExteriorTrivia(SyntaxTrivia trivia)
=> trivia.Kind() == SyntaxKind.DocumentationCommentExteriorTrivia;
public bool IsDocumentationComment(SyntaxNode node)
=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind());
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Roslyn.Utilities;
using System.Text;
namespace Microsoft.CodeAnalysis.LanguageServices
{
internal abstract class AbstractDocumentationCommentService<
TDocumentationCommentTriviaSyntax,
TXmlNodeSyntax,
TXmlAttributeSyntax,
TCrefSyntax,
TXmlElementSyntax,
TXmlTextSyntax,
TXmlEmptyElementSyntax,
TXmlCrefAttributeSyntax,
TXmlNameAttributeSyntax,
TXmlTextAttributeSyntax> : IDocumentationCommentService
where TDocumentationCommentTriviaSyntax : SyntaxNode
where TXmlNodeSyntax : SyntaxNode
where TXmlAttributeSyntax : SyntaxNode
where TCrefSyntax : SyntaxNode
where TXmlElementSyntax : TXmlNodeSyntax
where TXmlTextSyntax : TXmlNodeSyntax
where TXmlEmptyElementSyntax : TXmlNodeSyntax
where TXmlCrefAttributeSyntax : TXmlAttributeSyntax
where TXmlNameAttributeSyntax : TXmlAttributeSyntax
where TXmlTextAttributeSyntax : TXmlAttributeSyntax
{
public const string Ellipsis = "...";
public const int MaxXmlDocCommentBannerLength = 120;
private readonly ISyntaxFactsService _syntaxFacts;
protected AbstractDocumentationCommentService(ISyntaxFactsService syntaxFacts)
{
_syntaxFacts = syntaxFacts;
}
private static void AddSpaceIfNotAlreadyThere(StringBuilder sb)
{
if (sb.Length > 0 && sb[sb.Length - 1] != ' ')
{
sb.Append(' ');
}
}
private string GetDocumentationCommentPrefix(TDocumentationCommentTriviaSyntax documentationComment)
{
Contract.ThrowIfNull(documentationComment);
var leadingTrivia = documentationComment.GetLeadingTrivia();
var exteriorTrivia = leadingTrivia.Where(t => _syntaxFacts.IsDocumentationCommentExteriorTrivia(t))
.FirstOrNullable();
return exteriorTrivia != null ? exteriorTrivia.Value.ToString() : string.Empty;
}
public string GetBannerText(TDocumentationCommentTriviaSyntax documentationComment, CancellationToken cancellationToken)
{
// TODO: Consider unifying code to extract text from an Xml Documentation Comment (https://github.com/dotnet/roslyn/issues/2290)
var summaryElement =
documentationComment.ChildNodes().OfType<TXmlElementSyntax>()
.FirstOrDefault(e => GetName(e).ToString() == "summary");
var prefix = GetDocumentationCommentPrefix(documentationComment);
string text;
if (summaryElement != null)
{
var sb = new StringBuilder(summaryElement.Span.Length);
sb.Append(prefix);
sb.Append(" <summary>");
foreach (var node in summaryElement.ChildNodes())
{
if (node.HasLeadingTrivia)
{
// Collapse all trailing trivia to a single space.
AddSpaceIfNotAlreadyThere(sb);
}
if (node is TXmlTextSyntax xmlText)
{
var textTokens = GetTextTokens(xmlText);
AppendTextTokens(sb, textTokens);
}
else if (node is TXmlEmptyElementSyntax xmlEmpty)
{
foreach (var attribute in GetAttributes(xmlEmpty))
{
if (attribute is TXmlCrefAttributeSyntax xmlCref)
{
AddSpaceIfNotAlreadyThere(sb);
sb.Append(GetCref(xmlCref).ToString());
}
else if (attribute is TXmlNameAttributeSyntax xmlName)
{
AddSpaceIfNotAlreadyThere(sb);
sb.Append(GetIdentifier(xmlName).Text);
}
else if (attribute is TXmlTextAttributeSyntax xmlTextAttribute)
{
AddSpaceIfNotAlreadyThere(sb);
AppendTextTokens(sb, GetTextTokens(xmlTextAttribute));
}
else
{
Debug.Assert(false, $"Unexpected XML syntax kind {attribute.RawKind}");
}
}
}
if (node.HasTrailingTrivia)
{
// Collapse all trailing trivia to a single space.
AddSpaceIfNotAlreadyThere(sb);
}
}
text = sb.ToString().Trim();
}
else
{
// If a summary element isn't found, use the first line of the XML doc comment.
var syntaxTree = documentationComment.SyntaxTree;
var spanStart = documentationComment.SpanStart;
var line = syntaxTree.GetText(cancellationToken).Lines.GetLineFromPosition(spanStart);
text = prefix + " " + line.ToString().Substring(spanStart - line.Start).Trim() + " " + Ellipsis;
}
if (text.Length > MaxXmlDocCommentBannerLength)
{
text = text.Substring(0, MaxXmlDocCommentBannerLength) + " " + Ellipsis;
}
return text;
}
protected abstract SyntaxToken GetIdentifier(TXmlNameAttributeSyntax xmlName);
protected abstract TCrefSyntax GetCref(TXmlCrefAttributeSyntax xmlCref);
protected abstract SyntaxList<TXmlAttributeSyntax> GetAttributes(TXmlEmptyElementSyntax xmlEmpty);
protected abstract SyntaxTokenList GetTextTokens(TXmlTextSyntax xmlText);
protected abstract SyntaxTokenList GetTextTokens(TXmlTextAttributeSyntax xmlTextAttribute);
protected abstract SyntaxNode GetName(TXmlElementSyntax xmlElement);
private static void AppendTextTokens(StringBuilder sb, SyntaxTokenList textTokens)
{
foreach (var token in textTokens)
{
var trimmed = token.ToString().Trim();
if (trimmed == string.Empty)
{
// If it's all whitespace, then just add a single whitespace.
AddSpaceIfNotAlreadyThere(sb);
}
else
{
// Collapse all preceding trivia for this token to a single space.
if (token.LeadingTrivia.Count > 0)
{
AddSpaceIfNotAlreadyThere(sb);
}
sb.Append(trimmed);
}
}
}
public string GetBannerText(SyntaxNode documentationCommentTriviaSyntax, CancellationToken cancellationToken)
=> GetBannerText((TDocumentationCommentTriviaSyntax)documentationCommentTriviaSyntax, cancellationToken);
}
}
\ No newline at end of file
......@@ -386,5 +386,10 @@ public bool ContainsInterleavedDirective(SyntaxNode node, CancellationToken canc
}
protected abstract bool ContainsInterleavedDirective(TextSpan span, SyntaxToken token, CancellationToken cancellationToken);
public string GetBannerText(SyntaxNode documentationCommentTriviaSyntax, CancellationToken cancellationToken)
=> DocumentationCommentService.GetBannerText(documentationCommentTriviaSyntax, cancellationToken);
protected abstract IDocumentationCommentService DocumentationCommentService { get; }
}
}
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
namespace Microsoft.CodeAnalysis.LanguageServices
{
internal interface IDocumentationCommentService
{
string GetBannerText(SyntaxNode documentationCommentTriviaSyntax, CancellationToken cancellationToken);
}
}
\ No newline at end of file
......@@ -129,6 +129,7 @@ internal interface ISyntaxFactsService : ILanguageService
bool IsWhitespaceTrivia(SyntaxTrivia trivia);
bool IsEndOfLineTrivia(SyntaxTrivia trivia);
bool IsDocumentationCommentExteriorTrivia(SyntaxTrivia trivia);
SyntaxNode GetExpressionOfConditionalAccessExpression(SyntaxNode node);
......@@ -285,6 +286,8 @@ internal interface ISyntaxFactsService : ILanguageService
bool ContainsInterleavedDirective(SyntaxNode node, CancellationToken cancellationToken);
bool ContainsInterleavedDirective(ImmutableArray<SyntaxNode> nodes, CancellationToken cancellationToken);
string GetBannerText(SyntaxNode documentationCommentTriviaSyntax, CancellationToken cancellationToken);
}
[Flags]
......
......@@ -370,6 +370,8 @@
<Compile Include="FindSymbols\FindLiterals\FindLiteralsSearchEngine.cs" />
<Compile Include="FindSymbols\SymbolFinder.FindLiteralsServerCallback.cs" />
<Compile Include="FindSymbols\SyntaxTree\SyntaxTreeIndex.LiteralInfo.cs" />
<Compile Include="LanguageServices\SyntaxFactsService\AbstractDocumentationCommentService.cs" />
<Compile Include="LanguageServices\SyntaxFactsService\IDocumentationCommentService.cs" />
<Compile Include="NamingStyles\EditorConfig\EditorConfigSeverityStrings.cs" />
<Compile Include="NamingStyles\EditorConfig\EditorConfigNamingStyleParser.cs" />
<Compile Include="NamingStyles\EditorConfig\EditorConfigNamingStyleParser_NamingRule.cs" />
......
......@@ -167,6 +167,7 @@
<Compile Include="Formatting\VisualBasicSyntaxFormattingService.vb" />
<Compile Include="LanguageServices\VisualBasicCompilationFactoryService.vb" />
<Compile Include="LanguageServices\VisualBasicCommandLineParserService.vb" />
<Compile Include="LanguageServices\VisualBasicDocumentationCommentService.vb" />
<Compile Include="LanguageServices\VisualBasicSemanticFactsService.vb" />
<Compile Include="LanguageServices\VisualBasicSymbolDeclarationService.vb" />
<Compile Include="LanguageServices\VisualBasicSyntaxFactsService.vb" />
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Class VisualBasicDocumentationCommentService
Inherits AbstractDocumentationCommentService(Of
DocumentationCommentTriviaSyntax,
XmlNodeSyntax,
XmlNodeSyntax,
CrefReferenceSyntax,
XmlElementSyntax,
XmlTextSyntax,
XmlEmptyElementSyntax,
XmlCrefAttributeSyntax,
XmlNameAttributeSyntax,
XmlAttributeSyntax)
Public Shared ReadOnly Instance As New VisualBasicDocumentationCommentService()
Private Sub New()
MyBase.New(VisualBasicSyntaxFactsService.Instance)
End Sub
Protected Overrides Function GetIdentifier(xmlName As XmlNameAttributeSyntax) As SyntaxToken
Return xmlName.Reference.Identifier
End Function
Protected Overrides Function GetCref(xmlCref As XmlCrefAttributeSyntax) As CrefReferenceSyntax
Return xmlCref.Reference
End Function
Protected Overrides Function GetAttributes(xmlEmpty As XmlEmptyElementSyntax) As SyntaxList(Of XmlNodeSyntax)
Return xmlEmpty.Attributes
End Function
Protected Overrides Function GetTextTokens(xmlText As XmlTextSyntax) As SyntaxTokenList
Return xmlText.TextTokens
End Function
Protected Overrides Function GetTextTokens(xmlTextAttribute As XmlAttributeSyntax) As SyntaxTokenList
Dim value = TryCast(xmlTextAttribute.Value, XmlStringSyntax)
Return If(value Is Nothing, Nothing, value.TextTokens)
End Function
Protected Overrides Function GetName(xmlElement As XmlElementSyntax) As SyntaxNode
Return xmlElement.StartTag.Name
End Function
End Class
End Namespace
\ No newline at end of file
......@@ -16,7 +16,6 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.VisualBasic.SyntaxFacts
Namespace Microsoft.CodeAnalysis.VisualBasic
<ExportLanguageServiceFactory(GetType(ISyntaxFactsService), LanguageNames.VisualBasic), [Shared]>
Friend Class VisualBasicSyntaxFactsServiceFactory
Implements ILanguageServiceFactory
......@@ -41,6 +40,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
Protected Overrides ReadOnly Property DocumentationCommentService As IDocumentationCommentService
Get
Return VisualBasicDocumentationCommentService.Instance
End Get
End Property
Public Function SupportsIndexingInitializer(options As ParseOptions) As Boolean Implements ISyntaxFactsService.SupportsIndexingInitializer
Return False
End Function
......@@ -1771,5 +1776,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Private Function ISyntaxFactsService_ContainsInterleavedDirective1(nodes As ImmutableArray(Of SyntaxNode), cancellationToken As CancellationToken) As Boolean Implements ISyntaxFactsService.ContainsInterleavedDirective
Return ContainsInterleavedDirective(nodes, cancellationToken)
End Function
Public Function IsDocumentationCommentExteriorTrivia(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFactsService.IsDocumentationCommentExteriorTrivia
Return trivia.Kind() = SyntaxKind.DocumentationCommentExteriorTrivia
End Function
Private Function ISyntaxFactsService_GetBannerText(documentationCommentTriviaSyntax As SyntaxNode, cancellationToken As CancellationToken) As String Implements ISyntaxFactsService.GetBannerText
Return GetBannerText(documentationCommentTriviaSyntax, cancellationToken)
End Function
End Class
End Namespace
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册