-
Notifications
You must be signed in to change notification settings - Fork 3
Processing modules with Codemodel Rifle
Codemodel-Rifle should be able to process multiple related JavaScript files (modules) connected with ECMAScript 6's import and export statements. We need to connect the distinct ASG's into one ASG containing all related (connected) modules' contents. This is done via Cypher queries after synchronising a code repository into Codemodel-Rifle.
We distinguish different import-export syntaxes from different import-export cases. We do not care about the syntax, we are only interested in the AST- (and thus ASG-) representation of a certain case. The individual cases are detailed below. Within a case, all syntaxes are ASG-indifferent.
These names are used in the code consistently.
- exportAlias
Known issue of Shift parser: at export { name1 as default }, name1 gets exported as a named export with the name default.
export { name1 as exportedName1 };
export { name1 as exportedName1, name2 as exportedName2, … };
export { name1 as default, … };- exportDeclaration
Generators are represented as functions in the ASG with the FunctionDeclaration node's property isGenerator set to true. At simple functions, isGenerator is set to false.
export let name1;
export let name1, name2, …;
export var name1;
export var name1, name2, …;
export let name1 = …;
export let name1 = …, name2 = …, …;
export var name1 = …;
export var name1 = …, name2 = …, …;
export const name1 = …;
export const name1 = …, name2 = …, …;
export function name1(…) { … };
export function* name1(…) { … };
export class name1 { … }- exportDefaultDeclaration
Generators are represented as functions in the ASG with the FunctionDeclaration node's property isGenerator set to true. At simple functions, isGenerator is set to false.
export default function name1(…) { … };
export default function* name1(…) { … };
export default class name1 { … }- exportDefaultName
export default name1;- exportName
export { name1 };
export { name1, name2, … };- exportDefaultAnonymousDeclaration (not supported)
Currently not supported.
export default expression;
export default class { … }
export default function (…) { … }
export default function* (…) { … }- reexportAlias (not supported)
Currently not supported.
export { import1 as importedName1, import2 as importedName2, … } from …;- reexportName (not supported)
Currently not supported.
export { name1, name2, … } from … ;- reexportNamespace (not supported)
Currently not supported.
export * from … ;These names are used in the code consistently.
- importAlias
import { name1 as importedName1, … } from "exporter";- importDefault
import defaultName from "exporter";- importName
import { name1, … } from "exporter";- importModule (not supported)
Not supported: in this case, no bindings are made between the two module. The first such import executes the imported module's body. See here.
import "exporter";- importNamespace (not supported)
Currently not supported.
import * as exportedModule from "exporter";Currently unsupported import-export cases are not included in the compatibility table.
| Import / Export | importAlias | importDefault | importName |
|---|---|---|---|
| exportAlias | ✓ | ✓ | ✓ |
| exportDeclaration | ✓ | ✕ | ✓ |
| exportDefaultDeclaration | ✓ | ✓ | ✓ |
| exportDefaultName | ✓ | ✓ | ✓ |
| exportName | ✓ | ✕ | ✓ |
Since there are multiple default exports, this code is not valid. Thus the graph may also be incorrect.

Codemodel-Rifle // Graph-based incremental static analysis of ECMAScript 6 source code repositories
All code in this repository is available under the Eclipse Public License v1.0 and is supported by the MTA-BME Lendület Research Group on Cyber-Physical Systems.