mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
Java/Kotlin: Add File.is{,Java,Kotlin}SourceFile()
This commit is contained in:
@@ -181,6 +181,15 @@ class File extends Container, @file {
|
||||
override string getURL() { result = "file://" + this.getAbsolutePath() + ":0:0:0:0" }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "File" }
|
||||
|
||||
/** Holds if this is a (Java or Kotlin) source file. */
|
||||
predicate isSourceFile() { this.isJavaSourceFile() or this.isKotlinSourceFile() }
|
||||
|
||||
/** Holds if this is a Java source file. */
|
||||
predicate isJavaSourceFile() { this.getExtension() = "java" }
|
||||
|
||||
/** Holds if this is a Kotlin source file. */
|
||||
predicate isKotlinSourceFile() { this.getExtension() = "kt" }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -196,7 +196,7 @@ class Location extends @location {
|
||||
}
|
||||
|
||||
private predicate hasSourceLocation(Top l, Location loc, File f) {
|
||||
hasLocation(l, loc) and f = loc.getFile() and f.getExtension() = ["java", "kt"]
|
||||
hasLocation(l, loc) and f = loc.getFile() and f.isSourceFile()
|
||||
}
|
||||
|
||||
cached
|
||||
|
||||
@@ -34,7 +34,7 @@ class Element extends @element, Top {
|
||||
* Elements pertaining to source files may include generated elements
|
||||
* not visible in source code, such as implicit default constructors.
|
||||
*/
|
||||
predicate fromSource() { this.getCompilationUnit().getExtension() = ["java", "kt"] }
|
||||
predicate fromSource() { this.getCompilationUnit().isSourceFile() }
|
||||
|
||||
/** Gets the compilation unit that this element belongs to. */
|
||||
CompilationUnit getCompilationUnit() { result = this.getFile() }
|
||||
|
||||
Reference in New Issue
Block a user