mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 480238 - QML AST in Java
Created a set of Interfaces to represent the JavaScript and QML Ast in plain Java. Updated acorn-qml to be able to parse the entirety of QML syntax as specified by the QML grammar. Also modified the QML AST to represent the added syntax and modified tern-qml to handle the new AST elements. Changed the way that the QMLAnalyzer handles path resolution. Paths are now relative to the local file system. Note: the normal acorn-qml parser cannot parse the full range of QML syntax due to ambiguities. However, the loose parser can. We're still waiting on Acorn to bring lookahead to the normal parser in order to resolve this. Change-Id: I77c820ad46301975b2a91969a656d428ad9409c1 Signed-off-by: Matthew Bastien <mbastien@blackberry.com>
This commit is contained in:
parent
e62e2772fe
commit
84b5f4bfd2
80 changed files with 3192 additions and 489 deletions
|
@ -29,6 +29,6 @@ Export-Package: org.eclipse.cdt.internal.qt.core;x-friends:="org.eclipse.cdt.qt.
|
||||||
org.eclipse.cdt.internal.qt.core.parser;x-friends:="org.eclipse.cdt.qt.ui",
|
org.eclipse.cdt.internal.qt.core.parser;x-friends:="org.eclipse.cdt.qt.ui",
|
||||||
org.eclipse.cdt.internal.qt.core.project;x-friends:="org.eclipse.cdt.qt.ui",
|
org.eclipse.cdt.internal.qt.core.project;x-friends:="org.eclipse.cdt.qt.ui",
|
||||||
org.eclipse.cdt.internal.qt.core.qmldir;x-friends:="org.eclipse.cdt.qt.core.tests",
|
org.eclipse.cdt.internal.qt.core.qmldir;x-friends:="org.eclipse.cdt.qt.core.tests",
|
||||||
org.eclipse.cdt.qt.core;x-friends:="org.eclipse.cdt.qt.core.tests",
|
org.eclipse.cdt.qt.core,
|
||||||
org.eclipse.cdt.qt.core.location,
|
org.eclipse.cdt.qt.core.location,
|
||||||
org.eclipse.cdt.qt.core.qmldir
|
org.eclipse.cdt.qt.core.qmldir
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
kw("readonly", { isQMLContextual: true });
|
kw("readonly", { isQMLContextual: true });
|
||||||
kw("signal", { isQMLContextual: true });
|
kw("signal", { isQMLContextual: true });
|
||||||
kw("as");
|
kw("as");
|
||||||
|
kw("on", { isQMLContextual: true });
|
||||||
kw("boolean", { isPrimitive: true });
|
kw("boolean", { isPrimitive: true });
|
||||||
kw("double", { isPrimitive: true });
|
kw("double", { isPrimitive: true });
|
||||||
kw("int", { isPrimitive: true });
|
kw("int", { isPrimitive: true });
|
||||||
|
@ -83,47 +84,46 @@
|
||||||
var pp = acorn.Parser.prototype;
|
var pp = acorn.Parser.prototype;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a set of QML Header Statements which can either be of
|
* Parses a set of QML Header Items (QMLImport or QMLPragma)
|
||||||
* the type import or pragma
|
|
||||||
*/
|
*/
|
||||||
pp.qml_parseHeaderStatements = function () {
|
pp.qml_parseHeaderItemList = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
node.statements = [];
|
node.items = [];
|
||||||
|
|
||||||
var loop = true;
|
var loop = true;
|
||||||
while (loop) {
|
while (loop) {
|
||||||
if (this.isContextual(qtt._import)) {
|
if (this.isContextual(qtt._import)) {
|
||||||
node.statements.push(this.qml_parseImportStatement());
|
node.items.push(this.qml_parseImport());
|
||||||
} else if (this.isContextual(qtt._pragma)) {
|
} else if (this.isContextual(qtt._pragma)) {
|
||||||
node.statements.push(this.qml_parsePragmaStatement());
|
node.items.push(this.qml_parsePragma());
|
||||||
} else {
|
} else {
|
||||||
loop = false;
|
loop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.finishNode(node, "QMLHeaderStatements");
|
return this.finishNode(node, "QMLHeaderItemList");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Pragma statement of the form:
|
* Parses a QML Pragma statement of the form:
|
||||||
* 'pragma' <Identifier>
|
* 'pragma' <QMLQualifiedID>
|
||||||
*/
|
*/
|
||||||
pp.qml_parsePragmaStatement = function () {
|
pp.qml_parsePragma = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
this.expectContextual(qtt._pragma);
|
this.expectContextual(qtt._pragma);
|
||||||
node.id = this.parseIdent(false);
|
node.id = this.qml_parseQualifiedId(true);
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
return this.finishNode(node, "QMLPragmaStatement");
|
return this.finishNode(node, "QMLPragma");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Import statement of the form:
|
* Parses a QML Import of the form:
|
||||||
* 'import' <ModuleIdentifier> <Version.Number> [as <Qualifier>]
|
* 'import' <QMLModule> [as <QMLQualifier>]
|
||||||
* 'import' <DirectoryPath> [as <Qualifier>]
|
* 'import' <StringLiteral> [as <QMLQualifier>]
|
||||||
*
|
*
|
||||||
* as specified by http://doc.qt.io/qt-5/qtqml-syntax-imports.html
|
* as specified by http://doc.qt.io/qt-5/qtqml-syntax-imports.html
|
||||||
*/
|
*/
|
||||||
pp.qml_parseImportStatement = function () {
|
pp.qml_parseImport = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
|
|
||||||
if (!this.eatContextual(qtt._import)) {
|
if (!this.eatContextual(qtt._import)) {
|
||||||
|
@ -149,12 +149,12 @@
|
||||||
}
|
}
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
|
|
||||||
return this.finishNode(node, "QMLImportStatement");
|
return this.finishNode(node, "QMLImport");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Module of the form:
|
* Parses a QML Module of the form:
|
||||||
* <QMLQualifiedId> <QMLVersionLiteral> ['as' <QMLQualifier>]?
|
* <QMLQualifiedId> <QMLVersionLiteral>
|
||||||
*/
|
*/
|
||||||
pp.qml_parseModule = function () {
|
pp.qml_parseModule = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
|
@ -176,16 +176,12 @@
|
||||||
pp.qml_parseVersionLiteral = function () {
|
pp.qml_parseVersionLiteral = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
|
|
||||||
node.raw = this.input.slice(this.start, this.end);
|
|
||||||
node.value = this.value;
|
node.value = this.value;
|
||||||
var matches;
|
node.raw = this.input.slice(this.start, this.end);
|
||||||
if ((matches = /(\d+)\.(\d+)/.exec(node.raw))) {
|
if (!(/(\d+)\.(\d+)/.exec(node.raw))) {
|
||||||
node.major = parseInt(matches[1]);
|
|
||||||
node.minor = parseInt(matches[2]);
|
|
||||||
this.next();
|
|
||||||
} else {
|
|
||||||
this.raise(this.start, "QML module must specify major and minor version");
|
this.raise(this.start, "QML module must specify major and minor version");
|
||||||
}
|
}
|
||||||
|
this.next();
|
||||||
|
|
||||||
return this.finishNode(node, "QMLVersionLiteral");
|
return this.finishNode(node, "QMLVersionLiteral");
|
||||||
};
|
};
|
||||||
|
@ -202,45 +198,47 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Object Literal of the form:
|
* Parses a QML Object Definition of the form:
|
||||||
* <QualifiedId> { (<QMLMember>)* }
|
* <QMLQualifiedId> { (<QMLObjectMember>)* }
|
||||||
*
|
*
|
||||||
* http://doc.qt.io/qt-5/qtqml-syntax-basics.html#object-declarations
|
* http://doc.qt.io/qt-5/qtqml-syntax-basics.html#object-declarations
|
||||||
*/
|
*/
|
||||||
pp.qml_parseObjectLiteral = function (node) {
|
pp.qml_parseObjectDefinition = function (node, isBinding) {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
node = this.startNode();
|
node = this.startNode();
|
||||||
}
|
}
|
||||||
if (!node.id) {
|
if (!node.id) {
|
||||||
node.id = this.qml_parseQualifiedId(false);
|
node.id = this.qml_parseQualifiedId(false);
|
||||||
}
|
}
|
||||||
node.body = this.qml_parseMemberBlock();
|
node.body = this.qml_parseObjectInitializer();
|
||||||
return this.finishNode(node, "QMLObjectLiteral");
|
return this.finishNode(node, isBinding ? "QMLObjectBinding" : "QMLObjectDefinition");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Member Block of the form:
|
* Parses a QML Object Initializer of the form:
|
||||||
* { <QMLMember>* }
|
* '{' <QMLObjectMember>* '}'
|
||||||
*/
|
*/
|
||||||
pp.qml_parseMemberBlock = function () {
|
pp.qml_parseObjectInitializer = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
this.expect(tt.braceL);
|
this.expect(tt.braceL);
|
||||||
node.members = [];
|
node.members = [];
|
||||||
while (!this.eat(tt.braceR)) {
|
while (this.type !== tt.braceR) {
|
||||||
node.members.push(this.qml_parseMember());
|
node.members.push(this.qml_parseObjectMember());
|
||||||
}
|
}
|
||||||
return this.finishNode(node, "QMLMemberBlock");
|
this.expect(tt.braceR);
|
||||||
|
return this.finishNode(node, "QMLObjectInitializer");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Member which can be one of the following:
|
* Parses a QML Object Member which can be one of the following:
|
||||||
* - a QML Property Binding
|
* - a QML Property Binding
|
||||||
* - a Property Declaration (or Alias)
|
* - a QML Property Declaration
|
||||||
|
* - a QML Property Modifier
|
||||||
* - a QML Object Literal
|
* - a QML Object Literal
|
||||||
* - a JavaScript Function Declaration
|
* - a JavaScript Function Declaration
|
||||||
* - a Signal Definition
|
* - a QML Signal Definition
|
||||||
*/
|
*/
|
||||||
pp.qml_parseMember = function () {
|
pp.qml_parseObjectMember = function () {
|
||||||
if (this.type === tt._default || this.isContextual(qtt._readonly) || this.isContextual(qtt._property)) {
|
if (this.type === tt._default || this.isContextual(qtt._readonly) || this.isContextual(qtt._property)) {
|
||||||
return this.qml_parsePropertyDeclaration();
|
return this.qml_parsePropertyDeclaration();
|
||||||
} else if (this.isContextual(qtt._signal)) {
|
} else if (this.isContextual(qtt._signal)) {
|
||||||
|
@ -248,7 +246,7 @@
|
||||||
} else if (this.type === tt._function) {
|
} else if (this.type === tt._function) {
|
||||||
return this.qml_parseFunctionMember();
|
return this.qml_parseFunctionMember();
|
||||||
}
|
}
|
||||||
return this.qml_parseObjectLiteralOrPropertyBinding();
|
return this.qml_parseObjectDefinitionOrPropertyBinding();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -261,9 +259,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Object Literal or Property Binding depending on the tokens found.
|
* Parses a QML Object Definition or Property Binding depending on the tokens found.
|
||||||
*/
|
*/
|
||||||
pp.qml_parseObjectLiteralOrPropertyBinding = function (node) {
|
pp.qml_parseObjectDefinitionOrPropertyBinding = function (node) {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
node = this.startNode();
|
node = this.startNode();
|
||||||
}
|
}
|
||||||
|
@ -272,7 +270,7 @@
|
||||||
}
|
}
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case tt.braceL:
|
case tt.braceL:
|
||||||
return this.qml_parseObjectLiteral(node);
|
return this.qml_parseObjectDefinition(node);
|
||||||
case tt.colon:
|
case tt.colon:
|
||||||
return this.qml_parsePropertyBinding(node);
|
return this.qml_parsePropertyBinding(node);
|
||||||
}
|
}
|
||||||
|
@ -280,7 +278,26 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Property of the form:
|
* Parses a QML Property Modifier of the form:
|
||||||
|
* <QMLQualifiedID> 'on' <QMLQualifiedID> <QMLInitializer>
|
||||||
|
|
||||||
|
* TODO: Call this method in the normal parser once we can do lookahead
|
||||||
|
* Without lookahead, telling the difference between an Object Declaration,
|
||||||
|
* Property Binding, and Property Modifier would be too difficult. For now,
|
||||||
|
* we've implemented a workaround for Object Declarations and Property Bindings
|
||||||
|
* until Acorn gets lookahead.
|
||||||
|
*/
|
||||||
|
pp.qml_parsePropertyModifier = function () {
|
||||||
|
var node = this.startNode();
|
||||||
|
node.kind = this.qml_parseQualifiedID(false);
|
||||||
|
this.expectContextual(qtt._on);
|
||||||
|
node.id = this.qml_parseQualifiedID(false);
|
||||||
|
node.body = this.qml_parseObjectInitializer();
|
||||||
|
return this.finishNode(node, "QMLPropertyModifier");
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses a QML Property Binding of the form:
|
||||||
* <QMLQualifiedID> <QMLBinding>
|
* <QMLQualifiedID> <QMLBinding>
|
||||||
*/
|
*/
|
||||||
pp.qml_parsePropertyBinding = function (node) {
|
pp.qml_parsePropertyBinding = function (node) {
|
||||||
|
@ -297,7 +314,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Signal Definition of the form:
|
* Parses a QML Signal Definition of the form:
|
||||||
* 'signal' <Identifier> [(<Type> <Identifier> [',' <Type> <Identifier>]* )]?
|
* 'signal' <Identifier> [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
|
||||||
*/
|
*/
|
||||||
pp.qml_parseSignalDefinition = function () {
|
pp.qml_parseSignalDefinition = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
|
@ -312,12 +329,12 @@
|
||||||
if (this.type === tt.colon || this.type === tt.braceL) {
|
if (this.type === tt.colon || this.type === tt.braceL) {
|
||||||
// This is a property binding or object literal
|
// This is a property binding or object literal
|
||||||
node.id = signal;
|
node.id = signal;
|
||||||
return this.qml_parseObjectLiteralOrPropertyBinding(node);
|
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Signal keyword is a qualified ID. This is not a signal definition
|
// Signal keyword is a qualified ID. This is not a signal definition
|
||||||
node.id = signal;
|
node.id = signal;
|
||||||
return this.qml_parseObjectLiteralOrPropertyBinding(node);
|
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
node.id = this.qml_parseIdent(false);
|
node.id = this.qml_parseIdent(false);
|
||||||
|
@ -328,7 +345,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses QML Signal Parameters of the form:
|
* Parses QML Signal Parameters of the form:
|
||||||
* [(<Type> <Identifier> [',' <Type> <Identifier>]* )]?
|
* [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
|
||||||
*/
|
*/
|
||||||
pp.qml_parseSignalParams = function (node) {
|
pp.qml_parseSignalParams = function (node) {
|
||||||
node.params = [];
|
node.params = [];
|
||||||
|
@ -336,7 +353,7 @@
|
||||||
if (!this.eat(tt.parenR)) {
|
if (!this.eat(tt.parenR)) {
|
||||||
do {
|
do {
|
||||||
var param = this.startNode();
|
var param = this.startNode();
|
||||||
param.kind = this.qml_parseIdent(true);
|
param.kind = this.qml_parsePropertyType();
|
||||||
param.id = this.qml_parseIdent(false);
|
param.id = this.qml_parseIdent(false);
|
||||||
node.params.push(this.finishNode(param, "QMLParameter"));
|
node.params.push(this.finishNode(param, "QMLParameter"));
|
||||||
} while (this.eat(tt.comma));
|
} while (this.eat(tt.comma));
|
||||||
|
@ -346,7 +363,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Property Declaration (or Alias) of the form:
|
* Parses a QML Property Declaration of the form:
|
||||||
* ['default'|'readonly'] 'property' <QMLType> <Identifier> [<QMLBinding>]
|
* ['default'|'readonly'] 'property' <QMLType> <Identifier> [<QMLBinding>]
|
||||||
*/
|
*/
|
||||||
pp.qml_parsePropertyDeclaration = function () {
|
pp.qml_parsePropertyDeclaration = function () {
|
||||||
|
@ -364,13 +381,13 @@
|
||||||
if (this.type === tt.colon || this.type === tt.braceL) {
|
if (this.type === tt.colon || this.type === tt.braceL) {
|
||||||
// This is a property binding or object literal.
|
// This is a property binding or object literal.
|
||||||
node.id = readonly;
|
node.id = readonly;
|
||||||
return this.qml_parseObjectLiteralOrPropertyBinding(node);
|
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
|
||||||
}
|
}
|
||||||
node.readonly = true;
|
node.readonly = true;
|
||||||
} else {
|
} else {
|
||||||
// Readonly keyword is a qualified ID. This is not a property declaration.
|
// Readonly keyword is a qualified ID. This is not a property declaration.
|
||||||
node.id = readonly;
|
node.id = readonly;
|
||||||
return this.qml_parseObjectLiteralOrPropertyBinding(node);
|
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,17 +403,26 @@
|
||||||
node.default = undefined;
|
node.default = undefined;
|
||||||
node.readonly = undefined;
|
node.readonly = undefined;
|
||||||
node.id = property;
|
node.id = property;
|
||||||
return this.qml_parseObjectLiteralOrPropertyBinding(node);
|
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Property keyword is a qualified ID. This is not a property declaration.
|
// Property keyword is a qualified ID. This is not a property declaration.
|
||||||
node.default = undefined;
|
node.default = undefined;
|
||||||
node.readonly = undefined;
|
node.readonly = undefined;
|
||||||
node.id = property;
|
node.id = property;
|
||||||
return this.qml_parseObjectLiteralOrPropertyBinding(node);
|
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
node.kind = this.qml_parsePropertyType();
|
||||||
|
if (this.value === "<") {
|
||||||
|
this.expect(tt.relational); // '<'
|
||||||
|
node.modifier = this.qml_parsePropertyType();
|
||||||
|
if (this.value !== ">") {
|
||||||
|
this.unexpected();
|
||||||
|
}
|
||||||
|
this.expect(tt.relational); // '>'
|
||||||
}
|
}
|
||||||
|
|
||||||
node.kind = this.qml_parseKind();
|
|
||||||
node.id = this.qml_parseIdent(false);
|
node.id = this.qml_parseIdent(false);
|
||||||
if (!this.eat(tt.colon)) {
|
if (!this.eat(tt.colon)) {
|
||||||
node.binding = null;
|
node.binding = null;
|
||||||
|
@ -408,9 +434,24 @@
|
||||||
return this.finishNode(node, "QMLPropertyDeclaration");
|
return this.finishNode(node, "QMLPropertyDeclaration");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses a QML Property Type of the form:
|
||||||
|
* <Identifier>
|
||||||
|
*/
|
||||||
|
pp.qml_parsePropertyType = function () {
|
||||||
|
var node = this.startNode();
|
||||||
|
node.primitive = false;
|
||||||
|
if (this.qml_isPrimitiveType(this.type, this.value)) {
|
||||||
|
node.primitive = true;
|
||||||
|
}
|
||||||
|
node.id = this.qml_parseIdent(true);
|
||||||
|
return this.finishNode(node, "QMLPropertyType");
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses one of the following possibilities for a QML Property assignment:
|
* Parses one of the following possibilities for a QML Property assignment:
|
||||||
* - QML Object Literal
|
* - QML Object Binding
|
||||||
|
* - QML Array Binding
|
||||||
* - QML Script Binding
|
* - QML Script Binding
|
||||||
*/
|
*/
|
||||||
pp.qml_parseBinding = function () {
|
pp.qml_parseBinding = function () {
|
||||||
|
@ -426,6 +467,23 @@
|
||||||
return this.qml_parseScriptBinding(true);
|
return this.qml_parseScriptBinding(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses a QML Array Binding of the form:
|
||||||
|
* '[' [<QMLObjectDefinition> (',' <QMLObjectDefinition>)*] ']'
|
||||||
|
*
|
||||||
|
* TODO: call this in the parser once we can use lookahead to distinguish between
|
||||||
|
* a QML Array Binding and a JavaScript array.
|
||||||
|
*/
|
||||||
|
pp.qml_parseArrayBinding = function () {
|
||||||
|
var node = this.startNode();
|
||||||
|
this.expect(tt.bracketL);
|
||||||
|
node.members = [];
|
||||||
|
while (!this.eat(tt.bracketR)) {
|
||||||
|
node.members.push(this.qml_parseObjectDefinition());
|
||||||
|
}
|
||||||
|
return this.finishNode(node, "QMLArrayBinding");
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses one of the following Script Bindings:
|
* Parses one of the following Script Bindings:
|
||||||
* - Single JavaScript Expression
|
* - Single JavaScript Expression
|
||||||
|
@ -446,32 +504,18 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Statement Block of the form:
|
* Parses a QML Statement Block of the form:
|
||||||
* { <JavaScript Statement>* }
|
* { <Statement>* }
|
||||||
*/
|
*/
|
||||||
pp.qml_parseStatementBlock = function () {
|
pp.qml_parseStatementBlock = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
this.expect(tt.braceL);
|
this.expect(tt.braceL);
|
||||||
node.statements = [];
|
node.body = [];
|
||||||
while (!this.eat(tt.braceR)) {
|
while (!this.eat(tt.braceR)) {
|
||||||
node.statements.push(this.parseStatement(true, false));
|
node.body.push(this.parseStatement(true, false));
|
||||||
}
|
}
|
||||||
return this.finishNode(node, "QMLStatementBlock");
|
return this.finishNode(node, "QMLStatementBlock");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Parses a QML Type which can be either a Qualified ID or a primitive type keyword.
|
|
||||||
* Returns a node of type qtt._alias if the type keyword parsed was "alias".
|
|
||||||
*/
|
|
||||||
pp.qml_parseKind = function () {
|
|
||||||
var value = this.value;
|
|
||||||
if (this.qml_eatPrimitiveType(this.type, value)) {
|
|
||||||
return value;
|
|
||||||
} else {
|
|
||||||
return this.qml_parseQualifiedId(false);
|
|
||||||
}
|
|
||||||
this.unexpected();
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a Qualified ID of the form:
|
* Parses a Qualified ID of the form:
|
||||||
* <Identifier> ('.' <Identifier>)*
|
* <Identifier> ('.' <Identifier>)*
|
||||||
|
@ -579,10 +623,10 @@
|
||||||
// replacing JavaScripts top-level. Here we are parsing such things
|
// replacing JavaScripts top-level. Here we are parsing such things
|
||||||
// as the root object literal and header statements of QML. Eventually,
|
// as the root object literal and header statements of QML. Eventually,
|
||||||
// these rules will delegate down to JavaScript expressions.
|
// these rules will delegate down to JavaScript expressions.
|
||||||
node.headerStatements = this.qml_parseHeaderStatements();
|
node.headerItemList = this.qml_parseHeaderItemList();
|
||||||
node.rootObject = null;
|
node.rootObject = null;
|
||||||
if (this.type !== tt.eof) {
|
if (this.type !== tt.eof) {
|
||||||
node.rootObject = this.qml_parseObjectLiteral();
|
node.rootObject = this.qml_parseObjectDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.eat(tt.eof)) {
|
if (!this.eat(tt.eof)) {
|
||||||
|
|
|
@ -34,47 +34,46 @@ var injectQMLLoose;
|
||||||
var pp = acorn.Parser.prototype;
|
var pp = acorn.Parser.prototype;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a set of QML Header Statements which can either be of
|
* Parses a set of QML Header Items (QMLImport or QMLPragma)
|
||||||
* the type import or pragma
|
|
||||||
*/
|
*/
|
||||||
lp.qml_parseHeaderStatements = function () {
|
lp.qml_parseHeaderItemList = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
node.statements = [];
|
node.items = [];
|
||||||
|
|
||||||
var loop = true;
|
var loop = true;
|
||||||
while (loop) {
|
while (loop) {
|
||||||
if (this.isContextual(qtt._import)) {
|
if (this.isContextual(qtt._import)) {
|
||||||
node.statements.push(this.qml_parseImportStatement());
|
node.items.push(this.qml_parseImport());
|
||||||
} else if (this.isContextual(qtt._pragma)) {
|
} else if (this.isContextual(qtt._pragma)) {
|
||||||
node.statements.push(this.qml_parsePragmaStatement());
|
node.items.push(this.qml_parsePragma());
|
||||||
} else {
|
} else {
|
||||||
loop = false;
|
loop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.finishNode(node, "QMLHeaderStatements");
|
return this.finishNode(node, "QMLHeaderItemList");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Pragma statement of the form:
|
* Parses a QML Pragma statement of the form:
|
||||||
* 'pragma' <Identifier>
|
* 'pragma' <QMLQualifiedID>
|
||||||
*/
|
*/
|
||||||
lp.qml_parsePragmaStatement = function () {
|
lp.qml_parsePragma = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
this.expectContextual(qtt._pragma);
|
this.expectContextual(qtt._pragma);
|
||||||
node.id = this.parseIdent(false);
|
node.id = this.qml_parseQualifiedId(true);
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
return this.finishNode(node, "QMLPragmaStatement");
|
return this.finishNode(node, "QMLPragma");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Import statement of the form:
|
* Parses a QML Import of the form:
|
||||||
* 'import' <ModuleIdentifier> <Version.Number> [as <Qualifier>]
|
* 'import' <QMLModule> [as <QMLQualifier>]
|
||||||
* 'import' <DirectoryPath> [as <Qualifier>]
|
* 'import' <StringLiteral> [as <QMLQualifier>]
|
||||||
*
|
*
|
||||||
* as specified by http://doc.qt.io/qt-5/qtqml-syntax-imports.html
|
* as specified by http://doc.qt.io/qt-5/qtqml-syntax-imports.html
|
||||||
*/
|
*/
|
||||||
lp.qml_parseImportStatement = function () {
|
lp.qml_parseImport = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
this.expectContextual(qtt._import);
|
this.expectContextual(qtt._import);
|
||||||
|
|
||||||
|
@ -95,12 +94,12 @@ var injectQMLLoose;
|
||||||
}
|
}
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
|
|
||||||
return this.finishNode(node, "QMLImportStatement");
|
return this.finishNode(node, "QMLImport");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Module of the form:
|
* Parses a QML Module of the form:
|
||||||
* <QMLQualifiedId> <QMLVersionLiteral> ['as' <QMLQualifier>]?
|
* <QMLQualifiedId> <QMLVersionLiteral>
|
||||||
*/
|
*/
|
||||||
lp.qml_parseModule = function () {
|
lp.qml_parseModule = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
|
@ -118,22 +117,12 @@ var injectQMLLoose;
|
||||||
lp.qml_parseVersionLiteral = function () {
|
lp.qml_parseVersionLiteral = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
|
|
||||||
node.raw = this.input.slice(this.tok.start, this.tok.end);
|
|
||||||
node.value = this.tok.value;
|
|
||||||
var matches;
|
var matches;
|
||||||
if (this.tok.type === tt.num) {
|
if (this.tok.type === tt.num) {
|
||||||
if ((matches = /(\d+)\.(\d+)/.exec(node.raw))) {
|
node.raw = this.input.slice(this.tok.start, this.tok.end);
|
||||||
node.major = parseInt(matches[1]);
|
node.value = this.tok.value;
|
||||||
node.minor = parseInt(matches[2]);
|
this.next();
|
||||||
this.next();
|
|
||||||
} else {
|
|
||||||
node.major = parseInt(node.raw);
|
|
||||||
node.minor = 0;
|
|
||||||
this.next();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
node.major = 0;
|
|
||||||
node.minor = 0;
|
|
||||||
node.value = 0;
|
node.value = 0;
|
||||||
node.raw = "0.0";
|
node.raw = "0.0";
|
||||||
}
|
}
|
||||||
|
@ -153,48 +142,50 @@ var injectQMLLoose;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Object Literal of the form:
|
* Parses a QML Object Definition of the form:
|
||||||
* <QualifiedId> { (<QMLMember>)* }
|
* <QMLQualifiedId> { (<QMLObjectMember>)* }
|
||||||
*
|
*
|
||||||
* http://doc.qt.io/qt-5/qtqml-syntax-basics.html#object-declarations
|
* http://doc.qt.io/qt-5/qtqml-syntax-basics.html#object-declarations
|
||||||
*/
|
*/
|
||||||
lp.qml_parseObjectLiteral = function () {
|
lp.qml_parseObjectDefinition = function (isBinding) {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
node.id = this.qml_parseQualifiedId(false);
|
node.id = this.qml_parseQualifiedId(false);
|
||||||
node.body = this.qml_parseMemberBlock();
|
node.body = this.qml_parseObjectInitializer();
|
||||||
return this.finishNode(node, "QMLObjectLiteral");
|
return this.finishNode(node, isBinding ? "QMLObjectBinding" : "QMLObjectDefinition");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Member Block of the form:
|
* Parses a QML Object Initializer of the form:
|
||||||
* { <QMLMember>* }
|
* '{' <QMLObjectMember>* '}'
|
||||||
*/
|
*/
|
||||||
lp.qml_parseMemberBlock = function () {
|
lp.qml_parseObjectInitializer = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
this.pushCx();
|
this.pushCx();
|
||||||
this.expect(tt.braceL);
|
this.expect(tt.braceL);
|
||||||
var blockIndent = this.curIndent, line = this.curLineStart;
|
var blockIndent = this.curIndent,
|
||||||
|
line = this.curLineStart;
|
||||||
node.members = [];
|
node.members = [];
|
||||||
while (!this.closes(tt.braceR, blockIndent, line, true)) {
|
while (!this.closes(tt.braceR, blockIndent, line, true)) {
|
||||||
var member = this.qml_parseMember();
|
var member = this.qml_parseObjectMember();
|
||||||
if (member) {
|
if (member) {
|
||||||
node.members.push(member);
|
node.members.push(member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.popCx();
|
this.popCx();
|
||||||
this.eat(tt.braceR);
|
this.eat(tt.braceR);
|
||||||
return this.finishNode(node, "QMLMemberBlock");
|
return this.finishNode(node, "QMLObjectInitializer");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Member which can be one of the following:
|
* Parses a QML Object Member which can be one of the following:
|
||||||
* - a QML Property Binding
|
* - a QML Property Binding
|
||||||
* - a Property Declaration (or Alias)
|
* - a QML Property Declaration
|
||||||
|
* - a QML Property Modifier
|
||||||
* - a QML Object Literal
|
* - a QML Object Literal
|
||||||
* - a JavaScript Function Declaration
|
* - a JavaScript Function Declaration
|
||||||
* - a Signal Definition
|
* - a QML Signal Definition
|
||||||
*/
|
*/
|
||||||
lp.qml_parseMember = function () {
|
lp.qml_parseObjectMember = function () {
|
||||||
if (this.tok.type === tt._default || this.isContextual(qtt._readonly) || this.isContextual(qtt._property) || this.qml_isPrimitiveType(this.tok.type, this.tok.value)) {
|
if (this.tok.type === tt._default || this.isContextual(qtt._readonly) || this.isContextual(qtt._property) || this.qml_isPrimitiveType(this.tok.type, this.tok.value)) {
|
||||||
return this.qml_parsePropertyDeclaration();
|
return this.qml_parsePropertyDeclaration();
|
||||||
} else if (this.isContextual(qtt._signal)) {
|
} else if (this.isContextual(qtt._signal)) {
|
||||||
|
@ -203,27 +194,57 @@ var injectQMLLoose;
|
||||||
return this.qml_parseFunctionMember();
|
return this.qml_parseFunctionMember();
|
||||||
} else if (this.qml_isIdent(this.tok.type, this.tok.value) || this.tok.type === tt.dot) {
|
} else if (this.qml_isIdent(this.tok.type, this.tok.value) || this.tok.type === tt.dot) {
|
||||||
var la = this.lookAhead(1);
|
var la = this.lookAhead(1);
|
||||||
if (this.qml_isIdent(la.type, la.value)) {
|
if (this.qml_isIdent(la.type, la.value) && la.value !== qtt._on) {
|
||||||
// Two identifiers in a row means this is most likely a property declaration
|
// Two identifiers in a row means this is most likely a property declaration
|
||||||
// with the 'property' token missing
|
// with the 'property' token missing.
|
||||||
return this.qml_parsePropertyDeclaration();
|
return this.qml_parsePropertyDeclaration();
|
||||||
} else {
|
} else {
|
||||||
var node = this.qml_parseObjectLiteralOrPropertyBinding();
|
return this.qml_parseMemberStartsWithIdentifier() || this.qml_parsePropertyBinding();
|
||||||
if (node) {
|
|
||||||
return node;
|
|
||||||
} else {
|
|
||||||
return this.qml_parsePropertyBinding();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (this.tok.type === tt.colon) {
|
} else if (this.tok.type === tt.colon) {
|
||||||
return this.qml_parsePropertyBinding();
|
return this.qml_parsePropertyBinding();
|
||||||
} else if (this.tok.type === tt.braceL) {
|
} else if (this.tok.type === tt.braceL) {
|
||||||
return this.qml_parseObjectLiteral();
|
return this.qml_parseObjectDefinition();
|
||||||
}
|
}
|
||||||
// ignore the current token if it didn't pass the previous tests
|
// ignore the current token if it didn't pass the previous tests
|
||||||
this.next();
|
this.next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses a QML Object Member that starts with an identifier. This method solves the
|
||||||
|
* ambiguities that arise from QML having multiple Object Members that start with
|
||||||
|
* Qualified IDs as well as the fact that several of its keywords can be used as part
|
||||||
|
* of these Qualified IDs.
|
||||||
|
*/
|
||||||
|
lp.qml_parseMemberStartsWithIdentifier = function () {
|
||||||
|
// Jump past the potential Qualified ID
|
||||||
|
var i = 1,
|
||||||
|
la = this.tok;
|
||||||
|
if (this.qml_isIdent(la.type, la.value)) {
|
||||||
|
la = this.lookAhead(i++);
|
||||||
|
}
|
||||||
|
while (la.type === tt.dot) {
|
||||||
|
la = this.lookAhead(i++);
|
||||||
|
if (this.qml_isIdent(la.type, la.value)) {
|
||||||
|
la = this.lookAhead(i++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the last lookahead token
|
||||||
|
switch (la.type) {
|
||||||
|
case tt.braceL:
|
||||||
|
return this.qml_parseObjectDefinition();
|
||||||
|
case tt.colon:
|
||||||
|
return this.qml_parsePropertyBinding();
|
||||||
|
case tt.name:
|
||||||
|
if (la.value === qtt._on) {
|
||||||
|
return this.qml_parsePropertyModifier();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a JavaScript function as a member of a QML Object Literal
|
* Parses a JavaScript function as a member of a QML Object Literal
|
||||||
*/
|
*/
|
||||||
|
@ -234,14 +255,14 @@ var injectQMLLoose;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QML version of 'parseFunction' needed to have proper error tolerant parsing
|
* QML version of 'parseFunction' needed to have proper error tolerant parsing
|
||||||
* for QML member functions versus their JavaScript counterparts. The main
|
* for QML member functions versus their JavaScript counterparts. The main
|
||||||
* difference between the two functions is that this implementation will not
|
* difference between the two functions is that this implementation will not
|
||||||
* forcefully insert '(' and '{' tokens for the body and parameters. Instead,
|
* forcefully insert '(' and '{' tokens for the body and parameters. Instead,
|
||||||
* it will silently create an empty parameter list or body and let parsing
|
* it will silently create an empty parameter list or body and let parsing
|
||||||
* continue normally.
|
* continue normally.
|
||||||
*/
|
*/
|
||||||
lp.qml_parseFunction = function(node, isStatement) {
|
lp.qml_parseFunction = function (node, isStatement) {
|
||||||
this.initFunction(node);
|
this.initFunction(node);
|
||||||
if (this.tok.type === tt.name) node.id = this.parseIdent();
|
if (this.tok.type === tt.name) node.id = this.parseIdent();
|
||||||
else if (isStatement) node.id = this.dummyIdent();
|
else if (isStatement) node.id = this.dummyIdent();
|
||||||
|
@ -250,7 +271,7 @@ var injectQMLLoose;
|
||||||
node.body = this.parseBlock();
|
node.body = this.parseBlock();
|
||||||
} else {
|
} else {
|
||||||
if (this.options.locations) {
|
if (this.options.locations) {
|
||||||
node.body = this.startNodeAt([ this.last.end, this.last.loc.end ]);
|
node.body = this.startNodeAt([this.last.end, this.last.loc.end]);
|
||||||
} else {
|
} else {
|
||||||
node.body = this.startNodeAt(this.last.end);
|
node.body = this.startNodeAt(this.last.end);
|
||||||
}
|
}
|
||||||
|
@ -261,27 +282,16 @@ var injectQMLLoose;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Object Literal or Property Binding depending on the tokens found.
|
* Parses a QML Property Modifier of the form:
|
||||||
|
* <QMLQualifiedID> 'on' <QMLQualifiedID> <QMLInitializer>
|
||||||
*/
|
*/
|
||||||
lp.qml_parseObjectLiteralOrPropertyBinding = function () {
|
lp.qml_parsePropertyModifier = function () {
|
||||||
var i = 1, la = this.tok;
|
var node = this.startNode();
|
||||||
if (this.qml_isIdent(la.type, la.value)) {
|
node.kind = this.qml_parseQualifiedId(false);
|
||||||
la = this.lookAhead(i++);
|
this.expectContextual(qtt._on);
|
||||||
}
|
node.id = this.qml_parseQualifiedId(false);
|
||||||
while (la.type === tt.dot) {
|
node.body = this.qml_parseObjectInitializer();
|
||||||
la = this.lookAhead(i++);
|
return this.finishNode(node, "QMLPropertyModifier");
|
||||||
if (this.qml_isIdent(la.type, la.value)) {
|
|
||||||
la = this.lookAhead(i++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (la.type) {
|
|
||||||
case tt.braceL:
|
|
||||||
return this.qml_parseObjectLiteral();
|
|
||||||
case tt.colon:
|
|
||||||
return this.qml_parsePropertyBinding();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -299,13 +309,13 @@ var injectQMLLoose;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Signal Definition of the form:
|
* Parses a QML Signal Definition of the form:
|
||||||
* 'signal' <Identifier> [(<Type> <Identifier> [',' <Type> <Identifier>]* )]?
|
* 'signal' <Identifier> [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
|
||||||
*/
|
*/
|
||||||
lp.qml_parseSignalDefinition = function () {
|
lp.qml_parseSignalDefinition = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
|
|
||||||
// Check if this is an object literal or property binding first
|
// Check if this is an object literal or property binding first
|
||||||
var objOrBind = this.qml_parseObjectLiteralOrPropertyBinding();
|
var objOrBind = this.qml_parseMemberStartsWithIdentifier();
|
||||||
if (objOrBind) {
|
if (objOrBind) {
|
||||||
return objOrBind;
|
return objOrBind;
|
||||||
}
|
}
|
||||||
|
@ -318,28 +328,28 @@ var injectQMLLoose;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks if the given node is a dummy identifier
|
* Checks if the given node is a dummy identifier
|
||||||
*/
|
*/
|
||||||
function isDummy(node) {
|
function isDummy(node) {
|
||||||
return node.name === "✖";
|
return node.name === "✖";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses QML Signal Parameters of the form:
|
* Parses QML Signal Parameters of the form:
|
||||||
* [(<Type> <Identifier> [',' <Type> <Identifier>]* )]?
|
* [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
|
||||||
*/
|
*/
|
||||||
lp.qml_parseSignalParams = function (node) {
|
lp.qml_parseSignalParams = function (node) {
|
||||||
this.pushCx();
|
this.pushCx();
|
||||||
var indent = this.curIndent, line = this.curLineStart;
|
var indent = this.curIndent,
|
||||||
|
line = this.curLineStart;
|
||||||
node.params = [];
|
node.params = [];
|
||||||
if (this.eat(tt.parenL)) {
|
if (this.eat(tt.parenL)) {
|
||||||
while (!this.closes(tt.parenR, indent + 1, line)) {
|
while (!this.closes(tt.parenR, indent + 1, line) && this.tok.type !== tt.braceR) {
|
||||||
var param = this.startNode();
|
var param = this.startNode();
|
||||||
|
param.kind = this.qml_parsePropertyType();
|
||||||
param.kind = this.qml_parseIdent(true);
|
|
||||||
|
|
||||||
// Break out of an infinite loop where we continously consume dummy ids
|
// Break out of an infinite loop where we continously consume dummy ids
|
||||||
if (isDummy(param.kind) && this.tok.type !== tt.comma) {
|
if (isDummy(param.kind.id) && this.tok.type !== tt.comma) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +373,7 @@ var injectQMLLoose;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Property Declaration (or Alias) of the form:
|
* Parses a QML Property Declaration of the form:
|
||||||
* ['default'|'readonly'] 'property' <QMLType> <Identifier> [<QMLBinding>]
|
* ['default'|'readonly'] 'property' <QMLType> <Identifier> [<QMLBinding>]
|
||||||
*/
|
*/
|
||||||
lp.qml_parsePropertyDeclaration = function () {
|
lp.qml_parsePropertyDeclaration = function () {
|
||||||
|
@ -376,7 +386,7 @@ var injectQMLLoose;
|
||||||
if (this.eat(tt._default)) {
|
if (this.eat(tt._default)) {
|
||||||
node.default = true;
|
node.default = true;
|
||||||
} else if (this.isContextual(qtt._readonly)) {
|
} else if (this.isContextual(qtt._readonly)) {
|
||||||
objOrBind = this.qml_parseObjectLiteralOrPropertyBinding();
|
objOrBind = this.qml_parseMemberStartsWithIdentifier();
|
||||||
if (objOrBind) {
|
if (objOrBind) {
|
||||||
objOrBind.default = undefined;
|
objOrBind.default = undefined;
|
||||||
objOrBind.readonly = undefined;
|
objOrBind.readonly = undefined;
|
||||||
|
@ -387,7 +397,7 @@ var injectQMLLoose;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node.default && !node.readonly) {
|
if (!node.default && !node.readonly) {
|
||||||
objOrBind = this.qml_parseObjectLiteralOrPropertyBinding();
|
objOrBind = this.qml_parseMemberStartsWithIdentifier();
|
||||||
if (objOrBind) {
|
if (objOrBind) {
|
||||||
return objOrBind;
|
return objOrBind;
|
||||||
}
|
}
|
||||||
|
@ -397,7 +407,13 @@ var injectQMLLoose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
node.kind = this.qml_parseKind();
|
node.kind = this.qml_parsePropertyType();
|
||||||
|
if (this.tok.value === "<") {
|
||||||
|
this.expect(tt.relational); // '<'
|
||||||
|
node.modifier = this.qml_parsePropertyType();
|
||||||
|
this.expect(tt.relational); // '>'
|
||||||
|
}
|
||||||
|
|
||||||
node.id = this.qml_parseIdent(false);
|
node.id = this.qml_parseIdent(false);
|
||||||
|
|
||||||
var start = this.storeCurrentPos();
|
var start = this.storeCurrentPos();
|
||||||
|
@ -411,22 +427,53 @@ var injectQMLLoose;
|
||||||
return this.finishNode(node, "QMLPropertyDeclaration");
|
return this.finishNode(node, "QMLPropertyDeclaration");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses a QML Property Type of the form:
|
||||||
|
* <Identifier>
|
||||||
|
*/
|
||||||
|
lp.qml_parsePropertyType = function () {
|
||||||
|
var node = this.startNode();
|
||||||
|
node.primitive = false;
|
||||||
|
if (this.qml_isPrimitiveType(this.tok.type, this.tok.value)) {
|
||||||
|
node.primitive = true;
|
||||||
|
}
|
||||||
|
node.id = this.qml_parseIdent(true);
|
||||||
|
return this.finishNode(node, "QMLPropertyType");
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses one of the following possibilities for a QML Property assignment:
|
* Parses one of the following possibilities for a QML Property assignment:
|
||||||
* - QML Object Literal
|
* - QML Object Binding
|
||||||
|
* - QML Array Binding
|
||||||
* - QML Script Binding
|
* - QML Script Binding
|
||||||
*/
|
*/
|
||||||
lp.qml_parseBinding = function (start) {
|
lp.qml_parseBinding = function (start) {
|
||||||
|
var i, la;
|
||||||
if (this.options.mode === "qmltypes") {
|
if (this.options.mode === "qmltypes") {
|
||||||
return this.qml_parseScriptBinding(start, false);
|
return this.qml_parseScriptBinding(start, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.tok.type === tt.braceL) {
|
if (this.tok.type === tt.braceL) {
|
||||||
return this.qml_parseScriptBinding(start, true);
|
return this.qml_parseScriptBinding(start, true);
|
||||||
|
} else if (this.tok.type === tt.bracketL) {
|
||||||
|
// Perform look ahead to determine whether this is an expression or
|
||||||
|
// a QML Array Binding
|
||||||
|
i = 1;
|
||||||
|
la = this.lookAhead(i++);
|
||||||
|
if (la.type === tt.name) {
|
||||||
|
while (la.type === tt.dot || la.type === tt.name) {
|
||||||
|
la = this.lookAhead(i++);
|
||||||
|
}
|
||||||
|
if (la.type === tt.braceL) {
|
||||||
|
return this.qml_parseArrayBinding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.qml_parseScriptBinding(start, true);
|
||||||
}
|
}
|
||||||
// Perform look ahead to determine whether this is an expression or
|
// Perform look ahead to determine whether this is an expression or
|
||||||
// a QML Object Literal
|
// a QML Object Literal
|
||||||
var i = 1, la = this.tok;
|
i = 1;
|
||||||
|
la = this.tok;
|
||||||
if (this.qml_isIdent(la.type, la.value)) {
|
if (this.qml_isIdent(la.type, la.value)) {
|
||||||
la = this.lookAhead(i++);
|
la = this.lookAhead(i++);
|
||||||
}
|
}
|
||||||
|
@ -438,12 +485,44 @@ var injectQMLLoose;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (la.type === tt.braceL) {
|
if (la.type === tt.braceL) {
|
||||||
return this.qml_parseObjectLiteral();
|
return this.qml_parseObjectDefinition(true);
|
||||||
} else {
|
} else {
|
||||||
return this.qml_parseScriptBinding(start, true);
|
return this.qml_parseScriptBinding(start, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses a QML Array Binding of the form:
|
||||||
|
* '[' [<QMLObjectDefinition> (',' <QMLObjectDefinition>)*] ']'
|
||||||
|
*/
|
||||||
|
lp.qml_parseArrayBinding = function () {
|
||||||
|
var node = this.startNode();
|
||||||
|
var indent = this.curIndent,
|
||||||
|
line = this.curLineStart;
|
||||||
|
this.pushCx();
|
||||||
|
this.expect(tt.bracketL);
|
||||||
|
node.elements = [];
|
||||||
|
while (!this.closes(tt.bracketR, indent + 1, line) && this.tok.type !== tt.braceR) {
|
||||||
|
var obj = this.qml_parseObjectDefinition();
|
||||||
|
node.elements.push(obj);
|
||||||
|
|
||||||
|
// Break out of an infinite loop where we continously consume dummy ids
|
||||||
|
if (isDummy(obj.id) && this.tok.type !== tt.comma) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.eat(tt.comma);
|
||||||
|
}
|
||||||
|
this.popCx();
|
||||||
|
if (!this.eat(tt.bracketR)) {
|
||||||
|
// If there is no closing brace, make the node span to the start
|
||||||
|
// of the next token (this is useful for Tern)
|
||||||
|
this.last.end = this.tok.start;
|
||||||
|
if (this.options.locations) this.last.loc.end = this.tok.loc.start;
|
||||||
|
}
|
||||||
|
return this.finishNode(node, "QMLArrayBinding");
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses one of the following Script Bindings:
|
* Parses one of the following Script Bindings:
|
||||||
* - Single JavaScript Expression
|
* - Single JavaScript Expression
|
||||||
|
@ -479,7 +558,7 @@ var injectQMLLoose;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a QML Statement Block of the form:
|
* Parses a QML Statement Block of the form:
|
||||||
* { <JavaScript Statement>* }
|
* { <Statement>* }
|
||||||
*/
|
*/
|
||||||
lp.qml_parseStatementBlock = function () {
|
lp.qml_parseStatementBlock = function () {
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
|
@ -487,27 +566,15 @@ var injectQMLLoose;
|
||||||
this.expect(tt.braceL);
|
this.expect(tt.braceL);
|
||||||
var blockIndent = this.curIndent,
|
var blockIndent = this.curIndent,
|
||||||
line = this.curLineStart;
|
line = this.curLineStart;
|
||||||
node.statements = [];
|
node.body = [];
|
||||||
while (!this.closes(tt.braceR, blockIndent, line, true)) {
|
while (!this.closes(tt.braceR, blockIndent, line, true)) {
|
||||||
node.statements.push(this.parseStatement(true, false));
|
node.body.push(this.parseStatement(true, false));
|
||||||
}
|
}
|
||||||
this.popCx();
|
this.popCx();
|
||||||
this.eat(tt.braceR);
|
this.eat(tt.braceR);
|
||||||
return this.finishNode(node, "QMLStatementBlock");
|
return this.finishNode(node, "QMLStatementBlock");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Parses a QML Type which can be either a Qualified ID or a primitive type keyword.
|
|
||||||
*/
|
|
||||||
lp.qml_parseKind = function () {
|
|
||||||
var value = this.tok.value;
|
|
||||||
if (this.qml_eatPrimitiveType(this.tok.type, value)) {
|
|
||||||
return value;
|
|
||||||
} else {
|
|
||||||
return this.qml_parseQualifiedId(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses a Qualified ID of the form:
|
* Parses a Qualified ID of the form:
|
||||||
* <Identifier> ('.' <Identifier>)*
|
* <Identifier> ('.' <Identifier>)*
|
||||||
|
@ -552,11 +619,11 @@ var injectQMLLoose;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks the next token to see if it matches the given contextual keyword. If the
|
* Checks the next token to see if it matches the given contextual keyword. If the
|
||||||
* contextual keyword was not found, this function looks ahead at the next two tokens
|
* contextual keyword was not found, this function looks ahead at the next two tokens
|
||||||
* and jumps ahead if it was found there. Returns whether or not the keyword was found.
|
* and jumps ahead if it was found there. Returns whether or not the keyword was found.
|
||||||
*/
|
*/
|
||||||
lp.expectContextual = function(name) {
|
lp.expectContextual = function (name) {
|
||||||
if (this.eatContextual(name)) return true;
|
if (this.eatContextual(name)) return true;
|
||||||
for (var i = 1; i <= 2; i++) {
|
for (var i = 1; i <= 2; i++) {
|
||||||
if (this.lookAhead(i).type == tt.name && this.lookAhead(i).value === name) {
|
if (this.lookAhead(i).type == tt.name && this.lookAhead(i).value === name) {
|
||||||
|
@ -589,15 +656,15 @@ var injectQMLLoose;
|
||||||
// as the root object literal and header statements of QML. Eventually,
|
// as the root object literal and header statements of QML. Eventually,
|
||||||
// these rules will delegate down to JavaScript expressions.
|
// these rules will delegate down to JavaScript expressions.
|
||||||
var node = this.startNode();
|
var node = this.startNode();
|
||||||
node.headerStatements = this.qml_parseHeaderStatements();
|
node.headerItemList = this.qml_parseHeaderItemList();
|
||||||
node.rootObject = null;
|
node.rootObject = null;
|
||||||
if (this.tok.type !== tt.eof) {
|
if (this.tok.type !== tt.eof) {
|
||||||
node.rootObject = this.qml_parseObjectLiteral();
|
node.rootObject = this.qml_parseObjectDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.finishNode(node, "QMLProgram");
|
return this.finishNode(node, "QMLProgram");
|
||||||
} else if (this.options.mode === "js") {
|
} else if (this.options.mode === "js") {
|
||||||
return nextMethod.call(this, node);
|
return nextMethod.call(this);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Unknown mode '" + this.options.mode + "'");
|
throw new Error("Unknown mode '" + this.options.mode + "'");
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -31,45 +31,54 @@
|
||||||
|
|
||||||
extendWalk(walk.base, {
|
extendWalk(walk.base, {
|
||||||
QMLProgram: function (node, st, c) {
|
QMLProgram: function (node, st, c) {
|
||||||
c(node.headerStatements, st);
|
c(node.headerItemList, st);
|
||||||
if (node.rootObject) {
|
if (node.rootObject) {
|
||||||
c(node.rootObject, st, "QMLRootObject");
|
c(node.rootObject, st, "QMLRootObject");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
QMLHeaderStatements: function (node, st, c) {
|
QMLHeaderItemList: function (node, st, c) {
|
||||||
for (var i = 0; i < node.statements.length; i++) {
|
for (var i = 0; i < node.items.length; i++) {
|
||||||
c(node.statements[i], st, "QMLHeaderStatement");
|
c(node.items[i], st, "QMLHeaderItem");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
QMLHeaderStatement: skipThrough,
|
QMLHeaderItem: skipThrough,
|
||||||
QMLImportStatement: ignore,
|
QMLImport: ignore,
|
||||||
QMLPragmaStatement: ignore,
|
QMLPragma: ignore,
|
||||||
QMLRootObject: skipThrough,
|
QMLRootObject: skipThrough,
|
||||||
QMLObjectLiteral: function (node, st, c) {
|
QMLObjectDefinition: function (node, st, c) {
|
||||||
c(node.body, st);
|
c(node.body, st);
|
||||||
},
|
},
|
||||||
QMLMemberBlock: function (node, st, c) {
|
QMLObjectInitializer: function (node, st, c) {
|
||||||
for (var i = 0; i < node.members.length; i++) {
|
for (var i = 0; i < node.members.length; i++) {
|
||||||
c(node.members[i], st, "QMLMember");
|
c(node.members[i], st, "QMLObjectMember");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
QMLMember: skipThrough,
|
QMLObjectMember: skipThrough,
|
||||||
QMLPropertyDeclaration: function (node, st, c) {
|
QMLPropertyDeclaration: function (node, st, c) {
|
||||||
if (node.binding) {
|
if (node.binding) {
|
||||||
c(node.binding, st);
|
c(node.binding, st, "QMLBinding");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
QMLSignalDefinition: ignore,
|
QMLSignalDefinition: ignore,
|
||||||
QMLPropertyBinding: function (node, st, c) {
|
QMLPropertyBinding: function (node, st, c) {
|
||||||
c(node.binding, st);
|
c(node.binding, st, "QMLBinding");
|
||||||
|
},
|
||||||
|
QMLBinding: skipThrough,
|
||||||
|
QMLObjectBinding: function (node, st, c) {
|
||||||
|
c(node.body, st);
|
||||||
|
},
|
||||||
|
QMLArrayBinding: function (node, st, c) {
|
||||||
|
for (var i = 0; i < node.elements.length; i++) {
|
||||||
|
c(node.elements[i], st);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
QMLScriptBinding: function (node, st, c) {
|
QMLScriptBinding: function (node, st, c) {
|
||||||
c(node.script, st);
|
c(node.script, st);
|
||||||
},
|
},
|
||||||
QMLQualifiedID: ignore,
|
QMLQualifiedID: ignore,
|
||||||
QMLStatementBlock: function (node, st, c) {
|
QMLStatementBlock: function (node, st, c) {
|
||||||
for (var i = 0; i < node.statements.length; i++) {
|
for (var i = 0; i < node.body.length; i++) {
|
||||||
c(node.statements[i], st, "Statement");
|
c(node.body[i], st, "Statement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,11 +8,14 @@
|
||||||
package org.eclipse.cdt.qt.core;
|
package org.eclipse.cdt.qt.core;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -25,12 +28,6 @@ import javax.script.ScriptEngineManager;
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.qt.core.Activator;
|
import org.eclipse.cdt.internal.qt.core.Activator;
|
||||||
import org.eclipse.core.resources.IContainer;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
public class QMLAnalyzer {
|
public class QMLAnalyzer {
|
||||||
|
@ -74,28 +71,16 @@ public class QMLAnalyzer {
|
||||||
|
|
||||||
ResolveDirectory resolveDirectory = (file, pathString) -> {
|
ResolveDirectory resolveDirectory = (file, pathString) -> {
|
||||||
String filename = (String) file.get("name");
|
String filename = (String) file.get("name");
|
||||||
int slash = filename.lastIndexOf('/');
|
String fileDirectory = new File(filename).getParent();
|
||||||
String fileDirectory = slash >= 0 ? filename.substring(0, slash + 1) : filename;
|
|
||||||
if (pathString == null) {
|
if (pathString == null) {
|
||||||
return fileDirectory;
|
return fixPathString(fileDirectory);
|
||||||
}
|
}
|
||||||
IPath path = Path.fromOSString(pathString);
|
Path fileDirectoryPath = Paths.get(fileDirectory);
|
||||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
Path path = Paths.get(pathString);
|
||||||
if (!path.isAbsolute()) {
|
if (!path.isAbsolute()) {
|
||||||
IResource res = root.findMember(fileDirectory);
|
path = fileDirectoryPath.toAbsolutePath().resolve(path);
|
||||||
if (res instanceof IContainer) {
|
|
||||||
IContainer dir = (IContainer) res;
|
|
||||||
res = dir.findMember(path);
|
|
||||||
if (res != null) {
|
|
||||||
String p = res.getFullPath().toString().substring(1);
|
|
||||||
if (!p.isEmpty() && !p.endsWith("/")) {
|
|
||||||
p += "/";
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return pathString;
|
return fixPathString(path.normalize().toString());
|
||||||
};
|
};
|
||||||
options.put("resolveDirectory", invoke.invokeFunction("resolveDirectory", resolveDirectory));
|
options.put("resolveDirectory", invoke.invokeFunction("resolveDirectory", resolveDirectory));
|
||||||
|
|
||||||
|
@ -137,19 +122,28 @@ public class QMLAnalyzer {
|
||||||
void callback(Object err, Object data);
|
void callback(Object err, Object data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String fixPathString(String fileName) {
|
||||||
|
fileName = fileName.replaceAll("\\\\", "/");
|
||||||
|
if (fileName.startsWith("/")) {
|
||||||
|
fileName = fileName.substring(1);
|
||||||
|
}
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
public void addFile(String fileName, String code) throws NoSuchMethodException, ScriptException {
|
public void addFile(String fileName, String code) throws NoSuchMethodException, ScriptException {
|
||||||
waitUntilLoaded();
|
waitUntilLoaded();
|
||||||
invoke.invokeMethod(tern, "addFile", fileName, code);
|
invoke.invokeMethod(tern, "addFile", fixPathString(fileName), code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFile(String fileName) throws NoSuchMethodException, ScriptException {
|
public void deleteFile(String fileName) throws NoSuchMethodException, ScriptException {
|
||||||
waitUntilLoaded();
|
waitUntilLoaded();
|
||||||
invoke.invokeMethod(tern, "delFile", fileName);
|
invoke.invokeMethod(tern, "delFile", fixPathString(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<QMLTernCompletion> getCompletions(String fileName, String text, int pos)
|
public Collection<QMLTernCompletion> getCompletions(String fileName, String text, int pos)
|
||||||
throws NoSuchMethodException, ScriptException {
|
throws NoSuchMethodException, ScriptException {
|
||||||
waitUntilLoaded();
|
waitUntilLoaded();
|
||||||
|
fileName = fixPathString(fileName);
|
||||||
Bindings file = engine.createBindings();
|
Bindings file = engine.createBindings();
|
||||||
file.put("type", "full");
|
file.put("type", "full");
|
||||||
file.put("name", fileName);
|
file.put("name", fileName);
|
||||||
|
@ -201,6 +195,7 @@ public class QMLAnalyzer {
|
||||||
public List<Bindings> getDefinition(String identifier, String fileName, String text, int pos)
|
public List<Bindings> getDefinition(String identifier, String fileName, String text, int pos)
|
||||||
throws NoSuchMethodException, ScriptException {
|
throws NoSuchMethodException, ScriptException {
|
||||||
waitUntilLoaded();
|
waitUntilLoaded();
|
||||||
|
fileName = fixPathString(fileName);
|
||||||
Bindings file = engine.createBindings();
|
Bindings file = engine.createBindings();
|
||||||
file.put("type", "full");
|
file.put("type", "full");
|
||||||
file.put("name", fileName);
|
file.put("name", fileName);
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript array expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#arrayexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSArrayExpression extends IJSExpression {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ArrayExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IJSExpression> getElements();
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript assignment expression from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#assignmentexpression">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSAssignmentExpression extends IJSExpression {
|
||||||
|
/**
|
||||||
|
* An Enumeration covering the 12 assignment operators in JavaScript
|
||||||
|
*/
|
||||||
|
enum AssignmentOperator {
|
||||||
|
Assign("="), //$NON-NLS-1$
|
||||||
|
AssignAdd("+="), //$NON-NLS-1$
|
||||||
|
AssignSubtract("-="), //$NON-NLS-1$
|
||||||
|
AssignMultiply("*="), //$NON-NLS-1$
|
||||||
|
AssignDivide("/="), //$NON-NLS-1$
|
||||||
|
AssignModulus("%="), //$NON-NLS-1$
|
||||||
|
AssignLeftShift("<<="), //$NON-NLS-1$
|
||||||
|
AssignRightShift(">>="), //$NON-NLS-1$
|
||||||
|
AssignUnsignedRightShift(">>>="), //$NON-NLS-1$
|
||||||
|
AssignOr("|="), //$NON-NLS-1$
|
||||||
|
AssignExclusiveOr("^"), //$NON-NLS-1$
|
||||||
|
AssignAnd("&="); //$NON-NLS-1$
|
||||||
|
|
||||||
|
private final String op;
|
||||||
|
|
||||||
|
private AssignmentOperator(String op) {
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.op;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "AssignmentExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssignmentOperator getOperator();
|
||||||
|
|
||||||
|
public IJSExpression getLeft();
|
||||||
|
|
||||||
|
public IJSExpression getRight();
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript binary expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#binaryexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSBinaryExpression extends IJSExpression {
|
||||||
|
/**
|
||||||
|
* An Enumeration covering the 21 binary operators in JavaScript
|
||||||
|
*/
|
||||||
|
enum BinaryOperator {
|
||||||
|
Equality("=="), //$NON-NLS-1$
|
||||||
|
Inequality("!="), //$NON-NLS-1$
|
||||||
|
StrictEquality("==="), //$NON-NLS-1$
|
||||||
|
LessThan("<"), //$NON-NLS-1$
|
||||||
|
LessThanOrEqual("<="), //$NON-NLS-1$
|
||||||
|
GreaterThan(">"), //$NON-NLS-1$
|
||||||
|
GreaterThanOrEqual(">="), //$NON-NLS-1$
|
||||||
|
LeftShift("<<"), //$NON-NLS-1$
|
||||||
|
RightShift(">>"), //$NON-NLS-1$
|
||||||
|
UnsignedRightShift(">>>"), //$NON-NLS-1$
|
||||||
|
Add("+"), //$NON-NLS-1$
|
||||||
|
Subtract("-"), //$NON-NLS-1$
|
||||||
|
Multiply("*"), //$NON-NLS-1$
|
||||||
|
Divide("/"), //$NON-NLS-1$
|
||||||
|
Modulus("%"), //$NON-NLS-1$
|
||||||
|
Or("|"), //$NON-NLS-1$
|
||||||
|
EclusiveOr("^"), //$NON-NLS-1$
|
||||||
|
And("&"), //$NON-NLS-1$
|
||||||
|
In("in"), //$NON-NLS-1$
|
||||||
|
Instanceof("instanceof"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
private final String op;
|
||||||
|
|
||||||
|
private BinaryOperator(String op) {
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.op;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "UnaryExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public BinaryOperator getOperator();
|
||||||
|
|
||||||
|
public IJSExpression getLeft();
|
||||||
|
|
||||||
|
public IJSExpression getRight();
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript block statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#blockstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSBlockStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "BlockStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IJSStatement> getBody();
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript break statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#breakstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSBreakStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "BreakStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSIdentifier getLabel();
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript call expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#callexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSCallExpression extends IJSExpression {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "CallExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getCallee();
|
||||||
|
|
||||||
|
public List<IJSExpression> getArguments();
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript catch clause from the <a href="https://github.com/estree/estree/blob/master/spec.md#catchclause">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSCatchClause extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "CatchClause"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSPattern getParam();
|
||||||
|
|
||||||
|
public IJSBlockStatement getBody();
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript conditional expression from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#conditionalexpression">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSConditionalExpression extends IJSExpression {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ConditionalExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getTest();
|
||||||
|
|
||||||
|
public IJSExpression getAlternate();
|
||||||
|
|
||||||
|
public IJSExpression getConsequent();
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript continue statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#continuestatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSContinueStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ContinueStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSIdentifier getLabel();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript debugger statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#debuggerstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSDebuggerStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "DebuggerStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript declaration from the <a href="https://github.com/estree/estree/blob/master/spec.md#declarations">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSDeclaration extends IJSStatement {
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript do while statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#dowhilestatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSDoWhileStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "DoWhileStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getTest();
|
||||||
|
|
||||||
|
public IJSStatement getBody();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An empty JavaScrit statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#emptystatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSEmptyStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "EmptyStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#expressions">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSExpression extends IQmlASTNode {
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript expression statement from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#expressionstatement">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSExpressionStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ExpressionStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getExpression();
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript for in statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#forinstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSForInStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ForInStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link IJSVariableDeclaration}, or {@link IJSExpression}
|
||||||
|
*/
|
||||||
|
public IQmlASTNode getRight();
|
||||||
|
|
||||||
|
public IJSExpression getLeft();
|
||||||
|
|
||||||
|
public IJSStatement getBody();
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript for statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#forstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSForStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ForStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link IJSVariableDeclaration}, {@link IJSExpression}, or <code>null</code>
|
||||||
|
*/
|
||||||
|
public IQmlASTNode getInit();
|
||||||
|
|
||||||
|
public IJSExpression getTest();
|
||||||
|
|
||||||
|
public IJSExpression getUpdate();
|
||||||
|
|
||||||
|
public IJSStatement getBody();
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript function from the <a href="https://github.com/estree/estree/blob/master/spec.md#functions">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSFunction extends IQmlASTNode {
|
||||||
|
public IJSIdentifier getIdentifier();
|
||||||
|
|
||||||
|
public List<IJSPattern> getParams();
|
||||||
|
|
||||||
|
public IJSBlockStatement getBody();
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript function declaration from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#functiondeclaration">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSFunctionDeclaration extends IJSFunction, IJSDeclaration, IQmlObjectMember {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "FunctionDeclaration"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IJSIdentifier getIdentifier();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript function expression from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#functionexpression">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSFunctionExpression extends IJSExpression {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "FunctionExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript identifier from the <a href="https://github.com/estree/estree/blob/master/spec.md#identifier">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSIdentifier extends IJSExpression, IJSPattern {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "Identifier"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public String getName();
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript if statement from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#ifstatement">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSIfStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "IfStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getTest();
|
||||||
|
|
||||||
|
public IJSStatement getConsequence();
|
||||||
|
|
||||||
|
public IJSStatement getAlternate();
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript labeled statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#labeledstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSLabeledStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "LabledStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSIdentifier getLabel();
|
||||||
|
|
||||||
|
public IJSStatement getBody();
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript literal from the <a href="https://github.com/estree/estree/blob/master/spec.md#literal">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSLiteral extends IJSExpression {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "Literal"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String, Boolean, Integer, Double, or Regular Expression
|
||||||
|
*/
|
||||||
|
public Object getValue();
|
||||||
|
|
||||||
|
public String getRaw();
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript logical expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#logicalexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSLogicalExpression extends IJSExpression {
|
||||||
|
/**
|
||||||
|
* An Enumeration covering the two logical operators in JavaScript
|
||||||
|
*/
|
||||||
|
enum LogicalOperator {
|
||||||
|
Or("||"), //$NON-NLS-1$
|
||||||
|
And("&&"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
private final String op;
|
||||||
|
|
||||||
|
private LogicalOperator(String op) {
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.op;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "LogicalExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public LogicalOperator getOperator();
|
||||||
|
|
||||||
|
public IJSExpression getLeft();
|
||||||
|
|
||||||
|
public IJSExpression getRight();
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript member expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#memberexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSMemberExpression extends IJSExpression {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "MemberExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getOjbect();
|
||||||
|
|
||||||
|
public IJSExpression getProperty();
|
||||||
|
|
||||||
|
public boolean isComputed();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript new expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#newexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSNewExpression extends IJSCallExpression {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "NewExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript object expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#objectexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSObjectExpression extends IJSExpression {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ObjectExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IJSProperty> getProperties();
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript pattern from the <a href="https://github.com/estree/estree/blob/master/spec.md#patterns">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSPattern extends IQmlASTNode {
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript program from the <a href="https://github.com/estree/estree/blob/master/spec.md#programs">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSProgram extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "Program"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IJSStatement> getBody();
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript object property from the <a href="https://github.com/estree/estree/blob/master/spec.md#property">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSProperty extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "Property"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link IJSLiteral}, or {@link IJSIdentifier}
|
||||||
|
*/
|
||||||
|
public IQmlASTNode getKey();
|
||||||
|
|
||||||
|
public IJSExpression getValue();
|
||||||
|
|
||||||
|
public String getKind();
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript regular expression literal from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#regexpliteral">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSRegExpLiteral extends IJSLiteral {
|
||||||
|
/**
|
||||||
|
* A JavaScript regular expression that holds a pattern and a set of flags. Both are represented as plain Strings.
|
||||||
|
*/
|
||||||
|
public static class JSRegExp {
|
||||||
|
private final String pattern;
|
||||||
|
private final String flags;
|
||||||
|
|
||||||
|
public JSRegExp(String pattern, String flags) {
|
||||||
|
this.pattern = pattern;
|
||||||
|
this.flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPattern() {
|
||||||
|
return pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlags() {
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSRegExp getRegex();
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript return statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#returnstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSReturnStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ReturnStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getArgument();
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript sequence expression from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#sequenceexpression">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSSequenceExpression extends IJSExpression {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "SequenceExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IJSExpression> getExpressions();
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#statements">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSStatement extends IQmlASTNode {
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript switch case from the <a href="https://github.com/estree/estree/blob/master/spec.md#switchcase">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSSwitchCase extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "SwitchCase"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getTest();
|
||||||
|
|
||||||
|
public List<IJSStatement> getConsequent();
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript switch statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#switchstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSSwitchStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "SwitchStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getDiscriminant();
|
||||||
|
|
||||||
|
public IJSSwitchCase getCases();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript this expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#thisexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSThisExpression extends IJSExpression {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ThisExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript throw statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#throwstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSThrowStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "ThrowStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getArgument();
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript try statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#trystatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSTryStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "TryStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSBlockStatement getBlock();
|
||||||
|
|
||||||
|
public IJSCatchClause getHandler();
|
||||||
|
|
||||||
|
public IJSBlockStatement getFinalizer();
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript unary expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#unaryexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSUnaryExpression extends IJSExpression {
|
||||||
|
/**
|
||||||
|
* An Enumeration covering the 7 unary operators in JavaScript
|
||||||
|
*/
|
||||||
|
enum UnaryOperator {
|
||||||
|
Negation("-"), //$NON-NLS-1$
|
||||||
|
Plus("+"), //$NON-NLS-1$
|
||||||
|
Not("!"), //$NON-NLS-1$
|
||||||
|
BitwiseNot("~"), //$NON-NLS-1$
|
||||||
|
Typeof("typeof"), //$NON-NLS-1$
|
||||||
|
Void("void"), //$NON-NLS-1$
|
||||||
|
Delete("delete"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
private final String op;
|
||||||
|
|
||||||
|
private UnaryOperator(String op) {
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.op;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "UnaryExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnaryOperator getOperator();
|
||||||
|
|
||||||
|
public boolean isPrefix();
|
||||||
|
|
||||||
|
public IJSExpression getArgument();
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript update expression from the <a href="https://github.com/estree/estree/blob/master/spec.md#updateexpression">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSUpdateExpression extends IQmlASTNode {
|
||||||
|
/**
|
||||||
|
* An Enumeration covering the two update operators in JavaScript
|
||||||
|
*/
|
||||||
|
enum UpdateOperator {
|
||||||
|
Decrement("--"), //$NON-NLS-1$
|
||||||
|
Increment("++"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
private final String op;
|
||||||
|
|
||||||
|
private UpdateOperator(String op) {
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.op;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "UpdateExpression"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdateOperator getOperator();
|
||||||
|
|
||||||
|
public IJSExpression getArgument();
|
||||||
|
|
||||||
|
public boolean isPrefix();
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript variable declaration from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#variabledeclaration">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSVariableDeclaration extends IJSDeclaration {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "VariableDeclaration"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IJSVariableDeclarator> getDeclarations();
|
||||||
|
|
||||||
|
default public String getKind() {
|
||||||
|
return "var"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript variable declarator from the
|
||||||
|
* <a href="https://github.com/estree/estree/blob/master/spec.md#variabledeclarator">ESTree Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSVariableDeclarator extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "VariableDeclarator"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSPattern getIdentifier();
|
||||||
|
|
||||||
|
public IJSExpression getInit();
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript while statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#whilestatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSWhileStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "WhileStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getTest();
|
||||||
|
|
||||||
|
public IJSStatement getBody();
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A JavaScript with statement from the <a href="https://github.com/estree/estree/blob/master/spec.md#withstatement">ESTree
|
||||||
|
* Specification</a>
|
||||||
|
*/
|
||||||
|
public interface IJSWithStatement extends IJSStatement {
|
||||||
|
@Override
|
||||||
|
default String getType() {
|
||||||
|
return "WithStatement"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public IJSExpression getObject();
|
||||||
|
|
||||||
|
public IJSStatement getBody();
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.qt.core.location.ISourceLocation;
|
||||||
|
import org.eclipse.cdt.qt.core.qmldir.IQDirASTNode;
|
||||||
|
import org.eclipse.cdt.qt.core.tern.ITernScope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base node interface for all QML and JavaScript Abstract Syntax Tree elements. Conforms to the ESTree Specification as well as
|
||||||
|
* the extra features added by Acorn.
|
||||||
|
*
|
||||||
|
* @see <a href="https://github.com/estree/estree/blob/master/spec.md#node-objects">ESTree Node Objects</a>
|
||||||
|
*/
|
||||||
|
public interface IQmlASTNode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the String representation of the type of AST node that this node represents. This is a bit redundant in Java with access
|
||||||
|
* to <code>instanceof</code>, but is provided for the sake of conforming to the ESTree Specification for node objects.
|
||||||
|
*
|
||||||
|
* @return the String representation of this node
|
||||||
|
*/
|
||||||
|
public String getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a more detailed description of this node's location than {@link IQDirASTNode#getStart()} and
|
||||||
|
* {@link IQDirASTNode#getStart()}. This method allows the retrieval of line and column information in order to make output for
|
||||||
|
* syntax errors and the like more human-readable.<br>
|
||||||
|
* <br>
|
||||||
|
* <b>Note</b>: It is necessary to set the 'locations' option to <code>true</code> when parsing with acorn in order to use this
|
||||||
|
* method.
|
||||||
|
*
|
||||||
|
* @return the {@link ISourceLocation} representing this node's location in the source or <code>null</code> if not available
|
||||||
|
*/
|
||||||
|
public ISourceLocation getLocation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the range of this node if available. A range is an array of two integers containing the start and end offset of this
|
||||||
|
* node in that order. Like {@link IQmlASTNode#getStart()} and {@link IQmlASTNode#getEnd()}, this method returns zero-indexed
|
||||||
|
* offsets relative to the beginning of the source.<br>
|
||||||
|
* <br>
|
||||||
|
* <b>Note</b>: It is necessary to set the 'ranges' option to <code>true</code> when parsing with acorn in order to use this
|
||||||
|
* method.
|
||||||
|
*
|
||||||
|
* @return the range of this node or <code>null</code> if not available
|
||||||
|
*/
|
||||||
|
public int[] getRange();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the zero-indexed offset indicating the start of this node relative to the beginning of the source.
|
||||||
|
*
|
||||||
|
* @return the node's start offset
|
||||||
|
*/
|
||||||
|
public int getStart();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the zero-indexed offset indicating the end of this node relative to the beginning of the source.
|
||||||
|
*
|
||||||
|
* @return the node's end offset
|
||||||
|
*/
|
||||||
|
public int getEnd();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link ITernScope} attached to this node if one exists. This method will only return a non-null value if the AST was
|
||||||
|
* already processed by Tern. For example, if the AST was retrieved from Tern using the 'parseFile' query, then at least one of
|
||||||
|
* the AST nodes will contain a scope object. However, if the 'parseString' query was used, no static analysis will be performed
|
||||||
|
* on the parsed AST and there will be no scope objects attached to any of its nodes.
|
||||||
|
*
|
||||||
|
* @return the Tern scope or <code>null</code> if not available
|
||||||
|
*/
|
||||||
|
public ITernScope getScope();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IQmlArrayBinding extends IQmlBinding {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLArrayBinding"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<IQmlObjectDefinition> getElements();
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlBinding extends IQmlASTNode {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlHeaderItem extends IQmlASTNode {
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IQmlHeaderItemList extends IQmlASTNode {
|
||||||
|
public List<IQmlHeaderItem> getItems();
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlImport extends IQmlHeaderItem {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLImport"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public IQmlModule getModule();
|
||||||
|
|
||||||
|
public IJSLiteral getDirectory();
|
||||||
|
|
||||||
|
public IQmlQualifier getQualifier();
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlModule extends IQmlASTNode {
|
||||||
|
public IQmlQualifiedID getIdentifier();
|
||||||
|
|
||||||
|
public IQmlVersionLiteral getVersion();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlObjectBinding extends IQmlBinding {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLObjectBinding"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public IQmlQualifiedID getIdentifier();
|
||||||
|
|
||||||
|
public IQmlObjectInitializer getBody();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlObjectDefinition extends IQmlObjectMember {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLObjectDefinition"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public IQmlQualifiedID getIdentifier();
|
||||||
|
|
||||||
|
public IQmlObjectInitializer getBody();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IQmlObjectInitializer extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLObjectInitializer"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<IQmlObjectMember> getMembers();
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlObjectMember extends IQmlASTNode {
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlParameter extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLParameter"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public IQmlPropertyType getKind();
|
||||||
|
|
||||||
|
public IJSIdentifier getIdentifier();
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlPragma extends IQmlHeaderItem {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLPragma"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public IQmlQualifiedID getIdentifier();
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlProgram extends IQmlASTNode {
|
||||||
|
public static enum Modes {
|
||||||
|
QML("qml"), QMLTypes("qmltypes"), JavaScript("js"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
|
||||||
|
private final String ident;
|
||||||
|
|
||||||
|
private Modes(String s) {
|
||||||
|
this.ident = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModeIdentifier() {
|
||||||
|
return this.ident;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLProgram"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public Modes getMode();
|
||||||
|
|
||||||
|
public IQmlHeaderItemList getHeaderItemList();
|
||||||
|
|
||||||
|
public IQmlRootObject getRootObject();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlPropertyBinding extends IQmlObjectMember {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLPropertyBinding"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public IQmlQualifiedID getIdentifier();
|
||||||
|
|
||||||
|
public IQmlBinding getBinding();
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlPropertyDeclaration extends IQmlObjectMember {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLPropertyDeclaration"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public boolean isReadonly();
|
||||||
|
|
||||||
|
public boolean isDefault();
|
||||||
|
|
||||||
|
public IQmlPropertyType getKind();
|
||||||
|
|
||||||
|
public IQmlPropertyType getModifier();
|
||||||
|
|
||||||
|
public IJSIdentifier getIdentifier();
|
||||||
|
|
||||||
|
public IQmlBinding getBinding();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlPropertyType extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLPropertyType"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public boolean isPrimitive();
|
||||||
|
|
||||||
|
public IJSIdentifier getIdentifier();
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IQmlQualifiedID extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLQualifiedID"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<IJSIdentifier> getParts();
|
||||||
|
|
||||||
|
public String getName();
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlQualifier extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLQualifier"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public IJSIdentifier getIdentifier();
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlRootObject extends IQmlObjectDefinition {
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlScriptBinding extends IQmlBinding {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLScriptBinding"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public boolean isBlock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link IJSExpression}, or {@link IQmlStatementBlock}
|
||||||
|
*/
|
||||||
|
public IQmlASTNode getScript();
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IQmlSignalDefinition extends IQmlObjectMember {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLSignalDefinition"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public IJSIdentifier getIdentifier();
|
||||||
|
|
||||||
|
public List<IQmlParameter> getParams();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IQmlStatementBlock extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLStatementBlock"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<IJSStatement> getBody();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.qmljs;
|
||||||
|
|
||||||
|
public interface IQmlVersionLiteral extends IQmlASTNode {
|
||||||
|
@Override
|
||||||
|
default public String getType() {
|
||||||
|
return "QMLVersionLiteral"; //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
public double getValue();
|
||||||
|
|
||||||
|
public String getRaw();
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.qt.core.tern;
|
||||||
|
|
||||||
|
public interface ITernScope {
|
||||||
|
// TODO: Determine the necessary components of a Tern Scope
|
||||||
|
}
|
|
@ -141,7 +141,7 @@
|
||||||
// Walk the AST for any imports
|
// Walk the AST for any imports
|
||||||
var ih = this;
|
var ih = this;
|
||||||
walk.simple(file.ast, {
|
walk.simple(file.ast, {
|
||||||
QMLImportStatement: function (node) {
|
QMLImport: function (node) {
|
||||||
var prop = null;
|
var prop = null;
|
||||||
var scope = file.scope;
|
var scope = file.scope;
|
||||||
if (node.qualifier) {
|
if (node.qualifier) {
|
||||||
|
@ -551,19 +551,22 @@
|
||||||
|
|
||||||
// Infers the property's type from its given primitive value
|
// Infers the property's type from its given primitive value
|
||||||
function infKind(kind, out) {
|
function infKind(kind, out) {
|
||||||
switch (kind) {
|
// TODO: infer list type
|
||||||
case "int":
|
if (kind.primitive) {
|
||||||
case "double":
|
switch (kind.id.name) {
|
||||||
case "real":
|
case "int":
|
||||||
infer.cx().num.propagate(out);
|
case "double":
|
||||||
break;
|
case "real":
|
||||||
case "string":
|
infer.cx().num.propagate(out);
|
||||||
case "color":
|
break;
|
||||||
infer.cx().str.propagate(out);
|
case "string":
|
||||||
break;
|
case "color":
|
||||||
case "boolean":
|
infer.cx().str.propagate(out);
|
||||||
infer.cx().bool.propagate(out);
|
break;
|
||||||
break;
|
case "boolean":
|
||||||
|
infer.cx().bool.propagate(out);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,11 +615,15 @@
|
||||||
function extendTernScopeGatherer(scopeGatherer) {
|
function extendTernScopeGatherer(scopeGatherer) {
|
||||||
// Extend the Tern scopeGatherer to build up our custom QML scoping
|
// Extend the Tern scopeGatherer to build up our custom QML scoping
|
||||||
extendWalk(scopeGatherer, {
|
extendWalk(scopeGatherer, {
|
||||||
QMLObjectLiteral: function (node, scope, c) {
|
QMLObjectDefinition: function (node, scope, c) {
|
||||||
var inner = node.scope = getScopeBuilder().newObjScope(node);
|
var inner = node.scope = getScopeBuilder().newObjScope(node);
|
||||||
c(node.body, inner);
|
c(node.body, inner);
|
||||||
},
|
},
|
||||||
QMLMemberBlock: function (node, scope, c) {
|
QMLObjectBinding: function (node, scope, c) {
|
||||||
|
var inner = node.scope = getScopeBuilder().newObjScope(node);
|
||||||
|
c(node.body, inner);
|
||||||
|
},
|
||||||
|
QMLObjectInitializer: function (node, scope, c) {
|
||||||
var memScope = node.scope = getScopeBuilder().newMemberScope(scope, node);
|
var memScope = node.scope = getScopeBuilder().newMemberScope(scope, node);
|
||||||
for (var i = 0; i < node.members.length; i++) {
|
for (var i = 0; i < node.members.length; i++) {
|
||||||
var member = node.members[i];
|
var member = node.members[i];
|
||||||
|
@ -667,8 +674,8 @@
|
||||||
QMLStatementBlock: function (node, scope, c) {
|
QMLStatementBlock: function (node, scope, c) {
|
||||||
var inner = getScopeBuilder().newJSScope(scope, node);
|
var inner = getScopeBuilder().newJSScope(scope, node);
|
||||||
node.scope = inner;
|
node.scope = inner;
|
||||||
for (var i = 0; i < node.statements.length; i++) {
|
for (var i = 0; i < node.body.length; i++) {
|
||||||
c(node.statements[i], inner, "Statement");
|
c(node.body[i], inner, "Statement");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
QMLSignalDefinition: function (node, scope, c) {
|
QMLSignalDefinition: function (node, scope, c) {
|
||||||
|
@ -707,8 +714,11 @@
|
||||||
QMLScriptBinding: fill(function (node, scope, out, name) {
|
QMLScriptBinding: fill(function (node, scope, out, name) {
|
||||||
return inf(node.script, node.scope, out, name);
|
return inf(node.script, node.scope, out, name);
|
||||||
}),
|
}),
|
||||||
QMLObjectLiteral: ret(function (node, scope, name) {
|
QMLObjectBinding: ret(function (node, scope, name) {
|
||||||
return node.scope.objType;
|
return node.scope.objType;
|
||||||
|
}),
|
||||||
|
QMLArrayBinding: ret(function (node, scope, name) {
|
||||||
|
return new infer.Arr(null); // TODO: populate with type of array contents
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -716,10 +726,13 @@
|
||||||
function extendTernInferWrapper(inferWrapper) {
|
function extendTernInferWrapper(inferWrapper) {
|
||||||
// Extend the inferWrapper methods
|
// Extend the inferWrapper methods
|
||||||
extendWalk(inferWrapper, {
|
extendWalk(inferWrapper, {
|
||||||
QMLObjectLiteral: function (node, scope, c) {
|
QMLObjectDefinition: function (node, scope, c) {
|
||||||
c(node.body, node.scope);
|
c(node.body, node.scope);
|
||||||
},
|
},
|
||||||
QMLMemberBlock: function (node, scope, c) {
|
QMLObjectBinding: function (node, scope, c) {
|
||||||
|
c(node.body, node.scope);
|
||||||
|
},
|
||||||
|
QMLObjectInitializer: function (node, scope, c) {
|
||||||
for (var i = 0; i < node.members.length; i++) {
|
for (var i = 0; i < node.members.length; i++) {
|
||||||
var member = node.members[i];
|
var member = node.members[i];
|
||||||
if (member.type === "QMLPropertyDeclaration" || member.type === "QMLPropertyBinding") {
|
if (member.type === "QMLPropertyDeclaration" || member.type === "QMLPropertyBinding") {
|
||||||
|
@ -765,15 +778,15 @@
|
||||||
c(node.script, node.scope);
|
c(node.script, node.scope);
|
||||||
},
|
},
|
||||||
QMLStatementBlock: function (node, scope, c) {
|
QMLStatementBlock: function (node, scope, c) {
|
||||||
for (var i = 0; i < node.statements.length; i++) {
|
for (var i = 0; i < node.body.length; i++) {
|
||||||
c(node.statements[i], node.scope, "Statement");
|
c(node.body[i], node.scope, "Statement");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
QMLSignalDefinition: function (node, scope, c) {
|
QMLSignalDefinition: function (node, scope, c) {
|
||||||
var sig = scope.getProp(node.id.name);
|
var sig = scope.getProp(node.id.name);
|
||||||
for (var i = 0; i < node.params.length; i++) {
|
for (var i = 0; i < node.params.length; i++) {
|
||||||
var param = node.params[i];
|
var param = node.params[i];
|
||||||
infKind(param.kind.name, sig.sigType.args[i]);
|
infKind(param.kind, sig.sigType.args[i]);
|
||||||
}
|
}
|
||||||
sig.sigType.retval = infer.ANull;
|
sig.sigType.retval = infer.ANull;
|
||||||
sig.sigType.propagate(sig);
|
sig.sigType.propagate(sig);
|
||||||
|
@ -788,10 +801,13 @@
|
||||||
function extendTernTypeFinder(typeFinder) {
|
function extendTernTypeFinder(typeFinder) {
|
||||||
// Extend the type finder to return valid types for QML AST elements
|
// Extend the type finder to return valid types for QML AST elements
|
||||||
extendWalk(typeFinder, {
|
extendWalk(typeFinder, {
|
||||||
QMLObjectLiteral: function (node, scope) {
|
QMLObjectDefinition: function (node, scope) {
|
||||||
return node.scope.objType;
|
return node.scope.objType;
|
||||||
},
|
},
|
||||||
QMLMemberBlock: function (node, scope) {
|
QMLObjectBinding: function (node, scope) {
|
||||||
|
return node.scope.objType;
|
||||||
|
},
|
||||||
|
QMLObjectInitializer: function (node, scope) {
|
||||||
return infer.ANull;
|
return infer.ANull;
|
||||||
},
|
},
|
||||||
FunctionDeclaration: function (node, scope) {
|
FunctionDeclaration: function (node, scope) {
|
||||||
|
@ -819,10 +835,13 @@
|
||||||
function extendTernSearchVisitor(searchVisitor) {
|
function extendTernSearchVisitor(searchVisitor) {
|
||||||
// Extend the search visitor to traverse the scope properly
|
// Extend the search visitor to traverse the scope properly
|
||||||
extendWalk(searchVisitor, {
|
extendWalk(searchVisitor, {
|
||||||
QMLObjectLiteral: function (node, scope, c) {
|
QMLObjectDefinition: function (node, scope, c) {
|
||||||
c(node.body, node.scope);
|
c(node.body, node.scope);
|
||||||
},
|
},
|
||||||
QMLMemberBlock: function (node, scope, c) {
|
QMLObjectBinding: function (node, scope, c) {
|
||||||
|
c(node.body, node.scope);
|
||||||
|
},
|
||||||
|
QMLObjectInitializer: function (node, scope, c) {
|
||||||
for (var i = 0; i < node.members.length; i++) {
|
for (var i = 0; i < node.members.length; i++) {
|
||||||
var member = node.members[i];
|
var member = node.members[i];
|
||||||
if (member.type === "QMLPropertyDeclaration" || member.type === "QMLPropertyBinding") {
|
if (member.type === "QMLPropertyDeclaration" || member.type === "QMLPropertyBinding") {
|
||||||
|
@ -868,8 +887,8 @@
|
||||||
// Ignore
|
// Ignore
|
||||||
},
|
},
|
||||||
QMLStatementBlock: function (node, scope, c) {
|
QMLStatementBlock: function (node, scope, c) {
|
||||||
for (var i = 0; i < node.statements.length; i++) {
|
for (var i = 0; i < node.body.length; i++) {
|
||||||
c(node.statements[i], node.scope, "Statement");
|
c(node.body[i], node.scope, "Statement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class QMLContentAssistProcessor implements IContentAssistProcessor {
|
||||||
String prefix = lastWord(document, offset);
|
String prefix = lastWord(document, offset);
|
||||||
// Save the file
|
// Save the file
|
||||||
IFileEditorInput fileInput = (IFileEditorInput) editor.getEditorInput();
|
IFileEditorInput fileInput = (IFileEditorInput) editor.getEditorInput();
|
||||||
String fileName = new File(fileInput.getFile().getLocationURI()).getAbsolutePath().substring(1);
|
String fileName = new File(fileInput.getFile().getLocationURI()).getAbsolutePath();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String contents = document.get();
|
String contents = document.get();
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.qt.ui.editor;
|
package org.eclipse.cdt.internal.qt.ui.editor;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.qt.ui.Activator;
|
import org.eclipse.cdt.internal.qt.ui.Activator;
|
||||||
|
@ -50,7 +52,7 @@ public class QMLEditor extends TextEditor {
|
||||||
@Override
|
@Override
|
||||||
public void doSave(IProgressMonitor progressMonitor) {
|
public void doSave(IProgressMonitor progressMonitor) {
|
||||||
IFileEditorInput fileInput = (IFileEditorInput) getEditorInput();
|
IFileEditorInput fileInput = (IFileEditorInput) getEditorInput();
|
||||||
String fileName = fileInput.getFile().getFullPath().toString().substring(1);
|
String fileName = new File(fileInput.getFile().getLocationURI()).getAbsolutePath();
|
||||||
IDocument document = getSourceViewer().getDocument();
|
IDocument document = getSourceViewer().getDocument();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue