mirror of
https://github.com/github/codeql.git
synced 2026-04-24 00:05:14 +02:00
Merge pull request #2418 from max-schaefer/js/file-locatable
JavaScript: Make `File` not extend `Locatable` anymore.
This commit is contained in:
@@ -198,8 +198,13 @@ class Folder extends Container, @folder {
|
||||
}
|
||||
|
||||
/** A file. */
|
||||
class File extends Container, @file, Locatable {
|
||||
override Location getLocation() { hasLocation(this, result) }
|
||||
class File extends Container, @file {
|
||||
/**
|
||||
* Gets the location of this file.
|
||||
*
|
||||
* Note that files have special locations starting and ending at line zero, column zero.
|
||||
*/
|
||||
Location getLocation() { hasLocation(this, result) }
|
||||
|
||||
override string getAbsolutePath() { files(this, result, _, _, _) }
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ abstract class Documentable extends ASTNode {
|
||||
class JSDocTypeExprParent extends @jsdoc_type_expr_parent, Locatable {
|
||||
override Location getLocation() { hasLocation(this, result) }
|
||||
|
||||
/** Gets the JSDoc comment to which this element belongs. */
|
||||
JSDoc getJSDocComment() { none() }
|
||||
}
|
||||
|
||||
|
||||
@@ -132,3 +132,15 @@ class Locatable extends @locatable {
|
||||
none()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A `File`, considered as a `Locatable`.
|
||||
*
|
||||
* For reasons of backwards compatibility, @file is a subtype of @locatable. This class exists to
|
||||
* provide an override of `Locatable.getLocation()` for @files, since it would otherwise default
|
||||
* to `none()`, which is unhelpful.
|
||||
*/
|
||||
private class FileLocatable extends File, Locatable {
|
||||
override Location getLocation() { result = File.super.getLocation() }
|
||||
override string toString() { result = File.super.toString() }
|
||||
}
|
||||
|
||||
@@ -194,7 +194,8 @@ abstract class ScriptDependency extends Dependency {
|
||||
abstract Expr getAnApiUse();
|
||||
|
||||
override Locatable getAUse(string kind) {
|
||||
kind = "import" and result.(HTML::HtmlFile) = this.getFile()
|
||||
kind = "import" and
|
||||
result = this.getFile().(HTML::HtmlFile).getATopLevel()
|
||||
or
|
||||
kind = "use" and result = getAnApiUse()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user