mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Revert "JS: Add support for Closure modules"
This commit is contained in:
@@ -49,7 +49,5 @@ where
|
||||
// don't flag assignments in externs
|
||||
not dead.(ASTNode).inExternsFile() and
|
||||
// don't flag exported variables
|
||||
not any(ES2015Module m).exportsAs(v, _) and
|
||||
// don't flag 'exports' assignments in closure modules
|
||||
not any(Closure::ClosureModule mod).getExportsVariable() = v
|
||||
not any(ES2015Module m).exportsAs(v, _)
|
||||
select dead, "This definition of " + v.getName() + " is useless, since its value is never read."
|
||||
|
||||
@@ -46,7 +46,5 @@ where
|
||||
moduleExportsAssign(_, exportsVal) and
|
||||
// however, if there are no further uses of `exports` the assignment is useless anyway
|
||||
strictcount(exportsVar.getAnAccess()) > 1
|
||||
) and
|
||||
// export assignments do work in closure modules
|
||||
not assgn.getTopLevel() instanceof Closure::ClosureModule
|
||||
)
|
||||
select assgn, "Assigning to 'exports' does not export anything."
|
||||
|
||||
@@ -8,7 +8,6 @@ import semmle.javascript.AST
|
||||
import semmle.javascript.BasicBlocks
|
||||
import semmle.javascript.CFG
|
||||
import semmle.javascript.Classes
|
||||
import semmle.javascript.Closure
|
||||
import semmle.javascript.Comments
|
||||
import semmle.javascript.Concepts
|
||||
import semmle.javascript.Constants
|
||||
|
||||
@@ -1,209 +1,75 @@
|
||||
/**
|
||||
* Provides classes for working with the Closure-Library module system.
|
||||
* Provides classes for working with Google Closure code.
|
||||
*/
|
||||
|
||||
import javascript
|
||||
|
||||
module Closure {
|
||||
/**
|
||||
* A call to a function in the `goog` namespace such as `goog.provide` or `goog.load`.
|
||||
*/
|
||||
class GoogFunctionCall extends CallExpr {
|
||||
GoogFunctionCall() {
|
||||
exists(GlobalVariable gv | gv.getName() = "goog" |
|
||||
this.getCallee().(DotExpr).getBase() = gv.getAnAccess()
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the name of the invoked function. */
|
||||
string getFunctionName() { result = getCallee().(DotExpr).getPropertyName() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression statement consisting of a call to a function
|
||||
* in the `goog` namespace.
|
||||
*/
|
||||
class GoogFunctionCallStmt extends ExprStmt {
|
||||
GoogFunctionCallStmt() { super.getExpr() instanceof GoogFunctionCall }
|
||||
|
||||
override GoogFunctionCall getExpr() { result = super.getExpr() }
|
||||
|
||||
/** Gets the name of the invoked function. */
|
||||
string getFunctionName() { result = getExpr().getFunctionName() }
|
||||
|
||||
/** Gets the `i`th argument to the invoked function. */
|
||||
Expr getArgument(int i) { result = getExpr().getArgument(i) }
|
||||
|
||||
/** Gets an argument to the invoked function. */
|
||||
Expr getAnArgument() { result = getArgument(_) }
|
||||
}
|
||||
|
||||
abstract private class GoogNamespaceRef extends ExprOrStmt { abstract string getNamespaceId(); }
|
||||
|
||||
/**
|
||||
* A call to `goog.provide`.
|
||||
*/
|
||||
class GoogProvide extends GoogFunctionCallStmt, GoogNamespaceRef {
|
||||
GoogProvide() { getFunctionName() = "provide" }
|
||||
|
||||
/** Gets the identifier of the namespace created by this call. */
|
||||
override string getNamespaceId() { result = getArgument(0).getStringValue() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to `goog.require`.
|
||||
*/
|
||||
class GoogRequire extends GoogFunctionCall, GoogNamespaceRef {
|
||||
GoogRequire() { getFunctionName() = "require" }
|
||||
|
||||
/** Gets the identifier of the namespace imported by this call. */
|
||||
override string getNamespaceId() { result = getArgument(0).getStringValue() }
|
||||
}
|
||||
|
||||
private class GoogRequireImport extends GoogRequire, Import {
|
||||
/** Gets the module in which this import appears. */
|
||||
override Module getEnclosingModule() { result = getTopLevel() }
|
||||
|
||||
/** Gets the (unresolved) path that this import refers to. */
|
||||
override PathExpr getImportedPath() { result = getArgument(0) }
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to `goog.module` or `goog.declareModuleId`.
|
||||
*/
|
||||
class GoogModuleDeclaration extends GoogFunctionCallStmt, GoogNamespaceRef {
|
||||
GoogModuleDeclaration() {
|
||||
getFunctionName() = "module" or
|
||||
getFunctionName() = "declareModuleId"
|
||||
}
|
||||
|
||||
/** Gets the identifier of the namespace imported by this call. */
|
||||
override string getNamespaceId() { result = getArgument(0).getStringValue() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A module using the Closure module system, declared using `goog.module()` or `goog.declareModuleId()`.
|
||||
*/
|
||||
class ClosureModule extends Module {
|
||||
ClosureModule() { getAChildStmt() instanceof GoogModuleDeclaration }
|
||||
|
||||
/**
|
||||
* Gets the call to `goog.module` or `goog.declareModuleId` in this module.
|
||||
*/
|
||||
GoogModuleDeclaration getModuleDeclaration() { result = getAChildStmt() }
|
||||
|
||||
/**
|
||||
* Gets the namespace of this module.
|
||||
*/
|
||||
string getNamespaceId() { result = getModuleDeclaration().getNamespaceId() }
|
||||
|
||||
override Module getAnImportedModule() {
|
||||
exists(GoogRequireImport imprt |
|
||||
imprt.getEnclosingModule() = this and
|
||||
result.(ClosureModule).getNamespaceId() = imprt.getNamespaceId()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the top-level `exports` variable in this module, if this module is defined by
|
||||
* a `good.module` call.
|
||||
*
|
||||
* This variable denotes the object exported from this module.
|
||||
*
|
||||
* Has no result for ES6 modules using `goog.declareModuleId`.
|
||||
*/
|
||||
Variable getExportsVariable() {
|
||||
getModuleDeclaration().getFunctionName() = "module" and
|
||||
result = getScope().getVariable("exports")
|
||||
}
|
||||
|
||||
override predicate exports(string name, ASTNode export) {
|
||||
exists(DataFlow::PropWrite write, Expr base |
|
||||
write.getAstNode() = export and
|
||||
write.writes(base.flow(), name, _) and
|
||||
(
|
||||
base = getExportsVariable().getAReference()
|
||||
or
|
||||
base = getExportsVariable().getAnAssignedExpr()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A global Closure script, that is, a toplevel that is executed in the global scope and
|
||||
* contains a toplevel call to `goog.provide` or `goog.require`.
|
||||
*/
|
||||
class ClosureScript extends TopLevel {
|
||||
ClosureScript() {
|
||||
not this instanceof ClosureModule and
|
||||
getAChildStmt() instanceof GoogProvide
|
||||
or
|
||||
getAChildStmt().(ExprStmt).getExpr() instanceof GoogRequire
|
||||
}
|
||||
|
||||
/** Gets the identifier of a namespace required by this module. */
|
||||
string getARequiredNamespace() {
|
||||
result = getAChildStmt().(ExprStmt).getExpr().(GoogRequire).getNamespaceId()
|
||||
}
|
||||
|
||||
/** Gets the identifer of a namespace provided by this module. */
|
||||
string getAProvidedNamespace() { result = getAChildStmt().(GoogProvide).getNamespaceId() }
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `name` is a closure namespace, including proper namespace prefixes.
|
||||
*/
|
||||
pragma[noinline]
|
||||
predicate isLibraryNamespacePath(string name) {
|
||||
exists(string namespace | namespace = any(GoogNamespaceRef provide).getNamespaceId() |
|
||||
name = namespace.substring(0, namespace.indexOf("."))
|
||||
or
|
||||
name = namespace
|
||||
/**
|
||||
* A call to a function in the `goog` namespace such as `goog.provide` or `goog.load`.
|
||||
*/
|
||||
class GoogFunctionCall extends CallExpr {
|
||||
GoogFunctionCall() {
|
||||
exists(GlobalVariable gv | gv.getName() = "goog" |
|
||||
this.getCallee().(DotExpr).getBase() = gv.getAnAccess()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the closure namespace path addressed by the given dataflow node, if any.
|
||||
*/
|
||||
string getLibraryAccessPath(DataFlow::SourceNode node) {
|
||||
isLibraryNamespacePath(result) and
|
||||
node = DataFlow::globalVarRef(result)
|
||||
or
|
||||
isLibraryNamespacePath(result) and
|
||||
exists(DataFlow::PropRead read | node = read |
|
||||
result = getLibraryAccessPath(read.getBase().getALocalSource()) + "." + read.getPropertyName()
|
||||
)
|
||||
or
|
||||
// Associate an access path with the immediate RHS of a store on a closure namespace.
|
||||
// This is to support patterns like:
|
||||
// foo.bar = { baz() {} }
|
||||
exists(DataFlow::PropWrite write |
|
||||
node = write.getRhs() and
|
||||
result = getWrittenLibraryAccessPath(write)
|
||||
)
|
||||
or
|
||||
result = node.asExpr().(GoogRequire).getNamespaceId()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the closure namespace path written to by the given property write, if any.
|
||||
*/
|
||||
string getWrittenLibraryAccessPath(DataFlow::PropWrite node) {
|
||||
result = getLibraryAccessPath(node.getBase().getALocalSource()) + "." + node.getPropertyName()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a dataflow node that refers to the given Closure module.
|
||||
*/
|
||||
DataFlow::SourceNode moduleImport(string moduleName) {
|
||||
getLibraryAccessPath(result) = moduleName
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a dataflow node that refers to the given member of a Closure module.
|
||||
*/
|
||||
DataFlow::SourceNode moduleMember(string moduleName, string memberName) {
|
||||
result = moduleImport(moduleName).getAPropertyRead(memberName)
|
||||
}
|
||||
/** Gets the name of the invoked function. */
|
||||
string getFunctionName() { result = getCallee().(DotExpr).getPropertyName() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression statement consisting of a call to a function
|
||||
* in the `goog` namespace.
|
||||
*/
|
||||
class GoogFunctionCallStmt extends ExprStmt {
|
||||
GoogFunctionCallStmt() { super.getExpr() instanceof GoogFunctionCall }
|
||||
|
||||
override GoogFunctionCall getExpr() { result = super.getExpr() }
|
||||
|
||||
/** Gets the name of the invoked function. */
|
||||
string getFunctionName() { result = getExpr().getFunctionName() }
|
||||
|
||||
/** Gets the `i`th argument to the invoked function. */
|
||||
Expr getArgument(int i) { result = getExpr().getArgument(i) }
|
||||
|
||||
/** Gets an argument to the invoked function. */
|
||||
Expr getAnArgument() { result = getArgument(_) }
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to `goog.provide`.
|
||||
*/
|
||||
class GoogProvide extends GoogFunctionCallStmt {
|
||||
GoogProvide() { getFunctionName() = "provide" }
|
||||
|
||||
/** Gets the identifier of the namespace created by this call. */
|
||||
string getNamespaceId() { result = getArgument(0).(ConstantString).getStringValue() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to `goog.require`.
|
||||
*/
|
||||
class GoogRequire extends GoogFunctionCallStmt {
|
||||
GoogRequire() { getFunctionName() = "require" }
|
||||
|
||||
/** Gets the identifier of the namespace imported by this call. */
|
||||
string getNamespaceId() { result = getArgument(0).(ConstantString).getStringValue() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A Closure module, that is, a toplevel that contains a call to `goog.provide` or
|
||||
* `goog.require`.
|
||||
*/
|
||||
class ClosureModule extends TopLevel {
|
||||
ClosureModule() {
|
||||
getAChildStmt() instanceof GoogProvide or
|
||||
getAChildStmt() instanceof GoogRequire
|
||||
}
|
||||
|
||||
/** Gets the identifier of a namespace required by this module. */
|
||||
string getARequiredNamespace() { result = getAChildStmt().(GoogRequire).getNamespaceId() }
|
||||
|
||||
/** Gets the identifer of a namespace provided by this module. */
|
||||
string getAProvidedNamespace() { result = getAChildStmt().(GoogProvide).getNamespaceId() }
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import javascript
|
||||
*/
|
||||
class ES2015Module extends Module {
|
||||
ES2015Module() {
|
||||
isES2015Module(this)
|
||||
isModule(this) and
|
||||
not isNodejs(this)
|
||||
}
|
||||
|
||||
override ModuleScope getScope() { result.getScopeElement() = this }
|
||||
|
||||
@@ -1039,7 +1039,7 @@ module DataFlow {
|
||||
or
|
||||
exists(GlobalVarAccess va |
|
||||
nd = valueNode(va.(VarUse)) and
|
||||
if Closure::isLibraryNamespacePath(va.getName()) then cause = "heap" else cause = "global"
|
||||
cause = "global"
|
||||
)
|
||||
or
|
||||
exists(Expr e | e = nd.asExpr() and cause = "call" |
|
||||
|
||||
@@ -332,48 +332,3 @@ private class AnalyzedExportAssign extends AnalyzedPropertyWrite, DataFlow::Valu
|
||||
source = this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flow analysis for assignments to the `exports` variable in a Closure module.
|
||||
*/
|
||||
private class AnalyzedClosureExportAssign extends AnalyzedPropertyWrite, DataFlow::ValueNode {
|
||||
override AssignExpr astNode;
|
||||
|
||||
Closure::ClosureModule mod;
|
||||
|
||||
AnalyzedClosureExportAssign() { astNode.getLhs() = mod.getExportsVariable().getAReference() }
|
||||
|
||||
override predicate writes(AbstractValue baseVal, string propName, DataFlow::AnalyzedNode source) {
|
||||
baseVal = TAbstractModuleObject(astNode.getTopLevel()) and
|
||||
propName = "exports" and
|
||||
source = astNode.getRhs().flow()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read of a global access path exported by a Closure library.
|
||||
*
|
||||
* This adds a direct flow edge to the assigned value.
|
||||
*/
|
||||
private class AnalyzedClosureGlobalAccessPath extends AnalyzedNode, AnalyzedPropertyRead {
|
||||
string accessPath;
|
||||
|
||||
AnalyzedClosureGlobalAccessPath() { accessPath = Closure::getLibraryAccessPath(this) }
|
||||
|
||||
override AnalyzedNode localFlowPred() {
|
||||
exists(DataFlow::PropWrite write |
|
||||
Closure::getWrittenLibraryAccessPath(write) = accessPath and
|
||||
result = write.getRhs()
|
||||
)
|
||||
or
|
||||
result = AnalyzedNode.super.localFlowPred()
|
||||
}
|
||||
|
||||
override predicate reads(AbstractValue base, string propName) {
|
||||
exists(Closure::ClosureModule mod |
|
||||
mod.getNamespaceId() = accessPath and
|
||||
base = TAbstractModuleObject(mod) and
|
||||
propName = "exports"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,8 +128,6 @@ case @toplevel.kind of
|
||||
|
||||
isModule (int tl: @toplevel ref);
|
||||
isNodejs (int tl: @toplevel ref);
|
||||
isES2015Module (int tl: @toplevel ref);
|
||||
isClosureModule (int tl: @toplevel ref);
|
||||
|
||||
// statements
|
||||
#keyset[parent, idx]
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
| tests/importFromEs6.js:9:1:9:15 | es6Module.fun() | tests/es6Module.js:3:8:3:24 | function fun() {} | 0 |
|
||||
| tests/importFromEs6.js:10:1:10:18 | es6ModuleDefault() | tests/es6ModuleDefault.js:3:16:3:28 | function() {} | 0 |
|
||||
| tests/importFromEs6.js:12:1:12:16 | googModule.fun() | tests/googModule.js:4:6:4:10 | () {} | 0 |
|
||||
| tests/importFromEs6.js:13:1:13:19 | googModuleDefault() | tests/googModuleDefault.js:3:11:3:27 | function fun() {} | 0 |
|
||||
| tests/requireFromEs6.js:12:1:12:18 | globalModule.fun() | tests/globalModule.js:4:6:4:10 | () {} | 0 |
|
||||
| tests/requireFromEs6.js:13:1:13:21 | globalM ... fault() | tests/globalModuleDefault.js:3:23:3:39 | function fun() {} | 0 |
|
||||
| tests/requireFromEs6.js:15:1:15:15 | es6Module.fun() | tests/es6Module.js:3:8:3:24 | function fun() {} | 0 |
|
||||
| tests/requireFromEs6.js:16:1:16:18 | es6ModuleDefault() | tests/es6ModuleDefault.js:3:16:3:28 | function() {} | 0 |
|
||||
| tests/requireFromEs6.js:18:1:18:16 | googModule.fun() | tests/googModule.js:4:6:4:10 | () {} | 0 |
|
||||
| tests/requireFromEs6.js:19:1:19:19 | googModuleDefault() | tests/googModuleDefault.js:3:11:3:27 | function fun() {} | 0 |
|
||||
| tests/requireFromGlobalModule.js:10:1:10:18 | x.y.z.global.fun() | tests/globalModule.js:4:6:4:10 | () {} | 0 |
|
||||
| tests/requireFromGlobalModule.js:11:1:11:21 | x.y.z.g ... fault() | tests/globalModuleDefault.js:3:23:3:39 | function fun() {} | 0 |
|
||||
| tests/requireFromGlobalModule.js:13:1:13:16 | x.y.z.goog.fun() | tests/googModule.js:4:6:4:10 | () {} | 0 |
|
||||
| tests/requireFromGlobalModule.js:14:1:14:19 | x.y.z.googdefault() | tests/googModuleDefault.js:3:11:3:27 | function fun() {} | 0 |
|
||||
| tests/requireFromGlobalModule.js:16:1:16:15 | x.y.z.es6.fun() | tests/es6Module.js:3:8:3:24 | function fun() {} | 0 |
|
||||
| tests/requireFromGlobalModule.js:17:1:17:18 | x.y.z.es6default() | tests/es6ModuleDefault.js:3:16:3:28 | function() {} | 0 |
|
||||
| tests/requireFromGoogModule.js:12:1:12:18 | globalModule.fun() | tests/globalModule.js:4:6:4:10 | () {} | 0 |
|
||||
| tests/requireFromGoogModule.js:13:1:13:21 | globalM ... fault() | tests/globalModuleDefault.js:3:23:3:39 | function fun() {} | 0 |
|
||||
| tests/requireFromGoogModule.js:15:1:15:15 | es6Module.fun() | tests/es6Module.js:3:8:3:24 | function fun() {} | 0 |
|
||||
| tests/requireFromGoogModule.js:16:1:16:18 | es6ModuleDefault() | tests/es6ModuleDefault.js:3:16:3:28 | function() {} | 0 |
|
||||
| tests/requireFromGoogModule.js:18:1:18:16 | googModule.fun() | tests/googModule.js:4:6:4:10 | () {} | 0 |
|
||||
| tests/requireFromGoogModule.js:19:1:19:19 | googModuleDefault() | tests/googModuleDefault.js:3:11:3:27 | function fun() {} | 0 |
|
||||
@@ -1,4 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from DataFlow::InvokeNode node, int imprecision
|
||||
select node, node.getACallee(imprecision), imprecision
|
||||
@@ -0,0 +1,2 @@
|
||||
| a.js:1:1:5:1 | <toplevel> |
|
||||
| b.js:1:1:3:21 | <toplevel> |
|
||||
@@ -0,0 +1,4 @@
|
||||
import semmle.javascript.Closure
|
||||
|
||||
from ClosureModule cm
|
||||
select cm
|
||||
@@ -0,0 +1 @@
|
||||
| a.js:1:1:5:1 | <toplevel> | a |
|
||||
@@ -0,0 +1,4 @@
|
||||
import semmle.javascript.Closure
|
||||
|
||||
from ClosureModule cm
|
||||
select cm, cm.getAProvidedNamespace()
|
||||
@@ -0,0 +1 @@
|
||||
| b.js:1:1:3:21 | <toplevel> | a |
|
||||
@@ -0,0 +1,4 @@
|
||||
import semmle.javascript.Closure
|
||||
|
||||
from ClosureModule cm
|
||||
select cm, cm.getARequiredNamespace()
|
||||
@@ -0,0 +1,3 @@
|
||||
| a.js:1:1:1:17 | goog.provide('a') | provide |
|
||||
| b.js:1:1:1:17 | goog.require('a') | require |
|
||||
| c.js:2:1:2:14 | goog.leyness() | leyness |
|
||||
@@ -0,0 +1,4 @@
|
||||
import semmle.javascript.Closure
|
||||
|
||||
from GoogFunctionCall gfc
|
||||
select gfc, gfc.getFunctionName()
|
||||
@@ -0,0 +1 @@
|
||||
| a.js:1:1:1:18 | goog.provide('a'); | a |
|
||||
4
javascript/ql/test/library-tests/Closure/GoogProvide.ql
Normal file
4
javascript/ql/test/library-tests/Closure/GoogProvide.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import semmle.javascript.Closure
|
||||
|
||||
from GoogProvide gp
|
||||
select gp, gp.getNamespaceId()
|
||||
@@ -0,0 +1 @@
|
||||
| b.js:1:1:1:18 | goog.require('a'); | a |
|
||||
4
javascript/ql/test/library-tests/Closure/GoogRequire.ql
Normal file
4
javascript/ql/test/library-tests/Closure/GoogRequire.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import semmle.javascript.Closure
|
||||
|
||||
from GoogRequire gr
|
||||
select gr, gr.getNamespaceId()
|
||||
@@ -1,4 +0,0 @@
|
||||
| tests/es6Module.js:0:0:0:0 | tests/es6Module.js |
|
||||
| tests/es6ModuleDefault.js:0:0:0:0 | tests/es6ModuleDefault.js |
|
||||
| tests/importFromEs6.js:0:0:0:0 | tests/importFromEs6.js |
|
||||
| tests/requireFromEs6.js:0:0:0:0 | tests/requireFromEs6.js |
|
||||
@@ -1,5 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from TopLevel tl
|
||||
where tl.isStrict()
|
||||
select tl.getFile()
|
||||
5
javascript/ql/test/library-tests/Closure/a.js
Normal file
5
javascript/ql/test/library-tests/Closure/a.js
Normal file
@@ -0,0 +1,5 @@
|
||||
goog.provide('a');
|
||||
|
||||
a.foo = function() {
|
||||
return 42;
|
||||
}
|
||||
3
javascript/ql/test/library-tests/Closure/b.js
Normal file
3
javascript/ql/test/library-tests/Closure/b.js
Normal file
@@ -0,0 +1,3 @@
|
||||
goog.require('a');
|
||||
|
||||
console.log(a.foo());
|
||||
2
javascript/ql/test/library-tests/Closure/c.js
Normal file
2
javascript/ql/test/library-tests/Closure/c.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// not a Closure module
|
||||
goog.leyness();
|
||||
@@ -1,51 +0,0 @@
|
||||
| x | tests/globalModule.js:3:1:3:1 | x |
|
||||
| x | tests/globalModuleDefault.js:3:1:3:1 | x |
|
||||
| x | tests/requireFromGlobalModule.js:10:1:10:1 | x |
|
||||
| x | tests/requireFromGlobalModule.js:11:1:11:1 | x |
|
||||
| x | tests/requireFromGlobalModule.js:13:1:13:1 | x |
|
||||
| x | tests/requireFromGlobalModule.js:14:1:14:1 | x |
|
||||
| x | tests/requireFromGlobalModule.js:16:1:16:1 | x |
|
||||
| x | tests/requireFromGlobalModule.js:17:1:17:1 | x |
|
||||
| x.y | tests/globalModule.js:3:1:3:3 | x.y |
|
||||
| x.y | tests/globalModuleDefault.js:3:1:3:3 | x.y |
|
||||
| x.y | tests/requireFromGlobalModule.js:10:1:10:3 | x.y |
|
||||
| x.y | tests/requireFromGlobalModule.js:11:1:11:3 | x.y |
|
||||
| x.y | tests/requireFromGlobalModule.js:13:1:13:3 | x.y |
|
||||
| x.y | tests/requireFromGlobalModule.js:14:1:14:3 | x.y |
|
||||
| x.y | tests/requireFromGlobalModule.js:16:1:16:3 | x.y |
|
||||
| x.y | tests/requireFromGlobalModule.js:17:1:17:3 | x.y |
|
||||
| x.y.z | tests/globalModule.js:3:1:3:5 | x.y.z |
|
||||
| x.y.z | tests/globalModuleDefault.js:3:1:3:5 | x.y.z |
|
||||
| x.y.z | tests/requireFromGlobalModule.js:10:1:10:5 | x.y.z |
|
||||
| x.y.z | tests/requireFromGlobalModule.js:11:1:11:5 | x.y.z |
|
||||
| x.y.z | tests/requireFromGlobalModule.js:13:1:13:5 | x.y.z |
|
||||
| x.y.z | tests/requireFromGlobalModule.js:14:1:14:5 | x.y.z |
|
||||
| x.y.z | tests/requireFromGlobalModule.js:16:1:16:5 | x.y.z |
|
||||
| x.y.z | tests/requireFromGlobalModule.js:17:1:17:5 | x.y.z |
|
||||
| x.y.z.es6 | tests/requireFromEs6.js:6:17:6:41 | goog.re ... z.es6') |
|
||||
| x.y.z.es6 | tests/requireFromGlobalModule.js:7:1:7:25 | goog.re ... z.es6') |
|
||||
| x.y.z.es6 | tests/requireFromGlobalModule.js:16:1:16:9 | x.y.z.es6 |
|
||||
| x.y.z.es6 | tests/requireFromGoogModule.js:6:17:6:41 | goog.re ... z.es6') |
|
||||
| x.y.z.es6default | tests/requireFromEs6.js:7:24:7:55 | goog.re ... fault') |
|
||||
| x.y.z.es6default | tests/requireFromGlobalModule.js:8:1:8:32 | goog.re ... fault') |
|
||||
| x.y.z.es6default | tests/requireFromGlobalModule.js:17:1:17:16 | x.y.z.es6default |
|
||||
| x.y.z.es6default | tests/requireFromGoogModule.js:7:24:7:55 | goog.re ... fault') |
|
||||
| x.y.z.global | tests/globalModule.js:3:16:5:1 | {\\n fun() {}\\n} |
|
||||
| x.y.z.global | tests/requireFromEs6.js:3:20:3:47 | goog.re ... lobal') |
|
||||
| x.y.z.global | tests/requireFromGlobalModule.js:1:1:1:28 | goog.re ... lobal') |
|
||||
| x.y.z.global | tests/requireFromGlobalModule.js:10:1:10:12 | x.y.z.global |
|
||||
| x.y.z.global | tests/requireFromGoogModule.js:3:20:3:47 | goog.re ... lobal') |
|
||||
| x.y.z.global.fun | tests/globalModule.js:4:6:4:10 | () {} |
|
||||
| x.y.z.globaldefault | tests/globalModuleDefault.js:3:23:3:39 | function fun() {} |
|
||||
| x.y.z.globaldefault | tests/requireFromEs6.js:4:27:4:61 | goog.re ... fault') |
|
||||
| x.y.z.globaldefault | tests/requireFromGlobalModule.js:2:1:2:35 | goog.re ... fault') |
|
||||
| x.y.z.globaldefault | tests/requireFromGlobalModule.js:11:1:11:19 | x.y.z.globaldefault |
|
||||
| x.y.z.globaldefault | tests/requireFromGoogModule.js:4:27:4:61 | goog.re ... fault') |
|
||||
| x.y.z.goog | tests/requireFromEs6.js:9:18:9:43 | goog.re ... .goog') |
|
||||
| x.y.z.goog | tests/requireFromGlobalModule.js:4:1:4:26 | goog.re ... .goog') |
|
||||
| x.y.z.goog | tests/requireFromGlobalModule.js:13:1:13:10 | x.y.z.goog |
|
||||
| x.y.z.goog | tests/requireFromGoogModule.js:9:18:9:43 | goog.re ... .goog') |
|
||||
| x.y.z.googdefault | tests/requireFromEs6.js:10:25:10:57 | goog.re ... fault') |
|
||||
| x.y.z.googdefault | tests/requireFromGlobalModule.js:5:1:5:33 | goog.re ... fault') |
|
||||
| x.y.z.googdefault | tests/requireFromGlobalModule.js:14:1:14:17 | x.y.z.googdefault |
|
||||
| x.y.z.googdefault | tests/requireFromGoogModule.js:10:25:10:57 | goog.re ... fault') |
|
||||
@@ -1,4 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from string name
|
||||
select name, Closure::moduleImport(name)
|
||||
@@ -1,31 +0,0 @@
|
||||
| x | y | tests/globalModule.js:3:1:3:3 | x.y |
|
||||
| x | y | tests/globalModuleDefault.js:3:1:3:3 | x.y |
|
||||
| x | y | tests/requireFromGlobalModule.js:10:1:10:3 | x.y |
|
||||
| x | y | tests/requireFromGlobalModule.js:11:1:11:3 | x.y |
|
||||
| x | y | tests/requireFromGlobalModule.js:13:1:13:3 | x.y |
|
||||
| x | y | tests/requireFromGlobalModule.js:14:1:14:3 | x.y |
|
||||
| x | y | tests/requireFromGlobalModule.js:16:1:16:3 | x.y |
|
||||
| x | y | tests/requireFromGlobalModule.js:17:1:17:3 | x.y |
|
||||
| x.y | z | tests/globalModule.js:3:1:3:5 | x.y.z |
|
||||
| x.y | z | tests/globalModuleDefault.js:3:1:3:5 | x.y.z |
|
||||
| x.y | z | tests/requireFromGlobalModule.js:10:1:10:5 | x.y.z |
|
||||
| x.y | z | tests/requireFromGlobalModule.js:11:1:11:5 | x.y.z |
|
||||
| x.y | z | tests/requireFromGlobalModule.js:13:1:13:5 | x.y.z |
|
||||
| x.y | z | tests/requireFromGlobalModule.js:14:1:14:5 | x.y.z |
|
||||
| x.y | z | tests/requireFromGlobalModule.js:16:1:16:5 | x.y.z |
|
||||
| x.y | z | tests/requireFromGlobalModule.js:17:1:17:5 | x.y.z |
|
||||
| x.y.z | es6 | tests/requireFromGlobalModule.js:16:1:16:9 | x.y.z.es6 |
|
||||
| x.y.z | es6default | tests/requireFromGlobalModule.js:17:1:17:16 | x.y.z.es6default |
|
||||
| x.y.z | global | tests/requireFromGlobalModule.js:10:1:10:12 | x.y.z.global |
|
||||
| x.y.z | globaldefault | tests/requireFromGlobalModule.js:11:1:11:19 | x.y.z.globaldefault |
|
||||
| x.y.z | goog | tests/requireFromGlobalModule.js:13:1:13:10 | x.y.z.goog |
|
||||
| x.y.z | googdefault | tests/requireFromGlobalModule.js:14:1:14:17 | x.y.z.googdefault |
|
||||
| x.y.z.es6 | fun | tests/requireFromEs6.js:15:1:15:13 | es6Module.fun |
|
||||
| x.y.z.es6 | fun | tests/requireFromGlobalModule.js:16:1:16:13 | x.y.z.es6.fun |
|
||||
| x.y.z.es6 | fun | tests/requireFromGoogModule.js:15:1:15:13 | es6Module.fun |
|
||||
| x.y.z.global | fun | tests/requireFromEs6.js:12:1:12:16 | globalModule.fun |
|
||||
| x.y.z.global | fun | tests/requireFromGlobalModule.js:10:1:10:16 | x.y.z.global.fun |
|
||||
| x.y.z.global | fun | tests/requireFromGoogModule.js:12:1:12:16 | globalModule.fun |
|
||||
| x.y.z.goog | fun | tests/requireFromEs6.js:18:1:18:14 | googModule.fun |
|
||||
| x.y.z.goog | fun | tests/requireFromGlobalModule.js:13:1:13:14 | x.y.z.goog.fun |
|
||||
| x.y.z.goog | fun | tests/requireFromGoogModule.js:18:1:18:14 | googModule.fun |
|
||||
@@ -1,4 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from string mod, string name
|
||||
select mod, name, Closure::moduleMember(mod, name)
|
||||
@@ -1,3 +0,0 @@
|
||||
goog.declareModuleId('x.y.z.es6');
|
||||
|
||||
export function fun() {}
|
||||
@@ -1,3 +0,0 @@
|
||||
goog.declareModuleId('x.y.z.es6default');
|
||||
|
||||
export default function() {}
|
||||
@@ -1,5 +0,0 @@
|
||||
goog.provide('x.y.z.global');
|
||||
|
||||
x.y.z.global = {
|
||||
fun() {}
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
goog.provide('x.y.z.globaldefault');
|
||||
|
||||
x.y.z.globaldefault = function fun() {}
|
||||
@@ -1,5 +0,0 @@
|
||||
goog.module('x.y.z.goog');
|
||||
|
||||
exports = {
|
||||
fun() {}
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
goog.module('x.y.z.googdefault');
|
||||
|
||||
exports = function fun() {};
|
||||
@@ -1,13 +0,0 @@
|
||||
// ES6 imports can import files by name, as long as they are modules
|
||||
|
||||
import * as googModule from './googModule';
|
||||
import * as googModuleDefault from './googModuleDefault';
|
||||
|
||||
import * as es6Module from './es6Module';
|
||||
import * as es6ModuleDefault from './es6ModuleDefault';
|
||||
|
||||
es6Module.fun();
|
||||
es6ModuleDefault();
|
||||
|
||||
googModule.fun();
|
||||
googModuleDefault();
|
||||
@@ -1,19 +0,0 @@
|
||||
import * as dummy from 'dummy'; // treat as ES6 module
|
||||
|
||||
let globalModule = goog.require('x.y.z.global');
|
||||
let globalModuleDefault = goog.require('x.y.z.globaldefault');
|
||||
|
||||
let es6Module = goog.require('x.y.z.es6');
|
||||
let es6ModuleDefault = goog.require('x.y.z.es6default');
|
||||
|
||||
let googModule = goog.require('x.y.z.goog');
|
||||
let googModuleDefault = goog.require('x.y.z.googdefault');
|
||||
|
||||
globalModule.fun();
|
||||
globalModuleDefault();
|
||||
|
||||
es6Module.fun();
|
||||
es6ModuleDefault();
|
||||
|
||||
googModule.fun();
|
||||
googModuleDefault();
|
||||
@@ -1,17 +0,0 @@
|
||||
goog.require('x.y.z.global');
|
||||
goog.require('x.y.z.globaldefault');
|
||||
|
||||
goog.require('x.y.z.goog');
|
||||
goog.require('x.y.z.googdefault');
|
||||
|
||||
goog.require('x.y.z.es6');
|
||||
goog.require('x.y.z.es6default');
|
||||
|
||||
x.y.z.global.fun();
|
||||
x.y.z.globaldefault();
|
||||
|
||||
x.y.z.goog.fun();
|
||||
x.y.z.googdefault();
|
||||
|
||||
x.y.z.es6.fun();
|
||||
x.y.z.es6default();
|
||||
@@ -1,19 +0,0 @@
|
||||
goog.module('test.importer');
|
||||
|
||||
let globalModule = goog.require('x.y.z.global');
|
||||
let globalModuleDefault = goog.require('x.y.z.globaldefault');
|
||||
|
||||
let es6Module = goog.require('x.y.z.es6');
|
||||
let es6ModuleDefault = goog.require('x.y.z.es6default');
|
||||
|
||||
let googModule = goog.require('x.y.z.goog');
|
||||
let googModuleDefault = goog.require('x.y.z.googdefault');
|
||||
|
||||
globalModule.fun();
|
||||
globalModuleDefault();
|
||||
|
||||
es6Module.fun();
|
||||
es6ModuleDefault();
|
||||
|
||||
googModule.fun();
|
||||
googModuleDefault();
|
||||
@@ -1,3 +0,0 @@
|
||||
| a.js:5:31:5:31 | o |
|
||||
| exports.js:3:9:3:15 | exports |
|
||||
| tst.html:6:3:6:7 | alert |
|
||||
@@ -1,5 +0,0 @@
|
||||
import javascript
|
||||
|
||||
from VarAccess access
|
||||
where access.getVariable() instanceof GlobalVariable
|
||||
select access
|
||||
@@ -1,2 +1 @@
|
||||
| exports.js:1:8:1:17 | * as dummy |
|
||||
| m/c.js:1:8:1:13 | * as b |
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
| b.js:1:8:1:8 | f | b.js:1:8:1:8 | f |
|
||||
| d.js:1:10:1:21 | default as g | d.js:1:21:1:21 | g |
|
||||
| d.js:1:24:1:29 | x as y | d.js:1:29:1:29 | y |
|
||||
| exports.js:1:8:1:17 | * as dummy | exports.js:1:13:1:17 | dummy |
|
||||
| f.ts:1:8:1:8 | g | f.ts:1:8:1:8 | g |
|
||||
| g.ts:1:9:1:11 | foo | g.ts:1:9:1:11 | foo |
|
||||
| import-in-mjs.mjs:1:8:1:24 | exported_from_mjs | import-in-mjs.mjs:1:8:1:24 | exported_from_mjs |
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
| b.js:1:1:1:20 | import f from './a'; | b.js:1:15:1:19 | './a' | 1 |
|
||||
| d.js:1:1:1:43 | import ... './a'; | d.js:1:38:1:42 | './a' | 2 |
|
||||
| d.js:2:1:2:13 | import './b'; | d.js:2:8:2:12 | './b' | 0 |
|
||||
| exports.js:1:1:1:31 | import ... dummy'; | exports.js:1:24:1:30 | 'dummy' | 1 |
|
||||
| f.ts:1:1:1:19 | import g from './e' | f.ts:1:15:1:19 | './e' | 1 |
|
||||
| g.ts:1:1:1:23 | import ... m './f' | g.ts:1:19:1:23 | './f' | 1 |
|
||||
| import-in-mjs.mjs:1:1:1:46 | import ... n-mjs'; | import-in-mjs.mjs:1:31:1:45 | 'export-in-mjs' | 1 |
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import * as dummy from 'dummy'; // Recognize as ES6 module
|
||||
|
||||
let x = exports; // global variable
|
||||
x.foo();
|
||||
Reference in New Issue
Block a user