Skip to content

Commit

Permalink
S4663: Fix highlighting to remove underlying whitespaces (#6725)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-paidis-sonarsource committed Feb 7, 2023
1 parent a783fbe commit b3aeb3c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
Expand Up @@ -62,10 +62,9 @@ private void CheckTrivia(SonarSyntaxTreeReportingContext context, IEnumerable<Sy

foreach (var partition in partitions.Where(trivia => trivia.Any() && trivia.All(x => string.IsNullOrWhiteSpace(GetCommentText(x)))))
{
var start = partition.First().GetLocation().SourceSpan.Start;
var end = partition.Last().GetLocation().SourceSpan.End;
var location = Location.Create(context.Tree, TextSpan.FromBounds(start, end));
context.ReportIssue(Diagnostic.Create(Rule, location));
var location = partition.First().GetLocation();
var secondary = partition.Skip(1).Select(x => x.GetLocation());
context.ReportIssue(Diagnostic.Create(Rule, location, secondary));
}
}

Expand Down
Expand Up @@ -10,7 +10,7 @@ public class SingleLine //

// Noncompliant@-2 (a lot of whitespace before)

//
//

// Noncompliant@-2 (a lot of whitespace after)

Expand Down Expand Up @@ -75,6 +75,8 @@ public class SingleLine //
//
/// text
// Noncompliant@-4
// Secondary@-4
// Secondary@-4

//
//
Expand All @@ -83,6 +85,8 @@ public class SingleLine //
* text
*/
// Noncompliant@-6
// Secondary@-6
// Secondary@-6

//
//
Expand All @@ -91,10 +95,14 @@ public class SingleLine //
* text
*/
// Noncompliant@-6
// Secondary@-6
// Secondary@-6

void Method()
{
// Noncompliant@+2
// Noncompliant@+4
// Secondary@+4
// Secondary@+4

//
//
Expand All @@ -106,6 +114,8 @@ void Method()

// Noncompliant@-5
// Noncompliant@-5
// Secondary@-5
// Secondary@-5

//
//
Expand Down Expand Up @@ -136,7 +146,7 @@ public class SingleLineDocumentation ///
///
// Noncompliant@-1 (a lot of whitespace before)

///
///
// Noncompliant@-1 (a lot of whitespace after)

///
Expand Down Expand Up @@ -188,7 +198,7 @@ public class MultiLine /* */
/* */
// Noncompliant@-1 (a lot of whitespace inside)

/**/
/**/
// Noncompliant@-1 (a lot of whitespace after)

// Noncompliant@+1
Expand Down Expand Up @@ -286,7 +296,7 @@ public class MultiLineDocumentation /** */
/** */
// Noncompliant@-1 (a lot of whitespace inside)

/***/
/***/
// Noncompliant@-1 (a lot of whitespace after)

// Noncompliant@+1
Expand Down Expand Up @@ -381,7 +391,9 @@ hey there
///


// Noncompliant@+2
// Noncompliant@+4
// Secondary@+4
// Secondary@+4

//
//
Expand Down
Expand Up @@ -14,7 +14,7 @@
Dim b = 42 ''' Ipsem Lorum
Dim c = 42 '''

'
'

' Noncompliant@-2 (whitespace)

Expand All @@ -29,13 +29,17 @@
'
'

' Noncompliant@+2

'
'
'
'

' Noncompliant@-5
' Secondary@-5
' Secondary@-5
' Secondary@-5

' Noncompliant@+2

'
Expand All @@ -45,6 +49,8 @@
'

' Noncompliant@-4
' Secondary@-4
' Secondary@-4

' *
' Ipsem Lorum
Expand Down Expand Up @@ -80,10 +86,12 @@
'
''' Ipsem Lorum
' Noncompliant@-4
' Secondary@-4
' Secondary@-4
End Sub

Public Sub DocumentationComment()
'''
'''
' Noncompliant@-1 (whitespace)

''' *
Expand Down Expand Up @@ -133,12 +141,15 @@ End Class
'''


' Noncompliant@+2

'
'
'

' Noncompliant@-4
' Secondary@-4
' Secondary@-4

' Noncompliant@+1
'''
'''

0 comments on commit b3aeb3c

Please sign in to comment.