mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
C#: Remove 'extractor.CreateContext' factory method
This commit is contained in:
@@ -136,7 +136,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
trapFile = trapWriter.TrapFile;
|
||||
if (nocache || !System.IO.File.Exists(trapFile))
|
||||
{
|
||||
var cx = extractor.CreateContext(null, trapWriter, null, false);
|
||||
var cx = new Extraction.Context(extractor, trapWriter);
|
||||
ExtractCIL(cx, assemblyPath, extractPdbs);
|
||||
extracted = true;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace Semmle.Extraction.CSharp
|
||||
var projectLayout = layout.LookupProjectOrDefault(transformedAssemblyPath);
|
||||
var trapWriter = projectLayout.CreateTrapWriter(Logger, transformedAssemblyPath, options.TrapCompression, discardDuplicates: false);
|
||||
compilationTrapFile = trapWriter; // Dispose later
|
||||
var cx = extractor.CreateContext(compilation.Clone(), trapWriter, new AssemblyScope(assembly, assemblyPath), AddAssemblyTrapPrefix);
|
||||
var cx = new Context(extractor, compilation.Clone(), trapWriter, new AssemblyScope(assembly, assemblyPath), AddAssemblyTrapPrefix);
|
||||
|
||||
compilationEntity = Entities.Compilation.Create(cx);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ namespace Semmle.Extraction.CSharp
|
||||
|
||||
if (c.GetAssemblyOrModuleSymbol(r) is IAssemblySymbol assembly)
|
||||
{
|
||||
var cx = extractor.CreateContext(c, trapWriter, new AssemblyScope(assembly, assemblyPath), AddAssemblyTrapPrefix);
|
||||
var cx = new Context(extractor, c, trapWriter, new AssemblyScope(assembly, assemblyPath), AddAssemblyTrapPrefix);
|
||||
|
||||
foreach (var module in assembly.Modules)
|
||||
{
|
||||
@@ -371,7 +371,7 @@ namespace Semmle.Extraction.CSharp
|
||||
|
||||
if (!upToDate)
|
||||
{
|
||||
var cx = extractor.CreateContext(compilation.Clone(), trapWriter, new SourceScope(tree), AddAssemblyTrapPrefix);
|
||||
var cx = new Context(extractor, compilation.Clone(), trapWriter, new SourceScope(tree), AddAssemblyTrapPrefix);
|
||||
// Ensure that the file itself is populated in case the source file is totally empty
|
||||
var root = tree.GetRoot();
|
||||
Extraction.Entities.File.Create(cx, root.SyntaxTree.FilePath);
|
||||
|
||||
@@ -225,14 +225,6 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
public Compilation Compilation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new context, one per source file/assembly.
|
||||
/// </summary>
|
||||
/// <param name="e">The extractor.</param>
|
||||
/// <param name="c">The Roslyn compilation.</param>
|
||||
/// <param name="extractedEntity">Name of the source/dll file.</param>
|
||||
/// <param name="scope">Defines which symbols are included in the trap file (e.g. AssemblyScope or SourceScope)</param>
|
||||
/// <param name="addAssemblyTrapPrefix">Whether to add assembly prefixes to TRAP labels.</param>
|
||||
public Context(IExtractor e, Compilation c, TrapWriter trapWriter, IExtractionScope scope, bool addAssemblyTrapPrefix)
|
||||
{
|
||||
Extractor = e;
|
||||
@@ -242,6 +234,11 @@ namespace Semmle.Extraction
|
||||
ShouldAddAssemblyTrapPrefix = addAssemblyTrapPrefix;
|
||||
}
|
||||
|
||||
public Context(IExtractor e, TrapWriter trapWriter)
|
||||
: this(e, null, trapWriter, null, false)
|
||||
{
|
||||
}
|
||||
|
||||
public bool FromSource => scope is SourceScope;
|
||||
|
||||
public ICommentGenerator CommentGenerator { get; } = new CommentProcessor();
|
||||
|
||||
@@ -83,16 +83,6 @@ namespace Semmle.Extraction
|
||||
/// The path transformer to apply.
|
||||
/// </summary>
|
||||
PathTransformer PathTransformer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new context.
|
||||
/// </summary>
|
||||
/// <param name="c">The C# compilation.</param>
|
||||
/// <param name="trapWriter">The trap writer.</param>
|
||||
/// <param name="scope">The extraction scope (what to include in this trap file).</param>
|
||||
/// <param name="addAssemblyTrapPrefix">Whether to add assembly prefixes to TRAP labels.</param>
|
||||
/// <returns></returns>
|
||||
Context CreateContext(Compilation c, TrapWriter trapWriter, IExtractionScope scope, bool addAssemblyTrapPrefix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -189,11 +179,6 @@ namespace Semmle.Extraction
|
||||
}
|
||||
}
|
||||
|
||||
public Context CreateContext(Compilation c, TrapWriter trapWriter, IExtractionScope scope, bool addAssemblyTrapPrefix)
|
||||
{
|
||||
return new Context(this, c, trapWriter, scope, addAssemblyTrapPrefix);
|
||||
}
|
||||
|
||||
public IEnumerable<string> MissingTypes => missingTypes;
|
||||
|
||||
public IEnumerable<string> MissingNamespaces => missingNamespaces;
|
||||
|
||||
Reference in New Issue
Block a user