Merge pull request #6489 from hvitved/csharp/files-folders-drop-columns

C#: Drop redundant columns from `files` and `folders` relations
This commit is contained in:
Tom Hvitved
2021-09-13 11:02:13 +02:00
committed by GitHub
15 changed files with 4206 additions and 572 deletions

View File

@@ -161,8 +161,12 @@ namespace Semmle.Autobuild.Shared
pi.WorkingDirectory = workingDirectory;
// Environment variables can only be used when not redirecting stdout
if (!redirectStandardOutput && environment is not null)
environment.ForEach(kvp => pi.Environment[kvp.Key] = kvp.Value);
if (!redirectStandardOutput)
{
if (environment is not null)
environment.ForEach(kvp => pi.Environment[kvp.Key] = kvp.Value);
pi.Environment["CODEQL_REDUCE_FILES_FOLDERS_RELATIONS"] = "true";
}
return pi;
}

View File

@@ -10,6 +10,7 @@ extra_env_vars:
CORECLR_ENABLE_PROFILING: "1"
CORECLR_PROFILER: "{A3C70A64-7D41-4A94-A3F6-FD47D9259997}"
CORECLR_PROFILER_PATH_64: "${env.CODEQL_EXTRACTOR_CSHARP_ROOT}/tools/${env.CODEQL_PLATFORM}/clrtracer64${env.CODEQL_PLATFORM_DLL_EXTENSION}"
CODEQL_REDUCE_FILES_FOLDERS_RELATIONS: "true"
file_types:
- name: cs
display_name: C# sources

View File

@@ -37,7 +37,7 @@ namespace Semmle.Extraction.CIL.Entities
yield return parent;
yield return Tuples.containerparent(parent, this);
}
yield return Tuples.files(this, TransformedPath.Value, TransformedPath.NameWithoutExtension, TransformedPath.Extension);
yield return Tuples.files(this, TransformedPath.Value);
}
}
}

View File

@@ -28,7 +28,7 @@ namespace Semmle.Extraction.CIL.Entities
yield return parentFolder;
yield return Tuples.containerparent(parentFolder, this);
}
yield return Tuples.folders(this, transformedPath.Value, transformedPath.NameWithoutExtension);
yield return Tuples.folders(this, transformedPath.Value);
}
}

View File

@@ -203,14 +203,14 @@ namespace Semmle.Extraction.CIL
internal static Tuple containerparent(Folder parent, IFileOrFolder child) =>
new Tuple("containerparent", parent, child);
internal static Tuple files(File file, string fullName, string name, string extension) =>
new Tuple("files", file, fullName, name, extension, 0);
internal static Tuple files(File file, string fullName) =>
new Tuple("files", file, fullName);
internal static Tuple file_extraction_mode(File file, int mode) =>
new Tuple("file_extraction_mode", file, mode);
internal static Tuple folders(Folder folder, string path, string name) =>
new Tuple("folders", folder, path, name);
internal static Tuple folders(Folder folder, string path) =>
new Tuple("folders", folder, path);
internal static Tuple locations_default(PdbSourceLocation label, File file, int startLine, int startCol, int endLine, int endCol) =>
new Tuple("locations_default", label, file, startLine, startCol, endLine, endCol);

View File

@@ -17,7 +17,7 @@ namespace Semmle.Extraction.CSharp.Entities
public override void Populate(TextWriter trapFile)
{
trapFile.files(this, TransformedPath.Value, TransformedPath.NameWithoutExtension, TransformedPath.Extension);
trapFile.files(this, TransformedPath.Value);
if (TransformedPath.ParentDirectory is PathTransformer.ITransformedPath dir)
trapFile.containerparent(Extraction.Entities.Folder.Create(Context, dir), this);

View File

@@ -8,7 +8,7 @@ namespace Semmle.Extraction.Entities
public override void Populate(TextWriter trapFile)
{
trapFile.folders(this, Symbol.Value, Symbol.NameWithoutExtension);
trapFile.folders(this, Symbol.Value);
if (Symbol.ParentDirectory is PathTransformer.ITransformedPath parent)
trapFile.containerparent(Create(Context, parent), this);
}

View File

@@ -10,7 +10,7 @@ namespace Semmle.Extraction.Entities
public override void Populate(TextWriter trapFile)
{
trapFile.files(this, "", "", "");
trapFile.files(this, "");
}
public override void WriteId(EscapingTextWriter trapFile)

View File

@@ -18,14 +18,14 @@ namespace Semmle.Extraction
trapFile.WriteTuple("extractor_messages", error, (int)severity, origin, errorMessage, entityText, location, stackTrace);
}
public static void files(this System.IO.TextWriter trapFile, File file, string fullName, string name, string extension)
public static void files(this System.IO.TextWriter trapFile, File file, string fullName)
{
trapFile.WriteTuple("files", file, fullName, name, extension, 0);
trapFile.WriteTuple("files", file, fullName);
}
internal static void folders(this System.IO.TextWriter trapFile, Folder folder, string path, string name)
internal static void folders(this System.IO.TextWriter trapFile, Folder folder, string path)
{
trapFile.WriteTuple("folders", folder, path, name);
trapFile.WriteTuple("folders", folder, path);
}
public static void locations_default(this System.IO.TextWriter trapFile, SourceLocation label, Entities.File file, int startLine, int startCol, int endLine, int endCol)

View File

@@ -171,14 +171,14 @@ class Container extends @container {
/** A folder. */
class Folder extends Container, @folder {
override string getAbsolutePath() { folders(this, result, _) }
override string getAbsolutePath() { folders(this, result) }
override string getURL() { result = "folder://" + getAbsolutePath() }
}
/** A file. */
class File extends Container, @file {
override string getAbsolutePath() { files(this, result, _, _, _) }
override string getAbsolutePath() { files(this, result) }
/** Gets the number of lines in this file. */
int getNumberOfLines() { numlines(this, result, _, _) }
@@ -192,7 +192,7 @@ class File extends Container, @file {
override string getURL() { result = "file://" + this.getAbsolutePath() + ":0:0:0:0" }
/** Holds if this file contains source code. */
predicate fromSource() { files(this, _, _, "cs", _) }
predicate fromSource() { this.getExtension() = "cs" }
/** Holds if this file is a library. */
predicate fromLibrary() {

View File

@@ -276,22 +276,13 @@ assemblies(
string name: string ref,
string version: string ref);
/*
fromSource(0) = unknown,
fromSource(1) = from source,
fromSource(2) = from library
*/
files(
unique int id: @file,
string name: string ref,
string simple: string ref,
string ext: string ref,
int fromSource: int ref);
string name: string ref);
folders(
unique int id: @folder,
string name: string ref,
string simple: string ref);
string name: string ref);
@container = @folder | @file ;

View File

@@ -11522,18 +11522,6 @@
<k>name</k>
<v>47336</v>
</e>
<e>
<k>simple</k>
<v>26591</v>
</e>
<e>
<k>ext</k>
<v>43</v>
</e>
<e>
<k>fromSource</k>
<v>4</v>
</e>
</columnsizes>
<dependencies>
<dep>
@@ -11553,54 +11541,6 @@
</val>
</dep>
<dep>
<src>id</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>47336</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>id</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>47336</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>id</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>47336</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>id</trg>
<val>
@@ -11616,376 +11556,6 @@
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>47336</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>47336</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>47336</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>24857</v>
</b>
<b>
<a>2</a>
<b>154</b>
<v>1734</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>24857</v>
</b>
<b>
<a>2</a>
<b>154</b>
<v>1734</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>25597</v>
</b>
<b>
<a>2</a>
<b>5</b>
<v>994</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>26591</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>4</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>4</v>
</b>
<b>
<a>6</a>
<b>7</b>
<v>4</v>
</b>
<b>
<a>166</a>
<b>167</b>
<v>4</v>
</b>
<b>
<a>173</a>
<b>174</b>
<v>4</v>
</b>
<b>
<a>861</a>
<b>862</b>
<v>4</v>
</b>
<b>
<a>995</a>
<b>996</b>
<v>4</v>
</b>
<b>
<a>2875</a>
<b>2876</b>
<v>4</v>
</b>
<b>
<a>4635</a>
<b>4636</b>
<v>4</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>4</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>4</v>
</b>
<b>
<a>6</a>
<b>7</b>
<v>4</v>
</b>
<b>
<a>166</a>
<b>167</b>
<v>4</v>
</b>
<b>
<a>173</a>
<b>174</b>
<v>4</v>
</b>
<b>
<a>861</a>
<b>862</b>
<v>4</v>
</b>
<b>
<a>995</a>
<b>996</b>
<v>4</v>
</b>
<b>
<a>2875</a>
<b>2876</b>
<v>4</v>
</b>
<b>
<a>4635</a>
<b>4636</b>
<v>4</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>4</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>9</v>
</b>
<b>
<a>166</a>
<b>167</b>
<v>4</v>
</b>
<b>
<a>169</a>
<b>170</b>
<v>4</v>
</b>
<b>
<a>214</a>
<b>215</b>
<v>4</v>
</b>
<b>
<a>650</a>
<b>651</b>
<v>4</v>
</b>
<b>
<a>790</a>
<b>791</b>
<v>4</v>
</b>
<b>
<a>3818</a>
<b>3819</b>
<v>4</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>43</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>9714</a>
<b>9715</b>
<v>4</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>9714</a>
<b>9715</b>
<v>4</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>5457</a>
<b>5458</b>
<v>4</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>9</a>
<b>10</b>
<v>4</v>
</b>
</bs>
</hist>
</val>
</dep>
</dependencies>
</relation>
<relation>
@@ -12000,10 +11570,6 @@
<k>name</k>
<v>15622</v>
</e>
<e>
<k>simple</k>
<v>2777</v>
</e>
</columnsizes>
<dependencies>
<dep>
@@ -12023,22 +11589,6 @@
</val>
</dep>
<dep>
<src>id</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>17839</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>id</trg>
<val>
@@ -12054,99 +11604,6 @@
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>13405</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>2217</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>1637</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>540</v>
</b>
<b>
<a>3</a>
<b>4</b>
<v>209</v>
</b>
<b>
<a>4</a>
<b>10</b>
<v>209</v>
</b>
<b>
<a>10</a>
<b>383</b>
<v>180</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>1637</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>540</v>
</b>
<b>
<a>3</a>
<b>4</b>
<v>209</v>
</b>
<b>
<a>4</a>
<b>10</b>
<v>209</v>
</b>
<b>
<a>10</a>
<b>383</b>
<v>180</v>
</b>
</bs>
</hist>
</val>
</dep>
</dependencies>
</relation>
<relation>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
description: Removed unused column from the `folders` and `files` relations
compatibility: full
files.rel: reorder files.rel (int id, string name, string simple, string ext, int fromSource) id name
folders.rel: reorder folders.rel (int id, string name, string simple) id name