|
1 | 1 | using Microsoft.CodeAnalysis; |
| 2 | +using Microsoft.CodeAnalysis.CSharp; |
2 | 3 | using Microsoft.CodeAnalysis.CSharp.Syntax; |
3 | 4 | using Semmle.Extraction.CSharp.Populators; |
4 | 5 | using System.Collections.Generic; |
|
7 | 8 |
|
8 | 9 | namespace Semmle.Extraction.CSharp.Entities |
9 | 10 | { |
10 | | - public abstract class Method : CachedSymbol<IMethodSymbol>, IExpressionParentEntity, IStatementParentEntity |
| 11 | + public abstract partial class Method : CachedSymbol<IMethodSymbol>, IExpressionParentEntity, IStatementParentEntity |
11 | 12 | { |
12 | 13 | protected Method(Context cx, IMethodSymbol init) |
13 | 14 | : base(cx, init) { } |
@@ -83,11 +84,21 @@ private void PopulateMethodBody(TextWriter trapFile) |
83 | 84 | else |
84 | 85 | Expression.Create(Context, expr, this, 0); |
85 | 86 |
|
86 | | - Context.NumberOfLines(trapFile, BodyDeclaringSymbol, this); |
| 87 | + NumberOfLines(trapFile, BodyDeclaringSymbol, this); |
87 | 88 | }); |
88 | 89 | } |
89 | 90 | } |
90 | 91 |
|
| 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 | + |
91 | 102 | public void Overrides(TextWriter trapFile) |
92 | 103 | { |
93 | 104 | foreach (var explicitInterface in symbol.ExplicitInterfaceImplementations |
|
0 commit comments