mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Relocate 'AstLineCounter'
This commit is contained in:
@@ -4,9 +4,9 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Semmle.Util;
|
||||
using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Populators
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
public static class MethodExtensions
|
||||
public abstract partial class Method
|
||||
{
|
||||
private class AstLineCounter : CSharpSyntaxVisitor<LineCounts>
|
||||
{
|
||||
@@ -47,15 +47,5 @@ namespace Semmle.Extraction.CSharp.Populators
|
||||
return Visit(node.OperatorToken, node.Body ?? (SyntaxNode)node.ExpressionBody);
|
||||
}
|
||||
}
|
||||
|
||||
public static void NumberOfLines(this Context cx, TextWriter trapFile, ISymbol symbol, IEntity callable)
|
||||
{
|
||||
foreach (var decl in symbol.DeclaringSyntaxReferences)
|
||||
{
|
||||
var node = (CSharpSyntaxNode)decl.GetSyntax();
|
||||
var lineCounts = node.Accept(new AstLineCounter());
|
||||
trapFile.numlines(callable, lineCounts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Semmle.Extraction.CSharp.Populators;
|
||||
using System.Collections.Generic;
|
||||
@@ -7,7 +8,7 @@ using System.Linq;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
public abstract class Method : CachedSymbol<IMethodSymbol>, IExpressionParentEntity, IStatementParentEntity
|
||||
public abstract partial class Method : CachedSymbol<IMethodSymbol>, IExpressionParentEntity, IStatementParentEntity
|
||||
{
|
||||
protected Method(Context cx, IMethodSymbol init)
|
||||
: base(cx, init) { }
|
||||
@@ -83,11 +84,21 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
else
|
||||
Expression.Create(Context, expr, this, 0);
|
||||
|
||||
Context.NumberOfLines(trapFile, BodyDeclaringSymbol, this);
|
||||
NumberOfLines(trapFile, BodyDeclaringSymbol, this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void NumberOfLines(TextWriter trapFile, ISymbol symbol, IEntity callable)
|
||||
{
|
||||
foreach (var decl in symbol.DeclaringSyntaxReferences)
|
||||
{
|
||||
var node = (CSharpSyntaxNode)decl.GetSyntax();
|
||||
var lineCounts = node.Accept(new AstLineCounter());
|
||||
trapFile.numlines(callable, lineCounts);
|
||||
}
|
||||
}
|
||||
|
||||
public void Overrides(TextWriter trapFile)
|
||||
{
|
||||
foreach (var explicitInterface in symbol.ExplicitInterfaceImplementations
|
||||
|
||||
Reference in New Issue
Block a user