Skip to content

Commit b36d35b

Browse files
committed
Revert "C#: Adjust 'fromSource' to hold only on files passed to the compiler as a source file"
This reverts commit 1dab159.
1 parent 1dab159 commit b36d35b

File tree

5 files changed

+8
-18
lines changed

5 files changed

+8
-18
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/File.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ protected File(Context cx, string path)
1717

1818
public override void Populate(TextWriter trapFile)
1919
{
20-
var trees = Context.Compilation.SyntaxTrees.Where(t => t.FilePath == originalPath);
21-
var isSource = trees.Any();
22-
23-
trapFile.files(this, TransformedPath.Value, TransformedPath.NameWithoutExtension, TransformedPath.Extension, isSource ? FileSourceKind.FromSource : FileSourceKind.Unknown);
20+
trapFile.files(this, TransformedPath.Value, TransformedPath.NameWithoutExtension, TransformedPath.Extension);
2421

2522
if (TransformedPath.ParentDirectory is PathTransformer.ITransformedPath dir)
2623
trapFile.containerparent(Extraction.Entities.Folder.Create(Context, dir), this);
2724

28-
if (isSource)
25+
var trees = Context.Compilation.SyntaxTrees.Where(t => t.FilePath == originalPath);
26+
27+
if (trees.Any())
2928
{
3029
foreach (var text in trees.Select(tree => tree.GetText()))
3130
{

csharp/extractor/Semmle.Extraction/Entities/GeneratedFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private GeneratedFile(Context cx) : base(cx, "") { }
1010

1111
public override void Populate(TextWriter trapFile)
1212
{
13-
trapFile.files(this, "", "", "", FileSourceKind.Unknown);
13+
trapFile.files(this, "", "", "");
1414
}
1515

1616
public override void WriteId(TextWriter trapFile)

csharp/extractor/Semmle.Extraction/FileSourceKind.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

csharp/extractor/Semmle.Extraction/Tuples.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ internal static void extractor_messages(this System.IO.TextWriter trapFile, Extr
1818
trapFile.WriteTuple("extractor_messages", error, (int)severity, origin, errorMessage, entityText, location, stackTrace);
1919
}
2020

21-
public static void files(this System.IO.TextWriter trapFile, File file, string fullName, string name, string extension, FileSourceKind kind)
21+
public static void files(this System.IO.TextWriter trapFile, File file, string fullName, string name, string extension)
2222
{
23-
trapFile.WriteTuple("files", file, fullName, name, extension, (int)kind);
23+
trapFile.WriteTuple("files", file, fullName, name, extension, 0);
2424
}
2525

2626
internal static void folders(this System.IO.TextWriter trapFile, Folder folder, string path, string name)

csharp/ql/src/semmle/code/csharp/File.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class File extends Container, @file {
192192
override string getURL() { result = "file://" + this.getAbsolutePath() + ":0:0:0:0" }
193193

194194
/** Holds if this file contains source code. */
195-
predicate fromSource() { files(this, _, _, _, 1) }
195+
predicate fromSource() { this.getNumberOfLinesOfCode() > 0 }
196196

197197
/** Holds if this file is a library. */
198198
predicate fromLibrary() {

0 commit comments

Comments
 (0)