mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
Merge pull request #3260 from asger-semmle/js/location-tweaks
Approved by erik-krogh
This commit is contained in:
@@ -23,6 +23,10 @@ import javascript
|
|||||||
class ASTNode extends @ast_node, Locatable {
|
class ASTNode extends @ast_node, Locatable {
|
||||||
override Location getLocation() { hasLocation(this, result) }
|
override Location getLocation() { hasLocation(this, result) }
|
||||||
|
|
||||||
|
override File getFile() {
|
||||||
|
result = getLocation().getFile() // Specialized for performance reasons
|
||||||
|
}
|
||||||
|
|
||||||
/** Gets the first token belonging to this element. */
|
/** Gets the first token belonging to this element. */
|
||||||
Token getFirstToken() {
|
Token getFirstToken() {
|
||||||
exists(Location l1, Location l2 |
|
exists(Location l1, Location l2 |
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ class BugTrackerInfo extends JSONValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the bug tracker URL. */
|
/** Gets the bug tracker URL. */
|
||||||
string getURL() {
|
string getUrl() {
|
||||||
result = this.(JSONObject).getPropStringValue("url") or
|
result = this.(JSONObject).getPropStringValue("url") or
|
||||||
result = this.(JSONString).getValue()
|
result = this.(JSONString).getValue()
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ class ContributorInfo extends JSONValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the contributor's homepage URL. */
|
/** Gets the contributor's homepage URL. */
|
||||||
string getURL() {
|
string getUrl() {
|
||||||
result = this.(JSONObject).getPropStringValue("url") or
|
result = this.(JSONObject).getPropStringValue("url") or
|
||||||
result = parseInfo(3)
|
result = parseInfo(3)
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ class RepositoryInfo extends JSONObject {
|
|||||||
string getType() { result = getPropStringValue("type") }
|
string getType() { result = getPropStringValue("type") }
|
||||||
|
|
||||||
/** Gets the repository URL. */
|
/** Gets the repository URL. */
|
||||||
string getURL() { result = getPropStringValue("url") }
|
string getUrl() { result = getPropStringValue("url") }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -166,15 +166,11 @@ module DataFlow {
|
|||||||
predicate hasLocationInfo(
|
predicate hasLocationInfo(
|
||||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||||
) {
|
) {
|
||||||
filepath = "" and
|
none()
|
||||||
startline = 0 and
|
|
||||||
startcolumn = 0 and
|
|
||||||
endline = 0 and
|
|
||||||
endcolumn = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the file this data flow node comes from. */
|
/** Gets the file this data flow node comes from. */
|
||||||
File getFile() { hasLocationInfo(result.getAbsolutePath(), _, _, _, _) }
|
File getFile() { none() } // overridden in subclasses
|
||||||
|
|
||||||
/** Gets the start line of this data flow node. */
|
/** Gets the start line of this data flow node. */
|
||||||
int getStartLine() { hasLocationInfo(_, result, _, _, _) }
|
int getStartLine() { hasLocationInfo(_, result, _, _, _) }
|
||||||
@@ -314,6 +310,8 @@ module DataFlow {
|
|||||||
astNode.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
astNode.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override File getFile() { result = astNode.getFile() }
|
||||||
|
|
||||||
override string toString() { result = astNode.toString() }
|
override string toString() { result = astNode.toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,6 +336,8 @@ module DataFlow {
|
|||||||
|
|
||||||
override string toString() { result = ssa.getSourceVariable().getName() }
|
override string toString() { result = ssa.getSourceVariable().getName() }
|
||||||
|
|
||||||
|
override File getFile() { result = ssa.getBasicBlock().getFile() }
|
||||||
|
|
||||||
override ASTNode getAstNode() { none() }
|
override ASTNode getAstNode() { none() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,6 +362,8 @@ module DataFlow {
|
|||||||
|
|
||||||
override string toString() { result = prop.(ASTNode).toString() }
|
override string toString() { result = prop.(ASTNode).toString() }
|
||||||
|
|
||||||
|
override File getFile() { result = prop.(ASTNode).getFile() }
|
||||||
|
|
||||||
override ASTNode getAstNode() { result = prop }
|
override ASTNode getAstNode() { result = prop }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,6 +387,8 @@ module DataFlow {
|
|||||||
|
|
||||||
override string toString() { result = "..." + rest.toString() }
|
override string toString() { result = "..." + rest.toString() }
|
||||||
|
|
||||||
|
override File getFile() { result = pattern.getFile() }
|
||||||
|
|
||||||
override ASTNode getAstNode() { result = rest }
|
override ASTNode getAstNode() { result = rest }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,6 +411,8 @@ module DataFlow {
|
|||||||
|
|
||||||
override string toString() { result = pattern.toString() }
|
override string toString() { result = pattern.toString() }
|
||||||
|
|
||||||
|
override File getFile() { result = pattern.getFile() }
|
||||||
|
|
||||||
override ASTNode getAstNode() { result = pattern }
|
override ASTNode getAstNode() { result = pattern }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,6 +436,8 @@ module DataFlow {
|
|||||||
|
|
||||||
override string toString() { result = elt.toString() }
|
override string toString() { result = elt.toString() }
|
||||||
|
|
||||||
|
override File getFile() { result = pattern.getFile() }
|
||||||
|
|
||||||
override ASTNode getAstNode() { result = elt }
|
override ASTNode getAstNode() { result = elt }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,6 +465,8 @@ module DataFlow {
|
|||||||
|
|
||||||
override string toString() { result = elt.toString() }
|
override string toString() { result = elt.toString() }
|
||||||
|
|
||||||
|
override File getFile() { result = arr.getFile() }
|
||||||
|
|
||||||
override ASTNode getAstNode() { result = elt }
|
override ASTNode getAstNode() { result = elt }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,6 +489,8 @@ module DataFlow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override string toString() { result = "reflective call" }
|
override string toString() { result = "reflective call" }
|
||||||
|
|
||||||
|
override File getFile() { result = call.getFile() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -498,6 +510,8 @@ module DataFlow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override string toString() { result = imprt.toString() }
|
override string toString() { result = imprt.toString() }
|
||||||
|
|
||||||
|
override File getFile() { result = imprt.getFile() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -925,6 +939,8 @@ module DataFlow {
|
|||||||
) {
|
) {
|
||||||
p.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
p.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override File getFile() { result = p.getFile() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -945,6 +961,8 @@ module DataFlow {
|
|||||||
|
|
||||||
/** Gets the attribute corresponding to this data flow node. */
|
/** Gets the attribute corresponding to this data flow node. */
|
||||||
HTML::Attribute getAttribute() { result = attr }
|
HTML::Attribute getAttribute() { result = attr }
|
||||||
|
|
||||||
|
override File getFile() { result = attr.getFile() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -969,6 +987,8 @@ module DataFlow {
|
|||||||
* Gets the function corresponding to this exceptional return node.
|
* Gets the function corresponding to this exceptional return node.
|
||||||
*/
|
*/
|
||||||
Function getFunction() { result = function }
|
Function getFunction() { result = function }
|
||||||
|
|
||||||
|
override File getFile() { result = function.getFile() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -993,6 +1013,8 @@ module DataFlow {
|
|||||||
* Gets the invocation corresponding to this exceptional return node.
|
* Gets the invocation corresponding to this exceptional return node.
|
||||||
*/
|
*/
|
||||||
DataFlow::InvokeNode getInvocation() { result = invoke.flow() }
|
DataFlow::InvokeNode getInvocation() { result = invoke.flow() }
|
||||||
|
|
||||||
|
override File getFile() { result = invoke.getFile() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1220,6 +1242,10 @@ module DataFlow {
|
|||||||
.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override File getFile() {
|
||||||
|
exists(StmtContainer container | this = TThisNode(container) | result = container.getFile())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user