1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42: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:
Matthew Bastien 2015-12-14 11:12:50 -05:00
parent e62e2772fe
commit 84b5f4bfd2
80 changed files with 3192 additions and 489 deletions

View file

@ -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.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.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.qmldir

View file

@ -56,6 +56,7 @@
kw("readonly", { isQMLContextual: true });
kw("signal", { isQMLContextual: true });
kw("as");
kw("on", { isQMLContextual: true });
kw("boolean", { isPrimitive: true });
kw("double", { isPrimitive: true });
kw("int", { isPrimitive: true });
@ -83,47 +84,46 @@
var pp = acorn.Parser.prototype;
/*
* Parses a set of QML Header Statements which can either be of
* the type import or pragma
* Parses a set of QML Header Items (QMLImport or QMLPragma)
*/
pp.qml_parseHeaderStatements = function () {
pp.qml_parseHeaderItemList = function () {
var node = this.startNode();
node.statements = [];
node.items = [];
var loop = true;
while (loop) {
if (this.isContextual(qtt._import)) {
node.statements.push(this.qml_parseImportStatement());
node.items.push(this.qml_parseImport());
} else if (this.isContextual(qtt._pragma)) {
node.statements.push(this.qml_parsePragmaStatement());
node.items.push(this.qml_parsePragma());
} else {
loop = false;
}
}
return this.finishNode(node, "QMLHeaderStatements");
return this.finishNode(node, "QMLHeaderItemList");
};
/*
* Parses a QML Pragma statement of the form:
* 'pragma' <Identifier>
* 'pragma' <QMLQualifiedID>
*/
pp.qml_parsePragmaStatement = function () {
pp.qml_parsePragma = function () {
var node = this.startNode();
this.expectContextual(qtt._pragma);
node.id = this.parseIdent(false);
node.id = this.qml_parseQualifiedId(true);
this.semicolon();
return this.finishNode(node, "QMLPragmaStatement");
return this.finishNode(node, "QMLPragma");
};
/*
* Parses a QML Import statement of the form:
* 'import' <ModuleIdentifier> <Version.Number> [as <Qualifier>]
* 'import' <DirectoryPath> [as <Qualifier>]
* Parses a QML Import of the form:
* 'import' <QMLModule> [as <QMLQualifier>]
* 'import' <StringLiteral> [as <QMLQualifier>]
*
* 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();
if (!this.eatContextual(qtt._import)) {
@ -149,12 +149,12 @@
}
this.semicolon();
return this.finishNode(node, "QMLImportStatement");
return this.finishNode(node, "QMLImport");
};
/*
* Parses a QML Module of the form:
* <QMLQualifiedId> <QMLVersionLiteral> ['as' <QMLQualifier>]?
* <QMLQualifiedId> <QMLVersionLiteral>
*/
pp.qml_parseModule = function () {
var node = this.startNode();
@ -176,16 +176,12 @@
pp.qml_parseVersionLiteral = function () {
var node = this.startNode();
node.raw = this.input.slice(this.start, this.end);
node.value = this.value;
var matches;
if ((matches = /(\d+)\.(\d+)/.exec(node.raw))) {
node.major = parseInt(matches[1]);
node.minor = parseInt(matches[2]);
this.next();
} else {
node.raw = this.input.slice(this.start, this.end);
if (!(/(\d+)\.(\d+)/.exec(node.raw))) {
this.raise(this.start, "QML module must specify major and minor version");
}
this.next();
return this.finishNode(node, "QMLVersionLiteral");
};
@ -202,45 +198,47 @@
};
/*
* Parses a QML Object Literal of the form:
* <QualifiedId> { (<QMLMember>)* }
* Parses a QML Object Definition of the form:
* <QMLQualifiedId> { (<QMLObjectMember>)* }
*
* 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) {
node = this.startNode();
}
if (!node.id) {
node.id = this.qml_parseQualifiedId(false);
}
node.body = this.qml_parseMemberBlock();
return this.finishNode(node, "QMLObjectLiteral");
node.body = this.qml_parseObjectInitializer();
return this.finishNode(node, isBinding ? "QMLObjectBinding" : "QMLObjectDefinition");
};
/*
* Parses a QML Member Block of the form:
* { <QMLMember>* }
* Parses a QML Object Initializer of the form:
* '{' <QMLObjectMember>* '}'
*/
pp.qml_parseMemberBlock = function () {
pp.qml_parseObjectInitializer = function () {
var node = this.startNode();
this.expect(tt.braceL);
node.members = [];
while (!this.eat(tt.braceR)) {
node.members.push(this.qml_parseMember());
while (this.type !== tt.braceR) {
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 Property Declaration (or Alias)
* - a QML Property Declaration
* - a QML Property Modifier
* - a QML Object Literal
* - 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)) {
return this.qml_parsePropertyDeclaration();
} else if (this.isContextual(qtt._signal)) {
@ -248,7 +246,7 @@
} else if (this.type === tt._function) {
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) {
node = this.startNode();
}
@ -272,7 +270,7 @@
}
switch (this.type) {
case tt.braceL:
return this.qml_parseObjectLiteral(node);
return this.qml_parseObjectDefinition(node);
case tt.colon:
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>
*/
pp.qml_parsePropertyBinding = function (node) {
@ -297,7 +314,7 @@
/*
* Parses a QML Signal Definition of the form:
* 'signal' <Identifier> [(<Type> <Identifier> [',' <Type> <Identifier>]* )]?
* 'signal' <Identifier> [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
*/
pp.qml_parseSignalDefinition = function () {
var node = this.startNode();
@ -312,12 +329,12 @@
if (this.type === tt.colon || this.type === tt.braceL) {
// This is a property binding or object literal
node.id = signal;
return this.qml_parseObjectLiteralOrPropertyBinding(node);
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
}
} else {
// Signal keyword is a qualified ID. This is not a signal definition
node.id = signal;
return this.qml_parseObjectLiteralOrPropertyBinding(node);
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
}
node.id = this.qml_parseIdent(false);
@ -328,7 +345,7 @@
/*
* Parses QML Signal Parameters of the form:
* [(<Type> <Identifier> [',' <Type> <Identifier>]* )]?
* [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
*/
pp.qml_parseSignalParams = function (node) {
node.params = [];
@ -336,7 +353,7 @@
if (!this.eat(tt.parenR)) {
do {
var param = this.startNode();
param.kind = this.qml_parseIdent(true);
param.kind = this.qml_parsePropertyType();
param.id = this.qml_parseIdent(false);
node.params.push(this.finishNode(param, "QMLParameter"));
} 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>]
*/
pp.qml_parsePropertyDeclaration = function () {
@ -364,13 +381,13 @@
if (this.type === tt.colon || this.type === tt.braceL) {
// This is a property binding or object literal.
node.id = readonly;
return this.qml_parseObjectLiteralOrPropertyBinding(node);
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
}
node.readonly = true;
} else {
// Readonly keyword is a qualified ID. This is not a property declaration.
node.id = readonly;
return this.qml_parseObjectLiteralOrPropertyBinding(node);
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
}
}
@ -386,17 +403,26 @@
node.default = undefined;
node.readonly = undefined;
node.id = property;
return this.qml_parseObjectLiteralOrPropertyBinding(node);
return this.qml_parseObjectDefinitionOrPropertyBinding(node);
}
} else {
// Property keyword is a qualified ID. This is not a property declaration.
node.default = undefined;
node.readonly = undefined;
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);
if (!this.eat(tt.colon)) {
node.binding = null;
@ -408,9 +434,24 @@
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:
* - QML Object Literal
* - QML Object Binding
* - QML Array Binding
* - QML Script Binding
*/
pp.qml_parseBinding = function () {
@ -426,6 +467,23 @@
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:
* - Single JavaScript Expression
@ -446,32 +504,18 @@
/*
* Parses a QML Statement Block of the form:
* { <JavaScript Statement>* }
* { <Statement>* }
*/
pp.qml_parseStatementBlock = function () {
var node = this.startNode();
this.expect(tt.braceL);
node.statements = [];
node.body = [];
while (!this.eat(tt.braceR)) {
node.statements.push(this.parseStatement(true, false));
node.body.push(this.parseStatement(true, false));
}
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:
* <Identifier> ('.' <Identifier>)*
@ -579,10 +623,10 @@
// replacing JavaScripts top-level. Here we are parsing such things
// as the root object literal and header statements of QML. Eventually,
// these rules will delegate down to JavaScript expressions.
node.headerStatements = this.qml_parseHeaderStatements();
node.headerItemList = this.qml_parseHeaderItemList();
node.rootObject = null;
if (this.type !== tt.eof) {
node.rootObject = this.qml_parseObjectLiteral();
node.rootObject = this.qml_parseObjectDefinition();
}
if (!this.eat(tt.eof)) {

View file

@ -34,47 +34,46 @@ var injectQMLLoose;
var pp = acorn.Parser.prototype;
/*
* Parses a set of QML Header Statements which can either be of
* the type import or pragma
* Parses a set of QML Header Items (QMLImport or QMLPragma)
*/
lp.qml_parseHeaderStatements = function () {
lp.qml_parseHeaderItemList = function () {
var node = this.startNode();
node.statements = [];
node.items = [];
var loop = true;
while (loop) {
if (this.isContextual(qtt._import)) {
node.statements.push(this.qml_parseImportStatement());
node.items.push(this.qml_parseImport());
} else if (this.isContextual(qtt._pragma)) {
node.statements.push(this.qml_parsePragmaStatement());
node.items.push(this.qml_parsePragma());
} else {
loop = false;
}
}
return this.finishNode(node, "QMLHeaderStatements");
return this.finishNode(node, "QMLHeaderItemList");
};
/*
* Parses a QML Pragma statement of the form:
* 'pragma' <Identifier>
* 'pragma' <QMLQualifiedID>
*/
lp.qml_parsePragmaStatement = function () {
lp.qml_parsePragma = function () {
var node = this.startNode();
this.expectContextual(qtt._pragma);
node.id = this.parseIdent(false);
node.id = this.qml_parseQualifiedId(true);
this.semicolon();
return this.finishNode(node, "QMLPragmaStatement");
return this.finishNode(node, "QMLPragma");
};
/*
* Parses a QML Import statement of the form:
* 'import' <ModuleIdentifier> <Version.Number> [as <Qualifier>]
* 'import' <DirectoryPath> [as <Qualifier>]
* Parses a QML Import of the form:
* 'import' <QMLModule> [as <QMLQualifier>]
* 'import' <StringLiteral> [as <QMLQualifier>]
*
* 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();
this.expectContextual(qtt._import);
@ -95,12 +94,12 @@ var injectQMLLoose;
}
this.semicolon();
return this.finishNode(node, "QMLImportStatement");
return this.finishNode(node, "QMLImport");
};
/*
* Parses a QML Module of the form:
* <QMLQualifiedId> <QMLVersionLiteral> ['as' <QMLQualifier>]?
* <QMLQualifiedId> <QMLVersionLiteral>
*/
lp.qml_parseModule = function () {
var node = this.startNode();
@ -118,22 +117,12 @@ var injectQMLLoose;
lp.qml_parseVersionLiteral = function () {
var node = this.startNode();
node.raw = this.input.slice(this.tok.start, this.tok.end);
node.value = this.tok.value;
var matches;
if (this.tok.type === tt.num) {
if ((matches = /(\d+)\.(\d+)/.exec(node.raw))) {
node.major = parseInt(matches[1]);
node.minor = parseInt(matches[2]);
this.next();
} else {
node.major = parseInt(node.raw);
node.minor = 0;
this.next();
}
node.raw = this.input.slice(this.tok.start, this.tok.end);
node.value = this.tok.value;
this.next();
} else {
node.major = 0;
node.minor = 0;
node.value = 0;
node.raw = "0.0";
}
@ -153,48 +142,50 @@ var injectQMLLoose;
};
/*
* Parses a QML Object Literal of the form:
* <QualifiedId> { (<QMLMember>)* }
* Parses a QML Object Definition of the form:
* <QMLQualifiedId> { (<QMLObjectMember>)* }
*
* 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();
node.id = this.qml_parseQualifiedId(false);
node.body = this.qml_parseMemberBlock();
return this.finishNode(node, "QMLObjectLiteral");
node.body = this.qml_parseObjectInitializer();
return this.finishNode(node, isBinding ? "QMLObjectBinding" : "QMLObjectDefinition");
};
/*
* Parses a QML Member Block of the form:
* { <QMLMember>* }
* Parses a QML Object Initializer of the form:
* '{' <QMLObjectMember>* '}'
*/
lp.qml_parseMemberBlock = function () {
lp.qml_parseObjectInitializer = function () {
var node = this.startNode();
this.pushCx();
this.expect(tt.braceL);
var blockIndent = this.curIndent, line = this.curLineStart;
var blockIndent = this.curIndent,
line = this.curLineStart;
node.members = [];
while (!this.closes(tt.braceR, blockIndent, line, true)) {
var member = this.qml_parseMember();
var member = this.qml_parseObjectMember();
if (member) {
node.members.push(member);
}
}
this.popCx();
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 Property Declaration (or Alias)
* - a QML Property Declaration
* - a QML Property Modifier
* - a QML Object Literal
* - 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)) {
return this.qml_parsePropertyDeclaration();
} else if (this.isContextual(qtt._signal)) {
@ -203,27 +194,57 @@ var injectQMLLoose;
return this.qml_parseFunctionMember();
} else if (this.qml_isIdent(this.tok.type, this.tok.value) || this.tok.type === tt.dot) {
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
// with the 'property' token missing
// with the 'property' token missing.
return this.qml_parsePropertyDeclaration();
} else {
var node = this.qml_parseObjectLiteralOrPropertyBinding();
if (node) {
return node;
} else {
return this.qml_parsePropertyBinding();
}
return this.qml_parseMemberStartsWithIdentifier() || this.qml_parsePropertyBinding();
}
} else if (this.tok.type === tt.colon) {
return this.qml_parsePropertyBinding();
} 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
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
*/
@ -234,14 +255,14 @@ var injectQMLLoose;
};
/*
* QML version of 'parseFunction' needed to have proper error tolerant parsing
* for QML member functions versus their JavaScript counterparts. The main
* difference between the two functions is that this implementation will not
* forcefully insert '(' and '{' tokens for the body and parameters. Instead,
* it will silently create an empty parameter list or body and let parsing
* continue normally.
*/
lp.qml_parseFunction = function(node, isStatement) {
* QML version of 'parseFunction' needed to have proper error tolerant parsing
* for QML member functions versus their JavaScript counterparts. The main
* difference between the two functions is that this implementation will not
* forcefully insert '(' and '{' tokens for the body and parameters. Instead,
* it will silently create an empty parameter list or body and let parsing
* continue normally.
*/
lp.qml_parseFunction = function (node, isStatement) {
this.initFunction(node);
if (this.tok.type === tt.name) node.id = this.parseIdent();
else if (isStatement) node.id = this.dummyIdent();
@ -250,7 +271,7 @@ var injectQMLLoose;
node.body = this.parseBlock();
} else {
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 {
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 () {
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++);
}
}
switch (la.type) {
case tt.braceL:
return this.qml_parseObjectLiteral();
case tt.colon:
return this.qml_parsePropertyBinding();
}
return null;
lp.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");
};
/*
@ -299,13 +309,13 @@ var injectQMLLoose;
/*
* Parses a QML Signal Definition of the form:
* 'signal' <Identifier> [(<Type> <Identifier> [',' <Type> <Identifier>]* )]?
* 'signal' <Identifier> [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
*/
lp.qml_parseSignalDefinition = function () {
var node = this.startNode();
// Check if this is an object literal or property binding first
var objOrBind = this.qml_parseObjectLiteralOrPropertyBinding();
var objOrBind = this.qml_parseMemberStartsWithIdentifier();
if (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) {
return node.name === "✖";
}
/*
* Parses QML Signal Parameters of the form:
* [(<Type> <Identifier> [',' <Type> <Identifier>]* )]?
* [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
*/
lp.qml_parseSignalParams = function (node) {
this.pushCx();
var indent = this.curIndent, line = this.curLineStart;
var indent = this.curIndent,
line = this.curLineStart;
node.params = [];
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();
param.kind = this.qml_parseIdent(true);
param.kind = this.qml_parsePropertyType();
// 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;
}
@ -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>]
*/
lp.qml_parsePropertyDeclaration = function () {
@ -376,7 +386,7 @@ var injectQMLLoose;
if (this.eat(tt._default)) {
node.default = true;
} else if (this.isContextual(qtt._readonly)) {
objOrBind = this.qml_parseObjectLiteralOrPropertyBinding();
objOrBind = this.qml_parseMemberStartsWithIdentifier();
if (objOrBind) {
objOrBind.default = undefined;
objOrBind.readonly = undefined;
@ -387,7 +397,7 @@ var injectQMLLoose;
}
if (!node.default && !node.readonly) {
objOrBind = this.qml_parseObjectLiteralOrPropertyBinding();
objOrBind = this.qml_parseMemberStartsWithIdentifier();
if (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);
var start = this.storeCurrentPos();
@ -411,22 +427,53 @@ var injectQMLLoose;
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:
* - QML Object Literal
* - QML Object Binding
* - QML Array Binding
* - QML Script Binding
*/
lp.qml_parseBinding = function (start) {
var i, la;
if (this.options.mode === "qmltypes") {
return this.qml_parseScriptBinding(start, false);
}
if (this.tok.type === tt.braceL) {
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
// a QML Object Literal
var i = 1, la = this.tok;
i = 1;
la = this.tok;
if (this.qml_isIdent(la.type, la.value)) {
la = this.lookAhead(i++);
}
@ -438,12 +485,44 @@ var injectQMLLoose;
}
if (la.type === tt.braceL) {
return this.qml_parseObjectLiteral();
return this.qml_parseObjectDefinition(true);
} else {
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:
* - Single JavaScript Expression
@ -479,7 +558,7 @@ var injectQMLLoose;
/*
* Parses a QML Statement Block of the form:
* { <JavaScript Statement>* }
* { <Statement>* }
*/
lp.qml_parseStatementBlock = function () {
var node = this.startNode();
@ -487,27 +566,15 @@ var injectQMLLoose;
this.expect(tt.braceL);
var blockIndent = this.curIndent,
line = this.curLineStart;
node.statements = [];
node.body = [];
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.eat(tt.braceR);
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:
* <Identifier> ('.' <Identifier>)*
@ -552,11 +619,11 @@ var injectQMLLoose;
};
/*
* 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
* and jumps ahead if it was found there. Returns whether or not the keyword was found.
*/
lp.expectContextual = function(name) {
* 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
* and jumps ahead if it was found there. Returns whether or not the keyword was found.
*/
lp.expectContextual = function (name) {
if (this.eatContextual(name)) return true;
for (var i = 1; i <= 2; i++) {
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,
// these rules will delegate down to JavaScript expressions.
var node = this.startNode();
node.headerStatements = this.qml_parseHeaderStatements();
node.headerItemList = this.qml_parseHeaderItemList();
node.rootObject = null;
if (this.tok.type !== tt.eof) {
node.rootObject = this.qml_parseObjectLiteral();
node.rootObject = this.qml_parseObjectDefinition();
}
return this.finishNode(node, "QMLProgram");
} else if (this.options.mode === "js") {
return nextMethod.call(this, node);
return nextMethod.call(this);
} else {
throw new Error("Unknown mode '" + this.options.mode + "'");
}

File diff suppressed because it is too large Load diff

View file

@ -31,45 +31,54 @@
extendWalk(walk.base, {
QMLProgram: function (node, st, c) {
c(node.headerStatements, st);
c(node.headerItemList, st);
if (node.rootObject) {
c(node.rootObject, st, "QMLRootObject");
}
},
QMLHeaderStatements: function (node, st, c) {
for (var i = 0; i < node.statements.length; i++) {
c(node.statements[i], st, "QMLHeaderStatement");
QMLHeaderItemList: function (node, st, c) {
for (var i = 0; i < node.items.length; i++) {
c(node.items[i], st, "QMLHeaderItem");
}
},
QMLHeaderStatement: skipThrough,
QMLImportStatement: ignore,
QMLPragmaStatement: ignore,
QMLHeaderItem: skipThrough,
QMLImport: ignore,
QMLPragma: ignore,
QMLRootObject: skipThrough,
QMLObjectLiteral: function (node, st, c) {
QMLObjectDefinition: function (node, st, c) {
c(node.body, st);
},
QMLMemberBlock: function (node, st, c) {
QMLObjectInitializer: function (node, st, c) {
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) {
if (node.binding) {
c(node.binding, st);
c(node.binding, st, "QMLBinding");
}
},
QMLSignalDefinition: ignore,
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) {
c(node.script, st);
},
QMLQualifiedID: ignore,
QMLStatementBlock: function (node, st, c) {
for (var i = 0; i < node.statements.length; i++) {
c(node.statements[i], st, "Statement");
for (var i = 0; i < node.body.length; i++) {
c(node.body[i], st, "Statement");
}
}
});

View file

@ -8,11 +8,14 @@
package org.eclipse.cdt.qt.core;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@ -25,12 +28,6 @@ import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
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")
public class QMLAnalyzer {
@ -74,28 +71,16 @@ public class QMLAnalyzer {
ResolveDirectory resolveDirectory = (file, pathString) -> {
String filename = (String) file.get("name");
int slash = filename.lastIndexOf('/');
String fileDirectory = slash >= 0 ? filename.substring(0, slash + 1) : filename;
String fileDirectory = new File(filename).getParent();
if (pathString == null) {
return fileDirectory;
return fixPathString(fileDirectory);
}
IPath path = Path.fromOSString(pathString);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
Path fileDirectoryPath = Paths.get(fileDirectory);
Path path = Paths.get(pathString);
if (!path.isAbsolute()) {
IResource res = root.findMember(fileDirectory);
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;
}
}
path = fileDirectoryPath.toAbsolutePath().resolve(path);
}
return pathString;
return fixPathString(path.normalize().toString());
};
options.put("resolveDirectory", invoke.invokeFunction("resolveDirectory", resolveDirectory));
@ -137,19 +122,28 @@ public class QMLAnalyzer {
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 {
waitUntilLoaded();
invoke.invokeMethod(tern, "addFile", fileName, code);
invoke.invokeMethod(tern, "addFile", fixPathString(fileName), code);
}
public void deleteFile(String fileName) throws NoSuchMethodException, ScriptException {
waitUntilLoaded();
invoke.invokeMethod(tern, "delFile", fileName);
invoke.invokeMethod(tern, "delFile", fixPathString(fileName));
}
public Collection<QMLTernCompletion> getCompletions(String fileName, String text, int pos)
throws NoSuchMethodException, ScriptException {
waitUntilLoaded();
fileName = fixPathString(fileName);
Bindings file = engine.createBindings();
file.put("type", "full");
file.put("name", fileName);
@ -201,6 +195,7 @@ public class QMLAnalyzer {
public List<Bindings> getDefinition(String identifier, String fileName, String text, int pos)
throws NoSuchMethodException, ScriptException {
waitUntilLoaded();
fileName = fixPathString(fileName);
Bindings file = engine.createBindings();
file.put("type", "full");
file.put("name", fileName);

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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$
}
}

View file

@ -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 {
}

View file

@ -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();
}

View file

@ -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$
}
}

View file

@ -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 {
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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$
}
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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$
}
}

View file

@ -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();
}

View file

@ -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 {
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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 {
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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$
}
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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$
}
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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 {
}

View file

@ -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 {
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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 {
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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 {
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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
}

View file

@ -141,7 +141,7 @@
// Walk the AST for any imports
var ih = this;
walk.simple(file.ast, {
QMLImportStatement: function (node) {
QMLImport: function (node) {
var prop = null;
var scope = file.scope;
if (node.qualifier) {
@ -551,19 +551,22 @@
// Infers the property's type from its given primitive value
function infKind(kind, out) {
switch (kind) {
case "int":
case "double":
case "real":
infer.cx().num.propagate(out);
break;
case "string":
case "color":
infer.cx().str.propagate(out);
break;
case "boolean":
infer.cx().bool.propagate(out);
break;
// TODO: infer list type
if (kind.primitive) {
switch (kind.id.name) {
case "int":
case "double":
case "real":
infer.cx().num.propagate(out);
break;
case "string":
case "color":
infer.cx().str.propagate(out);
break;
case "boolean":
infer.cx().bool.propagate(out);
break;
}
}
}
@ -612,11 +615,15 @@
function extendTernScopeGatherer(scopeGatherer) {
// Extend the Tern scopeGatherer to build up our custom QML scoping
extendWalk(scopeGatherer, {
QMLObjectLiteral: function (node, scope, c) {
QMLObjectDefinition: function (node, scope, c) {
var inner = node.scope = getScopeBuilder().newObjScope(node);
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);
for (var i = 0; i < node.members.length; i++) {
var member = node.members[i];
@ -667,8 +674,8 @@
QMLStatementBlock: function (node, scope, c) {
var inner = getScopeBuilder().newJSScope(scope, node);
node.scope = inner;
for (var i = 0; i < node.statements.length; i++) {
c(node.statements[i], inner, "Statement");
for (var i = 0; i < node.body.length; i++) {
c(node.body[i], inner, "Statement");
}
},
QMLSignalDefinition: function (node, scope, c) {
@ -707,8 +714,11 @@
QMLScriptBinding: fill(function (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;
}),
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) {
// Extend the inferWrapper methods
extendWalk(inferWrapper, {
QMLObjectLiteral: function (node, scope, c) {
QMLObjectDefinition: function (node, scope, c) {
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++) {
var member = node.members[i];
if (member.type === "QMLPropertyDeclaration" || member.type === "QMLPropertyBinding") {
@ -765,15 +778,15 @@
c(node.script, node.scope);
},
QMLStatementBlock: function (node, scope, c) {
for (var i = 0; i < node.statements.length; i++) {
c(node.statements[i], node.scope, "Statement");
for (var i = 0; i < node.body.length; i++) {
c(node.body[i], node.scope, "Statement");
}
},
QMLSignalDefinition: function (node, scope, c) {
var sig = scope.getProp(node.id.name);
for (var i = 0; i < node.params.length; 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.propagate(sig);
@ -788,10 +801,13 @@
function extendTernTypeFinder(typeFinder) {
// Extend the type finder to return valid types for QML AST elements
extendWalk(typeFinder, {
QMLObjectLiteral: function (node, scope) {
QMLObjectDefinition: function (node, scope) {
return node.scope.objType;
},
QMLMemberBlock: function (node, scope) {
QMLObjectBinding: function (node, scope) {
return node.scope.objType;
},
QMLObjectInitializer: function (node, scope) {
return infer.ANull;
},
FunctionDeclaration: function (node, scope) {
@ -819,10 +835,13 @@
function extendTernSearchVisitor(searchVisitor) {
// Extend the search visitor to traverse the scope properly
extendWalk(searchVisitor, {
QMLObjectLiteral: function (node, scope, c) {
QMLObjectDefinition: function (node, scope, c) {
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++) {
var member = node.members[i];
if (member.type === "QMLPropertyDeclaration" || member.type === "QMLPropertyBinding") {
@ -868,8 +887,8 @@
// Ignore
},
QMLStatementBlock: function (node, scope, c) {
for (var i = 0; i < node.statements.length; i++) {
c(node.statements[i], node.scope, "Statement");
for (var i = 0; i < node.body.length; i++) {
c(node.body[i], node.scope, "Statement");
}
}
});

View file

@ -42,7 +42,7 @@ public class QMLContentAssistProcessor implements IContentAssistProcessor {
String prefix = lastWord(document, offset);
// Save the file
IFileEditorInput fileInput = (IFileEditorInput) editor.getEditorInput();
String fileName = new File(fileInput.getFile().getLocationURI()).getAbsolutePath().substring(1);
String fileName = new File(fileInput.getFile().getLocationURI()).getAbsolutePath();
try {
String contents = document.get();

View file

@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.qt.ui.editor;
import java.io.File;
import javax.script.ScriptException;
import org.eclipse.cdt.internal.qt.ui.Activator;
@ -50,7 +52,7 @@ public class QMLEditor extends TextEditor {
@Override
public void doSave(IProgressMonitor progressMonitor) {
IFileEditorInput fileInput = (IFileEditorInput) getEditorInput();
String fileName = fileInput.getFile().getFullPath().toString().substring(1);
String fileName = new File(fileInput.getFile().getLocationURI()).getAbsolutePath();
IDocument document = getSourceViewer().getDocument();
try {