Skip to content

Commit 6f07230

Browse files
committed
Relocate 'AstLineCounter'
1 parent 1cd7fd6 commit 6f07230

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Populators/Methods.cs renamed to csharp/extractor/Semmle.Extraction.CSharp/Entities/Method.AstLineCounter.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
using Semmle.Util;
55
using System.IO;
66

7-
namespace Semmle.Extraction.CSharp.Populators
7+
namespace Semmle.Extraction.CSharp.Entities
88
{
9-
public static class MethodExtensions
9+
public abstract partial class Method
1010
{
1111
private class AstLineCounter : CSharpSyntaxVisitor<LineCounts>
1212
{
@@ -47,15 +47,5 @@ public override LineCounts VisitOperatorDeclaration(OperatorDeclarationSyntax no
4747
return Visit(node.OperatorToken, node.Body ?? (SyntaxNode)node.ExpressionBody);
4848
}
4949
}
50-
51-
public static void NumberOfLines(this Context cx, TextWriter trapFile, ISymbol symbol, IEntity callable)
52-
{
53-
foreach (var decl in symbol.DeclaringSyntaxReferences)
54-
{
55-
var node = (CSharpSyntaxNode)decl.GetSyntax();
56-
var lineCounts = node.Accept(new AstLineCounter());
57-
trapFile.numlines(callable, lineCounts);
58-
}
59-
}
6050
}
6151
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Method.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.CodeAnalysis;
2+
using Microsoft.CodeAnalysis.CSharp;
23
using Microsoft.CodeAnalysis.CSharp.Syntax;
34
using Semmle.Extraction.CSharp.Populators;
45
using System.Collections.Generic;
@@ -7,7 +8,7 @@
78

89
namespace Semmle.Extraction.CSharp.Entities
910
{
10-
public abstract class Method : CachedSymbol<IMethodSymbol>, IExpressionParentEntity, IStatementParentEntity
11+
public abstract partial class Method : CachedSymbol<IMethodSymbol>, IExpressionParentEntity, IStatementParentEntity
1112
{
1213
protected Method(Context cx, IMethodSymbol init)
1314
: base(cx, init) { }
@@ -83,11 +84,21 @@ private void PopulateMethodBody(TextWriter trapFile)
8384
else
8485
Expression.Create(Context, expr, this, 0);
8586

86-
Context.NumberOfLines(trapFile, BodyDeclaringSymbol, this);
87+
NumberOfLines(trapFile, BodyDeclaringSymbol, this);
8788
});
8889
}
8990
}
9091

92+
public static void NumberOfLines(TextWriter trapFile, ISymbol symbol, IEntity callable)
93+
{
94+
foreach (var decl in symbol.DeclaringSyntaxReferences)
95+
{
96+
var node = (CSharpSyntaxNode)decl.GetSyntax();
97+
var lineCounts = node.Accept(new AstLineCounter());
98+
trapFile.numlines(callable, lineCounts);
99+
}
100+
}
101+
91102
public void Overrides(TextWriter trapFile)
92103
{
93104
foreach (var explicitInterface in symbol.ExplicitInterfaceImplementations

0 commit comments

Comments
 (0)