mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
Simplify standalone extractor
This commit is contained in:
@@ -19,7 +19,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// </summary>
|
||||
public class Analyser : IDisposable
|
||||
{
|
||||
protected ExtractionContext? ExtractionContext;
|
||||
public ExtractionContext? ExtractionContext { get; protected set; }
|
||||
protected CSharpCompilation? compilation;
|
||||
protected CommonOptions? options;
|
||||
private protected Entities.Compilation? compilationEntity;
|
||||
|
||||
@@ -93,20 +93,13 @@ namespace Semmle.Extraction.CSharp
|
||||
/// <returns><see cref="ExitCode"/></returns>
|
||||
public static ExitCode Run(string[] args)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var analyzerStopwatch = new Stopwatch();
|
||||
analyzerStopwatch.Start();
|
||||
|
||||
var options = Options.CreateWithEnvironment(args);
|
||||
var workingDirectory = Directory.GetCurrentDirectory();
|
||||
var compilerArgs = options.CompilerArguments.ToArray();
|
||||
|
||||
using var logger = MakeLogger(options.Verbosity, options.Console);
|
||||
|
||||
var canonicalPathCache = CanonicalPathCache.Create(logger, 1000);
|
||||
var pathTransformer = new PathTransformer(canonicalPathCache);
|
||||
|
||||
using var analyser = new TracingAnalyser(new LogProgressMonitor(logger), logger, pathTransformer, canonicalPathCache, options.AssemblySensitiveTrap);
|
||||
|
||||
try
|
||||
{
|
||||
if (options.ProjectsToLoad.Any())
|
||||
@@ -115,13 +108,20 @@ namespace Semmle.Extraction.CSharp
|
||||
}
|
||||
|
||||
var compilerVersion = new CompilerVersion(options);
|
||||
|
||||
if (compilerVersion.SkipExtraction)
|
||||
{
|
||||
logger.Log(Severity.Warning, " Unrecognized compiler '{0}' because {1}", compilerVersion.SpecifiedCompiler, compilerVersion.SkipReason);
|
||||
return ExitCode.Ok;
|
||||
}
|
||||
|
||||
var workingDirectory = Directory.GetCurrentDirectory();
|
||||
var compilerArgs = options.CompilerArguments.ToArray();
|
||||
|
||||
var canonicalPathCache = CanonicalPathCache.Create(logger, 1000);
|
||||
var pathTransformer = new PathTransformer(canonicalPathCache);
|
||||
|
||||
using var analyser = new TracingAnalyser(new LogProgressMonitor(logger), logger, pathTransformer, canonicalPathCache, options.AssemblySensitiveTrap);
|
||||
|
||||
var compilerArguments = CSharpCommandLineParser.Default.Parse(
|
||||
compilerVersion.ArgsWithResponse,
|
||||
workingDirectory,
|
||||
@@ -144,7 +144,7 @@ namespace Semmle.Extraction.CSharp
|
||||
return ExitCode.Ok;
|
||||
}
|
||||
|
||||
return AnalyseTracing(workingDirectory, compilerArgs, analyser, compilerArguments, options, stopwatch);
|
||||
return AnalyseTracing(workingDirectory, compilerArgs, analyser, compilerArguments, options, analyzerStopwatch);
|
||||
}
|
||||
catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
@@ -22,13 +21,5 @@ namespace Semmle.Extraction.CSharp
|
||||
LogExtractorInfo();
|
||||
SetReferencePaths();
|
||||
}
|
||||
|
||||
#nullable disable warnings
|
||||
|
||||
public IEnumerable<string> MissingTypes => ExtractionContext.MissingTypes;
|
||||
|
||||
public IEnumerable<string> MissingNamespaces => ExtractionContext.MissingNamespaces;
|
||||
|
||||
#nullable restore warnings
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user