Skip to content

Commit 1cd7fd6

Browse files
committed
Simplify 'AstLineCounter'
1 parent e8fd6e1 commit 1cd7fd6

File tree

1 file changed

+5
-9
lines changed
  • csharp/extractor/Semmle.Extraction.CSharp/Populators

1 file changed

+5
-9
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Populators/Methods.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private class AstLineCounter : CSharpSyntaxVisitor<LineCounts>
1313
public override LineCounts DefaultVisit(SyntaxNode node)
1414
{
1515
var text = node.SyntaxTree.GetText().GetSubText(node.GetLocation().SourceSpan).ToString();
16-
return Semmle.Util.LineCounter.ComputeLineCounts(text);
16+
return LineCounter.ComputeLineCounts(text);
1717
}
1818

1919
public override LineCounts VisitMethodDeclaration(MethodDeclarationSyntax method)
@@ -29,7 +29,7 @@ public static LineCounts Visit(SyntaxToken identifier, SyntaxNode body)
2929
var textSpan = new Microsoft.CodeAnalysis.Text.TextSpan(start, end - start);
3030

3131
var text = body.SyntaxTree.GetText().GetSubText(textSpan) + "\r\n";
32-
return Semmle.Util.LineCounter.ComputeLineCounts(text);
32+
return LineCounter.ComputeLineCounts(text);
3333
}
3434

3535
public override LineCounts VisitConstructorDeclaration(ConstructorDeclarationSyntax method)
@@ -52,14 +52,10 @@ public static void NumberOfLines(this Context cx, TextWriter trapFile, ISymbol s
5252
{
5353
foreach (var decl in symbol.DeclaringSyntaxReferences)
5454
{
55-
cx.NumberOfLines(trapFile, (CSharpSyntaxNode)decl.GetSyntax(), callable);
55+
var node = (CSharpSyntaxNode)decl.GetSyntax();
56+
var lineCounts = node.Accept(new AstLineCounter());
57+
trapFile.numlines(callable, lineCounts);
5658
}
5759
}
58-
59-
public static void NumberOfLines(this Context cx, TextWriter trapFile, CSharpSyntaxNode node, IEntity callable)
60-
{
61-
var lineCounts = node.Accept(new AstLineCounter());
62-
trapFile.numlines(callable, lineCounts);
63-
}
6460
}
6561
}

0 commit comments

Comments
 (0)