Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
maroontress-tomohisa committed Aug 6, 2024
1 parent e6126fe commit f06efc4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,52 +74,27 @@ private void NoXmlTab()
{
}

/// <summary>
/// head <see cref="Okay"/> foot
/// </summary>
private void ContainsSeeElementInsideSummary()
private void NoDocumentationComment()
{
}
///

/// <summary>
/// <see cref="Okay"/> foot
/// </summary>
private void StartWithSeeElementInsideSummary()
{
}
/// hello

/// head <see cref="Okay"/> foot
private void ContainsSeeElement()
{
}
/// hello

/// <see cref="Okay"/> foot
private void StartWithSeeElement()
{
}
/// hello <see cref="world"/>

/// <summary>
/// head <see cref="Okay"/> foot
/// </summary>
private void Tab_ContainsSeeElementInsideSummary()
{
}
/// hello <see cref="world"/>

/// <summary>
/// <see cref="Okay"/> foot
/// </summary>
private void Tab_StartWithSeeElementInsideSummary()
{
}
///

/// head <see cref="Okay"/> foot
private void Tab_ContainsSeeElement()
{
}
/// hello

/// <see cref="Okay"/> foot
private void Tab_StartWithSeeElement()
{
/// hello

/// hello <see cref="world"/>

/// hello <see cref="world"/>
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ static bool DoesTokenHaveGoodSpace(SyntaxToken t)
|| !IsSldcTrivia(top)
|| GetNextElement(top, child) is null
|| IsNextTokenNewLine(child, t)
|| text.Length is 1);
|| text.Length is 1
|| !text.Skip(1).All(WhitespaceCharSet.Contains));
}

static bool DoesTokenStartWithWhiteSpace(SyntaxToken t)
Expand All @@ -126,14 +127,6 @@ static bool DoesTokenHaveSingleLeadingTrivia(SyntaxTrivia t)
&& a.Last() == t;
}

static bool DoesTokenHaveTextStartingWithSingleSpace(SyntaxTrivia t)
{
var text = t.Token.Text;
return text.Length > 1
&& WhitespaceCharSet.Contains(text[0])
&& !WhitespaceCharSet.Contains(text[1]);
}

static Func<SyntaxTrivia, Location> LocationSupplier(SyntaxTree tree)
=> t => Location.Create(tree, t.Token.Span);

Expand All @@ -146,8 +139,7 @@ static Func<SyntaxTrivia, Location> LocationSupplier(SyntaxTree tree)
.SelectMany(t => t.DescendantTrivia())
.Where(t => IsDceTrivia(t)
&& !DoesTokenHaveSingleLeadingTrivia(t)
&& !IsNextSiblingTriviaSingleSpace(t)
&& !DoesTokenHaveTextStartingWithSingleSpace(t))
&& !IsNextSiblingTriviaSingleSpace(t))
.Select(t => Diagnostic.Create(Rule, toLocation(t)))
.ToList();

Expand All @@ -163,7 +155,7 @@ static Func<SyntaxTrivia, Location> LocationSupplier(SyntaxTree tree)
+ ...
+ XmlText
| + ...
| + XmlTextLiteralToken (equals " ")
| + XmlTextLiteralToken (starts with " "... and contains non-" ")
| + Lead: ...
| + Lead: DocumentationCommentExteriorTrivia
+ ...
Expand Down

0 comments on commit f06efc4

Please sign in to comment.