diff options
Diffstat (limited to 'qt/org.eclipse.cdt.qt.core')
145 files changed, 17081 insertions, 17081 deletions
diff --git a/qt/org.eclipse.cdt.qt.core/acorn-qml/index.js b/qt/org.eclipse.cdt.qt.core/acorn-qml/index.js index 7f4ad9d5586..6bc36dd58ed 100644 --- a/qt/org.eclipse.cdt.qt.core/acorn-qml/index.js +++ b/qt/org.eclipse.cdt.qt.core/acorn-qml/index.js @@ -1,21 +1,21 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-(function (mod) {
- if (typeof exports == "object" && typeof module == "object") // CommonJS
- return mod(require("./inject.js"), require("acorn"));
- if (typeof define == "function" && define.amd) // AMD
- return define(["./inject.js", "acorn/dist/acorn"], mod);
- mod(acornQMLInjector, acorn); // Plain browser env
-})(function (acornQMLInjector, acorn) {
- 'use strict';
-
- acornQMLInjector.inject(acorn);
+/******************************************************************************* + * 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 + *******************************************************************************/ +(function (mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + return mod(require("./inject.js"), require("acorn")); + if (typeof define == "function" && define.amd) // AMD + return define(["./inject.js", "acorn/dist/acorn"], mod); + mod(acornQMLInjector, acorn); // Plain browser env +})(function (acornQMLInjector, acorn) { + 'use strict'; + + acornQMLInjector.inject(acorn); });
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/acorn-qml/inject.js b/qt/org.eclipse.cdt.qt.core/acorn-qml/inject.js index 3dc09cb40e1..6e27ab94a83 100644 --- a/qt/org.eclipse.cdt.qt.core/acorn-qml/inject.js +++ b/qt/org.eclipse.cdt.qt.core/acorn-qml/inject.js @@ -1,650 +1,650 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-(function (root, mod) {
- if (typeof exports === "object" && typeof module === "object") // CommonJS
- return mod(exports);
- if (typeof define === "function" && define.amd) // AMD
- return define(["exports"], mod);
- mod(root.acornQMLInjector || (root.acornQMLInjector = {})); // Plain browser env
-})(this, function (exports) {
- 'use strict';
-
- exports.inject = function (acorn) {
- // Add the 'mode' option to acorn
- acorn.defaultOptions.mode = "qml";
-
- // Acorn token types
- var tt = acorn.tokTypes;
-
- // QML token types
- var qtt = acorn.qmlTokTypes = {};
- var keywords = acorn.qmlKeywords = {};
-
- /*
- * Shorthand for defining keywords in the 'keywords' variable with the following
- * format:
- * keywords[name].isPrimitive : if this is a primitive type
- * keywords[name].isQMLContextual : if this is a contextual keyword for QML
- *
- * Also stores the token's name in qtt._<keyword> for easy referencing later. None
- * of these keywords will be tokenized and, as such, are allowed to be used in
- * JavaScript expressions by acorn. The 'isQMLContextual' boolean in keywords refers
- * to those contextual keywords that are also contextual in QML's parser rules such
- * as 'color', 'list', 'alias', etc.
- */
- function kw(name, options) {
- if (options === undefined)
- options = {};
- qtt["_" + name] = name;
- keywords[name] = {};
- keywords[name].isPrimitive = options.isPrimitive ? true : false;
- keywords[name].isQMLContextual = options.isQMLContextual ? true : false;
- }
-
- // QML keywords
- kw("import");
- kw("pragma");
- kw("property", { isQMLContextual: true });
- 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 });
- kw("alias", { isPrimitive: true, isQMLContextual: true });
- kw("list", { isPrimitive: true, isQMLContextual: true });
- kw("color", { isPrimitive: true, isQMLContextual: true });
- kw("real", { isPrimitive: true, isQMLContextual: true });
- kw("string", { isPrimitive: true, isQMLContextual: true });
- kw("url", { isPrimitive: true, isQMLContextual: true });
-
- // Future reserved words
- kw("transient");
- kw("synchronized");
- kw("abstract");
- kw("volatile");
- kw("native");
- kw("goto");
- kw("byte");
- kw("long");
- kw("char");
- kw("short");
- kw("float");
-
- // QML parser methods
- var pp = acorn.Parser.prototype;
-
- /*
- * Parses a set of QML Header Items (QMLImport or QMLPragma)
- */
- pp.qml_parseHeaderItemList = function () {
- var node = this.startNode();
- node.items = [];
-
- var loop = true;
- while (loop) {
- if (this.isContextual(qtt._import)) {
- node.items.push(this.qml_parseImport());
- } else if (this.isContextual(qtt._pragma)) {
- node.items.push(this.qml_parsePragma());
- } else {
- loop = false;
- }
- }
-
- return this.finishNode(node, "QMLHeaderItemList");
- };
-
- /*
- * Parses a QML Pragma statement of the form:
- * 'pragma' <QMLQualifiedID>
- */
- pp.qml_parsePragma = function () {
- var node = this.startNode();
- this.expectContextual(qtt._pragma);
- node.id = this.qml_parseQualifiedId(true);
- this.semicolon();
- return this.finishNode(node, "QMLPragma");
- };
-
- /*
- * 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_parseImport = function () {
- var node = this.startNode();
-
- if (!this.eatContextual(qtt._import)) {
- this.unexpected();
- }
-
- switch (this.type) {
- case tt.name:
- node.module = this.qml_parseModule();
- node.directory = null;
- break;
- case tt.string:
- node.module = null;
- node.directory = this.parseLiteral(this.value);
- break;
- default:
- this.unexpected();
- }
-
- // Parse the qualifier, if any
- if (this.isContextual(qtt._as)) {
- node.qualifier = this.qml_parseQualifier();
- }
- this.semicolon();
-
- return this.finishNode(node, "QMLImport");
- };
-
- /*
- * Parses a QML Module of the form:
- * <QMLQualifiedId> <QMLVersionLiteral>
- */
- pp.qml_parseModule = function () {
- var node = this.startNode();
-
- node.id = this.qml_parseQualifiedId(false);
- if (this.type === tt.num) {
- node.version = this.qml_parseVersionLiteral();
- } else {
- this.unexpected();
- }
-
- return this.finishNode(node, "QMLModule");
- };
-
- /*
- * Parses a QML Version Literal which consists of a major and minor
- * version separated by a '.'
- */
- pp.qml_parseVersionLiteral = function () {
- var node = this.startNode();
-
- node.value = this.value;
- 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");
- };
-
- /*
- * Parses a QML Qualifier of the form:
- * 'as' <Identifier>
- */
- pp.qml_parseQualifier = function () {
- var node = this.startNode();
- this.expectContextual(qtt._as);
- node.id = this.qml_parseIdent(false);
- return this.finishNode(node, "QMLQualifier");
- };
-
- /*
- * Parses a QML Object Definition of the form:
- * <QMLQualifiedId> { (<QMLObjectMember>)* }
- *
- * http://doc.qt.io/qt-5/qtqml-syntax-basics.html#object-declarations
- */
- pp.qml_parseObjectDefinition = function (node, isBinding) {
- if (!node) {
- node = this.startNode();
- }
- if (!node.id) {
- node.id = this.qml_parseQualifiedId(false);
- }
- node.body = this.qml_parseObjectInitializer();
- return this.finishNode(node, isBinding ? "QMLObjectBinding" : "QMLObjectDefinition");
- };
-
- /*
- * Parses a QML Object Initializer of the form:
- * '{' <QMLObjectMember>* '}'
- */
- pp.qml_parseObjectInitializer = function () {
- var node = this.startNode();
- this.expect(tt.braceL);
- node.members = [];
- while (this.type !== tt.braceR) {
- node.members.push(this.qml_parseObjectMember());
- }
- this.expect(tt.braceR);
- return this.finishNode(node, "QMLObjectInitializer");
- };
-
- /*
- * Parses a QML Object Member which can be one of the following:
- * - a QML Property Binding
- * - a QML Property Declaration
- * - a QML Property Modifier
- * - a QML Object Literal
- * - a JavaScript Function Declaration
- * - a QML Signal Definition
- */
- 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)) {
- return this.qml_parseSignalDefinition();
- } else if (this.type === tt._function) {
- return this.qml_parseFunctionMember();
- }
- return this.qml_parseObjectDefinitionOrPropertyBinding();
- };
-
- /*
- * Parses a JavaScript function as a member of a QML Object Literal
- */
- pp.qml_parseFunctionMember = function () {
- var node = this.startNode();
- this.expect(tt._function);
- return this.parseFunction(node, true);
- };
-
- /*
- * Parses a QML Object Definition or Property Binding depending on the tokens found.
- */
- pp.qml_parseObjectDefinitionOrPropertyBinding = function (node) {
- if (!node) {
- node = this.startNode();
- }
- if (!node.id) {
- node.id = this.qml_parseQualifiedId(false);
- }
- switch (this.type) {
- case tt.braceL:
- return this.qml_parseObjectDefinition(node);
- case tt.colon:
- return this.qml_parsePropertyBinding(node);
- }
- this.unexpected();
- };
-
- /*
- * 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) {
- if (!node) {
- node = this.startNode();
- }
- if (!node.id) {
- node.id = this.qml_parseQualifiedId(false);
- }
- this.expect(tt.colon);
- node.binding = this.qml_parseBinding();
- return this.finishNode(node, "QMLPropertyBinding");
- };
-
- /*
- * Parses a QML Signal Definition of the form:
- * 'signal' <Identifier> [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
- */
- pp.qml_parseSignalDefinition = function () {
- var node = this.startNode();
-
- // Parse as a qualified id in case this is not a signal definition
- var signal = this.qml_parseQualifiedId(true);
- if (signal.parts.length === 1) {
- if (signal.name !== qtt._signal) {
- this.unexpected();
- }
-
- if (this.type === tt.colon || this.type === tt.braceL) {
- // This is a property binding or object literal
- node.id = signal;
- return this.qml_parseObjectDefinitionOrPropertyBinding(node);
- }
- } else {
- // Signal keyword is a qualified ID. This is not a signal definition
- node.id = signal;
- return this.qml_parseObjectDefinitionOrPropertyBinding(node);
- }
-
- node.id = this.qml_parseIdent(false);
- this.qml_parseSignalParams(node);
- this.semicolon();
- return this.finishNode(node, "QMLSignalDefinition");
- };
-
- /*
- * Parses QML Signal Parameters of the form:
- * [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
- */
- pp.qml_parseSignalParams = function (node) {
- node.params = [];
- if (this.eat(tt.parenL)) {
- if (!this.eat(tt.parenR)) {
- do {
- var param = this.startNode();
- param.kind = this.qml_parsePropertyType();
- param.id = this.qml_parseIdent(false);
- node.params.push(this.finishNode(param, "QMLParameter"));
- } while (this.eat(tt.comma));
- this.expect(tt.parenR);
- }
- }
- };
-
- /*
- * Parses a QML Property Declaration of the form:
- * ['default'|'readonly'] 'property' <QMLType> <Identifier> [<QMLBinding>]
- */
- pp.qml_parsePropertyDeclaration = function () {
- var node = this.startNode();
-
- // Parse 'default' or 'readonly'
- node.default = false;
- node.readonly = false;
- if (this.eat(tt._default)) {
- node.default = true;
- } else if (this.isContextual(qtt._readonly)) {
- // Parse as a qualified id in case this is not a property declaration
- var readonly = this.qml_parseQualifiedId(true);
- if (readonly.parts.length === 1) {
- if (this.type === tt.colon || this.type === tt.braceL) {
- // This is a property binding or object literal.
- node.id = readonly;
- 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_parseObjectDefinitionOrPropertyBinding(node);
- }
- }
-
- // Parse as a qualified id in case this is not a property declaration
- var property = this.qml_parseQualifiedId(true);
- if (property.parts.length === 1 || node.default || node.readonly) {
- if (property.name !== qtt._property) {
- this.unexpected();
- }
-
- if (this.type === tt.colon || this.type === tt.braceL) {
- // This is a property binding or object literal.
- node.default = undefined;
- node.readonly = undefined;
- node.id = property;
- 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_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.id = this.qml_parseIdent(false);
- if (!this.eat(tt.colon)) {
- node.binding = null;
- this.semicolon();
- } else {
- node.binding = this.qml_parseBinding();
- }
-
- 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 Binding
- * - QML Array Binding
- * - QML Script Binding
- */
- pp.qml_parseBinding = function () {
- if (this.options.mode === "qmltypes") {
- return this.qml_parseScriptBinding(false);
- }
-
- // TODO: solve ambiguity where a QML Object Literal starts with a
- // Qualified Id that looks very similar to a MemberExpression in
- // JavaScript. For now, we just won't parse statements like:
- // test: QMLObject { }
- // test: QMLObject.QualifiedId { }
- 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
- * - QML Statement Block (A block of JavaScript statements)
- */
- pp.qml_parseScriptBinding = function (allowStatementBlock) {
- var node = this.startNode();
- node.block = false;
- if (allowStatementBlock && this.type === tt.braceL) {
- node.block = true;
- node.script = this.qml_parseStatementBlock();
- } else {
- node.script = this.parseExpression(false);
- this.semicolon();
- }
- return this.finishNode(node, "QMLScriptBinding");
- };
-
- /*
- * Parses a QML Statement Block of the form:
- * { <Statement>* }
- */
- pp.qml_parseStatementBlock = function () {
- var node = this.startNode();
- this.expect(tt.braceL);
- node.body = [];
- while (!this.eat(tt.braceR)) {
- node.body.push(this.parseStatement(true, false));
- }
- return this.finishNode(node, "QMLStatementBlock");
- };
-
- /*
- * Parses a Qualified ID of the form:
- * <Identifier> ('.' <Identifier>)*
- *
- * If 'liberal' is true then this method will allow non-contextual QML keywords as
- * identifiers.
- */
- pp.qml_parseQualifiedId = function (liberal) {
- var node = this.startNode();
- node.parts = [];
- node.parts.push(this.qml_parseIdent(liberal));
- while (this.eat(tt.dot)) {
- node.parts.push(this.qml_parseIdent(liberal));
- }
-
- node.name = "";
- for (var i = 0; i < node.parts.length; i++) {
- node.name += node.parts[i].name;
- if (i < node.parts.length - 1) {
- node.name += ".";
- }
- }
-
- return this.finishNode(node, "QMLQualifiedID");
- };
-
- /*
- * Parses an Identifier in a QML Context. That is, this method uses 'isQMLContextual'
- * to throw an error if a non-contextual QML keyword is found.
- *
- * If 'liberal' is true then this method will allow non-contextual QML keywords as
- * identifiers.
- */
- pp.qml_parseIdent = function (liberal) {
- // Check for non-contextual QML keywords
- if (!liberal) {
- if (!this.qml_isIdent(this.type, this.value)) {
- this.unexpected();
- }
- }
- return this.parseIdent(liberal);
- };
-
- /*
- * Returns whether or not a given token type and name can be a QML Identifier.
- * Uses the 'isQMLContextual' boolean of 'keywords' to determine this.
- */
- pp.qml_isIdent = function (type, name) {
- if (type === tt.name) {
- var key;
- if ((key = keywords[name])) {
- return key.isQMLContextual;
- }
- return true;
- }
- return false;
- };
-
- /*
- * Returns whether or not the current token is a QML primitive type and consumes
- * it as a side effect if it is.
- */
- pp.qml_eatPrimitiveType = function (type, name) {
- if (this.qml_isPrimitiveType(type, name)) {
- this.next();
- return true;
- }
- return false;
- };
-
- /*
- * Returns whether or not the current token is a QML primitive type.
- */
- pp.qml_isPrimitiveType = function (type, name) {
- if (name === "var") {
- return true;
- }
-
- if (type === tt.name) {
- var key;
- if ((key = keywords[name])) {
- return key.isPrimitive;
- }
- }
- return false;
- };
-
- acorn.plugins.qml = function (instance) {
-
- // Extend acorn's 'parseTopLevel' method
- instance.extend("parseTopLevel", function (nextMethod) {
- return function (node) {
- // Make parsing simpler by only allowing ECMA Version 5 or older ('import' is
- // not a keyword in this version of ECMA Script). Qt 5.5 runs with ECMA Script
- // 5 anyway, so this makes sense.
- if (!this.options.ecmaVersion || this.options.ecmaVersion > 5) {
- throw new Error("QML only supports ECMA Script Language Specification 5 or older");
- }
-
- // Disabled 'qmltypes' mode for now since the normal parser can't parse it anyway
- if (this.options.mode === "qml") {
- // Force strict mode
- this.strict = true;
-
- // Most of QML's constructs sit at the top-level of the parse tree,
- // 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.mode = this.options.mode;
- node.headerItemList = this.qml_parseHeaderItemList();
- node.rootObject = null;
- if (this.type !== tt.eof) {
- node.rootObject = this.qml_parseObjectDefinition();
- }
-
- if (!this.eat(tt.eof)) {
- this.raise(this.pos, "Expected EOF after QML Root Object");
- }
-
- return this.finishNode(node, "QMLProgram");
- } else if (this.options.mode === "js") {
- return nextMethod.call(this, node);
- } else {
- throw new Error("Unknown mode '" + this.options.mode + "'");
- }
- };
- });
- };
-
- return acorn;
- };
+/******************************************************************************* + * 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 + *******************************************************************************/ +(function (root, mod) { + if (typeof exports === "object" && typeof module === "object") // CommonJS + return mod(exports); + if (typeof define === "function" && define.amd) // AMD + return define(["exports"], mod); + mod(root.acornQMLInjector || (root.acornQMLInjector = {})); // Plain browser env +})(this, function (exports) { + 'use strict'; + + exports.inject = function (acorn) { + // Add the 'mode' option to acorn + acorn.defaultOptions.mode = "qml"; + + // Acorn token types + var tt = acorn.tokTypes; + + // QML token types + var qtt = acorn.qmlTokTypes = {}; + var keywords = acorn.qmlKeywords = {}; + + /* + * Shorthand for defining keywords in the 'keywords' variable with the following + * format: + * keywords[name].isPrimitive : if this is a primitive type + * keywords[name].isQMLContextual : if this is a contextual keyword for QML + * + * Also stores the token's name in qtt._<keyword> for easy referencing later. None + * of these keywords will be tokenized and, as such, are allowed to be used in + * JavaScript expressions by acorn. The 'isQMLContextual' boolean in keywords refers + * to those contextual keywords that are also contextual in QML's parser rules such + * as 'color', 'list', 'alias', etc. + */ + function kw(name, options) { + if (options === undefined) + options = {}; + qtt["_" + name] = name; + keywords[name] = {}; + keywords[name].isPrimitive = options.isPrimitive ? true : false; + keywords[name].isQMLContextual = options.isQMLContextual ? true : false; + } + + // QML keywords + kw("import"); + kw("pragma"); + kw("property", { isQMLContextual: true }); + 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 }); + kw("alias", { isPrimitive: true, isQMLContextual: true }); + kw("list", { isPrimitive: true, isQMLContextual: true }); + kw("color", { isPrimitive: true, isQMLContextual: true }); + kw("real", { isPrimitive: true, isQMLContextual: true }); + kw("string", { isPrimitive: true, isQMLContextual: true }); + kw("url", { isPrimitive: true, isQMLContextual: true }); + + // Future reserved words + kw("transient"); + kw("synchronized"); + kw("abstract"); + kw("volatile"); + kw("native"); + kw("goto"); + kw("byte"); + kw("long"); + kw("char"); + kw("short"); + kw("float"); + + // QML parser methods + var pp = acorn.Parser.prototype; + + /* + * Parses a set of QML Header Items (QMLImport or QMLPragma) + */ + pp.qml_parseHeaderItemList = function () { + var node = this.startNode(); + node.items = []; + + var loop = true; + while (loop) { + if (this.isContextual(qtt._import)) { + node.items.push(this.qml_parseImport()); + } else if (this.isContextual(qtt._pragma)) { + node.items.push(this.qml_parsePragma()); + } else { + loop = false; + } + } + + return this.finishNode(node, "QMLHeaderItemList"); + }; + + /* + * Parses a QML Pragma statement of the form: + * 'pragma' <QMLQualifiedID> + */ + pp.qml_parsePragma = function () { + var node = this.startNode(); + this.expectContextual(qtt._pragma); + node.id = this.qml_parseQualifiedId(true); + this.semicolon(); + return this.finishNode(node, "QMLPragma"); + }; + + /* + * 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_parseImport = function () { + var node = this.startNode(); + + if (!this.eatContextual(qtt._import)) { + this.unexpected(); + } + + switch (this.type) { + case tt.name: + node.module = this.qml_parseModule(); + node.directory = null; + break; + case tt.string: + node.module = null; + node.directory = this.parseLiteral(this.value); + break; + default: + this.unexpected(); + } + + // Parse the qualifier, if any + if (this.isContextual(qtt._as)) { + node.qualifier = this.qml_parseQualifier(); + } + this.semicolon(); + + return this.finishNode(node, "QMLImport"); + }; + + /* + * Parses a QML Module of the form: + * <QMLQualifiedId> <QMLVersionLiteral> + */ + pp.qml_parseModule = function () { + var node = this.startNode(); + + node.id = this.qml_parseQualifiedId(false); + if (this.type === tt.num) { + node.version = this.qml_parseVersionLiteral(); + } else { + this.unexpected(); + } + + return this.finishNode(node, "QMLModule"); + }; + + /* + * Parses a QML Version Literal which consists of a major and minor + * version separated by a '.' + */ + pp.qml_parseVersionLiteral = function () { + var node = this.startNode(); + + node.value = this.value; + 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"); + }; + + /* + * Parses a QML Qualifier of the form: + * 'as' <Identifier> + */ + pp.qml_parseQualifier = function () { + var node = this.startNode(); + this.expectContextual(qtt._as); + node.id = this.qml_parseIdent(false); + return this.finishNode(node, "QMLQualifier"); + }; + + /* + * Parses a QML Object Definition of the form: + * <QMLQualifiedId> { (<QMLObjectMember>)* } + * + * http://doc.qt.io/qt-5/qtqml-syntax-basics.html#object-declarations + */ + pp.qml_parseObjectDefinition = function (node, isBinding) { + if (!node) { + node = this.startNode(); + } + if (!node.id) { + node.id = this.qml_parseQualifiedId(false); + } + node.body = this.qml_parseObjectInitializer(); + return this.finishNode(node, isBinding ? "QMLObjectBinding" : "QMLObjectDefinition"); + }; + + /* + * Parses a QML Object Initializer of the form: + * '{' <QMLObjectMember>* '}' + */ + pp.qml_parseObjectInitializer = function () { + var node = this.startNode(); + this.expect(tt.braceL); + node.members = []; + while (this.type !== tt.braceR) { + node.members.push(this.qml_parseObjectMember()); + } + this.expect(tt.braceR); + return this.finishNode(node, "QMLObjectInitializer"); + }; + + /* + * Parses a QML Object Member which can be one of the following: + * - a QML Property Binding + * - a QML Property Declaration + * - a QML Property Modifier + * - a QML Object Literal + * - a JavaScript Function Declaration + * - a QML Signal Definition + */ + 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)) { + return this.qml_parseSignalDefinition(); + } else if (this.type === tt._function) { + return this.qml_parseFunctionMember(); + } + return this.qml_parseObjectDefinitionOrPropertyBinding(); + }; + + /* + * Parses a JavaScript function as a member of a QML Object Literal + */ + pp.qml_parseFunctionMember = function () { + var node = this.startNode(); + this.expect(tt._function); + return this.parseFunction(node, true); + }; + + /* + * Parses a QML Object Definition or Property Binding depending on the tokens found. + */ + pp.qml_parseObjectDefinitionOrPropertyBinding = function (node) { + if (!node) { + node = this.startNode(); + } + if (!node.id) { + node.id = this.qml_parseQualifiedId(false); + } + switch (this.type) { + case tt.braceL: + return this.qml_parseObjectDefinition(node); + case tt.colon: + return this.qml_parsePropertyBinding(node); + } + this.unexpected(); + }; + + /* + * 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) { + if (!node) { + node = this.startNode(); + } + if (!node.id) { + node.id = this.qml_parseQualifiedId(false); + } + this.expect(tt.colon); + node.binding = this.qml_parseBinding(); + return this.finishNode(node, "QMLPropertyBinding"); + }; + + /* + * Parses a QML Signal Definition of the form: + * 'signal' <Identifier> [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]? + */ + pp.qml_parseSignalDefinition = function () { + var node = this.startNode(); + + // Parse as a qualified id in case this is not a signal definition + var signal = this.qml_parseQualifiedId(true); + if (signal.parts.length === 1) { + if (signal.name !== qtt._signal) { + this.unexpected(); + } + + if (this.type === tt.colon || this.type === tt.braceL) { + // This is a property binding or object literal + node.id = signal; + return this.qml_parseObjectDefinitionOrPropertyBinding(node); + } + } else { + // Signal keyword is a qualified ID. This is not a signal definition + node.id = signal; + return this.qml_parseObjectDefinitionOrPropertyBinding(node); + } + + node.id = this.qml_parseIdent(false); + this.qml_parseSignalParams(node); + this.semicolon(); + return this.finishNode(node, "QMLSignalDefinition"); + }; + + /* + * Parses QML Signal Parameters of the form: + * [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]? + */ + pp.qml_parseSignalParams = function (node) { + node.params = []; + if (this.eat(tt.parenL)) { + if (!this.eat(tt.parenR)) { + do { + var param = this.startNode(); + param.kind = this.qml_parsePropertyType(); + param.id = this.qml_parseIdent(false); + node.params.push(this.finishNode(param, "QMLParameter")); + } while (this.eat(tt.comma)); + this.expect(tt.parenR); + } + } + }; + + /* + * Parses a QML Property Declaration of the form: + * ['default'|'readonly'] 'property' <QMLType> <Identifier> [<QMLBinding>] + */ + pp.qml_parsePropertyDeclaration = function () { + var node = this.startNode(); + + // Parse 'default' or 'readonly' + node.default = false; + node.readonly = false; + if (this.eat(tt._default)) { + node.default = true; + } else if (this.isContextual(qtt._readonly)) { + // Parse as a qualified id in case this is not a property declaration + var readonly = this.qml_parseQualifiedId(true); + if (readonly.parts.length === 1) { + if (this.type === tt.colon || this.type === tt.braceL) { + // This is a property binding or object literal. + node.id = readonly; + 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_parseObjectDefinitionOrPropertyBinding(node); + } + } + + // Parse as a qualified id in case this is not a property declaration + var property = this.qml_parseQualifiedId(true); + if (property.parts.length === 1 || node.default || node.readonly) { + if (property.name !== qtt._property) { + this.unexpected(); + } + + if (this.type === tt.colon || this.type === tt.braceL) { + // This is a property binding or object literal. + node.default = undefined; + node.readonly = undefined; + node.id = property; + 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_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.id = this.qml_parseIdent(false); + if (!this.eat(tt.colon)) { + node.binding = null; + this.semicolon(); + } else { + node.binding = this.qml_parseBinding(); + } + + 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 Binding + * - QML Array Binding + * - QML Script Binding + */ + pp.qml_parseBinding = function () { + if (this.options.mode === "qmltypes") { + return this.qml_parseScriptBinding(false); + } + + // TODO: solve ambiguity where a QML Object Literal starts with a + // Qualified Id that looks very similar to a MemberExpression in + // JavaScript. For now, we just won't parse statements like: + // test: QMLObject { } + // test: QMLObject.QualifiedId { } + 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 + * - QML Statement Block (A block of JavaScript statements) + */ + pp.qml_parseScriptBinding = function (allowStatementBlock) { + var node = this.startNode(); + node.block = false; + if (allowStatementBlock && this.type === tt.braceL) { + node.block = true; + node.script = this.qml_parseStatementBlock(); + } else { + node.script = this.parseExpression(false); + this.semicolon(); + } + return this.finishNode(node, "QMLScriptBinding"); + }; + + /* + * Parses a QML Statement Block of the form: + * { <Statement>* } + */ + pp.qml_parseStatementBlock = function () { + var node = this.startNode(); + this.expect(tt.braceL); + node.body = []; + while (!this.eat(tt.braceR)) { + node.body.push(this.parseStatement(true, false)); + } + return this.finishNode(node, "QMLStatementBlock"); + }; + + /* + * Parses a Qualified ID of the form: + * <Identifier> ('.' <Identifier>)* + * + * If 'liberal' is true then this method will allow non-contextual QML keywords as + * identifiers. + */ + pp.qml_parseQualifiedId = function (liberal) { + var node = this.startNode(); + node.parts = []; + node.parts.push(this.qml_parseIdent(liberal)); + while (this.eat(tt.dot)) { + node.parts.push(this.qml_parseIdent(liberal)); + } + + node.name = ""; + for (var i = 0; i < node.parts.length; i++) { + node.name += node.parts[i].name; + if (i < node.parts.length - 1) { + node.name += "."; + } + } + + return this.finishNode(node, "QMLQualifiedID"); + }; + + /* + * Parses an Identifier in a QML Context. That is, this method uses 'isQMLContextual' + * to throw an error if a non-contextual QML keyword is found. + * + * If 'liberal' is true then this method will allow non-contextual QML keywords as + * identifiers. + */ + pp.qml_parseIdent = function (liberal) { + // Check for non-contextual QML keywords + if (!liberal) { + if (!this.qml_isIdent(this.type, this.value)) { + this.unexpected(); + } + } + return this.parseIdent(liberal); + }; + + /* + * Returns whether or not a given token type and name can be a QML Identifier. + * Uses the 'isQMLContextual' boolean of 'keywords' to determine this. + */ + pp.qml_isIdent = function (type, name) { + if (type === tt.name) { + var key; + if ((key = keywords[name])) { + return key.isQMLContextual; + } + return true; + } + return false; + }; + + /* + * Returns whether or not the current token is a QML primitive type and consumes + * it as a side effect if it is. + */ + pp.qml_eatPrimitiveType = function (type, name) { + if (this.qml_isPrimitiveType(type, name)) { + this.next(); + return true; + } + return false; + }; + + /* + * Returns whether or not the current token is a QML primitive type. + */ + pp.qml_isPrimitiveType = function (type, name) { + if (name === "var") { + return true; + } + + if (type === tt.name) { + var key; + if ((key = keywords[name])) { + return key.isPrimitive; + } + } + return false; + }; + + acorn.plugins.qml = function (instance) { + + // Extend acorn's 'parseTopLevel' method + instance.extend("parseTopLevel", function (nextMethod) { + return function (node) { + // Make parsing simpler by only allowing ECMA Version 5 or older ('import' is + // not a keyword in this version of ECMA Script). Qt 5.5 runs with ECMA Script + // 5 anyway, so this makes sense. + if (!this.options.ecmaVersion || this.options.ecmaVersion > 5) { + throw new Error("QML only supports ECMA Script Language Specification 5 or older"); + } + + // Disabled 'qmltypes' mode for now since the normal parser can't parse it anyway + if (this.options.mode === "qml") { + // Force strict mode + this.strict = true; + + // Most of QML's constructs sit at the top-level of the parse tree, + // 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.mode = this.options.mode; + node.headerItemList = this.qml_parseHeaderItemList(); + node.rootObject = null; + if (this.type !== tt.eof) { + node.rootObject = this.qml_parseObjectDefinition(); + } + + if (!this.eat(tt.eof)) { + this.raise(this.pos, "Expected EOF after QML Root Object"); + } + + return this.finishNode(node, "QMLProgram"); + } else if (this.options.mode === "js") { + return nextMethod.call(this, node); + } else { + throw new Error("Unknown mode '" + this.options.mode + "'"); + } + }; + }); + }; + + return acorn; + }; });
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/acorn-qml/loose/index.js b/qt/org.eclipse.cdt.qt.core/acorn-qml/loose/index.js index 524c15db178..7b0bdc97a36 100644 --- a/qt/org.eclipse.cdt.qt.core/acorn-qml/loose/index.js +++ b/qt/org.eclipse.cdt.qt.core/acorn-qml/loose/index.js @@ -1,21 +1,21 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-(function (mod) {
- if (typeof exports == "object" && typeof module == "object") // CommonJS
- return mod(require("./inject.js"), require("acorn"), require("acorn/dist/acorn_loose"));
- if (typeof define == "function" && define.amd) // AMD
- return define(["./inject.js", "acorn", "acorn/dist/acorn_loose"], mod);
- mod(acornQMLLooseInjector, acorn, acorn); // Plain browser env
-})(function (acornQMLLooseInjector, acorn, acorn_loose) {
- "use strict";
-
- acornQMLLooseInjector.inject(acorn);
+/******************************************************************************* + * 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 + *******************************************************************************/ +(function (mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + return mod(require("./inject.js"), require("acorn"), require("acorn/dist/acorn_loose")); + if (typeof define == "function" && define.amd) // AMD + return define(["./inject.js", "acorn", "acorn/dist/acorn_loose"], mod); + mod(acornQMLLooseInjector, acorn, acorn); // Plain browser env +})(function (acornQMLLooseInjector, acorn, acorn_loose) { + "use strict"; + + acornQMLLooseInjector.inject(acorn); });
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/acorn-qml/loose/inject.js b/qt/org.eclipse.cdt.qt.core/acorn-qml/loose/inject.js index 0c2e0425834..64959ecb5eb 100644 --- a/qt/org.eclipse.cdt.qt.core/acorn-qml/loose/inject.js +++ b/qt/org.eclipse.cdt.qt.core/acorn-qml/loose/inject.js @@ -1,678 +1,678 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-
-// This will only be visible globally if we are in a browser environment
-var injectQMLLoose;
-
-(function (root, mod) {
- if (typeof exports === "object" && typeof module === "object") // CommonJS
- return mod(module.exports);
- if (typeof define === "function" && define.amd) // AMD
- return define(["exports"], mod);
- mod(root.acornQMLLooseInjector || (root.acornQMLLooseInjector = {})); // Plain browser env
-})(this, function (exports) {
- "use strict";
-
- exports.inject = function (acorn) {
- // Acorn token types
- var tt = acorn.tokTypes;
-
- // QML token types
- var qtt = acorn.qmlTokTypes;
- var keywords = acorn.qmlKeywords;
-
- // QML parser methods
- var lp = acorn.LooseParser.prototype;
- var pp = acorn.Parser.prototype;
-
- /*
- * Parses a set of QML Header Items (QMLImport or QMLPragma)
- */
- lp.qml_parseHeaderItemList = function () {
- var node = this.startNode();
- node.items = [];
-
- var loop = true;
- while (loop) {
- if (this.isContextual(qtt._import)) {
- node.items.push(this.qml_parseImport());
- } else if (this.isContextual(qtt._pragma)) {
- node.items.push(this.qml_parsePragma());
- } else {
- loop = false;
- }
- }
-
- return this.finishNode(node, "QMLHeaderItemList");
- };
-
- /*
- * Parses a QML Pragma statement of the form:
- * 'pragma' <QMLQualifiedID>
- */
- lp.qml_parsePragma = function () {
- var node = this.startNode();
- this.expectContextual(qtt._pragma);
- node.id = this.qml_parseQualifiedId(true);
- this.semicolon();
- return this.finishNode(node, "QMLPragma");
- };
-
- /*
- * 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_parseImport = function () {
- var node = this.startNode();
- this.expectContextual(qtt._import);
-
- switch (this.tok.type) {
- case tt.string:
- node.module = null;
- node.directory = this.parseExprAtom();
- break;
- default:
- node.module = this.qml_parseModule();
- node.directory = null;
- break;
- }
-
- // Parse the qualifier, if any
- if (this.isContextual(qtt._as)) {
- node.qualifier = this.qml_parseQualifier();
- }
- this.semicolon();
-
- return this.finishNode(node, "QMLImport");
- };
-
- /*
- * Parses a QML Module of the form:
- * <QMLQualifiedId> <QMLVersionLiteral>
- */
- lp.qml_parseModule = function () {
- var node = this.startNode();
-
- node.id = this.qml_parseQualifiedId(false);
- node.version = this.qml_parseVersionLiteral();
-
- return this.finishNode(node, "QMLModule");
- };
-
- /*
- * Parses a QML Version Literal which consists of a major and minor
- * version separated by a '.'
- */
- lp.qml_parseVersionLiteral = function () {
- var node = this.startNode();
-
- var matches;
- if (this.tok.type === tt.num) {
- node.raw = this.input.slice(this.tok.start, this.tok.end);
- node.value = this.tok.value;
- this.next();
- } else {
- node.value = 0;
- node.raw = "0.0";
- }
-
- return this.finishNode(node, "QMLVersionLiteral");
- };
-
- /*
- * Parses a QML Qualifier of the form:
- * 'as' <Identifier>
- */
- lp.qml_parseQualifier = function () {
- var node = this.startNode();
- this.expectContextual(qtt._as);
- node.id = this.qml_parseIdent(false);
- return this.finishNode(node, "QMLQualifier");
- };
-
- /*
- * Parses a QML Object Definition of the form:
- * <QMLQualifiedId> { (<QMLObjectMember>)* }
- *
- * http://doc.qt.io/qt-5/qtqml-syntax-basics.html#object-declarations
- */
- lp.qml_parseObjectDefinition = function (isBinding) {
- var node = this.startNode();
- node.id = this.qml_parseQualifiedId(false);
- node.body = this.qml_parseObjectInitializer();
- return this.finishNode(node, isBinding ? "QMLObjectBinding" : "QMLObjectDefinition");
- };
-
- /*
- * Parses a QML Object Initializer of the form:
- * '{' <QMLObjectMember>* '}'
- */
- lp.qml_parseObjectInitializer = function () {
- var node = this.startNode();
- this.pushCx();
- this.expect(tt.braceL);
- var blockIndent = this.curIndent,
- line = this.curLineStart;
- node.members = [];
- while (!this.closes(tt.braceR, blockIndent, line, true)) {
- var member = this.qml_parseObjectMember();
- if (member) {
- node.members.push(member);
- }
- }
- this.popCx();
- this.eat(tt.braceR);
- return this.finishNode(node, "QMLObjectInitializer");
- };
-
- /*
- * Parses a QML Object Member which can be one of the following:
- * - a QML Property Binding
- * - a QML Property Declaration
- * - a QML Property Modifier
- * - a QML Object Literal
- * - a JavaScript Function Declaration
- * - a QML Signal Definition
- */
- 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)) {
- return this.qml_parseSignalDefinition();
- } else if (this.tok.type === tt._function) {
- 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) && la.value !== qtt._on) {
- // Two identifiers in a row means this is most likely a property declaration
- // with the 'property' token missing.
- return this.qml_parsePropertyDeclaration();
- } else {
- 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_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
- */
- lp.qml_parseFunctionMember = function () {
- var node = this.startNode();
- this.expect(tt._function);
- return this.qml_parseFunction(node, true);
- };
-
- /*
- * 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();
- node.params = this.tok.type === tt.parenL ? this.parseFunctionParams() : [];
- if (this.tok.type === tt.braceL) {
- node.body = this.parseBlock();
- } else {
- if (this.options.locations) {
- node.body = this.startNodeAt([this.last.end, this.last.loc.end]);
- } else {
- node.body = this.startNodeAt(this.last.end);
- }
- node.body.body = [];
- this.finishNode(node.body, "BlockStatement");
- }
- return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
- };
-
- /*
- * Parses a QML Property Modifier of the form:
- * <QMLQualifiedID> 'on' <QMLQualifiedID> <QMLInitializer>
- */
- 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");
- };
-
- /*
- * Parses a QML Property of the form:
- * <QMLQualifiedID> <QMLBinding>
- */
- lp.qml_parsePropertyBinding = function () {
- var node = this.startNode();
- node.id = this.qml_parseQualifiedId(false);
- var start = this.storeCurrentPos();
- this.expect(tt.colon);
- node.binding = this.qml_parseBinding(start);
- return this.finishNode(node, "QMLPropertyBinding");
- };
-
- /*
- * Parses a QML Signal Definition of the form:
- * '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_parseMemberStartsWithIdentifier();
- if (objOrBind) {
- return objOrBind;
- }
- this.expectContextual(qtt._signal);
-
- node.id = this.qml_parseIdent(false);
- this.qml_parseSignalParams(node);
- this.semicolon();
- return this.finishNode(node, "QMLSignalDefinition");
- };
-
- /*
- * Checks if the given node is a dummy identifier
- */
- function isDummy(node) {
- return node.name === "✖";
- }
-
- /*
- * Parses QML Signal Parameters of the form:
- * [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]?
- */
- lp.qml_parseSignalParams = function (node) {
- this.pushCx();
- var indent = this.curIndent,
- line = this.curLineStart;
- node.params = [];
- if (this.eat(tt.parenL)) {
- while (!this.closes(tt.parenR, indent + 1, line) && this.tok.type !== tt.braceR) {
- var param = this.startNode();
- param.kind = this.qml_parsePropertyType();
-
- // Break out of an infinite loop where we continously consume dummy ids
- if (isDummy(param.kind.id) && this.tok.type !== tt.comma) {
- break;
- }
-
- param.id = this.qml_parseIdent(false);
- node.params.push(this.finishNode(param, "QMLParameter"));
-
- // Break out of an infinite loop where we continously consume dummy ids
- if (isDummy(param.id) && this.tok.type !== tt.comma) {
- break;
- }
- this.eat(tt.comma);
- }
- this.popCx();
- if (!this.eat(tt.parenR)) {
- // 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;
- }
- }
- };
-
- /*
- * Parses a QML Property Declaration of the form:
- * ['default'|'readonly'] 'property' <QMLType> <Identifier> [<QMLBinding>]
- */
- lp.qml_parsePropertyDeclaration = function () {
- var node = this.startNode();
- var objOrBind = null;
-
- // Parse 'default' or 'readonly'
- node.default = false;
- node.readonly = false;
- if (this.eat(tt._default)) {
- node.default = true;
- } else if (this.isContextual(qtt._readonly)) {
- objOrBind = this.qml_parseMemberStartsWithIdentifier();
- if (objOrBind) {
- objOrBind.default = undefined;
- objOrBind.readonly = undefined;
- return objOrBind;
- }
- this.expectContextual(qtt._readonly);
- node.readonly = true;
- }
-
- if (!node.default && !node.readonly) {
- objOrBind = this.qml_parseMemberStartsWithIdentifier();
- if (objOrBind) {
- return objOrBind;
- }
- this.expectContextual(qtt._property);
- } else {
- this.expectContextual(qtt._property);
- }
-
-
- 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();
- if (this.eat(tt.colon)) {
- node.binding = this.qml_parseBinding(start);
- } else {
- node.binding = null;
- this.semicolon();
- }
-
- 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 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
- 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++);
- }
- }
-
- if (la.type === tt.braceL) {
- 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
- * - QML Statement Block (A block of JavaScript statements)
- */
- lp.qml_parseScriptBinding = function (start, allowStatementBlock) {
- // Help out Tern a little by starting the Script Binding at the end of
- // the colon token (only if we consume invalid syntax).
- var node = this.startNodeAt(start);
- node.block = false;
- if (allowStatementBlock && this.tok.type === tt.braceL) {
- node.block = true;
- node.script = this.qml_parseStatementBlock();
- } else {
- node.script = this.parseExpression(false);
- this.semicolon();
- }
-
- // If this node consumed valid syntax, reset its start position
- if (node.script.type !== "Identifier" || node.script.name !== "✖") {
- if (node.loc) {
- node.loc.start = node.script.loc.start;
- }
- if (node.range) {
- node.range = node.script.range;
- }
- node.start = node.script.start;
- node.end = node.script.end;
- }
-
- return this.finishNode(node, "QMLScriptBinding");
- };
-
- /*
- * Parses a QML Statement Block of the form:
- * { <Statement>* }
- */
- lp.qml_parseStatementBlock = function () {
- var node = this.startNode();
- this.pushCx();
- this.expect(tt.braceL);
- var blockIndent = this.curIndent,
- line = this.curLineStart;
- node.body = [];
- while (!this.closes(tt.braceR, blockIndent, line, true)) {
- node.body.push(this.parseStatement(true, false));
- }
- this.popCx();
- this.eat(tt.braceR);
- return this.finishNode(node, "QMLStatementBlock");
- };
-
- /*
- * Parses a Qualified ID of the form:
- * <Identifier> ('.' <Identifier>)*
- *
- * If 'liberal' is true then this method will allow non-contextual QML keywords as
- * identifiers.
- */
- lp.qml_parseQualifiedId = function (liberal) {
- var node = this.startNode();
- node.parts = [];
- node.parts.push(this.qml_parseIdent(liberal));
- while (this.eat(tt.dot)) {
- node.parts.push(this.qml_parseIdent(liberal));
- }
-
- node.name = "";
- for (var i = 0; i < node.parts.length; i++) {
- node.name += node.parts[i].name;
- if (i < node.parts.length - 1) {
- node.name += ".";
- }
- }
-
- return this.finishNode(node, "QMLQualifiedID");
- };
-
- /*
- * Parses an Identifier in a QML Context. That is, this method uses 'isQMLContextual'
- * to throw an error if a non-contextual QML keyword is found.
- *
- * If 'liberal' is true then this method will allow non-contextual QML keywords as
- * identifiers.
- */
- lp.qml_parseIdent = function (liberal) {
- // Check for non-contextual QML keywords
- if (!liberal) {
- if (!this.qml_isIdent(this.tok.type, this.tok.value)) {
- return this.dummyIdent();
- }
- }
- return this.parseIdent();
- };
-
- /*
- * 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) {
- for (var j = 0; j < i; j++) this.next();
- return true;
- }
- }
- };
-
- // Functions left un-changed from the main parser
- lp.qml_isIdent = pp.qml_isIdent;
- lp.qml_eatPrimitiveType = pp.qml_eatPrimitiveType;
- lp.qml_isPrimitiveType = pp.qml_isPrimitiveType;
-
- acorn.pluginsLoose.qml = function (instance) {
-
- // Extend acorn's 'parseTopLevel' method
- instance.extend("parseTopLevel", function (nextMethod) {
- return function () {
- // Make parsing simpler by only allowing ECMA Version 5 or older ('import' is
- // not a keyword in this version of ECMA Script). Qt 5.5 runs with ECMA Script
- // 5 anyway, so this makes sense.
- if (!this.options.ecmaVersion || this.options.ecmaVersion > 5) {
- throw new Error("QML only supports ECMA Script Language Specification 5 or older");
- }
-
- if (this.options.mode === "qml" || this.options.mode === "qmltypes") {
- // Most of QML's constructs sit at the top-level of the parse tree,
- // 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.
- var node = this.startNode();
- node.mode = this.options.mode;
- node.headerItemList = this.qml_parseHeaderItemList();
- node.rootObject = null;
- if (this.tok.type !== tt.eof) {
- node.rootObject = this.qml_parseObjectDefinition();
- }
-
- return this.finishNode(node, "QMLProgram");
- } else if (this.options.mode === "js") {
- return nextMethod.call(this);
- } else {
- throw new Error("Unknown mode '" + this.options.mode + "'");
- }
- };
- });
- };
-
- return acorn;
- };
+/******************************************************************************* + * 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 + *******************************************************************************/ + +// This will only be visible globally if we are in a browser environment +var injectQMLLoose; + +(function (root, mod) { + if (typeof exports === "object" && typeof module === "object") // CommonJS + return mod(module.exports); + if (typeof define === "function" && define.amd) // AMD + return define(["exports"], mod); + mod(root.acornQMLLooseInjector || (root.acornQMLLooseInjector = {})); // Plain browser env +})(this, function (exports) { + "use strict"; + + exports.inject = function (acorn) { + // Acorn token types + var tt = acorn.tokTypes; + + // QML token types + var qtt = acorn.qmlTokTypes; + var keywords = acorn.qmlKeywords; + + // QML parser methods + var lp = acorn.LooseParser.prototype; + var pp = acorn.Parser.prototype; + + /* + * Parses a set of QML Header Items (QMLImport or QMLPragma) + */ + lp.qml_parseHeaderItemList = function () { + var node = this.startNode(); + node.items = []; + + var loop = true; + while (loop) { + if (this.isContextual(qtt._import)) { + node.items.push(this.qml_parseImport()); + } else if (this.isContextual(qtt._pragma)) { + node.items.push(this.qml_parsePragma()); + } else { + loop = false; + } + } + + return this.finishNode(node, "QMLHeaderItemList"); + }; + + /* + * Parses a QML Pragma statement of the form: + * 'pragma' <QMLQualifiedID> + */ + lp.qml_parsePragma = function () { + var node = this.startNode(); + this.expectContextual(qtt._pragma); + node.id = this.qml_parseQualifiedId(true); + this.semicolon(); + return this.finishNode(node, "QMLPragma"); + }; + + /* + * 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_parseImport = function () { + var node = this.startNode(); + this.expectContextual(qtt._import); + + switch (this.tok.type) { + case tt.string: + node.module = null; + node.directory = this.parseExprAtom(); + break; + default: + node.module = this.qml_parseModule(); + node.directory = null; + break; + } + + // Parse the qualifier, if any + if (this.isContextual(qtt._as)) { + node.qualifier = this.qml_parseQualifier(); + } + this.semicolon(); + + return this.finishNode(node, "QMLImport"); + }; + + /* + * Parses a QML Module of the form: + * <QMLQualifiedId> <QMLVersionLiteral> + */ + lp.qml_parseModule = function () { + var node = this.startNode(); + + node.id = this.qml_parseQualifiedId(false); + node.version = this.qml_parseVersionLiteral(); + + return this.finishNode(node, "QMLModule"); + }; + + /* + * Parses a QML Version Literal which consists of a major and minor + * version separated by a '.' + */ + lp.qml_parseVersionLiteral = function () { + var node = this.startNode(); + + var matches; + if (this.tok.type === tt.num) { + node.raw = this.input.slice(this.tok.start, this.tok.end); + node.value = this.tok.value; + this.next(); + } else { + node.value = 0; + node.raw = "0.0"; + } + + return this.finishNode(node, "QMLVersionLiteral"); + }; + + /* + * Parses a QML Qualifier of the form: + * 'as' <Identifier> + */ + lp.qml_parseQualifier = function () { + var node = this.startNode(); + this.expectContextual(qtt._as); + node.id = this.qml_parseIdent(false); + return this.finishNode(node, "QMLQualifier"); + }; + + /* + * Parses a QML Object Definition of the form: + * <QMLQualifiedId> { (<QMLObjectMember>)* } + * + * http://doc.qt.io/qt-5/qtqml-syntax-basics.html#object-declarations + */ + lp.qml_parseObjectDefinition = function (isBinding) { + var node = this.startNode(); + node.id = this.qml_parseQualifiedId(false); + node.body = this.qml_parseObjectInitializer(); + return this.finishNode(node, isBinding ? "QMLObjectBinding" : "QMLObjectDefinition"); + }; + + /* + * Parses a QML Object Initializer of the form: + * '{' <QMLObjectMember>* '}' + */ + lp.qml_parseObjectInitializer = function () { + var node = this.startNode(); + this.pushCx(); + this.expect(tt.braceL); + var blockIndent = this.curIndent, + line = this.curLineStart; + node.members = []; + while (!this.closes(tt.braceR, blockIndent, line, true)) { + var member = this.qml_parseObjectMember(); + if (member) { + node.members.push(member); + } + } + this.popCx(); + this.eat(tt.braceR); + return this.finishNode(node, "QMLObjectInitializer"); + }; + + /* + * Parses a QML Object Member which can be one of the following: + * - a QML Property Binding + * - a QML Property Declaration + * - a QML Property Modifier + * - a QML Object Literal + * - a JavaScript Function Declaration + * - a QML Signal Definition + */ + 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)) { + return this.qml_parseSignalDefinition(); + } else if (this.tok.type === tt._function) { + 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) && la.value !== qtt._on) { + // Two identifiers in a row means this is most likely a property declaration + // with the 'property' token missing. + return this.qml_parsePropertyDeclaration(); + } else { + 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_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 + */ + lp.qml_parseFunctionMember = function () { + var node = this.startNode(); + this.expect(tt._function); + return this.qml_parseFunction(node, true); + }; + + /* + * 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(); + node.params = this.tok.type === tt.parenL ? this.parseFunctionParams() : []; + if (this.tok.type === tt.braceL) { + node.body = this.parseBlock(); + } else { + if (this.options.locations) { + node.body = this.startNodeAt([this.last.end, this.last.loc.end]); + } else { + node.body = this.startNodeAt(this.last.end); + } + node.body.body = []; + this.finishNode(node.body, "BlockStatement"); + } + return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression"); + }; + + /* + * Parses a QML Property Modifier of the form: + * <QMLQualifiedID> 'on' <QMLQualifiedID> <QMLInitializer> + */ + 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"); + }; + + /* + * Parses a QML Property of the form: + * <QMLQualifiedID> <QMLBinding> + */ + lp.qml_parsePropertyBinding = function () { + var node = this.startNode(); + node.id = this.qml_parseQualifiedId(false); + var start = this.storeCurrentPos(); + this.expect(tt.colon); + node.binding = this.qml_parseBinding(start); + return this.finishNode(node, "QMLPropertyBinding"); + }; + + /* + * Parses a QML Signal Definition of the form: + * '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_parseMemberStartsWithIdentifier(); + if (objOrBind) { + return objOrBind; + } + this.expectContextual(qtt._signal); + + node.id = this.qml_parseIdent(false); + this.qml_parseSignalParams(node); + this.semicolon(); + return this.finishNode(node, "QMLSignalDefinition"); + }; + + /* + * Checks if the given node is a dummy identifier + */ + function isDummy(node) { + return node.name === "✖"; + } + + /* + * Parses QML Signal Parameters of the form: + * [(<QMLPropertyType> <Identifier> [',' <QMLPropertyType> <Identifier>]* )]? + */ + lp.qml_parseSignalParams = function (node) { + this.pushCx(); + var indent = this.curIndent, + line = this.curLineStart; + node.params = []; + if (this.eat(tt.parenL)) { + while (!this.closes(tt.parenR, indent + 1, line) && this.tok.type !== tt.braceR) { + var param = this.startNode(); + param.kind = this.qml_parsePropertyType(); + + // Break out of an infinite loop where we continously consume dummy ids + if (isDummy(param.kind.id) && this.tok.type !== tt.comma) { + break; + } + + param.id = this.qml_parseIdent(false); + node.params.push(this.finishNode(param, "QMLParameter")); + + // Break out of an infinite loop where we continously consume dummy ids + if (isDummy(param.id) && this.tok.type !== tt.comma) { + break; + } + this.eat(tt.comma); + } + this.popCx(); + if (!this.eat(tt.parenR)) { + // 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; + } + } + }; + + /* + * Parses a QML Property Declaration of the form: + * ['default'|'readonly'] 'property' <QMLType> <Identifier> [<QMLBinding>] + */ + lp.qml_parsePropertyDeclaration = function () { + var node = this.startNode(); + var objOrBind = null; + + // Parse 'default' or 'readonly' + node.default = false; + node.readonly = false; + if (this.eat(tt._default)) { + node.default = true; + } else if (this.isContextual(qtt._readonly)) { + objOrBind = this.qml_parseMemberStartsWithIdentifier(); + if (objOrBind) { + objOrBind.default = undefined; + objOrBind.readonly = undefined; + return objOrBind; + } + this.expectContextual(qtt._readonly); + node.readonly = true; + } + + if (!node.default && !node.readonly) { + objOrBind = this.qml_parseMemberStartsWithIdentifier(); + if (objOrBind) { + return objOrBind; + } + this.expectContextual(qtt._property); + } else { + this.expectContextual(qtt._property); + } + + + 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(); + if (this.eat(tt.colon)) { + node.binding = this.qml_parseBinding(start); + } else { + node.binding = null; + this.semicolon(); + } + + 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 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 + 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++); + } + } + + if (la.type === tt.braceL) { + 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 + * - QML Statement Block (A block of JavaScript statements) + */ + lp.qml_parseScriptBinding = function (start, allowStatementBlock) { + // Help out Tern a little by starting the Script Binding at the end of + // the colon token (only if we consume invalid syntax). + var node = this.startNodeAt(start); + node.block = false; + if (allowStatementBlock && this.tok.type === tt.braceL) { + node.block = true; + node.script = this.qml_parseStatementBlock(); + } else { + node.script = this.parseExpression(false); + this.semicolon(); + } + + // If this node consumed valid syntax, reset its start position + if (node.script.type !== "Identifier" || node.script.name !== "✖") { + if (node.loc) { + node.loc.start = node.script.loc.start; + } + if (node.range) { + node.range = node.script.range; + } + node.start = node.script.start; + node.end = node.script.end; + } + + return this.finishNode(node, "QMLScriptBinding"); + }; + + /* + * Parses a QML Statement Block of the form: + * { <Statement>* } + */ + lp.qml_parseStatementBlock = function () { + var node = this.startNode(); + this.pushCx(); + this.expect(tt.braceL); + var blockIndent = this.curIndent, + line = this.curLineStart; + node.body = []; + while (!this.closes(tt.braceR, blockIndent, line, true)) { + node.body.push(this.parseStatement(true, false)); + } + this.popCx(); + this.eat(tt.braceR); + return this.finishNode(node, "QMLStatementBlock"); + }; + + /* + * Parses a Qualified ID of the form: + * <Identifier> ('.' <Identifier>)* + * + * If 'liberal' is true then this method will allow non-contextual QML keywords as + * identifiers. + */ + lp.qml_parseQualifiedId = function (liberal) { + var node = this.startNode(); + node.parts = []; + node.parts.push(this.qml_parseIdent(liberal)); + while (this.eat(tt.dot)) { + node.parts.push(this.qml_parseIdent(liberal)); + } + + node.name = ""; + for (var i = 0; i < node.parts.length; i++) { + node.name += node.parts[i].name; + if (i < node.parts.length - 1) { + node.name += "."; + } + } + + return this.finishNode(node, "QMLQualifiedID"); + }; + + /* + * Parses an Identifier in a QML Context. That is, this method uses 'isQMLContextual' + * to throw an error if a non-contextual QML keyword is found. + * + * If 'liberal' is true then this method will allow non-contextual QML keywords as + * identifiers. + */ + lp.qml_parseIdent = function (liberal) { + // Check for non-contextual QML keywords + if (!liberal) { + if (!this.qml_isIdent(this.tok.type, this.tok.value)) { + return this.dummyIdent(); + } + } + return this.parseIdent(); + }; + + /* + * 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) { + for (var j = 0; j < i; j++) this.next(); + return true; + } + } + }; + + // Functions left un-changed from the main parser + lp.qml_isIdent = pp.qml_isIdent; + lp.qml_eatPrimitiveType = pp.qml_eatPrimitiveType; + lp.qml_isPrimitiveType = pp.qml_isPrimitiveType; + + acorn.pluginsLoose.qml = function (instance) { + + // Extend acorn's 'parseTopLevel' method + instance.extend("parseTopLevel", function (nextMethod) { + return function () { + // Make parsing simpler by only allowing ECMA Version 5 or older ('import' is + // not a keyword in this version of ECMA Script). Qt 5.5 runs with ECMA Script + // 5 anyway, so this makes sense. + if (!this.options.ecmaVersion || this.options.ecmaVersion > 5) { + throw new Error("QML only supports ECMA Script Language Specification 5 or older"); + } + + if (this.options.mode === "qml" || this.options.mode === "qmltypes") { + // Most of QML's constructs sit at the top-level of the parse tree, + // 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. + var node = this.startNode(); + node.mode = this.options.mode; + node.headerItemList = this.qml_parseHeaderItemList(); + node.rootObject = null; + if (this.tok.type !== tt.eof) { + node.rootObject = this.qml_parseObjectDefinition(); + } + + return this.finishNode(node, "QMLProgram"); + } else if (this.options.mode === "js") { + return nextMethod.call(this); + } else { + throw new Error("Unknown mode '" + this.options.mode + "'"); + } + }; + }); + }; + + return acorn; + }; });
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/acorn-qml/package.json b/qt/org.eclipse.cdt.qt.core/acorn-qml/package.json index 1a452cba41a..12ed66314d6 100644 --- a/qt/org.eclipse.cdt.qt.core/acorn-qml/package.json +++ b/qt/org.eclipse.cdt.qt.core/acorn-qml/package.json @@ -1,12 +1,12 @@ -{
- "name": "acorn-qml",
- "description": "QML Parser",
- "license": "EPL-1.0",
- "version": "0.0.0",
- "scripts": {
- "test": "node test/run.js"
- },
- "dependencies": {
- "acorn": "^2.6.4"
- }
+{ + "name": "acorn-qml", + "description": "QML Parser", + "license": "EPL-1.0", + "version": "0.0.0", + "scripts": { + "test": "node test/run.js" + }, + "dependencies": { + "acorn": "^2.6.4" + } }
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/acorn-qml/test/driver.js b/qt/org.eclipse.cdt.qt.core/acorn-qml/test/driver.js index 8c5fdcc9ffd..bee02325c5b 100644 --- a/qt/org.eclipse.cdt.qt.core/acorn-qml/test/driver.js +++ b/qt/org.eclipse.cdt.qt.core/acorn-qml/test/driver.js @@ -1,113 +1,113 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-var tests = [];
-
-exports.test = function(code, ast, options) {
- tests.push({code: code, ast: ast, options: options});
-};
-exports.testFail = function(code, message, options) {
- tests.push({code: code, error: message, options: options});
-};
-exports.testAssert = function(code, assert, options) {
- tests.push({code: code, assert: assert, options: options});
-};
-
-exports.runTests = function(config, callback) {
- var parse = config.parse;
- var opts = config.options || {};
-
- for (var i = 0; i < tests.length; ++i) {
- var test = tests[i];
- if (config.filter && !config.filter(test)) continue;
- try {
- var testOpts = test.options || {locations: true};
- for (var opt in opts) {
- testOpts[opt] = opts[opt];
- }
- var expected = {};
- if ((expected.onComment = testOpts.onComment)) {
- testOpts.onComment = [];
- }
- if ((expected.onToken = testOpts.onToken)) {
- testOpts.onToken = [];
- }
- testOpts.plugins = { qml: true };
- testOpts.pluginsLoose = { qml: true };
- var ast = parse(test.code, testOpts);
- if (test.error) {
- if (config.loose) {
- callback("ok", test.code);
- } else {
- callback("fail", test.code, "Expected error message: " + test.error + "\nBut parsing succeeded.");
- }
- }
- else if (test.assert) {
- var error = test.assert(ast);
- if (error) callback("fail", test.code,
- "\n Assertion failed:\n " + error);
- else callback("ok", test.code);
- } else {
- var mis = misMatch(test.ast, ast);
- for (var name in expected) {
- if (mis) break;
- if (expected[name]) {
- mis = misMatch(expected[name], testOpts[name]);
- testOpts[name] = expected[name];
- }
- }
- if (mis) callback("fail", test.code, mis);
- else callback("ok", test.code);
- }
- } catch(e) {
- if (!(e instanceof SyntaxError || e instanceof Error)) {
- throw e;
- }
- if (test.error) {
- if (e.message == test.error) callback("ok", test.code);
- else callback("fail", test.code,
- "Expected error message: " + test.error + "\nGot error message: " + e.message);
- } else {
- callback("error", test.code, e.stack || e.toString());
- }
- }
- }
-};
-
-function ppJSON(v) { return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2); }
-function addPath(str, pt) {
- if (str.charAt(str.length-1) == ")")
- return str.slice(0, str.length-1) + "/" + pt + ")";
- return str + " (" + pt + ")";
-}
-
-var misMatch = exports.misMatch = function(exp, act) {
- var mis = null;
- if (!exp || !act || (typeof exp != "object") || (typeof act != "object")) {
- if (exp !== act) return ppJSON(exp) + " !== " + ppJSON(act);
- } else if (exp instanceof RegExp || act instanceof RegExp) {
- var left = ppJSON(exp), right = ppJSON(act);
- if (left !== right) return left + " !== " + right;
- } else if (exp.splice) {
- if (!act.slice) return ppJSON(exp) + " != " + ppJSON(act);
- if (act.length != exp.length) return "array length mismatch " + exp.length + " != " + act.length;
- for (var i = 0; i < act.length; ++i) {
- mis = misMatch(exp[i], act[i]);
- if (mis) return addPath(mis, i);
- }
- } else {
- for (var prop in exp) {
- mis = misMatch(exp[prop], act[prop]);
- if (mis) return addPath(mis, prop);
- }
- }
+/******************************************************************************* + * 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 + *******************************************************************************/ +"use strict"; + +var tests = []; + +exports.test = function(code, ast, options) { + tests.push({code: code, ast: ast, options: options}); +}; +exports.testFail = function(code, message, options) { + tests.push({code: code, error: message, options: options}); +}; +exports.testAssert = function(code, assert, options) { + tests.push({code: code, assert: assert, options: options}); +}; + +exports.runTests = function(config, callback) { + var parse = config.parse; + var opts = config.options || {}; + + for (var i = 0; i < tests.length; ++i) { + var test = tests[i]; + if (config.filter && !config.filter(test)) continue; + try { + var testOpts = test.options || {locations: true}; + for (var opt in opts) { + testOpts[opt] = opts[opt]; + } + var expected = {}; + if ((expected.onComment = testOpts.onComment)) { + testOpts.onComment = []; + } + if ((expected.onToken = testOpts.onToken)) { + testOpts.onToken = []; + } + testOpts.plugins = { qml: true }; + testOpts.pluginsLoose = { qml: true }; + var ast = parse(test.code, testOpts); + if (test.error) { + if (config.loose) { + callback("ok", test.code); + } else { + callback("fail", test.code, "Expected error message: " + test.error + "\nBut parsing succeeded."); + } + } + else if (test.assert) { + var error = test.assert(ast); + if (error) callback("fail", test.code, + "\n Assertion failed:\n " + error); + else callback("ok", test.code); + } else { + var mis = misMatch(test.ast, ast); + for (var name in expected) { + if (mis) break; + if (expected[name]) { + mis = misMatch(expected[name], testOpts[name]); + testOpts[name] = expected[name]; + } + } + if (mis) callback("fail", test.code, mis); + else callback("ok", test.code); + } + } catch(e) { + if (!(e instanceof SyntaxError || e instanceof Error)) { + throw e; + } + if (test.error) { + if (e.message == test.error) callback("ok", test.code); + else callback("fail", test.code, + "Expected error message: " + test.error + "\nGot error message: " + e.message); + } else { + callback("error", test.code, e.stack || e.toString()); + } + } + } +}; + +function ppJSON(v) { return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2); } +function addPath(str, pt) { + if (str.charAt(str.length-1) == ")") + return str.slice(0, str.length-1) + "/" + pt + ")"; + return str + " (" + pt + ")"; +} + +var misMatch = exports.misMatch = function(exp, act) { + var mis = null; + if (!exp || !act || (typeof exp != "object") || (typeof act != "object")) { + if (exp !== act) return ppJSON(exp) + " !== " + ppJSON(act); + } else if (exp instanceof RegExp || act instanceof RegExp) { + var left = ppJSON(exp), right = ppJSON(act); + if (left !== right) return left + " !== " + right; + } else if (exp.splice) { + if (!act.slice) return ppJSON(exp) + " != " + ppJSON(act); + if (act.length != exp.length) return "array length mismatch " + exp.length + " != " + act.length; + for (var i = 0; i < act.length; ++i) { + mis = misMatch(exp[i], act[i]); + if (mis) return addPath(mis, i); + } + } else { + for (var prop in exp) { + mis = misMatch(exp[prop], act[prop]); + if (mis) return addPath(mis, prop); + } + } };
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/acorn-qml/test/run.js b/qt/org.eclipse.cdt.qt.core/acorn-qml/test/run.js index 07816ecda7d..dab4c8d4daa 100644 --- a/qt/org.eclipse.cdt.qt.core/acorn-qml/test/run.js +++ b/qt/org.eclipse.cdt.qt.core/acorn-qml/test/run.js @@ -1,114 +1,114 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-// Get the driver and test code
-var driver = require("./driver.js");
-require("./tests-qml.js");
-
-// Get and inject the QML plugin into Acorn
-var acorn = require("acorn");
-require("acorn/dist/acorn_loose");
-require("..");
-require("../loose");
-
-function group(name) {
- if (typeof console === "object" && console.group) {
- console.group(name);
- }
-}
-
-function groupEnd() {
- if (typeof console === "object" && console.groupEnd) {
- console.groupEnd(name);
- }
-}
-
-function log(title, message) {
- if (typeof console === "object") console.log(title, message);
-}
-
-var stats, modes = {
- "Normal QML": {
- config: {
- parse: acorn.parse,
- filter: function (test) {
- var opts = test.options || {};
- return opts.normal !== false && opts.qmltypes !== true;
- }
- }
- },
- "Loose QML": {
- config: {
- parse: acorn.parse_dammit,
- filter: function (test) {
- var opts = test.options || {};
- return opts.loose !== false && opts.qmltypes !== true;
- }
- }
- },
- "Loose QMLTypes": {
- config: {
- parse: acorn.parse_dammit,
- options: {
- mode: "qmltypes"
- },
- filter: function (test) {
- var opts = test.options || {};
- return opts.loose !== false && opts.qmltypes !== false;
- }
- }
- }
-};
-
-function report(state, code, message) {
- if (state != "ok") {++stats.failed; log(code, message);}
- ++stats.testsRun;
-}
-
-group("Errors");
-
-for (var name in modes) {
- group(name);
- var mode = modes[name];
- stats = mode.stats = {testsRun: 0, failed: 0};
- var t0 = +new Date();
- driver.runTests(mode.config, report);
- mode.stats.duration = +new Date() - t0;
- groupEnd();
-}
-
-groupEnd();
-
-function outputStats(name, stats) {
- log(name + ":", stats.testsRun + " tests run in " + stats.duration + "ms; " +
- (stats.failed ? stats.failed + " failures." : "all passed."));
-}
-
-var total = {testsRun: 0, failed: 0, duration: 0};
-
-group("Stats");
-
-for (var name in modes) {
- var stats = modes[name].stats;
- outputStats(name + " parser", stats);
- for (var key in stats) total[key] += stats[key];
-}
-
-outputStats("Total", total);
-
-groupEnd();
-
-if (total.failed && typeof process === "object") {
- process.stdout.write("", function () {
- process.exit(1);
- });
+/******************************************************************************* + * 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 + *******************************************************************************/ +"use strict"; + +// Get the driver and test code +var driver = require("./driver.js"); +require("./tests-qml.js"); + +// Get and inject the QML plugin into Acorn +var acorn = require("acorn"); +require("acorn/dist/acorn_loose"); +require(".."); +require("../loose"); + +function group(name) { + if (typeof console === "object" && console.group) { + console.group(name); + } +} + +function groupEnd() { + if (typeof console === "object" && console.groupEnd) { + console.groupEnd(name); + } +} + +function log(title, message) { + if (typeof console === "object") console.log(title, message); +} + +var stats, modes = { + "Normal QML": { + config: { + parse: acorn.parse, + filter: function (test) { + var opts = test.options || {}; + return opts.normal !== false && opts.qmltypes !== true; + } + } + }, + "Loose QML": { + config: { + parse: acorn.parse_dammit, + filter: function (test) { + var opts = test.options || {}; + return opts.loose !== false && opts.qmltypes !== true; + } + } + }, + "Loose QMLTypes": { + config: { + parse: acorn.parse_dammit, + options: { + mode: "qmltypes" + }, + filter: function (test) { + var opts = test.options || {}; + return opts.loose !== false && opts.qmltypes !== false; + } + } + } +}; + +function report(state, code, message) { + if (state != "ok") {++stats.failed; log(code, message);} + ++stats.testsRun; +} + +group("Errors"); + +for (var name in modes) { + group(name); + var mode = modes[name]; + stats = mode.stats = {testsRun: 0, failed: 0}; + var t0 = +new Date(); + driver.runTests(mode.config, report); + mode.stats.duration = +new Date() - t0; + groupEnd(); +} + +groupEnd(); + +function outputStats(name, stats) { + log(name + ":", stats.testsRun + " tests run in " + stats.duration + "ms; " + + (stats.failed ? stats.failed + " failures." : "all passed.")); +} + +var total = {testsRun: 0, failed: 0, duration: 0}; + +group("Stats"); + +for (var name in modes) { + var stats = modes[name].stats; + outputStats(name + " parser", stats); + for (var key in stats) total[key] += stats[key]; +} + +outputStats("Total", total); + +groupEnd(); + +if (total.failed && typeof process === "object") { + process.stdout.write("", function () { + process.exit(1); + }); }
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/acorn-qml/test/tests-qml.js b/qt/org.eclipse.cdt.qt.core/acorn-qml/test/tests-qml.js index 4610eb23362..4d2362db130 100644 --- a/qt/org.eclipse.cdt.qt.core/acorn-qml/test/tests-qml.js +++ b/qt/org.eclipse.cdt.qt.core/acorn-qml/test/tests-qml.js @@ -1,4022 +1,4022 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-var driver = require("./driver.js");
-var test = driver.test;
-var testFail = driver.testFail;
-var tokTypes = driver.tokTypes;
-
-testFail('', "QML only supports ECMA Script Language Specification 5 or older",
- { locations: true, ecmaVersion: 6, allowReserved: false });
-
-test('import QtQuick 2.02', headerItemList([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 19 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 19 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- },
- parts: [{ type: "Identifier", name: "QtQuick" }],
- name: "QtQuick"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 19 }
- },
- value: 2.02,
- raw: "2.02"
- }
- }
-}]));
-
-test('import "./file.js"', headerItemList([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 18 }
- },
- directory: {
- type: "Literal",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 18 }
- },
- value: "./file.js",
- raw: "\"./file.js\""
- }
-}]));
-
-test('import "./file.js" as MyModule', headerItemList([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 30 }
- },
- directory: {
- type: "Literal",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 18 }
- },
- value: "./file.js",
- raw: "\"./file.js\""
- },
- qualifier: {
- type: "QMLQualifier",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 30 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 30 }
- },
- name: "MyModule"
- }
- }
-}]));
-
-testFail('import QtQuick ver',
- "Unexpected token (1:15)",
- { locations: true, loose: false });
-
-testFail('import QtQuick 0x01',
- "QML module must specify major and minor version (1:15)",
- { locations: true, loose: false });
-
-testFail('import QtQuick 1',
- "QML module must specify major and minor version (1:15)",
- { locations: true, loose: false });
-
-test('import QtQuick 2.2\nimport "./file.js"', headerItemList([
- {
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 18 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 18 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- },
- parts: [{ type: "Identifier", name: "QtQuick" }],
- name: "QtQuick"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- },
- value: 2.2,
- raw: "2.2"
- }
- }
- },
- {
- type: "QMLImport",
- loc: {
- start: { line: 2, column: 0 },
- end: { line: 2, column: 18 }
- },
- directory: {
- type: "Literal",
- loc: {
- start: { line: 2, column: 7 },
- end: { line: 2, column: 18 }
- },
- value: "./file.js",
- raw: "\"./file.js\""
- }
- }
-]));
-
-test('import QtQuick 2.2;import "./file.js"', headerItemList([
- {
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 19 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 18 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- },
- parts: [{ type: "Identifier", name: "QtQuick" }],
- name: "QtQuick"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- },
- value: 2.2,
- raw: "2.2"
- }
- }
- },
- {
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 37 }
- },
- directory: {
- type: "Literal",
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 37 }
- },
- value: "./file.js",
- raw: "\"./file.js\""
- }
- }
-]));
-
-test('import Module 1.0 as MyModule', headerItemList([
- {
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 29 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 17 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 13 }
- },
- parts: [{ type: "Identifier", name: "Module" }],
- name: "Module"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 }
- },
- value: 1,
- raw: "1.0"
- }
- },
- qualifier: {
- type: "QMLQualifier",
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 29 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 29 }
- },
- name: "MyModule"
- }
- }
- }
-]));
-
-test('import Qualified.Id.Test 1.0', headerItemList([
- {
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 28 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 28 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 24 }
- },
- parts: [
- { type: "Identifier", name: "Qualified" },
- { type: "Identifier", name: "Id" },
- { type: "Identifier", name: "Test" }
- ],
- name: "Qualified.Id.Test"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 28 }
- },
- value: 1,
- raw: "1.0"
- }
- }
- }
-]));
-
-test('pragma Singleton', headerItemList([
- {
- type: "QMLPragma",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 16 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 16 }
- },
- parts: [{ type: "Identifier", name: "Singleton" }],
- name: "Singleton"
- }
- }
-]));
-
-test('pragma Singleton\npragma Other', headerItemList([
- {
- type: "QMLPragma",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 16 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 16 }
- },
- parts: [{ type: "Identifier", name: "Singleton" }],
- name: "Singleton"
- }
- },
- {
- type: "QMLPragma",
- loc: {
- start: { line: 2, column: 0 },
- end: { line: 2, column: 12 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 2, column: 7 },
- end: { line: 2, column: 12 }
- },
- parts: [{ type: "Identifier", name: "Other" }],
- name: "Other"
- }
- }
-]));
-
-test('pragma Singleton;pragma Other', headerItemList([
- {
- type: "QMLPragma",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 17 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 16 }
- },
- parts: [{ type: "Identifier", name: "Singleton" }],
- name: "Singleton"
- }
- },
- {
- type: "QMLPragma",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 29 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 29 }
- },
- parts: [{ type: "Identifier", name: "Other" }],
- name: "Other"
- }
- }
-]));
-
-test('Window {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 9 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 6 }
- },
- parts: [{ type: "Identifier", name: "Window" }],
- name: "Window"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 9 }
- },
- members: []
- }
-}));
-
-test('QtQuick.Window {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 17 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 14 }
- },
- parts: [
- { type: "Identifier", name: "QtQuick" },
- { type: "Identifier", name: "Window" }
- ],
- name: "QtQuick.Window"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 17 }
- },
- members: []
- }
-}));
-
-test('property {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 11 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 8 }
- },
- parts: [{ type: "Identifier", name: "property" }],
- name: "property"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 11 }
- },
- members: []
- }
-}));
-
-test('readonly {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 11 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 8 }
- },
- parts: [{ type: "Identifier", name: "readonly" }],
- name: "readonly"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 11 }
- },
- members: []
- }
-}));
-
-test('signal {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 9 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 6 }
- },
- parts: [{ type: "Identifier", name: "signal" }],
- name: "signal"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 9 }
- },
- members: []
- }
-}));
-
-test('alias {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 8 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 5 }
- },
- parts: [{ type: "Identifier", name: "alias" }],
- name: "alias"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 8 }
- },
- members: []
- }
-}));
-
-test('list {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 7 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "list" }],
- name: "list"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 7 }
- },
- members: []
- }
-}));
-
-test('color {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 8 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 5 }
- },
- parts: [{ type: "Identifier", name: "color" }],
- name: "color"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 8 }
- },
- members: []
- }
-}));
-
-test('real {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 7 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "real" }],
- name: "real"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 7 }
- },
- members: []
- }
-}));
-
-test('string {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 9 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 6 }
- },
- parts: [{ type: "Identifier", name: "string" }],
- name: "string"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 9 }
- },
- members: []
- }
-}));
-
-test('url {}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 6 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 3 }
- },
- parts: [{ type: "Identifier", name: "url" }],
- name: "url"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 6 }
- },
- members: []
- }
-}));
-
-test('Window {Button {}}', rootObjectMembers([{
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 17 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- },
- parts: [{ type: "Identifier", name: "Button" }],
- name: "Button"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 17 }
- },
- members: []
- }
-}]));
-
-test('a{ property {} }', rootObjectMembers([{
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 14 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- parts: [{ type: "Identifier", name: "property" }],
- name: "property"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 14 }
- },
- members: []
- }
-}]));
-
-test('a{ readonly {} }', rootObjectMembers([{
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 14 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- parts: [{ type: "Identifier", name: "readonly" }],
- name: "readonly"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 14 }
- },
- members: []
- }
-}]));
-
-test('a{ signal {} }', rootObjectMembers([{
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 12 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 9 }
- },
- parts: [{ type: "Identifier", name: "signal" }],
- name: "signal"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 12 }
- },
- members: []
- }
-}]));
-
-testFail('a{ readonly property var as: 3 }',
- "Unexpected token (1:25)",
- { locations: true, loose: false });
-
-test('a{ readonly property var w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 29 }
- },
- default: false,
- readonly: true,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 24 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 26 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 29 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ default property var w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 28 }
- },
- default: true,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 23 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 25 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 28 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-testFail('a{ property var public: 3 }',
- "The keyword 'public' is reserved (1:16)",
- { locations: true, loose: false });
-
-testFail('a{ property var export: 3 }',
- "The keyword 'export' is reserved (1:16)",
- { locations: true, loose: false });
-
-test('a{ property var w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 20 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 20 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property boolean w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 24 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 19 }
- },
- primitive: true,
- id: { type: "Identifier", name: "boolean"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 21 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 24 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property double w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 23 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 18 }
- },
- primitive: true,
- id: { type: "Identifier", name: "double"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 20 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 23 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property int w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 20 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- },
- primitive: true,
- id: { type: "Identifier", name: "int"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 20 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property list<Type> w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 27 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 16 }
- },
- primitive: true,
- id: { type: "Identifier", name: "list"},
- },
- modifier: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 21 }
- },
- primitive: false,
- id: { type: "Identifier", name: "Type" }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 24 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 27 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property color w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 22 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 17 }
- },
- primitive: true,
- id: { type: "Identifier", name: "color"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 22 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property real w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 21 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 16 }
- },
- primitive: true,
- id: { type: "Identifier", name: "real"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 18 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 21 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property string w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 23 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 18 }
- },
- primitive: true,
- id: { type: "Identifier", name: "string"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 20 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 23 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property url w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 20 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- },
- primitive: true,
- id: { type: "Identifier", name: "url"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 20 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-
-test('a{ property QtObject w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 25 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 20 }
- },
- primitive: false,
- id: { type: "Identifier", name: "QtObject"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 22 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 25 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property alias w: 3 }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 22 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 17 }
- },
- primitive: true,
- id: { type: "Identifier", name: "alias"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- },
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 22 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ w: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 7 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "w" }],
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 7 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ x.y.z: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 8 }
- },
- parts: [
- { type: "Identifier", name: "x" },
- { type: "Identifier", name: "y" },
- { type: "Identifier", name: "z" }
- ],
- name: "x.y.z"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-testFail('a{ import: 3 }',
- "Unexpected token (1:3)",
- { locations: true, loose: false });
-
-testFail('a{ pragma: 3 }',
- "Unexpected token (1:3)",
- { locations: true, loose: false });
-
-testFail('a{ as: 3 }',
- "Unexpected token (1:3)",
- { locations: true, loose: false });
-
-testFail('a{ boolean: 3 }',
- "Unexpected token (1:3)",
- { locations: true, loose: false });
-
-testFail('a{ double: 3 }',
- "Unexpected token (1:3)",
- { locations: true, loose: false });
-
-testFail('a{ int: 3 }',
- "Unexpected token (1:3)",
- { locations: true, loose: false });
-
-test('a{ alias: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 8 }
- },
- parts: [{ type: "Identifier", name: "alias" }],
- name: "alias"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ list: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 10 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 7 }
- },
- parts: [{ type: "Identifier", name: "list" }],
- name: "list"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 10 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ property: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 14 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- parts: [{ type: "Identifier", name: "property" }],
- name: "property"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ readonly: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 14 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- parts: [{ type: "Identifier", name: "readonly" }],
- name: "readonly"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ signal: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 12 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 9 }
- },
- parts: [{ type: "Identifier", name: "signal" }],
- name: "signal"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 12 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ color: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 8 }
- },
- parts: [{ type: "Identifier", name: "color" }],
- name: "color"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ real: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 10 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 7 }
- },
- parts: [{ type: "Identifier", name: "real" }],
- name: "real"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 10 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ string: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 12 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 9 }
- },
- parts: [{ type: "Identifier", name: "string" }],
- name: "string"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 12 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ url: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 9 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 6 }
- },
- parts: [{ type: "Identifier", name: "url" }],
- name: "url"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 9 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-test('a{ onClicked: Qt.quit(0) }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 24 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 12 }
- },
- parts: [{ type: "Identifier", name: "onClicked" }],
- name: "onClicked"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 24 }
- },
- script: {
- type: "CallExpression",
- callee: {
- type: "MemberExpression",
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 21 }
- },
- object: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 16 }
- },
- name: "Qt"
- },
- property: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 21 }
- },
- name: "quit"
- },
- computed: false
- },
- arguments: [{
- type: "Literal",
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 23 }
- },
- value: 0,
- raw: "0"
- }]
- }
- }
-}]));
-
-test('a{b:pragma}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 10 }
- },
- name: "pragma"
-}));
-
-test('a{b:property}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 12 }
- },
- name: "property"
-}));
-
-test('a{b:readonly}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 12 }
- },
- name: "readonly"
-}));
-
-test('a{b:signal}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 10 }
- },
- name: "signal"
-}));
-
-test('a{b:alias}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 9 }
- },
- name: "alias"
-}));
-
-test('a{b:list}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 8 }
- },
- name: "list"
-}));
-
-test('a{b:color}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 9 }
- },
- name: "color"
-}));
-
-test('a{b:real}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 8 }
- },
- name: "real"
-}));
-
-test('a{b:string}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 10 }
- },
- name: "string"
-}));
-
-test('a{b:url}', javaScript({
- type: "Identifier",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 7 }
- },
- name: "url"
-}));
-
-test('a{b:[]}', javaScript({
- type: "ArrayExpression",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 6 }
- },
- elements: []
-}));
-
-test('a{b:[{}]}', javaScript({
- type: "ArrayExpression",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 8 }
- },
- elements: [{
- type: "ObjectExpression",
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 7 }
- },
- }]
-}));
-
-test('a{ function fn() {} }', rootObjectMembers([{
- type: "FunctionDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 19 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 14 }
- },
- name: "fn"
- },
- params: [],
- body: {
- type: "BlockStatement",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 19 }
- },
- body: []
- }
-}]));
-
-test('a{ function add(a, b) { return a + b } }', rootObjectMembers([{
- type: "FunctionDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 38 }
- },
- id: {
- type: "Identifier",
- name: "add"
- },
- params: [
- { type: "Identifier", name: "a" },
- { type: "Identifier", name: "b" }
- ],
- body: {
- type: "BlockStatement",
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 38 }
- },
- body: [{
- type: "ReturnStatement",
- argument: {
- type: "BinaryExpression",
- left: { type: "Identifier", name: "a" },
- operator: "+",
- right: { type: "Identifier", name: "b" }
- }
- }]
- }
-}]));
-
-testFail('a{ function () {} }',
- "Unexpected token (1:12)",
- { locations: true, loose: false });
-
-test('a{ signal b }', rootObjectMembers([{
- type: "QMLSignalDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- },
- name: "b"
- },
- params: []
-}]));
-
-test('a{ signal b () }', rootObjectMembers([{
- type: "QMLSignalDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 14 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- },
- name: "b"
- },
- params: []
-}]));
-
-test('a{ signal b (type param)}', rootObjectMembers([{
- type: "QMLSignalDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 24 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- },
- name: "b"
- },
- params: [{
- type: "QMLParameter",
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 23 }
- },
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 17 }
- },
- primitive: false,
- id: { type: "Identifier", name: "type" }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 23 }
- },
- name: "param"
- }
- }]
-}]));
-
-test('a{ signal b (type1 param1, type2 param2, type3 param3)}', rootObjectMembers([{
- type: "QMLSignalDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 54 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- },
- name: "b"
- },
- params: [
- {
- type: "QMLParameter",
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 25 }
- },
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 18 }
- },
- primitive: false,
- id: { type: "Identifier", name: "type1" }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 25 }
- },
- name: "param1"
- }
- },
- {
- type: "QMLParameter",
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 39 }
- },
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 32 }
- },
- primitive: false,
- id: { type: "Identifier", name: "type2" }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 39 }
- },
- name: "param2"
- }
- },
- {
- type: "QMLParameter",
- loc: {
- start: { line: 1, column: 41 },
- end: { line: 1, column: 53 }
- },
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 41 },
- end: { line: 1, column: 46 }
- },
- primitive: false,
- id: { type: "Identifier", name: "type3" }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 47 },
- end: { line: 1, column: 53 }
- },
- name: "param3"
- }
- }
- ]
-}]));
-
-test('a{ id: test }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 5 }
- },
- parts: [{
- type: "Identifier",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 5 }
- },
- name: "id"
- }],
- name: "id"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 11 }
- },
- script: {
- type: "Identifier",
- name: "test"
- }
- }
-}]));
-
-/*
-* Test the base QML Hello World program created by Eclipse CDT.
-*/
-test('import QtQuick 2.3\nimport QtQuick.Window 2.2\nWindow {\n\tvisible: true\n\n\tMouseArea {\n\t\tanchors.fill: parent\n\t\tonClicked: {\n\t\t\tQt.quit();\n\t\t}\n\t}\n\tText {\n\t\ttext: qsTr("Hello World")\n\t\tanchors.centerIn: parent\n\t}\n}',
- program([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0
- },
- end: { line: 1, column: 18 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 18 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- },
- parts: [{ type: "Identifier", name: "QtQuick" }],
- name: "QtQuick"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- },
- raw: "2.3",
- }
- }
- },
- {
- type: "QMLImport",
- loc: {
- start: { line: 2, column: 0 },
- end: { line: 2, column: 25 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 2, column: 7 },
- end: { line: 2, column: 25 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 2, column: 7 },
- end: { line: 2, column: 21 }
- },
- parts: [
- { type: "Identifier", name: "QtQuick" },
- { type: "Identifier", name: "Window" }
- ],
- name: "QtQuick.Window"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 2, column: 22 },
- end: { line: 2, column: 25 }
- },
- raw: "2.2",
- }
- }
- }],{
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 3, column: 0 },
- end: { line: 16, column: 1 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 3, column: 0 },
- end: { line: 3, column: 6 }
- },
- parts: [{ type: "Identifier", name: "Window" }],
- name: "Window"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 3, column: 7 },
- end: { line: 16, column: 1 }
- },
- members: [
- {
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 4, column: 1 },
- end: { line: 4, column: 14 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 4, column: 1 },
- end: { line: 4, column: 8 }
- },
- parts: [{ type: "Identifier", name: "visible" }],
- name: "visible"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 4, column: 10 },
- end: { line: 4, column: 14 }
- },
- script: {
- type: "Literal",
- value: true,
- raw: "true"
- }
- }
- },
- {
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 6, column: 1 },
- end: { line: 11, column: 2 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 6, column: 1 },
- end: { line: 6, column: 10 }
- },
- parts: [{ type: "Identifier", name: "MouseArea" }],
- name: "MouseArea"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 6, column: 11 },
- end: { line: 11, column: 2 }
- },
- members: [
- {
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 7, column: 2 },
- end: { line: 7, column: 22 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 7, column: 2 },
- end: { line: 7, column: 14 }
- },
- parts: [
- { type: "Identifier", name: "anchors" },
- { type: "Identifier", name: "fill" }
- ],
- name: "anchors.fill"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 7, column: 16 },
- end: { line: 7, column: 22 }
- },
- script: {
- type: "Identifier",
- name: "parent"
- }
- }
- },
- {
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 8, column: 2 },
- end: { line: 10, column: 3 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 8, column: 2 },
- end: { line: 8, column: 11 }
- },
- parts: [{ type: "Identifier", name: "onClicked" }],
- name: "onClicked"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 8, column: 13 },
- end: { line: 10, column: 3 }
- },
- script: {
- type: "QMLStatementBlock",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "Qt"
- },
- property: {
- type: "Identifier",
- name: "quit"
- },
- computed: false
- },
- arguments: []
- }
- }]
- }
- }
- }
- ]
- }
- },
- {
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 12, column: 1 },
- end: { line: 15, column: 2 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 12, column: 1 },
- end: { line: 12, column: 5 }
- },
- parts: [{ type: "Identifier", name: "Text" }],
- name: "Text"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 12, column: 6 },
- end: { line: 15, column: 2 }
- },
- members: [
- {
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 13, column: 2 },
- end: { line: 13, column: 27 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 13, column: 2 },
- end: { line: 13, column: 6 }
- },
- parts: [{ type: "Identifier", name: "text" }],
- name: "text"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 13, column: 8 },
- end: { line: 13, column: 27 }
- },
- script: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "qsTr"
- },
- arguments: [{
- type: "Literal",
- value: "Hello World",
- raw: "\"Hello World\""
- }]
- }
- }
- },
- {
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 14, column: 2 },
- end: { line: 14, column: 26 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 14, column: 2 },
- end: { line: 14, column: 18 }
- },
- parts: [
- { type: "Identifier", name: "anchors" },
- { type: "Identifier", name: "centerIn" }
- ],
- name: "anchors.centerIn"
- },
- binding: {
- type: "QMLScriptBinding",
- script: {
- type: "Identifier",
- name: "parent"
- }
- }
- }
- ]
- }
- }
- ]
- }
- }
-), { locations: true, qmltypes: false });
-
-/***************************************************************************
-* Loose Parser Tests *
-****************************************************************************/
-function testLoose(code, ast, options) {
- var opts = options || {};
- opts.loose = true;
- opts.normal = false;
- opts.locations = true;
- test(code, ast, opts);
-}
-
-testLoose('import QtQuick', headerItemList([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 14 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- },
- parts: [{ type: "Identifier", name: "QtQuick" }],
- name: "QtQuick"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 14 }
- },
- value: 0,
- raw: "0.0"
- }
- }
-}]));
-
-testLoose('import ', headerItemList([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 7 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 7 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 7 }
- },
- parts: [{ type: "Identifier", name: "✖" }],
- name: "✖"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 7 }
- },
- value: 0,
- raw: "0.0"
- }
- }
-}]));
-
-testLoose('import QtQuick 0x01', headerItemList([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 19 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 19 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- },
- parts: [{ type: "Identifier", name: "QtQuick" }],
- name: "QtQuick"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 19 }
- },
- value: 1,
- raw: "0x01"
- }
- }
-}]));
-
-testLoose('import QtQuick 1', headerItemList([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 16 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 16 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- },
- parts: [{ type: "Identifier", name: "QtQuick" }],
- name: "QtQuick"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- },
- value: 1,
- raw: "1"
- }
- }
-}]));
-
-testLoose('import "./file.js', headerItemList([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 17 }
- },
- directory: {
- type: "Literal",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 17 }
- },
- value: "./file.js",
- raw: "\"./file.js"
- }
-}]));
-
-testLoose('import QtQuick 2.2 as ', headerItemList([{
- type: "QMLImport",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 22 }
- },
- module: {
- type: "QMLModule",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 18 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- },
- parts: [{ type: "Identifier", name: "QtQuick" }],
- name: "QtQuick"
- },
- version: {
- type: "QMLVersionLiteral",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- },
- value: 2.2,
- raw: "2.2"
- }
- },
- qualifier: {
- type: "QMLQualifier",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 22 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 22 }
- },
- name: "✖"
- }
- }
-}]));
-
-testLoose('Window {', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 8 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 6 }
- },
- parts: [{ type: "Identifier", name: "Window" }],
- name: "Window"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- },
- members: []
- }
-}));
-
-testLoose('Window {\n\tprop: 3', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 2, column: 8 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 6 }
- },
- parts: [{ type: "Identifier", name: "Window" }],
- name: "Window"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 2, column: 8 }
- },
- members: [{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 2, column: 1 },
- end: { line: 2, column: 8 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 2, column: 1 },
- end: { line: 2, column: 5 }
- },
- parts: [{ type: "Identifier", name: "prop" }],
- name: "prop"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 2, column: 7 },
- end: { line: 2, column: 8 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
- }]
- }
-}));
-
-testLoose('a {\n\tb {\n\n\tc {\n}', rootObject({
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 5, column: 1 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- },
- parts: [{ type: "Identifier", name: "a" }],
- name: "a"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 5, column: 1 }
- },
- members: [{
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 2, column: 1 },
- end: { line: 5, column: 1 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 2, column: 1 },
- end: { line: 2, column: 2 }
- },
- parts: [{ type: "Identifier", name: "b" }],
- name: "b"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 2, column: 3 },
- end: { line: 5, column: 1 }
- },
- members: [{
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 4, column: 1 },
- end: { line: 5, column: 1 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 4, column: 1 },
- end: { line: 4, column: 2 }
- },
- parts: [{ type: "Identifier", name: "c" }],
- name: "c"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 4, column: 3 },
- end: { line: 5, column: 1 }
- },
- members: []
- }
- }]
- }
- }]
- }
-}));
-
-testLoose('a{ property var }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 17 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 17 }
- },
- name: "✖"
- },
- binding: null
-}]));
-
-testLoose('a{ w }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 5 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "w" }],
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 5 }
- },
- script: {
- type: "Identifier",
- name: "✖"
- }
- }
-}]));
-
-testLoose('a{ w: }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 7 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "w" }],
- name: "w"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 7 }
- },
- script: {
- type: "Identifier",
- name: "✖"
- }
- }
-}]));
-
-testLoose('a{ : 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 6 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 3 }
- },
- parts: [{ type: "Identifier", name: "✖" }],
- name: "✖"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-testLoose('a{ anchors.: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 14 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- parts: [
- { type: "Identifier", name: "anchors" },
- { type: "Identifier", name: "✖" }
- ],
- name: "anchors.✖"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-testLoose('a{ anchors..: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 15 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 12 }
- },
- parts: [
- { type: "Identifier", name: "anchors" },
- { type: "Identifier", name: "✖" },
- { type: "Identifier", name: "✖" }
- ],
- name: "anchors.✖.✖"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-testLoose('a{ ..: 3 }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 8 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 5 }
- },
- parts: [
- { type: "Identifier", name: "✖" },
- { type: "Identifier", name: "✖" },
- { type: "Identifier", name: "✖" }
- ],
- name: "✖.✖.✖"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- },
- script: {
- type: "Literal",
- value: 3,
- raw: "3"
- }
- }
-}]));
-
-testLoose('a{ var }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 7 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 6 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 7 }
- },
- name: "✖"
- },
- binding: null
-}]));
-
-testLoose('a{ var w }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 8 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 6 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- },
- name: "w"
- },
- binding: null
-}]));
-
-testLoose('a{ obj w }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 8 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 6 }
- },
- primitive: false,
- id: { type: "Identifier", name: "obj"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- },
- name: "w"
- },
- binding: null
-}]));
-
-// TODO: Allow this to run with the normal parser once the ambiguity is solved
-testLoose('a{ property var b: Window {} }', rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 28 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- },
- name: "b"
- },
- binding: {
- type: "QMLObjectBinding",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 28 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 25 }
- },
- parts: [{ type: "Identifier", name: "Window" }],
- name: "Window"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 28 }
- },
- members: []
- }
- }
-}]), { locations: true, qmltypes: false });
-
-// TODO: Allow this to run with the normal parser once the ambiguity is solved
-testLoose('a{ b: Window {} }', rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 15 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "b" }],
- name: "b"
- },
- binding: {
- type: "QMLObjectBinding",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 15 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 12 }
- },
- parts: [{ type: "Identifier", name: "Window" }],
- name: "Window"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 15 }
- },
- members: []
- }
- }
-}]), { locations: true, qmltypes: false });
-
-testLoose('a{ signal }', rootObjectMembers([{
- type: "QMLSignalDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 10 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 10 }
- },
- name: "✖"
- },
- params: []
-}]));
-
-testLoose('a{ signal () }', rootObjectMembers([{
- type: "QMLSignalDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 12 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 10 }
- },
- name: "✖"
- },
- params: []
-}]));
-
-testLoose('a{ signal test( }', rootObjectMembers([{
- type: "QMLSignalDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 16 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 14 }
- },
- name: "test"
- },
- params: []
-}]));
-
-testLoose('a{ signal test(int test }', rootObjectMembers([{
- type: "QMLSignalDefinition",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 24 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 14 }
- },
- name: "test"
- },
- params: [{
- type: "QMLParameter",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 23 }
- },
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- },
- primitive: true,
- id: { type: "Identifier", name: "int" }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 23 }
- },
- name: "test"
- }
- }]
-}]));
-
-testLoose('Window {\n\tfunction\n\tproperty var prop\n}', rootObjectMembers([
- {
- type: "FunctionDeclaration",
- loc: {
- start: { line: 2, column: 1 },
- end: { line: 3, column: 9 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 3, column: 1 },
- end: { line: 3, column: 9 }
- },
- name: "property"
- },
- params: [],
- body: {
- type: "BlockStatement",
- loc: {
- start: { line: 3, column: 9 },
- end: { line: 3, column: 9 }
- },
- body: []
- }
- },
- {
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 3, column: 10 },
- end: { line: 3, column: 18 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 3, column: 10 },
- end: { line: 3, column: 13 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 3, column: 14 },
- end: { line: 3, column: 18 }
- },
- name: "prop"
- },
- binding: null
- }
-]));
-
-testLoose('Window {\n\tfunction (something)\n\tproperty var prop\n}', rootObjectMembers([
- {
- type: "FunctionDeclaration",
- loc: {
- start: { line: 2, column: 1 },
- end: { line: 2, column: 21 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 2, column: 10 },
- end: { line: 2, column: 10 }
- },
- name: "✖"
- },
- params: [
- {
- type: "Identifier",
- loc: {
- start: { line: 2, column: 11 },
- end: { line: 2, column: 20 }
- },
- name: "something"
- }
- ],
- body: {
- type: "BlockStatement",
- loc: {
- start: { line: 2, column: 21 },
- end: { line: 2, column: 21 }
- },
- body: []
- }
- },
- {
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 3, column: 1 },
- end: { line: 3, column: 18 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 3, column: 10 },
- end: { line: 3, column: 13 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 3, column: 14 },
- end: { line: 3, column: 18 }
- },
- name: "prop"
- },
- binding: null
- }
-]));
-
-testLoose('Window {\n\tfunction (\n\tproperty var prop\n}', rootObjectMembers([
- {
- type: "FunctionDeclaration",
- loc: {
- start: { line: 2, column: 1 },
- end: { line: 3, column: 1 }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 2, column: 10 },
- end: { line: 2, column: 10 }
- },
- name: "✖"
- },
- params: [],
- body: {
- type: "BlockStatement",
- loc: {
- start: { line: 3, column: 1 },
- end: { line: 3, column: 1 }
- },
- body: []
- }
- },
- {
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 3, column: 1 },
- end: { line: 3, column: 18 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 3, column: 10 },
- end: { line: 3, column: 13 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var"}
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 3, column: 14 },
- end: { line: 3, column: 18 }
- },
- name: "prop"
- },
- binding: null
- }
-]));
-
-// TODO: Allow this to run on the normal parser once the ambiguity is solved
-testLoose("a{ QtObject on test {} }", rootObjectMembers([{
- type: "QMLPropertyModifier",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 22 }
- },
- kind: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- parts: [{ type: "Identifier", name: "QtObject" }],
- name: "QtObject"
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 19 }
- },
- parts: [{ type: "Identifier", name: "test" }],
- name: "test"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 22 }
- },
- members: []
- }
-}]));
-
-// TODO: Allow this to run on the normal parser once the ambiguity is solved
-testLoose("a{ QtObject on test {} }", rootObjectMembers([{
- type: "QMLPropertyModifier",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 22 }
- },
- kind: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 11 }
- },
- parts: [{ type: "Identifier", name: "QtObject" }],
- name: "QtObject"
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 19 }
- },
- parts: [{ type: "Identifier", name: "test" }],
- name: "test"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 22 }
- },
- members: []
- }
-}]));
-
-testLoose("a{ QtObject. on test {} }", rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 23 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 15 }
- },
- parts: [
- { type: "Identifier", name: "QtObject" },
- { type: "Identifier", name: "on" }
- ],
- name: "QtObject.on"
- },
- binding: {
- type: "QMLObjectBinding",
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 23 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 20 }
- },
- parts: [{ type: "Identifier", name: "test" }],
- name: "test"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 23 }
- },
- members: []
- }
- }
-}]), { locations: true, qmltypes: false } );
-
-// TODO: Allow this to run on the normal parser once the ambiguity is solved
-testLoose("a{ s: [ QtObject {} ] }", rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 21 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "s" }],
- name: "s"
- },
- binding: {
- type: "QMLArrayBinding",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 21 }
- },
- elements: [
- {
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 19 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 16 }
- },
- parts: [{ type: "Identifier", name: "QtObject" }],
- name: "QtObject"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 19 }
- },
- members: []
- }
- }
- ]
- }
-}]), { locations: true, qmltypes: false });
-
-// TODO: Allow this to run on the normal parser once the ambiguity is solved
-testLoose("a{ s: [ QtObject {}, QtObject {} ] }", rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 34 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "s" }],
- name: "s"
- },
- binding: {
- type: "QMLArrayBinding",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 34 }
- },
- elements: [
- {
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 19 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 16 }
- },
- parts: [{ type: "Identifier", name: "QtObject" }],
- name: "QtObject"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 19 }
- },
- members: []
- }
- },
- {
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 32 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 29 }
- },
- parts: [{ type: "Identifier", name: "QtObject" }],
- name: "QtObject"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 32 }
- },
- members: []
- }
- }
- ]
- }
-}]), { locations: true, qmltypes: false });
-
-// TODO: Allow this to run on the normal parser once the ambiguity is solved
-testLoose("a{ s: [ QtObject ] }", rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 18 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "s" }],
- name: "s"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 18 }
- },
- block: false,
- script: {
- type: "ArrayExpression",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 18 }
- },
- elements: [
- {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 16 }
- },
- name: "QtObject"
- }
- ]
- }
- }
-}]
-), { locations: true, qmltypes: false });
-
-// TODO: Allow this to run on the normal parser once the ambiguity is solved
-testLoose("a{ property var s: [ QtObject {} ] }", rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 34 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var" }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- },
- name: "s"
- },
- binding: {
- type: "QMLArrayBinding",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 34 }
- },
- elements: [
- {
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 32 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 29 }
- },
- parts: [{ type: "Identifier", name: "QtObject" }],
- name: "QtObject"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 32 }
- },
- members: []
- }
- }
- ]
- }
-}]), { locations: true, qmltypes: false });
-
-// TODO: Allow this to run on the normal parser once the ambiguity is solved
-testLoose("a{ property var s: [ QtObject ] }", rootObjectMembers([{
- type: "QMLPropertyDeclaration",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 31 }
- },
- default: false,
- readonly: false,
- kind: {
- type: "QMLPropertyType",
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- },
- primitive: true,
- id: { type: "Identifier", name: "var" }
- },
- id: {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- },
- name: "s"
- },
- binding: {
- type: "QMLScriptBinding",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 31 }
- },
- block: false,
- script: {
- type: "ArrayExpression",
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 31 }
- },
- elements: [
- {
- type: "Identifier",
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 29 }
- },
- name: "QtObject"
- }
- ]
- }
- }
-}]), { locations: true, qmltypes: false });
-
-testLoose("a{ s: [ QtObject {} }", rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 20 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "s" }],
- name: "s"
- },
- binding: {
- type: "QMLArrayBinding",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 20 }
- },
- elements: [
- {
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 19 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 16 }
- },
- parts: [{ type: "Identifier", name: "QtObject" }],
- name: "QtObject"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 19 }
- },
- members: []
- }
- }
- ]
- }
-}]), { locations: true, qmltypes: false });
-
-testLoose("a{ s: [ QtObject { ] }", rootObjectMembers([{
- type: "QMLPropertyBinding",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 22 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- },
- parts: [{ type: "Identifier", name: "s" }],
- name: "s"
- },
- binding: {
- type: "QMLArrayBinding",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 22 }
- },
- elements: [
- {
- type: "QMLObjectDefinition",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 22 }
- },
- id: {
- type: "QMLQualifiedID",
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 16 }
- },
- parts: [{ type: "Identifier", name: "QtObject" }],
- name: "QtObject"
- },
- body: {
- type: "QMLObjectInitializer",
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 22 }
- },
- members: []
- }
- }
- ]
- }
-}]), { locations: true, qmltypes: false });
-
-/***************************************************************************
-* QMLTypes Parser Tests *
-****************************************************************************/
-function testQMLTypes(code, ast, options) {
- var opts = options || {};
- opts.qmltypes = true;
- opts.locations = true;
- test(code, ast, opts);
-}
-
-testQMLTypes("a{ b: {} }", javaScript({
- type: "ObjectExpression",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 8 }
- },
- properties: []
-}));
-
-testQMLTypes('a{ b: "test" }', javaScript({
- type: "Literal",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 12 }
- },
- value: "test",
- raw: '"test"'
-}));
-
-testQMLTypes('a{ b: ["one", "two"] }', javaScript({
- type: "ArrayExpression",
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 20 }
- },
- elements: [
- {
- type: "Literal",
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 12 }
- },
- value: "one",
- raw: '"one"'
- },
- {
- type: "Literal",
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 19 }
- },
- value: "two",
- raw: '"two"'
- }
- ]
-}));
-
-/*
-* Creates a Program with 'headerItemList' and 'rootObject' as the program's expected
-* body.
-*/
-function program(headerItemList, rootObject) {
- return {
- type: "QMLProgram",
- headerItemList: {
- type: "QMLHeaderItemList",
- items: headerItemList || []
- },
- rootObject: rootObject || null
- };
-}
-
-/*
-* Creates a QMLHeaderItemList with 'stmts' as the expected statements and 'prog' as the
-* parent Program. A value of null for 'prog' will append the QMLHeaderItemList AST to
-* the Program returned by program().
-*/
-function headerItemList(items, prog) {
- prog = prog || program();
- prog.headerItemList.items = items;
- return prog;
-}
-
-/*
-* Creates a QMLObjectDefinition with 'stmts' as the expected statements and 'prog' as the parent
-* Program. A value of null for 'prog' will append the QMLObjectDefinition AST to the Program
-* returned by program().
-*/
-function rootObject(obj, prog) {
- prog = prog || program();
- prog.rootObject = obj;
- return prog;
-}
-
-/*
-* Creates a QMLObjectInitializer with 'members' as the expected members and 'obj' as the parent
-* QMLObjectDefinition. A value of null for 'obj' will append the QMLObjectInitializer AST to the
-* QMLObjectDefinition returned by rootObject().
-*/
-function rootObjectMembers(members, obj) {
- var rootObj = obj || rootObject({
- type: "QMLObjectDefinition",
- body: {
- type: "QMLObjectInitializer",
- members: members
- }
- });
- return rootObj;
-}
-
-/*
-* Creates a JavaScript Expression with 'expr' as the expected expression and 'objMembers' as
-* the parent QMLObjectInitializer. A value of null for 'objMembers' will append the JavaScript
-* Expression to the QMLObjectInitializer returned by rootObjectMembers().
-*/
-function javaScript(expr, objMembers) {
- objMembers = objMembers || rootObjectMembers([{
- type: "QMLPropertyBinding",
- binding: {
- type: "QMLScriptBinding",
- script: expr
- }
- }]);
- return objMembers;
+/******************************************************************************* + * 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 + *******************************************************************************/ +"use strict"; + +var driver = require("./driver.js"); +var test = driver.test; +var testFail = driver.testFail; +var tokTypes = driver.tokTypes; + +testFail('', "QML only supports ECMA Script Language Specification 5 or older", + { locations: true, ecmaVersion: 6, allowReserved: false }); + +test('import QtQuick 2.02', headerItemList([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 19 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 19 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + }, + parts: [{ type: "Identifier", name: "QtQuick" }], + name: "QtQuick" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 19 } + }, + value: 2.02, + raw: "2.02" + } + } +}])); + +test('import "./file.js"', headerItemList([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 18 } + }, + directory: { + type: "Literal", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 18 } + }, + value: "./file.js", + raw: "\"./file.js\"" + } +}])); + +test('import "./file.js" as MyModule', headerItemList([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 30 } + }, + directory: { + type: "Literal", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 18 } + }, + value: "./file.js", + raw: "\"./file.js\"" + }, + qualifier: { + type: "QMLQualifier", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 30 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 30 } + }, + name: "MyModule" + } + } +}])); + +testFail('import QtQuick ver', + "Unexpected token (1:15)", + { locations: true, loose: false }); + +testFail('import QtQuick 0x01', + "QML module must specify major and minor version (1:15)", + { locations: true, loose: false }); + +testFail('import QtQuick 1', + "QML module must specify major and minor version (1:15)", + { locations: true, loose: false }); + +test('import QtQuick 2.2\nimport "./file.js"', headerItemList([ + { + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 18 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 18 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + }, + parts: [{ type: "Identifier", name: "QtQuick" }], + name: "QtQuick" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + }, + value: 2.2, + raw: "2.2" + } + } + }, + { + type: "QMLImport", + loc: { + start: { line: 2, column: 0 }, + end: { line: 2, column: 18 } + }, + directory: { + type: "Literal", + loc: { + start: { line: 2, column: 7 }, + end: { line: 2, column: 18 } + }, + value: "./file.js", + raw: "\"./file.js\"" + } + } +])); + +test('import QtQuick 2.2;import "./file.js"', headerItemList([ + { + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 19 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 18 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + }, + parts: [{ type: "Identifier", name: "QtQuick" }], + name: "QtQuick" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + }, + value: 2.2, + raw: "2.2" + } + } + }, + { + type: "QMLImport", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 37 } + }, + directory: { + type: "Literal", + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 37 } + }, + value: "./file.js", + raw: "\"./file.js\"" + } + } +])); + +test('import Module 1.0 as MyModule', headerItemList([ + { + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 29 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 17 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 13 } + }, + parts: [{ type: "Identifier", name: "Module" }], + name: "Module" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + }, + value: 1, + raw: "1.0" + } + }, + qualifier: { + type: "QMLQualifier", + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 29 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 29 } + }, + name: "MyModule" + } + } + } +])); + +test('import Qualified.Id.Test 1.0', headerItemList([ + { + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 28 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 28 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 24 } + }, + parts: [ + { type: "Identifier", name: "Qualified" }, + { type: "Identifier", name: "Id" }, + { type: "Identifier", name: "Test" } + ], + name: "Qualified.Id.Test" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 28 } + }, + value: 1, + raw: "1.0" + } + } + } +])); + +test('pragma Singleton', headerItemList([ + { + type: "QMLPragma", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 16 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 16 } + }, + parts: [{ type: "Identifier", name: "Singleton" }], + name: "Singleton" + } + } +])); + +test('pragma Singleton\npragma Other', headerItemList([ + { + type: "QMLPragma", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 16 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 16 } + }, + parts: [{ type: "Identifier", name: "Singleton" }], + name: "Singleton" + } + }, + { + type: "QMLPragma", + loc: { + start: { line: 2, column: 0 }, + end: { line: 2, column: 12 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 2, column: 7 }, + end: { line: 2, column: 12 } + }, + parts: [{ type: "Identifier", name: "Other" }], + name: "Other" + } + } +])); + +test('pragma Singleton;pragma Other', headerItemList([ + { + type: "QMLPragma", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 17 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 16 } + }, + parts: [{ type: "Identifier", name: "Singleton" }], + name: "Singleton" + } + }, + { + type: "QMLPragma", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 29 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 29 } + }, + parts: [{ type: "Identifier", name: "Other" }], + name: "Other" + } + } +])); + +test('Window {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 9 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 6 } + }, + parts: [{ type: "Identifier", name: "Window" }], + name: "Window" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 9 } + }, + members: [] + } +})); + +test('QtQuick.Window {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 17 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 14 } + }, + parts: [ + { type: "Identifier", name: "QtQuick" }, + { type: "Identifier", name: "Window" } + ], + name: "QtQuick.Window" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 17 } + }, + members: [] + } +})); + +test('property {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 11 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 8 } + }, + parts: [{ type: "Identifier", name: "property" }], + name: "property" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 11 } + }, + members: [] + } +})); + +test('readonly {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 11 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 8 } + }, + parts: [{ type: "Identifier", name: "readonly" }], + name: "readonly" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 11 } + }, + members: [] + } +})); + +test('signal {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 9 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 6 } + }, + parts: [{ type: "Identifier", name: "signal" }], + name: "signal" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 9 } + }, + members: [] + } +})); + +test('alias {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 8 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 5 } + }, + parts: [{ type: "Identifier", name: "alias" }], + name: "alias" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 8 } + }, + members: [] + } +})); + +test('list {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 7 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "list" }], + name: "list" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 7 } + }, + members: [] + } +})); + +test('color {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 8 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 5 } + }, + parts: [{ type: "Identifier", name: "color" }], + name: "color" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 8 } + }, + members: [] + } +})); + +test('real {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 7 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "real" }], + name: "real" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 7 } + }, + members: [] + } +})); + +test('string {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 9 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 6 } + }, + parts: [{ type: "Identifier", name: "string" }], + name: "string" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 9 } + }, + members: [] + } +})); + +test('url {}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 6 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 3 } + }, + parts: [{ type: "Identifier", name: "url" }], + name: "url" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 6 } + }, + members: [] + } +})); + +test('Window {Button {}}', rootObjectMembers([{ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 17 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 14 } + }, + parts: [{ type: "Identifier", name: "Button" }], + name: "Button" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 17 } + }, + members: [] + } +}])); + +test('a{ property {} }', rootObjectMembers([{ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 14 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + parts: [{ type: "Identifier", name: "property" }], + name: "property" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 14 } + }, + members: [] + } +}])); + +test('a{ readonly {} }', rootObjectMembers([{ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 14 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + parts: [{ type: "Identifier", name: "readonly" }], + name: "readonly" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 14 } + }, + members: [] + } +}])); + +test('a{ signal {} }', rootObjectMembers([{ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 12 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 9 } + }, + parts: [{ type: "Identifier", name: "signal" }], + name: "signal" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 12 } + }, + members: [] + } +}])); + +testFail('a{ readonly property var as: 3 }', + "Unexpected token (1:25)", + { locations: true, loose: false }); + +test('a{ readonly property var w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 29 } + }, + default: false, + readonly: true, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 24 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 25 }, + end: { line: 1, column: 26 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 28 }, + end: { line: 1, column: 29 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ default property var w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 28 } + }, + default: true, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 23 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 25 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 28 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +testFail('a{ property var public: 3 }', + "The keyword 'public' is reserved (1:16)", + { locations: true, loose: false }); + +testFail('a{ property var export: 3 }', + "The keyword 'export' is reserved (1:16)", + { locations: true, loose: false }); + +test('a{ property var w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 20 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 20 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property boolean w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 24 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 19 } + }, + primitive: true, + id: { type: "Identifier", name: "boolean"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 21 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 24 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property double w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 23 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 18 } + }, + primitive: true, + id: { type: "Identifier", name: "double"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 20 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 23 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property int w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 20 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + }, + primitive: true, + id: { type: "Identifier", name: "int"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 20 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property list<Type> w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 27 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 16 } + }, + primitive: true, + id: { type: "Identifier", name: "list"}, + }, + modifier: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 21 } + }, + primitive: false, + id: { type: "Identifier", name: "Type" } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 23 }, + end: { line: 1, column: 24 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 27 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property color w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 22 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 17 } + }, + primitive: true, + id: { type: "Identifier", name: "color"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 22 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property real w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 21 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 16 } + }, + primitive: true, + id: { type: "Identifier", name: "real"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 18 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 21 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property string w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 23 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 18 } + }, + primitive: true, + id: { type: "Identifier", name: "string"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 20 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 23 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property url w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 20 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + }, + primitive: true, + id: { type: "Identifier", name: "url"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 20 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + + +test('a{ property QtObject w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 25 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 20 } + }, + primitive: false, + id: { type: "Identifier", name: "QtObject"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 22 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 24 }, + end: { line: 1, column: 25 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property alias w: 3 }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 22 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 17 } + }, + primitive: true, + id: { type: "Identifier", name: "alias"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 19 } + }, + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 22 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ w: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 7 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "w" }], + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 7 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ x.y.z: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 8 } + }, + parts: [ + { type: "Identifier", name: "x" }, + { type: "Identifier", name: "y" }, + { type: "Identifier", name: "z" } + ], + name: "x.y.z" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +testFail('a{ import: 3 }', + "Unexpected token (1:3)", + { locations: true, loose: false }); + +testFail('a{ pragma: 3 }', + "Unexpected token (1:3)", + { locations: true, loose: false }); + +testFail('a{ as: 3 }', + "Unexpected token (1:3)", + { locations: true, loose: false }); + +testFail('a{ boolean: 3 }', + "Unexpected token (1:3)", + { locations: true, loose: false }); + +testFail('a{ double: 3 }', + "Unexpected token (1:3)", + { locations: true, loose: false }); + +testFail('a{ int: 3 }', + "Unexpected token (1:3)", + { locations: true, loose: false }); + +test('a{ alias: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 8 } + }, + parts: [{ type: "Identifier", name: "alias" }], + name: "alias" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ list: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 10 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 7 } + }, + parts: [{ type: "Identifier", name: "list" }], + name: "list" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 10 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ property: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 14 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + parts: [{ type: "Identifier", name: "property" }], + name: "property" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ readonly: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 14 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + parts: [{ type: "Identifier", name: "readonly" }], + name: "readonly" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ signal: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 12 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 9 } + }, + parts: [{ type: "Identifier", name: "signal" }], + name: "signal" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 12 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ color: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 8 } + }, + parts: [{ type: "Identifier", name: "color" }], + name: "color" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ real: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 10 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 7 } + }, + parts: [{ type: "Identifier", name: "real" }], + name: "real" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 9 }, + end: { line: 1, column: 10 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ string: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 12 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 9 } + }, + parts: [{ type: "Identifier", name: "string" }], + name: "string" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 11 }, + end: { line: 1, column: 12 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ url: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 9 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 6 } + }, + parts: [{ type: "Identifier", name: "url" }], + name: "url" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 9 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +test('a{ onClicked: Qt.quit(0) }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 24 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 12 } + }, + parts: [{ type: "Identifier", name: "onClicked" }], + name: "onClicked" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 24 } + }, + script: { + type: "CallExpression", + callee: { + type: "MemberExpression", + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 21 } + }, + object: { + type: "Identifier", + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 16 } + }, + name: "Qt" + }, + property: { + type: "Identifier", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 21 } + }, + name: "quit" + }, + computed: false + }, + arguments: [{ + type: "Literal", + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 23 } + }, + value: 0, + raw: "0" + }] + } + } +}])); + +test('a{b:pragma}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 10 } + }, + name: "pragma" +})); + +test('a{b:property}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 12 } + }, + name: "property" +})); + +test('a{b:readonly}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 12 } + }, + name: "readonly" +})); + +test('a{b:signal}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 10 } + }, + name: "signal" +})); + +test('a{b:alias}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 9 } + }, + name: "alias" +})); + +test('a{b:list}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 8 } + }, + name: "list" +})); + +test('a{b:color}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 9 } + }, + name: "color" +})); + +test('a{b:real}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 8 } + }, + name: "real" +})); + +test('a{b:string}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 10 } + }, + name: "string" +})); + +test('a{b:url}', javaScript({ + type: "Identifier", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 7 } + }, + name: "url" +})); + +test('a{b:[]}', javaScript({ + type: "ArrayExpression", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 6 } + }, + elements: [] +})); + +test('a{b:[{}]}', javaScript({ + type: "ArrayExpression", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 8 } + }, + elements: [{ + type: "ObjectExpression", + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 7 } + }, + }] +})); + +test('a{ function fn() {} }', rootObjectMembers([{ + type: "FunctionDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 19 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 14 } + }, + name: "fn" + }, + params: [], + body: { + type: "BlockStatement", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 19 } + }, + body: [] + } +}])); + +test('a{ function add(a, b) { return a + b } }', rootObjectMembers([{ + type: "FunctionDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 38 } + }, + id: { + type: "Identifier", + name: "add" + }, + params: [ + { type: "Identifier", name: "a" }, + { type: "Identifier", name: "b" } + ], + body: { + type: "BlockStatement", + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 38 } + }, + body: [{ + type: "ReturnStatement", + argument: { + type: "BinaryExpression", + left: { type: "Identifier", name: "a" }, + operator: "+", + right: { type: "Identifier", name: "b" } + } + }] + } +}])); + +testFail('a{ function () {} }', + "Unexpected token (1:12)", + { locations: true, loose: false }); + +test('a{ signal b }', rootObjectMembers([{ + type: "QMLSignalDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + }, + name: "b" + }, + params: [] +}])); + +test('a{ signal b () }', rootObjectMembers([{ + type: "QMLSignalDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 14 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + }, + name: "b" + }, + params: [] +}])); + +test('a{ signal b (type param)}', rootObjectMembers([{ + type: "QMLSignalDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 24 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + }, + name: "b" + }, + params: [{ + type: "QMLParameter", + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 23 } + }, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 17 } + }, + primitive: false, + id: { type: "Identifier", name: "type" } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 18 }, + end: { line: 1, column: 23 } + }, + name: "param" + } + }] +}])); + +test('a{ signal b (type1 param1, type2 param2, type3 param3)}', rootObjectMembers([{ + type: "QMLSignalDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 54 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 11 } + }, + name: "b" + }, + params: [ + { + type: "QMLParameter", + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 25 } + }, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 18 } + }, + primitive: false, + id: { type: "Identifier", name: "type1" } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 25 } + }, + name: "param1" + } + }, + { + type: "QMLParameter", + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 39 } + }, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 27 }, + end: { line: 1, column: 32 } + }, + primitive: false, + id: { type: "Identifier", name: "type2" } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 33 }, + end: { line: 1, column: 39 } + }, + name: "param2" + } + }, + { + type: "QMLParameter", + loc: { + start: { line: 1, column: 41 }, + end: { line: 1, column: 53 } + }, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 41 }, + end: { line: 1, column: 46 } + }, + primitive: false, + id: { type: "Identifier", name: "type3" } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 47 }, + end: { line: 1, column: 53 } + }, + name: "param3" + } + } + ] +}])); + +test('a{ id: test }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 5 } + }, + parts: [{ + type: "Identifier", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 5 } + }, + name: "id" + }], + name: "id" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 11 } + }, + script: { + type: "Identifier", + name: "test" + } + } +}])); + +/* +* Test the base QML Hello World program created by Eclipse CDT. +*/ +test('import QtQuick 2.3\nimport QtQuick.Window 2.2\nWindow {\n\tvisible: true\n\n\tMouseArea {\n\t\tanchors.fill: parent\n\t\tonClicked: {\n\t\t\tQt.quit();\n\t\t}\n\t}\n\tText {\n\t\ttext: qsTr("Hello World")\n\t\tanchors.centerIn: parent\n\t}\n}', + program([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 + }, + end: { line: 1, column: 18 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 18 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + }, + parts: [{ type: "Identifier", name: "QtQuick" }], + name: "QtQuick" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + }, + raw: "2.3", + } + } + }, + { + type: "QMLImport", + loc: { + start: { line: 2, column: 0 }, + end: { line: 2, column: 25 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 2, column: 7 }, + end: { line: 2, column: 25 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 2, column: 7 }, + end: { line: 2, column: 21 } + }, + parts: [ + { type: "Identifier", name: "QtQuick" }, + { type: "Identifier", name: "Window" } + ], + name: "QtQuick.Window" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 2, column: 22 }, + end: { line: 2, column: 25 } + }, + raw: "2.2", + } + } + }],{ + type: "QMLObjectDefinition", + loc: { + start: { line: 3, column: 0 }, + end: { line: 16, column: 1 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 3, column: 0 }, + end: { line: 3, column: 6 } + }, + parts: [{ type: "Identifier", name: "Window" }], + name: "Window" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 3, column: 7 }, + end: { line: 16, column: 1 } + }, + members: [ + { + type: "QMLPropertyBinding", + loc: { + start: { line: 4, column: 1 }, + end: { line: 4, column: 14 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 4, column: 1 }, + end: { line: 4, column: 8 } + }, + parts: [{ type: "Identifier", name: "visible" }], + name: "visible" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 4, column: 10 }, + end: { line: 4, column: 14 } + }, + script: { + type: "Literal", + value: true, + raw: "true" + } + } + }, + { + type: "QMLObjectDefinition", + loc: { + start: { line: 6, column: 1 }, + end: { line: 11, column: 2 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 6, column: 1 }, + end: { line: 6, column: 10 } + }, + parts: [{ type: "Identifier", name: "MouseArea" }], + name: "MouseArea" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 6, column: 11 }, + end: { line: 11, column: 2 } + }, + members: [ + { + type: "QMLPropertyBinding", + loc: { + start: { line: 7, column: 2 }, + end: { line: 7, column: 22 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 7, column: 2 }, + end: { line: 7, column: 14 } + }, + parts: [ + { type: "Identifier", name: "anchors" }, + { type: "Identifier", name: "fill" } + ], + name: "anchors.fill" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 7, column: 16 }, + end: { line: 7, column: 22 } + }, + script: { + type: "Identifier", + name: "parent" + } + } + }, + { + type: "QMLPropertyBinding", + loc: { + start: { line: 8, column: 2 }, + end: { line: 10, column: 3 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 8, column: 2 }, + end: { line: 8, column: 11 } + }, + parts: [{ type: "Identifier", name: "onClicked" }], + name: "onClicked" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 8, column: 13 }, + end: { line: 10, column: 3 } + }, + script: { + type: "QMLStatementBlock", + body: [{ + type: "ExpressionStatement", + expression: { + type: "CallExpression", + callee: { + type: "MemberExpression", + object: { + type: "Identifier", + name: "Qt" + }, + property: { + type: "Identifier", + name: "quit" + }, + computed: false + }, + arguments: [] + } + }] + } + } + } + ] + } + }, + { + type: "QMLObjectDefinition", + loc: { + start: { line: 12, column: 1 }, + end: { line: 15, column: 2 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 12, column: 1 }, + end: { line: 12, column: 5 } + }, + parts: [{ type: "Identifier", name: "Text" }], + name: "Text" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 12, column: 6 }, + end: { line: 15, column: 2 } + }, + members: [ + { + type: "QMLPropertyBinding", + loc: { + start: { line: 13, column: 2 }, + end: { line: 13, column: 27 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 13, column: 2 }, + end: { line: 13, column: 6 } + }, + parts: [{ type: "Identifier", name: "text" }], + name: "text" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 13, column: 8 }, + end: { line: 13, column: 27 } + }, + script: { + type: "CallExpression", + callee: { + type: "Identifier", + name: "qsTr" + }, + arguments: [{ + type: "Literal", + value: "Hello World", + raw: "\"Hello World\"" + }] + } + } + }, + { + type: "QMLPropertyBinding", + loc: { + start: { line: 14, column: 2 }, + end: { line: 14, column: 26 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 14, column: 2 }, + end: { line: 14, column: 18 } + }, + parts: [ + { type: "Identifier", name: "anchors" }, + { type: "Identifier", name: "centerIn" } + ], + name: "anchors.centerIn" + }, + binding: { + type: "QMLScriptBinding", + script: { + type: "Identifier", + name: "parent" + } + } + } + ] + } + } + ] + } + } +), { locations: true, qmltypes: false }); + +/*************************************************************************** +* Loose Parser Tests * +****************************************************************************/ +function testLoose(code, ast, options) { + var opts = options || {}; + opts.loose = true; + opts.normal = false; + opts.locations = true; + test(code, ast, opts); +} + +testLoose('import QtQuick', headerItemList([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 14 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + }, + parts: [{ type: "Identifier", name: "QtQuick" }], + name: "QtQuick" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 14 } + }, + value: 0, + raw: "0.0" + } + } +}])); + +testLoose('import ', headerItemList([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 7 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 7 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 7 } + }, + parts: [{ type: "Identifier", name: "✖" }], + name: "✖" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 7 } + }, + value: 0, + raw: "0.0" + } + } +}])); + +testLoose('import QtQuick 0x01', headerItemList([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 19 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 19 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + }, + parts: [{ type: "Identifier", name: "QtQuick" }], + name: "QtQuick" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 19 } + }, + value: 1, + raw: "0x01" + } + } +}])); + +testLoose('import QtQuick 1', headerItemList([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 16 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 16 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + }, + parts: [{ type: "Identifier", name: "QtQuick" }], + name: "QtQuick" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 16 } + }, + value: 1, + raw: "1" + } + } +}])); + +testLoose('import "./file.js', headerItemList([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 17 } + }, + directory: { + type: "Literal", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 17 } + }, + value: "./file.js", + raw: "\"./file.js" + } +}])); + +testLoose('import QtQuick 2.2 as ', headerItemList([{ + type: "QMLImport", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 22 } + }, + module: { + type: "QMLModule", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 18 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 14 } + }, + parts: [{ type: "Identifier", name: "QtQuick" }], + name: "QtQuick" + }, + version: { + type: "QMLVersionLiteral", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + }, + value: 2.2, + raw: "2.2" + } + }, + qualifier: { + type: "QMLQualifier", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 22 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 22 }, + end: { line: 1, column: 22 } + }, + name: "✖" + } + } +}])); + +testLoose('Window {', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 8 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 6 } + }, + parts: [{ type: "Identifier", name: "Window" }], + name: "Window" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + }, + members: [] + } +})); + +testLoose('Window {\n\tprop: 3', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 2, column: 8 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 6 } + }, + parts: [{ type: "Identifier", name: "Window" }], + name: "Window" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 7 }, + end: { line: 2, column: 8 } + }, + members: [{ + type: "QMLPropertyBinding", + loc: { + start: { line: 2, column: 1 }, + end: { line: 2, column: 8 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 2, column: 1 }, + end: { line: 2, column: 5 } + }, + parts: [{ type: "Identifier", name: "prop" }], + name: "prop" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 2, column: 7 }, + end: { line: 2, column: 8 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } + }] + } +})); + +testLoose('a {\n\tb {\n\n\tc {\n}', rootObject({ + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 0 }, + end: { line: 5, column: 1 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 1 } + }, + parts: [{ type: "Identifier", name: "a" }], + name: "a" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 2 }, + end: { line: 5, column: 1 } + }, + members: [{ + type: "QMLObjectDefinition", + loc: { + start: { line: 2, column: 1 }, + end: { line: 5, column: 1 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 2, column: 1 }, + end: { line: 2, column: 2 } + }, + parts: [{ type: "Identifier", name: "b" }], + name: "b" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 2, column: 3 }, + end: { line: 5, column: 1 } + }, + members: [{ + type: "QMLObjectDefinition", + loc: { + start: { line: 4, column: 1 }, + end: { line: 5, column: 1 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 4, column: 1 }, + end: { line: 4, column: 2 } + }, + parts: [{ type: "Identifier", name: "c" }], + name: "c" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 4, column: 3 }, + end: { line: 5, column: 1 } + }, + members: [] + } + }] + } + }] + } +})); + +testLoose('a{ property var }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 17 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 17 } + }, + name: "✖" + }, + binding: null +}])); + +testLoose('a{ w }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 5 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "w" }], + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 5 } + }, + script: { + type: "Identifier", + name: "✖" + } + } +}])); + +testLoose('a{ w: }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 7 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "w" }], + name: "w" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 7 } + }, + script: { + type: "Identifier", + name: "✖" + } + } +}])); + +testLoose('a{ : 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 6 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 3 } + }, + parts: [{ type: "Identifier", name: "✖" }], + name: "✖" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 5 }, + end: { line: 1, column: 6 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +testLoose('a{ anchors.: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 14 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + parts: [ + { type: "Identifier", name: "anchors" }, + { type: "Identifier", name: "✖" } + ], + name: "anchors.✖" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 14 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +testLoose('a{ anchors..: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 15 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 12 } + }, + parts: [ + { type: "Identifier", name: "anchors" }, + { type: "Identifier", name: "✖" }, + { type: "Identifier", name: "✖" } + ], + name: "anchors.✖.✖" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 15 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +testLoose('a{ ..: 3 }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 8 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 5 } + }, + parts: [ + { type: "Identifier", name: "✖" }, + { type: "Identifier", name: "✖" }, + { type: "Identifier", name: "✖" } + ], + name: "✖.✖.✖" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + }, + script: { + type: "Literal", + value: 3, + raw: "3" + } + } +}])); + +testLoose('a{ var }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 7 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 6 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 7 } + }, + name: "✖" + }, + binding: null +}])); + +testLoose('a{ var w }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 8 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 6 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + }, + name: "w" + }, + binding: null +}])); + +testLoose('a{ obj w }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 8 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 6 } + }, + primitive: false, + id: { type: "Identifier", name: "obj"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 8 } + }, + name: "w" + }, + binding: null +}])); + +// TODO: Allow this to run with the normal parser once the ambiguity is solved +testLoose('a{ property var b: Window {} }', rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 28 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + }, + name: "b" + }, + binding: { + type: "QMLObjectBinding", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 28 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 25 } + }, + parts: [{ type: "Identifier", name: "Window" }], + name: "Window" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 26 }, + end: { line: 1, column: 28 } + }, + members: [] + } + } +}]), { locations: true, qmltypes: false }); + +// TODO: Allow this to run with the normal parser once the ambiguity is solved +testLoose('a{ b: Window {} }', rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 15 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "b" }], + name: "b" + }, + binding: { + type: "QMLObjectBinding", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 15 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 12 } + }, + parts: [{ type: "Identifier", name: "Window" }], + name: "Window" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 13 }, + end: { line: 1, column: 15 } + }, + members: [] + } + } +}]), { locations: true, qmltypes: false }); + +testLoose('a{ signal }', rootObjectMembers([{ + type: "QMLSignalDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 10 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 10 } + }, + name: "✖" + }, + params: [] +}])); + +testLoose('a{ signal () }', rootObjectMembers([{ + type: "QMLSignalDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 12 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 10 } + }, + name: "✖" + }, + params: [] +}])); + +testLoose('a{ signal test( }', rootObjectMembers([{ + type: "QMLSignalDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 16 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 14 } + }, + name: "test" + }, + params: [] +}])); + +testLoose('a{ signal test(int test }', rootObjectMembers([{ + type: "QMLSignalDefinition", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 24 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 14 } + }, + name: "test" + }, + params: [{ + type: "QMLParameter", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 23 } + }, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 18 } + }, + primitive: true, + id: { type: "Identifier", name: "int" } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 23 } + }, + name: "test" + } + }] +}])); + +testLoose('Window {\n\tfunction\n\tproperty var prop\n}', rootObjectMembers([ + { + type: "FunctionDeclaration", + loc: { + start: { line: 2, column: 1 }, + end: { line: 3, column: 9 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 3, column: 1 }, + end: { line: 3, column: 9 } + }, + name: "property" + }, + params: [], + body: { + type: "BlockStatement", + loc: { + start: { line: 3, column: 9 }, + end: { line: 3, column: 9 } + }, + body: [] + } + }, + { + type: "QMLPropertyDeclaration", + loc: { + start: { line: 3, column: 10 }, + end: { line: 3, column: 18 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 3, column: 10 }, + end: { line: 3, column: 13 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 3, column: 14 }, + end: { line: 3, column: 18 } + }, + name: "prop" + }, + binding: null + } +])); + +testLoose('Window {\n\tfunction (something)\n\tproperty var prop\n}', rootObjectMembers([ + { + type: "FunctionDeclaration", + loc: { + start: { line: 2, column: 1 }, + end: { line: 2, column: 21 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 2, column: 10 }, + end: { line: 2, column: 10 } + }, + name: "✖" + }, + params: [ + { + type: "Identifier", + loc: { + start: { line: 2, column: 11 }, + end: { line: 2, column: 20 } + }, + name: "something" + } + ], + body: { + type: "BlockStatement", + loc: { + start: { line: 2, column: 21 }, + end: { line: 2, column: 21 } + }, + body: [] + } + }, + { + type: "QMLPropertyDeclaration", + loc: { + start: { line: 3, column: 1 }, + end: { line: 3, column: 18 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 3, column: 10 }, + end: { line: 3, column: 13 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 3, column: 14 }, + end: { line: 3, column: 18 } + }, + name: "prop" + }, + binding: null + } +])); + +testLoose('Window {\n\tfunction (\n\tproperty var prop\n}', rootObjectMembers([ + { + type: "FunctionDeclaration", + loc: { + start: { line: 2, column: 1 }, + end: { line: 3, column: 1 } + }, + id: { + type: "Identifier", + loc: { + start: { line: 2, column: 10 }, + end: { line: 2, column: 10 } + }, + name: "✖" + }, + params: [], + body: { + type: "BlockStatement", + loc: { + start: { line: 3, column: 1 }, + end: { line: 3, column: 1 } + }, + body: [] + } + }, + { + type: "QMLPropertyDeclaration", + loc: { + start: { line: 3, column: 1 }, + end: { line: 3, column: 18 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 3, column: 10 }, + end: { line: 3, column: 13 } + }, + primitive: true, + id: { type: "Identifier", name: "var"} + }, + id: { + type: "Identifier", + loc: { + start: { line: 3, column: 14 }, + end: { line: 3, column: 18 } + }, + name: "prop" + }, + binding: null + } +])); + +// TODO: Allow this to run on the normal parser once the ambiguity is solved +testLoose("a{ QtObject on test {} }", rootObjectMembers([{ + type: "QMLPropertyModifier", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 22 } + }, + kind: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + parts: [{ type: "Identifier", name: "QtObject" }], + name: "QtObject" + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 19 } + }, + parts: [{ type: "Identifier", name: "test" }], + name: "test" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 22 } + }, + members: [] + } +}])); + +// TODO: Allow this to run on the normal parser once the ambiguity is solved +testLoose("a{ QtObject on test {} }", rootObjectMembers([{ + type: "QMLPropertyModifier", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 22 } + }, + kind: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 11 } + }, + parts: [{ type: "Identifier", name: "QtObject" }], + name: "QtObject" + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 15 }, + end: { line: 1, column: 19 } + }, + parts: [{ type: "Identifier", name: "test" }], + name: "test" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 20 }, + end: { line: 1, column: 22 } + }, + members: [] + } +}])); + +testLoose("a{ QtObject. on test {} }", rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 23 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 15 } + }, + parts: [ + { type: "Identifier", name: "QtObject" }, + { type: "Identifier", name: "on" } + ], + name: "QtObject.on" + }, + binding: { + type: "QMLObjectBinding", + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 23 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 20 } + }, + parts: [{ type: "Identifier", name: "test" }], + name: "test" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 23 } + }, + members: [] + } + } +}]), { locations: true, qmltypes: false } ); + +// TODO: Allow this to run on the normal parser once the ambiguity is solved +testLoose("a{ s: [ QtObject {} ] }", rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 21 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "s" }], + name: "s" + }, + binding: { + type: "QMLArrayBinding", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 21 } + }, + elements: [ + { + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 19 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 16 } + }, + parts: [{ type: "Identifier", name: "QtObject" }], + name: "QtObject" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 19 } + }, + members: [] + } + } + ] + } +}]), { locations: true, qmltypes: false }); + +// TODO: Allow this to run on the normal parser once the ambiguity is solved +testLoose("a{ s: [ QtObject {}, QtObject {} ] }", rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 34 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "s" }], + name: "s" + }, + binding: { + type: "QMLArrayBinding", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 34 } + }, + elements: [ + { + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 19 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 16 } + }, + parts: [{ type: "Identifier", name: "QtObject" }], + name: "QtObject" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 19 } + }, + members: [] + } + }, + { + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 32 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 29 } + }, + parts: [{ type: "Identifier", name: "QtObject" }], + name: "QtObject" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 32 } + }, + members: [] + } + } + ] + } +}]), { locations: true, qmltypes: false }); + +// TODO: Allow this to run on the normal parser once the ambiguity is solved +testLoose("a{ s: [ QtObject ] }", rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 18 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "s" }], + name: "s" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 18 } + }, + block: false, + script: { + type: "ArrayExpression", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 18 } + }, + elements: [ + { + type: "Identifier", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 16 } + }, + name: "QtObject" + } + ] + } + } +}] +), { locations: true, qmltypes: false }); + +// TODO: Allow this to run on the normal parser once the ambiguity is solved +testLoose("a{ property var s: [ QtObject {} ] }", rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 34 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + }, + primitive: true, + id: { type: "Identifier", name: "var" } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + }, + name: "s" + }, + binding: { + type: "QMLArrayBinding", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 34 } + }, + elements: [ + { + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 32 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 29 } + }, + parts: [{ type: "Identifier", name: "QtObject" }], + name: "QtObject" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 30 }, + end: { line: 1, column: 32 } + }, + members: [] + } + } + ] + } +}]), { locations: true, qmltypes: false }); + +// TODO: Allow this to run on the normal parser once the ambiguity is solved +testLoose("a{ property var s: [ QtObject ] }", rootObjectMembers([{ + type: "QMLPropertyDeclaration", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 31 } + }, + default: false, + readonly: false, + kind: { + type: "QMLPropertyType", + loc: { + start: { line: 1, column: 12 }, + end: { line: 1, column: 15 } + }, + primitive: true, + id: { type: "Identifier", name: "var" } + }, + id: { + type: "Identifier", + loc: { + start: { line: 1, column: 16 }, + end: { line: 1, column: 17 } + }, + name: "s" + }, + binding: { + type: "QMLScriptBinding", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 31 } + }, + block: false, + script: { + type: "ArrayExpression", + loc: { + start: { line: 1, column: 19 }, + end: { line: 1, column: 31 } + }, + elements: [ + { + type: "Identifier", + loc: { + start: { line: 1, column: 21 }, + end: { line: 1, column: 29 } + }, + name: "QtObject" + } + ] + } + } +}]), { locations: true, qmltypes: false }); + +testLoose("a{ s: [ QtObject {} }", rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 20 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "s" }], + name: "s" + }, + binding: { + type: "QMLArrayBinding", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 20 } + }, + elements: [ + { + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 19 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 16 } + }, + parts: [{ type: "Identifier", name: "QtObject" }], + name: "QtObject" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 19 } + }, + members: [] + } + } + ] + } +}]), { locations: true, qmltypes: false }); + +testLoose("a{ s: [ QtObject { ] }", rootObjectMembers([{ + type: "QMLPropertyBinding", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 22 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 3 }, + end: { line: 1, column: 4 } + }, + parts: [{ type: "Identifier", name: "s" }], + name: "s" + }, + binding: { + type: "QMLArrayBinding", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 22 } + }, + elements: [ + { + type: "QMLObjectDefinition", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 22 } + }, + id: { + type: "QMLQualifiedID", + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 16 } + }, + parts: [{ type: "Identifier", name: "QtObject" }], + name: "QtObject" + }, + body: { + type: "QMLObjectInitializer", + loc: { + start: { line: 1, column: 17 }, + end: { line: 1, column: 22 } + }, + members: [] + } + } + ] + } +}]), { locations: true, qmltypes: false }); + +/*************************************************************************** +* QMLTypes Parser Tests * +****************************************************************************/ +function testQMLTypes(code, ast, options) { + var opts = options || {}; + opts.qmltypes = true; + opts.locations = true; + test(code, ast, opts); +} + +testQMLTypes("a{ b: {} }", javaScript({ + type: "ObjectExpression", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 8 } + }, + properties: [] +})); + +testQMLTypes('a{ b: "test" }', javaScript({ + type: "Literal", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 12 } + }, + value: "test", + raw: '"test"' +})); + +testQMLTypes('a{ b: ["one", "two"] }', javaScript({ + type: "ArrayExpression", + loc: { + start: { line: 1, column: 6 }, + end: { line: 1, column: 20 } + }, + elements: [ + { + type: "Literal", + loc: { + start: { line: 1, column: 7 }, + end: { line: 1, column: 12 } + }, + value: "one", + raw: '"one"' + }, + { + type: "Literal", + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 19 } + }, + value: "two", + raw: '"two"' + } + ] +})); + +/* +* Creates a Program with 'headerItemList' and 'rootObject' as the program's expected +* body. +*/ +function program(headerItemList, rootObject) { + return { + type: "QMLProgram", + headerItemList: { + type: "QMLHeaderItemList", + items: headerItemList || [] + }, + rootObject: rootObject || null + }; +} + +/* +* Creates a QMLHeaderItemList with 'stmts' as the expected statements and 'prog' as the +* parent Program. A value of null for 'prog' will append the QMLHeaderItemList AST to +* the Program returned by program(). +*/ +function headerItemList(items, prog) { + prog = prog || program(); + prog.headerItemList.items = items; + return prog; +} + +/* +* Creates a QMLObjectDefinition with 'stmts' as the expected statements and 'prog' as the parent +* Program. A value of null for 'prog' will append the QMLObjectDefinition AST to the Program +* returned by program(). +*/ +function rootObject(obj, prog) { + prog = prog || program(); + prog.rootObject = obj; + return prog; +} + +/* +* Creates a QMLObjectInitializer with 'members' as the expected members and 'obj' as the parent +* QMLObjectDefinition. A value of null for 'obj' will append the QMLObjectInitializer AST to the +* QMLObjectDefinition returned by rootObject(). +*/ +function rootObjectMembers(members, obj) { + var rootObj = obj || rootObject({ + type: "QMLObjectDefinition", + body: { + type: "QMLObjectInitializer", + members: members + } + }); + return rootObj; +} + +/* +* Creates a JavaScript Expression with 'expr' as the expected expression and 'objMembers' as +* the parent QMLObjectInitializer. A value of null for 'objMembers' will append the JavaScript +* Expression to the QMLObjectInitializer returned by rootObjectMembers(). +*/ +function javaScript(expr, objMembers) { + objMembers = objMembers || rootObjectMembers([{ + type: "QMLPropertyBinding", + binding: { + type: "QMLScriptBinding", + script: expr + } + }]); + return objMembers; }
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/acorn-qml/walk/index.js b/qt/org.eclipse.cdt.qt.core/acorn-qml/walk/index.js index a1883ac501f..09063fc7034 100644 --- a/qt/org.eclipse.cdt.qt.core/acorn-qml/walk/index.js +++ b/qt/org.eclipse.cdt.qt.core/acorn-qml/walk/index.js @@ -1,85 +1,85 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-(function (mod) {
- if (typeof exports == "object" && typeof module == "object") // CommonJS
- return mod(require("acorn/dist/walk"));
- if (typeof define == "function" && define.amd) // AMD
- return define(["acorn/dist/walk"], mod);
- mod(acorn.walk); // Plain browser env
-})(function (walk) {
- "use strict";
-
- function skipThrough(node, st, c) {
- c(node, st);
- }
-
- function ignore(node, st, c) {}
-
- function extendWalk(walker, funcs) {
- for (var prop in funcs) {
- walker[prop] = funcs[prop];
- }
- }
-
- extendWalk(walk.base, {
- QMLProgram: function (node, st, c) {
- c(node.headerItemList, st);
- if (node.rootObject) {
- c(node.rootObject, st, "QMLRootObject");
- }
- },
- QMLHeaderItemList: function (node, st, c) {
- for (var i = 0; i < node.items.length; i++) {
- c(node.items[i], st, "QMLHeaderItem");
- }
- },
- QMLHeaderItem: skipThrough,
- QMLImport: ignore,
- QMLPragma: ignore,
- QMLRootObject: skipThrough,
- QMLObjectDefinition: function (node, st, c) {
- c(node.body, st);
- },
- QMLObjectInitializer: function (node, st, c) {
- for (var i = 0; i < node.members.length; i++) {
- c(node.members[i], st, "QMLObjectMember");
- }
- },
- QMLObjectMember: skipThrough,
- QMLPropertyDeclaration: function (node, st, c) {
- if (node.binding) {
- c(node.binding, st, "QMLBinding");
- }
- },
- QMLSignalDefinition: ignore,
- QMLPropertyBinding: function (node, st, c) {
- 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.body.length; i++) {
- c(node.body[i], st, "Statement");
- }
- }
- });
+/******************************************************************************* + * 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 + *******************************************************************************/ +(function (mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + return mod(require("acorn/dist/walk")); + if (typeof define == "function" && define.amd) // AMD + return define(["acorn/dist/walk"], mod); + mod(acorn.walk); // Plain browser env +})(function (walk) { + "use strict"; + + function skipThrough(node, st, c) { + c(node, st); + } + + function ignore(node, st, c) {} + + function extendWalk(walker, funcs) { + for (var prop in funcs) { + walker[prop] = funcs[prop]; + } + } + + extendWalk(walk.base, { + QMLProgram: function (node, st, c) { + c(node.headerItemList, st); + if (node.rootObject) { + c(node.rootObject, st, "QMLRootObject"); + } + }, + QMLHeaderItemList: function (node, st, c) { + for (var i = 0; i < node.items.length; i++) { + c(node.items[i], st, "QMLHeaderItem"); + } + }, + QMLHeaderItem: skipThrough, + QMLImport: ignore, + QMLPragma: ignore, + QMLRootObject: skipThrough, + QMLObjectDefinition: function (node, st, c) { + c(node.body, st); + }, + QMLObjectInitializer: function (node, st, c) { + for (var i = 0; i < node.members.length; i++) { + c(node.members[i], st, "QMLObjectMember"); + } + }, + QMLObjectMember: skipThrough, + QMLPropertyDeclaration: function (node, st, c) { + if (node.binding) { + c(node.binding, st, "QMLBinding"); + } + }, + QMLSignalDefinition: ignore, + QMLPropertyBinding: function (node, st, c) { + 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.body.length; i++) { + c(node.body[i], st, "Statement"); + } + } + }); });
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QMLModuleResolver.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QMLModuleResolver.java index 602533ee129..40d91caec70 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QMLModuleResolver.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QMLModuleResolver.java @@ -1,99 +1,99 @@ -/*******************************************************************************
- * 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.internal.qt.core;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Path;
-
-import javax.script.ScriptException;
-
-import org.eclipse.cdt.internal.qt.core.qmltypes.QMLModelBuilder;
-import org.eclipse.cdt.internal.qt.core.qmltypes.QMLModuleInfo;
-import org.eclipse.cdt.qt.core.IQtInstall;
-import org.eclipse.cdt.qt.core.IQtInstallManager;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryInfo;
-import org.eclipse.cdt.qt.core.qmljs.IQmlASTNode;
-
-public class QMLModuleResolver {
- private final QMLAnalyzer analyzer;
- private final IQtInstallManager manager;
- private final QMLModelBuilder builder;
-
- public QMLModuleResolver(QMLAnalyzer analyzer) {
- this.analyzer = analyzer;
- this.manager = Activator.getService(IQtInstallManager.class);
- this.builder = new QMLModelBuilder();
- }
-
- // TODO: determine exactly how to give this to Tern. For now we'll just return the reference to the QMLModuleInfo
- // that we found
- public QMLModuleInfo resolveModule(String module) throws NoSuchMethodException, ScriptException {
- QMLModuleInfo info = builder.getModule(module);
- if (info == null) {
- Path path = getModulePath(module);
- if (path != null) {
- File qmldir = path.resolve("qmldir").normalize().toFile(); //$NON-NLS-1$
- try {
- String types = getQmlTypesFile(qmldir);
- File qmlTypes = path.resolve(types).toFile();
- String typeContents = fileToString(qmlTypes);
- IQmlASTNode ast = analyzer.parseString(typeContents, "qmltypes", false, false); //$NON-NLS-1$
- info = builder.addModule(module, ast);
- } catch (IOException e) {
- Activator.log(e);
- }
- }
- }
- return info;
- }
-
- private String fileToString(File file) throws IOException {
- try (InputStream stream = new FileInputStream(file)) {
- StringBuilder sb = new StringBuilder();
- int read = -1;
- while ((read = stream.read()) != -1) {
- sb.append((char) read);
- }
- return sb.toString();
- }
- }
-
- private String getQmlTypesFile(File qmldir) throws IOException {
- try (InputStream stream = new FileInputStream(qmldir)) {
- QMLDirectoryInfo info = new QMLDirectoryInfo(stream);
- return info.getTypesFileName();
- }
- }
-
- private Path getModulePath(String module) {
- if (module != null) {
- for (IQtInstall install : manager.getInstalls()) {
- Path qmlPath = install.getQmlPath();
- Path modPath = null;
- if (module.equals("QtQuick")) { //$NON-NLS-1$
- modPath = qmlPath.resolve("QtQuick.2").normalize(); //$NON-NLS-1$
- } else {
- modPath = qmlPath;
- for (String part : module.split("\\.")) { //$NON-NLS-1$
- modPath = modPath.resolve(part).normalize();
- }
- }
- if (modPath.toFile().exists()) {
- return modPath;
- }
- }
- }
- return null;
- }
-}
+/******************************************************************************* + * 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.internal.qt.core; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Path; + +import javax.script.ScriptException; + +import org.eclipse.cdt.internal.qt.core.qmltypes.QMLModelBuilder; +import org.eclipse.cdt.internal.qt.core.qmltypes.QMLModuleInfo; +import org.eclipse.cdt.qt.core.IQtInstall; +import org.eclipse.cdt.qt.core.IQtInstallManager; +import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryInfo; +import org.eclipse.cdt.qt.core.qmljs.IQmlASTNode; + +public class QMLModuleResolver { + private final QMLAnalyzer analyzer; + private final IQtInstallManager manager; + private final QMLModelBuilder builder; + + public QMLModuleResolver(QMLAnalyzer analyzer) { + this.analyzer = analyzer; + this.manager = Activator.getService(IQtInstallManager.class); + this.builder = new QMLModelBuilder(); + } + + // TODO: determine exactly how to give this to Tern. For now we'll just return the reference to the QMLModuleInfo + // that we found + public QMLModuleInfo resolveModule(String module) throws NoSuchMethodException, ScriptException { + QMLModuleInfo info = builder.getModule(module); + if (info == null) { + Path path = getModulePath(module); + if (path != null) { + File qmldir = path.resolve("qmldir").normalize().toFile(); //$NON-NLS-1$ + try { + String types = getQmlTypesFile(qmldir); + File qmlTypes = path.resolve(types).toFile(); + String typeContents = fileToString(qmlTypes); + IQmlASTNode ast = analyzer.parseString(typeContents, "qmltypes", false, false); //$NON-NLS-1$ + info = builder.addModule(module, ast); + } catch (IOException e) { + Activator.log(e); + } + } + } + return info; + } + + private String fileToString(File file) throws IOException { + try (InputStream stream = new FileInputStream(file)) { + StringBuilder sb = new StringBuilder(); + int read = -1; + while ((read = stream.read()) != -1) { + sb.append((char) read); + } + return sb.toString(); + } + } + + private String getQmlTypesFile(File qmldir) throws IOException { + try (InputStream stream = new FileInputStream(qmldir)) { + QMLDirectoryInfo info = new QMLDirectoryInfo(stream); + return info.getTypesFileName(); + } + } + + private Path getModulePath(String module) { + if (module != null) { + for (IQtInstall install : manager.getInstalls()) { + Path qmlPath = install.getQmlPath(); + Path modPath = null; + if (module.equals("QtQuick")) { //$NON-NLS-1$ + modPath = qmlPath.resolve("QtQuick.2").normalize(); //$NON-NLS-1$ + } else { + modPath = qmlPath; + for (String part : module.split("\\.")) { //$NON-NLS-1$ + modPath = modPath.resolve(part).normalize(); + } + } + if (modPath.toFile().exists()) { + return modPath; + } + } + } + return null; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QmlASTNodeHandler.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QmlASTNodeHandler.java index 46e98663935..1e2d4e8fce1 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QmlASTNodeHandler.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QmlASTNodeHandler.java @@ -1,252 +1,252 @@ -/*******************************************************************************
- * Copyright (c) 2015, 2016 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.internal.qt.core;
-
-import java.lang.invoke.MethodHandles;
-import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.script.Bindings;
-
-import org.eclipse.cdt.internal.qt.core.location.Position;
-import org.eclipse.cdt.internal.qt.core.location.SourceLocation;
-import org.eclipse.cdt.qt.core.IQMLAnalyzer;
-import org.eclipse.cdt.qt.core.location.ISourceLocation;
-import org.eclipse.cdt.qt.core.qmljs.IJSLiteral;
-import org.eclipse.cdt.qt.core.qmljs.IJSRegExpLiteral;
-import org.eclipse.cdt.qt.core.qmljs.IQmlASTNode;
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition;
-import org.eclipse.cdt.qt.core.qmljs.IQmlRootObject;
-
-/**
- * Translates a JavaScript {@link Bindings} object into a QML AST. This class employs {@link java.lang.reflect.Proxy} in order to
- * dynamically create the AST at runtime.
- * <p>
- * To begin translation simply call the static method <code>createQmlASTProxy</code>. The AST is translated only when it needs to be
- * (i.e. when one of its 'get' methods are called).
- */
-public class QmlASTNodeHandler implements InvocationHandler {
- private static final String NODE_QML_PREFIX = "QML"; //$NON-NLS-1$
- private static final String NODE_TYPE_PROPERTY = "type"; //$NON-NLS-1$
- private static final String NODE_REGEX_PROPERTY = "regex"; //$NON-NLS-1$
- private static final String CREATE_ENUM_METHOD = "fromObject"; //$NON-NLS-1$
- private static final String AST_PACKAGE = "org.eclipse.cdt.qt.core.qmljs."; //$NON-NLS-1$
- private static final String AST_QML_PREFIX = "IQml"; //$NON-NLS-1$
- private static final String AST_JS_PREFIX = "IJS"; //$NON-NLS-1$
-
- private static String getPropertyName(String method) {
- String name = ""; //$NON-NLS-1$
- if (method.startsWith("is")) { //$NON-NLS-1$
- name = method.substring(2, 3).toLowerCase() + method.substring(3);
- } else if (method.startsWith("get")) { //$NON-NLS-1$
- name = method.substring(3, 4).toLowerCase() + method.substring(4);
- }
- if (name.equalsIgnoreCase("identifier")) { //$NON-NLS-1$
- return "id"; //$NON-NLS-1$
- } else if (name.equalsIgnoreCase("location")) { //$NON-NLS-1$
- return "loc"; //$NON-NLS-1$
- }
- return name;
- }
-
- /**
- * Constructs a new {@link IQmlASTNode} from the given {@link Bindings}. This is a helper method equivalent to
- * <code>createQmlASTProxy(node, null)</code>
- *
- * @param node
- * the AST node as retrieved from Nashorn
- * @return a Proxy representing the given node
- * @throws ClassNotFoundException
- * if the node does not represent a valid QML AST Node
- * @see {@link QmlASTNodeHandler#createQmlASTProxy(Bindings, Class)}
- */
- public static IQmlASTNode createQmlASTProxy(Bindings node) throws ClassNotFoundException {
- return createQmlASTProxy(node, null);
- }
-
- /**
- * Constructs a new {@link IQmlASTNode} from the given {@link Bindings}. If a return type is specified, it will take precedence
- * over the type retrieved from the binding. This is useful for nodes that extend, but do not add functionality to, an acorn AST
- * element. A good example of this is {@link IQmlRootObject} which extends {@link IQmlObjectDefinition}. We can easily determine
- * the location in the AST at which we want an IQmlRootObject over an IQmlObjectDefinition and set the returnType accordingly.
- *
- * @param node
- * the node as retrieved from acorn
- * @param returnType
- * the expected node to return or null
- * @return a Proxy representing the given node
- * @throws ClassNotFoundException
- * if the node does not represent a valid QML AST Node
- */
- public static IQmlASTNode createQmlASTProxy(Bindings node, Class<?> returnType) throws ClassNotFoundException {
- String type = (String) node.getOrDefault(NODE_TYPE_PROPERTY, ""); //$NON-NLS-1$
- if (type.startsWith(NODE_QML_PREFIX)) {
- type = AST_QML_PREFIX + type.substring(3);
- } else {
- type = AST_JS_PREFIX + type;
- }
- Class<?> astClass = Class.forName(AST_PACKAGE + type);
- if (astClass.equals(IJSLiteral.class)) {
- // If this is a Literal, we have to distinguish it between a RegExp Literal using the 'regex' property
- if (node.get(NODE_REGEX_PROPERTY) != null) {
- astClass = IJSRegExpLiteral.class;
- }
- }
- if (returnType != null) {
- if (!IQmlASTNode.class.isAssignableFrom(astClass)) {
- throw new ClassCastException(astClass + " cannot be cast to " + IQmlASTNode.class); //$NON-NLS-1$
- }
- if (astClass.isAssignableFrom(returnType)) {
- astClass = returnType;
- }
- }
- return (IQmlASTNode) Proxy.newProxyInstance(QmlASTNodeHandler.class.getClassLoader(),
- new Class<?>[] { astClass },
- new QmlASTNodeHandler(node));
- }
-
- private final QMLAnalyzer analyzer;
- private final Bindings node;
- private final Map<String, Object> methodResults;
-
- private QmlASTNodeHandler(Bindings node) {
- this.analyzer = (QMLAnalyzer) Activator.getService(IQMLAnalyzer.class);
- this.node = node;
- this.methodResults = new HashMap<>();
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- String mName = method.getName();
- if (!methodResults.containsKey(method.getName())) {
- // Invoke the default implementation of the method if possible
- if (method.isDefault()) {
- final Class<?> declaringClass = method.getDeclaringClass();
- Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class.getDeclaredConstructor(Class.class,
- int.class);
- constructor.setAccessible(true);
- methodResults.put(mName, constructor.newInstance(declaringClass, MethodHandles.Lookup.PRIVATE)
- .unreflectSpecial(method, declaringClass)
- .bindTo(proxy)
- .invokeWithArguments(args));
- } else {
- // Use the return type of the method as well as its contents of the node to get the Object to return
- String pName = getPropertyName(mName);
- methodResults.put(mName, handleObject(node.get(pName), method.getReturnType()));
- }
- }
- return methodResults.get(mName);
- }
-
- private Object handleObject(Object value, Class<?> expectedType) throws Throwable {
- if (expectedType.isArray()) {
- Object arr = Array.newInstance(expectedType.getComponentType(), ((Bindings) value).size());
- int ctr = 0;
- for (Object obj : ((Bindings) value).values()) {
- Array.set(arr, ctr++, handleObject(obj, expectedType.getComponentType()));
- }
- return arr;
- } else if (expectedType.equals(Object.class)) {
- return value;
- } else if (expectedType.isAssignableFrom(ISourceLocation.class)) {
- // ISourceLocation doesn't correspond to an AST Node and needs to be created manually from
- // the given Bindings.
- if (value instanceof Bindings) {
- Bindings bind = (Bindings) value;
- SourceLocation loc = new SourceLocation();
- loc.setSource((String) bind.get("source")); //$NON-NLS-1$
- Bindings start = (Bindings) bind.get("start"); //$NON-NLS-1$
- loc.setStart(new Position(((Number) start.get("line")).intValue(), //$NON-NLS-1$
- ((Number) start.get("column")).intValue())); //$NON-NLS-1$
- Bindings end = (Bindings) bind.get("end"); //$NON-NLS-1$
- loc.setEnd(new Position(((Number) end.get("line")).intValue(), //$NON-NLS-1$
- ((Number) end.get("column")).intValue())); //$NON-NLS-1$
- return loc;
- }
- return new SourceLocation();
- } else if (expectedType.isAssignableFrom(List.class)) {
- if (value instanceof Bindings) {
- List<Object> list = new ArrayList<>();
- for (Bindings object : analyzer.toJavaArray((Bindings) value, Bindings[].class)) {
- list.add(QmlASTNodeHandler.createQmlASTProxy(object));
- }
- return list;
- }
- return null;
- } else if (expectedType.isPrimitive()) {
- return handlePrimitive(value, expectedType);
- } else if (expectedType.isAssignableFrom(Number.class)) {
- if (value instanceof Number) {
- return value;
- }
- return 0;
- } else if (expectedType.isEnum()) {
- return expectedType.getMethod(CREATE_ENUM_METHOD, Object.class).invoke(null, value);
- } else if (value instanceof Bindings) {
- return QmlASTNodeHandler.createQmlASTProxy((Bindings) value, expectedType);
- }
- return value;
- }
-
- private Object handlePrimitive(Object value, Class<?> expectedType) throws Throwable {
- if (expectedType.isPrimitive()) {
- if (expectedType.equals(Boolean.TYPE)) {
- if (value instanceof Boolean) {
- return value;
- }
- return false;
- } else if (expectedType.equals(Character.TYPE)) {
- if (value instanceof Character) {
- return value;
- }
- return '\0';
- } else if (expectedType.equals(Byte.TYPE)) {
- if (value instanceof Number) {
- return ((Number) value).byteValue();
- }
- return (byte) 0;
- } else if (expectedType.equals(Short.TYPE)) {
- if (value instanceof Number) {
- return ((Number) value).shortValue();
- }
- return (short) 0;
- } else if (expectedType.equals(Integer.TYPE)) {
- if (value instanceof Number) {
- return ((Number) value).intValue();
- }
- return 0;
- } else if (expectedType.equals(Long.TYPE)) {
- if (value instanceof Number) {
- return ((Number) value).longValue();
- }
- return 0l;
- } else if (expectedType.equals(Float.TYPE)) {
- if (value instanceof Number) {
- return ((Number) value).floatValue();
- }
- return 0.0f;
- } else if (expectedType.equals(Double.TYPE)) {
- if (value instanceof Number) {
- return ((Number) value).doubleValue();
- }
- return 0.0d;
- }
- }
- throw new IllegalArgumentException("expectedType was not a primitive type"); //$NON-NLS-1$
- }
-}
+/******************************************************************************* + * Copyright (c) 2015, 2016 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.internal.qt.core; + +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.script.Bindings; + +import org.eclipse.cdt.internal.qt.core.location.Position; +import org.eclipse.cdt.internal.qt.core.location.SourceLocation; +import org.eclipse.cdt.qt.core.IQMLAnalyzer; +import org.eclipse.cdt.qt.core.location.ISourceLocation; +import org.eclipse.cdt.qt.core.qmljs.IJSLiteral; +import org.eclipse.cdt.qt.core.qmljs.IJSRegExpLiteral; +import org.eclipse.cdt.qt.core.qmljs.IQmlASTNode; +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition; +import org.eclipse.cdt.qt.core.qmljs.IQmlRootObject; + +/** + * Translates a JavaScript {@link Bindings} object into a QML AST. This class employs {@link java.lang.reflect.Proxy} in order to + * dynamically create the AST at runtime. + * <p> + * To begin translation simply call the static method <code>createQmlASTProxy</code>. The AST is translated only when it needs to be + * (i.e. when one of its 'get' methods are called). + */ +public class QmlASTNodeHandler implements InvocationHandler { + private static final String NODE_QML_PREFIX = "QML"; //$NON-NLS-1$ + private static final String NODE_TYPE_PROPERTY = "type"; //$NON-NLS-1$ + private static final String NODE_REGEX_PROPERTY = "regex"; //$NON-NLS-1$ + private static final String CREATE_ENUM_METHOD = "fromObject"; //$NON-NLS-1$ + private static final String AST_PACKAGE = "org.eclipse.cdt.qt.core.qmljs."; //$NON-NLS-1$ + private static final String AST_QML_PREFIX = "IQml"; //$NON-NLS-1$ + private static final String AST_JS_PREFIX = "IJS"; //$NON-NLS-1$ + + private static String getPropertyName(String method) { + String name = ""; //$NON-NLS-1$ + if (method.startsWith("is")) { //$NON-NLS-1$ + name = method.substring(2, 3).toLowerCase() + method.substring(3); + } else if (method.startsWith("get")) { //$NON-NLS-1$ + name = method.substring(3, 4).toLowerCase() + method.substring(4); + } + if (name.equalsIgnoreCase("identifier")) { //$NON-NLS-1$ + return "id"; //$NON-NLS-1$ + } else if (name.equalsIgnoreCase("location")) { //$NON-NLS-1$ + return "loc"; //$NON-NLS-1$ + } + return name; + } + + /** + * Constructs a new {@link IQmlASTNode} from the given {@link Bindings}. This is a helper method equivalent to + * <code>createQmlASTProxy(node, null)</code> + * + * @param node + * the AST node as retrieved from Nashorn + * @return a Proxy representing the given node + * @throws ClassNotFoundException + * if the node does not represent a valid QML AST Node + * @see {@link QmlASTNodeHandler#createQmlASTProxy(Bindings, Class)} + */ + public static IQmlASTNode createQmlASTProxy(Bindings node) throws ClassNotFoundException { + return createQmlASTProxy(node, null); + } + + /** + * Constructs a new {@link IQmlASTNode} from the given {@link Bindings}. If a return type is specified, it will take precedence + * over the type retrieved from the binding. This is useful for nodes that extend, but do not add functionality to, an acorn AST + * element. A good example of this is {@link IQmlRootObject} which extends {@link IQmlObjectDefinition}. We can easily determine + * the location in the AST at which we want an IQmlRootObject over an IQmlObjectDefinition and set the returnType accordingly. + * + * @param node + * the node as retrieved from acorn + * @param returnType + * the expected node to return or null + * @return a Proxy representing the given node + * @throws ClassNotFoundException + * if the node does not represent a valid QML AST Node + */ + public static IQmlASTNode createQmlASTProxy(Bindings node, Class<?> returnType) throws ClassNotFoundException { + String type = (String) node.getOrDefault(NODE_TYPE_PROPERTY, ""); //$NON-NLS-1$ + if (type.startsWith(NODE_QML_PREFIX)) { + type = AST_QML_PREFIX + type.substring(3); + } else { + type = AST_JS_PREFIX + type; + } + Class<?> astClass = Class.forName(AST_PACKAGE + type); + if (astClass.equals(IJSLiteral.class)) { + // If this is a Literal, we have to distinguish it between a RegExp Literal using the 'regex' property + if (node.get(NODE_REGEX_PROPERTY) != null) { + astClass = IJSRegExpLiteral.class; + } + } + if (returnType != null) { + if (!IQmlASTNode.class.isAssignableFrom(astClass)) { + throw new ClassCastException(astClass + " cannot be cast to " + IQmlASTNode.class); //$NON-NLS-1$ + } + if (astClass.isAssignableFrom(returnType)) { + astClass = returnType; + } + } + return (IQmlASTNode) Proxy.newProxyInstance(QmlASTNodeHandler.class.getClassLoader(), + new Class<?>[] { astClass }, + new QmlASTNodeHandler(node)); + } + + private final QMLAnalyzer analyzer; + private final Bindings node; + private final Map<String, Object> methodResults; + + private QmlASTNodeHandler(Bindings node) { + this.analyzer = (QMLAnalyzer) Activator.getService(IQMLAnalyzer.class); + this.node = node; + this.methodResults = new HashMap<>(); + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + String mName = method.getName(); + if (!methodResults.containsKey(method.getName())) { + // Invoke the default implementation of the method if possible + if (method.isDefault()) { + final Class<?> declaringClass = method.getDeclaringClass(); + Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class.getDeclaredConstructor(Class.class, + int.class); + constructor.setAccessible(true); + methodResults.put(mName, constructor.newInstance(declaringClass, MethodHandles.Lookup.PRIVATE) + .unreflectSpecial(method, declaringClass) + .bindTo(proxy) + .invokeWithArguments(args)); + } else { + // Use the return type of the method as well as its contents of the node to get the Object to return + String pName = getPropertyName(mName); + methodResults.put(mName, handleObject(node.get(pName), method.getReturnType())); + } + } + return methodResults.get(mName); + } + + private Object handleObject(Object value, Class<?> expectedType) throws Throwable { + if (expectedType.isArray()) { + Object arr = Array.newInstance(expectedType.getComponentType(), ((Bindings) value).size()); + int ctr = 0; + for (Object obj : ((Bindings) value).values()) { + Array.set(arr, ctr++, handleObject(obj, expectedType.getComponentType())); + } + return arr; + } else if (expectedType.equals(Object.class)) { + return value; + } else if (expectedType.isAssignableFrom(ISourceLocation.class)) { + // ISourceLocation doesn't correspond to an AST Node and needs to be created manually from + // the given Bindings. + if (value instanceof Bindings) { + Bindings bind = (Bindings) value; + SourceLocation loc = new SourceLocation(); + loc.setSource((String) bind.get("source")); //$NON-NLS-1$ + Bindings start = (Bindings) bind.get("start"); //$NON-NLS-1$ + loc.setStart(new Position(((Number) start.get("line")).intValue(), //$NON-NLS-1$ + ((Number) start.get("column")).intValue())); //$NON-NLS-1$ + Bindings end = (Bindings) bind.get("end"); //$NON-NLS-1$ + loc.setEnd(new Position(((Number) end.get("line")).intValue(), //$NON-NLS-1$ + ((Number) end.get("column")).intValue())); //$NON-NLS-1$ + return loc; + } + return new SourceLocation(); + } else if (expectedType.isAssignableFrom(List.class)) { + if (value instanceof Bindings) { + List<Object> list = new ArrayList<>(); + for (Bindings object : analyzer.toJavaArray((Bindings) value, Bindings[].class)) { + list.add(QmlASTNodeHandler.createQmlASTProxy(object)); + } + return list; + } + return null; + } else if (expectedType.isPrimitive()) { + return handlePrimitive(value, expectedType); + } else if (expectedType.isAssignableFrom(Number.class)) { + if (value instanceof Number) { + return value; + } + return 0; + } else if (expectedType.isEnum()) { + return expectedType.getMethod(CREATE_ENUM_METHOD, Object.class).invoke(null, value); + } else if (value instanceof Bindings) { + return QmlASTNodeHandler.createQmlASTProxy((Bindings) value, expectedType); + } + return value; + } + + private Object handlePrimitive(Object value, Class<?> expectedType) throws Throwable { + if (expectedType.isPrimitive()) { + if (expectedType.equals(Boolean.TYPE)) { + if (value instanceof Boolean) { + return value; + } + return false; + } else if (expectedType.equals(Character.TYPE)) { + if (value instanceof Character) { + return value; + } + return '\0'; + } else if (expectedType.equals(Byte.TYPE)) { + if (value instanceof Number) { + return ((Number) value).byteValue(); + } + return (byte) 0; + } else if (expectedType.equals(Short.TYPE)) { + if (value instanceof Number) { + return ((Number) value).shortValue(); + } + return (short) 0; + } else if (expectedType.equals(Integer.TYPE)) { + if (value instanceof Number) { + return ((Number) value).intValue(); + } + return 0; + } else if (expectedType.equals(Long.TYPE)) { + if (value instanceof Number) { + return ((Number) value).longValue(); + } + return 0l; + } else if (expectedType.equals(Float.TYPE)) { + if (value instanceof Number) { + return ((Number) value).floatValue(); + } + return 0.0f; + } else if (expectedType.equals(Double.TYPE)) { + if (value instanceof Number) { + return ((Number) value).doubleValue(); + } + return 0.0d; + } + } + throw new IllegalArgumentException("expectedType was not a primitive type"); //$NON-NLS-1$ + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/Position.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/Position.java index 1ec2df36bb8..b8cdfc6fa06 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/Position.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/Position.java @@ -1,38 +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.internal.qt.core.location;
-
-import org.eclipse.cdt.qt.core.location.IPosition;
-
-public class Position implements IPosition {
- private final int line;
- private final int column;
-
- public Position(int line, int column) {
- this.line = line;
- this.column = column;
- }
-
- @Override
- public int getLine() {
- return line;
- }
-
- @Override
- public int getColumn() {
- return column;
- }
-
- @Override
- public String toString() {
- return "(" + line + ":" + column + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-}
+/******************************************************************************* + * 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.internal.qt.core.location; + +import org.eclipse.cdt.qt.core.location.IPosition; + +public class Position implements IPosition { + private final int line; + private final int column; + + public Position(int line, int column) { + this.line = line; + this.column = column; + } + + @Override + public int getLine() { + return line; + } + + @Override + public int getColumn() { + return column; + } + + @Override + public String toString() { + return "(" + line + ":" + column + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/SourceLocation.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/SourceLocation.java index d1a702a7720..12e42a241d9 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/SourceLocation.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/SourceLocation.java @@ -1,58 +1,58 @@ -/*******************************************************************************
- * 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.internal.qt.core.location;
-
-import org.eclipse.cdt.qt.core.location.IPosition;
-import org.eclipse.cdt.qt.core.location.ISourceLocation;
-
-public class SourceLocation implements ISourceLocation {
- private String source;
- private IPosition start;
- private IPosition end;
-
- public SourceLocation() {
- this(null, null, null);
- }
-
- public SourceLocation(String source, IPosition start, IPosition end) {
- this.source = source;
- this.start = start;
- this.end = end;
- }
-
- public void setSource(String value) {
- this.source = value;
- }
-
- @Override
- public String getSource() {
- return source;
- }
-
- public void setStart(IPosition value) {
- this.start = value;
- }
-
- @Override
- public IPosition getStart() {
- return start;
- }
-
- public void setEnd(IPosition value) {
- this.end = value;
- }
-
- @Override
- public IPosition getEnd() {
- return end;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.location; + +import org.eclipse.cdt.qt.core.location.IPosition; +import org.eclipse.cdt.qt.core.location.ISourceLocation; + +public class SourceLocation implements ISourceLocation { + private String source; + private IPosition start; + private IPosition end; + + public SourceLocation() { + this(null, null, null); + } + + public SourceLocation(String source, IPosition start, IPosition end) { + this.source = source; + this.start = start; + this.end = end; + } + + public void setSource(String value) { + this.source = value; + } + + @Override + public String getSource() { + return source; + } + + public void setStart(IPosition value) { + this.start = value; + } + + @Override + public IPosition getStart() { + return start; + } + + public void setEnd(IPosition value) { + this.end = value; + } + + @Override + public IPosition getEnd() { + return end; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirAST.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirAST.java index 78f0f3e62eb..5a618546840 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirAST.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirAST.java @@ -1,36 +1,36 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmldir;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirAST;
-import org.eclipse.cdt.qt.core.qmldir.IQDirCommand;
-
-public class QDirAST extends QDirASTNode implements IQDirAST {
- private final List<IQDirCommand> commands;
-
- public QDirAST() {
- commands = new ArrayList<>();
- }
-
- public void addCommand(IQDirCommand command) {
- commands.add(command);
- }
-
- @Override
- public List<IQDirCommand> getCommands() {
- return Collections.unmodifiableList(commands);
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.qt.core.qmldir.IQDirAST; +import org.eclipse.cdt.qt.core.qmldir.IQDirCommand; + +public class QDirAST extends QDirASTNode implements IQDirAST { + private final List<IQDirCommand> commands; + + public QDirAST() { + commands = new ArrayList<>(); + } + + public void addCommand(IQDirCommand command) { + commands.add(command); + } + + @Override + public List<IQDirCommand> getCommands() { + return Collections.unmodifiableList(commands); + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirASTNode.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirASTNode.java index a3fd9322755..1a9e3ef4fd0 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirASTNode.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirASTNode.java @@ -1,55 +1,55 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.internal.qt.core.location.SourceLocation;
-import org.eclipse.cdt.qt.core.qmldir.IQDirASTNode;
-
-public class QDirASTNode implements IQDirASTNode {
-
- private SourceLocation location;
- private int start;
- private int end;
-
- public QDirASTNode() {
- this.location = new SourceLocation();
- this.start = -1;
- this.end = -1;
- }
-
- public void setLocation(SourceLocation value) {
- this.location = value;
- }
-
- @Override
- public SourceLocation getLocation() {
- return location;
- }
-
- public void setStart(int value) {
- this.start = value;
- }
-
- @Override
- public int getStart() {
- return start;
- }
-
- public void setEnd(int value) {
- this.end = value;
- }
-
- @Override
- public int getEnd() {
- return end;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.internal.qt.core.location.SourceLocation; +import org.eclipse.cdt.qt.core.qmldir.IQDirASTNode; + +public class QDirASTNode implements IQDirASTNode { + + private SourceLocation location; + private int start; + private int end; + + public QDirASTNode() { + this.location = new SourceLocation(); + this.start = -1; + this.end = -1; + } + + public void setLocation(SourceLocation value) { + this.location = value; + } + + @Override + public SourceLocation getLocation() { + return location; + } + + public void setStart(int value) { + this.start = value; + } + + @Override + public int getStart() { + return start; + } + + public void setEnd(int value) { + this.end = value; + } + + @Override + public int getEnd() { + return end; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirClassnameCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirClassnameCommand.java index 6963f345416..a1ea7ab75ac 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirClassnameCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirClassnameCommand.java @@ -1,28 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirClassnameCommand;
-
-public class QDirClassnameCommand extends QDirASTNode implements IQDirClassnameCommand {
-
- private QDirWord ident;
-
- public void setIdentifier(QDirWord value) {
- this.ident = value;
- }
-
- @Override
- public QDirWord getIdentifier() {
- return ident;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirClassnameCommand; + +public class QDirClassnameCommand extends QDirASTNode implements IQDirClassnameCommand { + + private QDirWord ident; + + public void setIdentifier(QDirWord value) { + this.ident = value; + } + + @Override + public QDirWord getIdentifier() { + return ident; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirCommentCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirCommentCommand.java index 40505866bb0..b44d34be567 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirCommentCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirCommentCommand.java @@ -1,28 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirCommentCommand;
-
-public class QDirCommentCommand extends QDirASTNode implements IQDirCommentCommand {
-
- private String text;
-
- public void setText(String value) {
- this.text = value;
- }
-
- @Override
- public String getText() {
- return text;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirCommentCommand; + +public class QDirCommentCommand extends QDirASTNode implements IQDirCommentCommand { + + private String text; + + public void setText(String value) { + this.text = value; + } + + @Override + public String getText() { + return text; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDependsCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDependsCommand.java index 45639004a4f..15ffaa40900 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDependsCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDependsCommand.java @@ -1,38 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirDependsCommand;
-
-public class QDirDependsCommand extends QDirASTNode implements IQDirDependsCommand {
-
- private QDirWord moduleName;
- private QDirVersion version;
-
- public void setModuleIdentifier(QDirWord value) {
- this.moduleName = value;
- }
-
- @Override
- public QDirWord getModuleIdentifier() {
- return moduleName;
- }
-
- public void setInitialVersion(QDirVersion value) {
- this.version = value;
- }
-
- @Override
- public QDirVersion getInitialVersion() {
- return version;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirDependsCommand; + +public class QDirDependsCommand extends QDirASTNode implements IQDirDependsCommand { + + private QDirWord moduleName; + private QDirVersion version; + + public void setModuleIdentifier(QDirWord value) { + this.moduleName = value; + } + + @Override + public QDirWord getModuleIdentifier() { + return moduleName; + } + + public void setInitialVersion(QDirVersion value) { + this.version = value; + } + + @Override + public QDirVersion getInitialVersion() { + return version; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDesignerSupportedCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDesignerSupportedCommand.java index 9b7583a437c..b73274eefac 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDesignerSupportedCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDesignerSupportedCommand.java @@ -1,16 +1,16 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirDesignerSupportedCommand;
-
-public class QDirDesignerSupportedCommand extends QDirASTNode implements IQDirDesignerSupportedCommand {
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirDesignerSupportedCommand; + +public class QDirDesignerSupportedCommand extends QDirASTNode implements IQDirDesignerSupportedCommand { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirInternalCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirInternalCommand.java index b437e8dc708..9262ffec54a 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirInternalCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirInternalCommand.java @@ -1,38 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirInternalCommand;
-
-public class QDirInternalCommand extends QDirASTNode implements IQDirInternalCommand {
-
- private QDirWord typeName;
- private QDirWord file;
-
- public void setTypeName(QDirWord value) {
- this.typeName = value;
- }
-
- @Override
- public QDirWord getTypeName() {
- return typeName;
- }
-
- public void setFile(QDirWord value) {
- this.file = value;
- }
-
- @Override
- public QDirWord getFile() {
- return file;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirInternalCommand; + +public class QDirInternalCommand extends QDirASTNode implements IQDirInternalCommand { + + private QDirWord typeName; + private QDirWord file; + + public void setTypeName(QDirWord value) { + this.typeName = value; + } + + @Override + public QDirWord getTypeName() { + return typeName; + } + + public void setFile(QDirWord value) { + this.file = value; + } + + @Override + public QDirWord getFile() { + return file; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirModuleCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirModuleCommand.java index cea1f44b25b..08b29a05777 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirModuleCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirModuleCommand.java @@ -1,27 +1,27 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirModuleCommand;
-
-public class QDirModuleCommand extends QDirASTNode implements IQDirModuleCommand {
- private QDirWord identifier;
-
- public void setModuleIdentifier(QDirWord value) {
- this.identifier = value;
- }
-
- @Override
- public QDirWord getModuleIdentifier() {
- return identifier;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirModuleCommand; + +public class QDirModuleCommand extends QDirASTNode implements IQDirModuleCommand { + private QDirWord identifier; + + public void setModuleIdentifier(QDirWord value) { + this.identifier = value; + } + + @Override + public QDirWord getModuleIdentifier() { + return identifier; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirPluginCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirPluginCommand.java index 61fbb2fbdbe..e2ff96311d5 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirPluginCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirPluginCommand.java @@ -1,38 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirPluginCommand;
-
-public class QDirPluginCommand extends QDirASTNode implements IQDirPluginCommand {
-
- private QDirWord qid;
- private QDirWord path;
-
- public void setName(QDirWord value) {
- this.qid = value;
- }
-
- @Override
- public QDirWord getName() {
- return qid;
- }
-
- public void setPath(QDirWord value) {
- this.path = value;
- }
-
- @Override
- public QDirWord getPath() {
- return path;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirPluginCommand; + +public class QDirPluginCommand extends QDirASTNode implements IQDirPluginCommand { + + private QDirWord qid; + private QDirWord path; + + public void setName(QDirWord value) { + this.qid = value; + } + + @Override + public QDirWord getName() { + return qid; + } + + public void setPath(QDirWord value) { + this.path = value; + } + + @Override + public QDirWord getPath() { + return path; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirResourceCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirResourceCommand.java index 7c9b8541a80..7c3a2e5c280 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirResourceCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirResourceCommand.java @@ -1,47 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirResourceCommand;
-
-public class QDirResourceCommand extends QDirASTNode implements IQDirResourceCommand {
- private QDirWord typeName;
- private QDirVersion version;
- private QDirWord file;
-
- public void setResourceIdentifier(QDirWord value) {
- this.typeName = value;
- }
-
- @Override
- public QDirWord getResourceIdentifier() {
- return typeName;
- }
-
- public void setInitialVersion(QDirVersion value) {
- this.version = value;
- }
-
- @Override
- public QDirVersion getInitialVersion() {
- return version;
- }
-
- public void setFile(QDirWord value) {
- this.file = value;
- }
-
- @Override
- public QDirWord getFile() {
- return file;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirResourceCommand; + +public class QDirResourceCommand extends QDirASTNode implements IQDirResourceCommand { + private QDirWord typeName; + private QDirVersion version; + private QDirWord file; + + public void setResourceIdentifier(QDirWord value) { + this.typeName = value; + } + + @Override + public QDirWord getResourceIdentifier() { + return typeName; + } + + public void setInitialVersion(QDirVersion value) { + this.version = value; + } + + @Override + public QDirVersion getInitialVersion() { + return version; + } + + public void setFile(QDirWord value) { + this.file = value; + } + + @Override + public QDirWord getFile() { + return file; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSingletonCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSingletonCommand.java index 03208f0afd6..933ccaaefd8 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSingletonCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSingletonCommand.java @@ -1,48 +1,48 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirSingletonCommand;
-
-public class QDirSingletonCommand extends QDirASTNode implements IQDirSingletonCommand {
-
- private QDirWord typeName;
- private QDirVersion version;
- private QDirWord file;
-
- public void setTypeName(QDirWord value) {
- this.typeName = value;
- }
-
- @Override
- public QDirWord getTypeName() {
- return typeName;
- }
-
- public void setInitialVersion(QDirVersion value) {
- this.version = value;
- }
-
- @Override
- public QDirVersion getInitialVersion() {
- return version;
- }
-
- public void setFile(QDirWord value) {
- this.file = value;
- }
-
- @Override
- public QDirWord getFile() {
- return file;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirSingletonCommand; + +public class QDirSingletonCommand extends QDirASTNode implements IQDirSingletonCommand { + + private QDirWord typeName; + private QDirVersion version; + private QDirWord file; + + public void setTypeName(QDirWord value) { + this.typeName = value; + } + + @Override + public QDirWord getTypeName() { + return typeName; + } + + public void setInitialVersion(QDirVersion value) { + this.version = value; + } + + @Override + public QDirVersion getInitialVersion() { + return version; + } + + public void setFile(QDirWord value) { + this.file = value; + } + + @Override + public QDirWord getFile() { + return file; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSyntaxError.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSyntaxError.java index a66b968ddb3..d186887cc70 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSyntaxError.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSyntaxError.java @@ -1,40 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirASTNode;
-import org.eclipse.cdt.qt.core.qmldir.IQDirSyntaxError;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.Token;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryParser.SyntaxError;
-
-public class QDirSyntaxError extends QDirASTNode implements IQDirSyntaxError {
- private SyntaxError exception;
-
- public QDirSyntaxError(SyntaxError exception) {
- this.exception = exception;
- }
-
- @Override
- public Token getOffendingToken() {
- return this.exception.getOffendingToken();
- }
-
- @Override
- public IQDirASTNode getIncompleteNode() {
- return this.exception.getIncompleteNode();
- }
-
- @Override
- public SyntaxError getSyntaxError() {
- return this.exception;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirASTNode; +import org.eclipse.cdt.qt.core.qmldir.IQDirSyntaxError; +import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.Token; +import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryParser.SyntaxError; + +public class QDirSyntaxError extends QDirASTNode implements IQDirSyntaxError { + private SyntaxError exception; + + public QDirSyntaxError(SyntaxError exception) { + this.exception = exception; + } + + @Override + public Token getOffendingToken() { + return this.exception.getOffendingToken(); + } + + @Override + public IQDirASTNode getIncompleteNode() { + return this.exception.getIncompleteNode(); + } + + @Override + public SyntaxError getSyntaxError() { + return this.exception; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirTypeInfoCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirTypeInfoCommand.java index 9b2f00e1a9b..0332e141ee2 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirTypeInfoCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirTypeInfoCommand.java @@ -1,28 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirTypeInfoCommand;
-
-public class QDirTypeInfoCommand extends QDirASTNode implements IQDirTypeInfoCommand {
-
- private QDirWord file;
-
- public void setFile(QDirWord value) {
- this.file = value;
- }
-
- @Override
- public QDirWord getFile() {
- return file;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirTypeInfoCommand; + +public class QDirTypeInfoCommand extends QDirASTNode implements IQDirTypeInfoCommand { + + private QDirWord file; + + public void setFile(QDirWord value) { + this.file = value; + } + + @Override + public QDirWord getFile() { + return file; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirVersion.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirVersion.java index 4a3c3dabe3a..161ffdf6726 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirVersion.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirVersion.java @@ -1,28 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirVersion;
-
-public class QDirVersion extends QDirASTNode implements IQDirVersion {
-
- private String version;
-
- public void setVersionString(String value) {
- this.version = value;
- }
-
- @Override
- public String getVersionString() {
- return version;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirVersion; + +public class QDirVersion extends QDirASTNode implements IQDirVersion { + + private String version; + + public void setVersionString(String value) { + this.version = value; + } + + @Override + public String getVersionString() { + return version; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirWord.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirWord.java index 89aac96b739..76ea26a8bf0 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirWord.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirWord.java @@ -1,28 +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.internal.qt.core.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.IQDirWord;
-
-public class QDirWord extends QDirASTNode implements IQDirWord {
-
- private String text;
-
- public void setText(String value) {
- this.text = value;
- }
-
- @Override
- public String getText() {
- return text;
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.IQDirWord; + +public class QDirWord extends QDirASTNode implements IQDirWord { + + private String text; + + public void setText(String value) { + this.text = value; + } + + @Override + public String getText() { + return text; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLComponentInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLComponentInfo.java index b33d24a18a5..5a30528aaf1 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLComponentInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLComponentInfo.java @@ -1,139 +1,139 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmltypes;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition;
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember;
-import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding;
-
-public class QMLComponentInfo {
- static final String IDENTIFIER = "Component"; //$NON-NLS-1$
-
- static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
- static final String PROPERTY_PROTOTYPE = "prototype"; //$NON-NLS-1$
- static final String PROPERTY_DEF_PROPERTY = "defaultProperty"; //$NON-NLS-1$
- static final String PROPERTY_ATTACHED_TYPE = "attachedType"; //$NON-NLS-1$
- static final String PROPERTY_EXPORTS = "exports"; //$NON-NLS-1$
- static final String PROPERTY_EXPORT_REVISIONS = "exportMetaObjectRevisions"; //$NON-NLS-1$
-
- private String name;
- private String prototype;
- private String defaultProperty;
- private String attachedType;
- private Integer[] exportMetaObjectRevisions;
- private List<QMLExportInfo> exportList = new ArrayList<>();
- private List<QMLPropertyInfo> propertyList = new ArrayList<>();
- private List<QMLMethodInfo> methodList = new ArrayList<>();
- private List<QMLSignalInfo> signalList = new ArrayList<>();
- private List<QMLEnumInfo> enumList = new ArrayList<>();
-
- protected QMLComponentInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) {
- builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER);
- for (IQmlObjectMember member : obj.getBody().getMembers()) {
- if (member instanceof IQmlPropertyBinding) {
- IQmlPropertyBinding prop = (IQmlPropertyBinding) member;
- switch (prop.getIdentifier().getName()) {
- case PROPERTY_NAME:
- this.name = builder.getStringBinding(prop);
- break;
- case PROPERTY_PROTOTYPE:
- this.prototype = builder.getStringBinding(prop);
- break;
- case PROPERTY_DEF_PROPERTY:
- this.defaultProperty = builder.getStringBinding(prop);
- break;
- case PROPERTY_ATTACHED_TYPE:
- this.attachedType = builder.getStringBinding(prop);
- break;
- case PROPERTY_EXPORTS:
- String[] exports = builder.getStringArrayBinding(prop);
- for (String exp : exports) {
- this.exportList.add(new QMLExportInfo(builder, exp));
- }
- break;
- case PROPERTY_EXPORT_REVISIONS:
- this.exportMetaObjectRevisions = builder.getIntegerArrayBinding(prop);
- break;
- default:
- }
- } else if (member instanceof IQmlObjectDefinition) {
- IQmlObjectDefinition object = (IQmlObjectDefinition) member;
- switch (object.getIdentifier().getName()) {
- case QMLPropertyInfo.IDENTIFIER:
- this.propertyList.add(new QMLPropertyInfo(builder, object));
- break;
- case QMLMethodInfo.IDENTIFIER:
- this.methodList.add(new QMLMethodInfo(builder, object));
- break;
- case QMLSignalInfo.IDENTIFIER:
- this.signalList.add(new QMLSignalInfo(builder, object));
- break;
- case QMLEnumInfo.IDENTIFIER:
- this.enumList.add(new QMLEnumInfo(builder, object));
- break;
- default:
- }
- } else {
- builder.unexpectedNode(member);
- }
- }
- exportList = Collections.unmodifiableList(exportList);
- propertyList = Collections.unmodifiableList(propertyList);
- methodList = Collections.unmodifiableList(methodList);
- signalList = Collections.unmodifiableList(signalList);
- enumList = Collections.unmodifiableList(enumList);
- }
-
- public String getName() {
- return name;
- }
-
- public String getPrototype() {
- return prototype;
- }
-
- public String getDefaultProperty() {
- return defaultProperty;
- }
-
- public String getAttachedType() {
- return attachedType;
- }
-
- public List<QMLExportInfo> getExports() {
- return exportList;
- }
-
- public Integer[] getExportMetaObjectRevisions() {
- return Arrays.copyOf(exportMetaObjectRevisions, exportMetaObjectRevisions.length);
- }
-
- public List<QMLPropertyInfo> getProperties() {
- return propertyList;
- }
-
- public List<QMLMethodInfo> getMethods() {
- return methodList;
- }
-
- public List<QMLSignalInfo> getSignals() {
- return signalList;
- }
-
- public List<QMLEnumInfo> getEnums() {
- return enumList;
- }
-}
+/******************************************************************************* + * 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.internal.qt.core.qmltypes; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition; +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember; +import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding; + +public class QMLComponentInfo { + static final String IDENTIFIER = "Component"; //$NON-NLS-1$ + + static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ + static final String PROPERTY_PROTOTYPE = "prototype"; //$NON-NLS-1$ + static final String PROPERTY_DEF_PROPERTY = "defaultProperty"; //$NON-NLS-1$ + static final String PROPERTY_ATTACHED_TYPE = "attachedType"; //$NON-NLS-1$ + static final String PROPERTY_EXPORTS = "exports"; //$NON-NLS-1$ + static final String PROPERTY_EXPORT_REVISIONS = "exportMetaObjectRevisions"; //$NON-NLS-1$ + + private String name; + private String prototype; + private String defaultProperty; + private String attachedType; + private Integer[] exportMetaObjectRevisions; + private List<QMLExportInfo> exportList = new ArrayList<>(); + private List<QMLPropertyInfo> propertyList = new ArrayList<>(); + private List<QMLMethodInfo> methodList = new ArrayList<>(); + private List<QMLSignalInfo> signalList = new ArrayList<>(); + private List<QMLEnumInfo> enumList = new ArrayList<>(); + + protected QMLComponentInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) { + builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER); + for (IQmlObjectMember member : obj.getBody().getMembers()) { + if (member instanceof IQmlPropertyBinding) { + IQmlPropertyBinding prop = (IQmlPropertyBinding) member; + switch (prop.getIdentifier().getName()) { + case PROPERTY_NAME: + this.name = builder.getStringBinding(prop); + break; + case PROPERTY_PROTOTYPE: + this.prototype = builder.getStringBinding(prop); + break; + case PROPERTY_DEF_PROPERTY: + this.defaultProperty = builder.getStringBinding(prop); + break; + case PROPERTY_ATTACHED_TYPE: + this.attachedType = builder.getStringBinding(prop); + break; + case PROPERTY_EXPORTS: + String[] exports = builder.getStringArrayBinding(prop); + for (String exp : exports) { + this.exportList.add(new QMLExportInfo(builder, exp)); + } + break; + case PROPERTY_EXPORT_REVISIONS: + this.exportMetaObjectRevisions = builder.getIntegerArrayBinding(prop); + break; + default: + } + } else if (member instanceof IQmlObjectDefinition) { + IQmlObjectDefinition object = (IQmlObjectDefinition) member; + switch (object.getIdentifier().getName()) { + case QMLPropertyInfo.IDENTIFIER: + this.propertyList.add(new QMLPropertyInfo(builder, object)); + break; + case QMLMethodInfo.IDENTIFIER: + this.methodList.add(new QMLMethodInfo(builder, object)); + break; + case QMLSignalInfo.IDENTIFIER: + this.signalList.add(new QMLSignalInfo(builder, object)); + break; + case QMLEnumInfo.IDENTIFIER: + this.enumList.add(new QMLEnumInfo(builder, object)); + break; + default: + } + } else { + builder.unexpectedNode(member); + } + } + exportList = Collections.unmodifiableList(exportList); + propertyList = Collections.unmodifiableList(propertyList); + methodList = Collections.unmodifiableList(methodList); + signalList = Collections.unmodifiableList(signalList); + enumList = Collections.unmodifiableList(enumList); + } + + public String getName() { + return name; + } + + public String getPrototype() { + return prototype; + } + + public String getDefaultProperty() { + return defaultProperty; + } + + public String getAttachedType() { + return attachedType; + } + + public List<QMLExportInfo> getExports() { + return exportList; + } + + public Integer[] getExportMetaObjectRevisions() { + return Arrays.copyOf(exportMetaObjectRevisions, exportMetaObjectRevisions.length); + } + + public List<QMLPropertyInfo> getProperties() { + return propertyList; + } + + public List<QMLMethodInfo> getMethods() { + return methodList; + } + + public List<QMLSignalInfo> getSignals() { + return signalList; + } + + public List<QMLEnumInfo> getEnums() { + return enumList; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLEnumInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLEnumInfo.java index 3d1c19dc0b2..99676d4d851 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLEnumInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLEnumInfo.java @@ -1,96 +1,96 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmltypes;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.qt.core.qmljs.IJSObjectExpression;
-import org.eclipse.cdt.qt.core.qmljs.IJSProperty;
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition;
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember;
-import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding;
-import org.eclipse.cdt.qt.core.qmljs.IQmlScriptBinding;
-import org.eclipse.cdt.qt.core.qmljs.QMLExpressionEvaluator;
-import org.eclipse.cdt.qt.core.qmljs.QMLExpressionEvaluator.InvalidExpressionException;
-
-public class QMLEnumInfo {
- public static class EnumConst {
- private final String identifier;
- private final int value;
-
- private EnumConst(String ident, int val) {
- this.identifier = ident;
- this.value = val;
- }
-
- public String getIdentifier() {
- return identifier;
- }
-
- public int getValue() {
- return value;
- }
- }
-
- static final String IDENTIFIER = "Enum"; //$NON-NLS-1$
-
- static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
- static final String PROPERTY_VALUE = "values"; //$NON-NLS-1$
-
- private String name;
- private List<EnumConst> constantList = new ArrayList<>();
-
- QMLEnumInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) {
- if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) {
- for (IQmlObjectMember member : obj.getBody().getMembers()) {
- if (builder.ensureNode(member, IQmlPropertyBinding.class)) {
- IQmlPropertyBinding prop = (IQmlPropertyBinding) member;
- switch (prop.getIdentifier().getName()) {
- case PROPERTY_NAME:
- this.name = builder.getStringBinding(prop);
- break;
- case PROPERTY_VALUE:
- if (builder.ensureNode(prop.getBinding(), IQmlScriptBinding.class)) {
- IQmlScriptBinding binding = ((IQmlScriptBinding) prop.getBinding());
- if (builder.ensureNode(binding.getScript(), IJSObjectExpression.class)) {
- IJSObjectExpression objExpr = (IJSObjectExpression) binding.getScript();
- for (IJSProperty property : objExpr.getProperties()) {
- Object value;
- try {
- value = QMLExpressionEvaluator.evaluateConstExpr(property.getValue());
- if (value instanceof Number) {
- constantList.add(new EnumConst(property.getType(), ((Number) value).intValue()));
- }
- } catch (InvalidExpressionException e) {
- builder.handleException(e);
- }
- }
- }
- }
- break;
- default:
- }
- }
- }
- }
- constantList = Collections.unmodifiableList(constantList);
- }
-
- public String getName() {
- return name;
- }
-
- public List<EnumConst> getConstants() {
- return constantList;
- }
-}
+/******************************************************************************* + * 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.internal.qt.core.qmltypes; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.qt.core.qmljs.IJSObjectExpression; +import org.eclipse.cdt.qt.core.qmljs.IJSProperty; +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition; +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember; +import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding; +import org.eclipse.cdt.qt.core.qmljs.IQmlScriptBinding; +import org.eclipse.cdt.qt.core.qmljs.QMLExpressionEvaluator; +import org.eclipse.cdt.qt.core.qmljs.QMLExpressionEvaluator.InvalidExpressionException; + +public class QMLEnumInfo { + public static class EnumConst { + private final String identifier; + private final int value; + + private EnumConst(String ident, int val) { + this.identifier = ident; + this.value = val; + } + + public String getIdentifier() { + return identifier; + } + + public int getValue() { + return value; + } + } + + static final String IDENTIFIER = "Enum"; //$NON-NLS-1$ + + static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ + static final String PROPERTY_VALUE = "values"; //$NON-NLS-1$ + + private String name; + private List<EnumConst> constantList = new ArrayList<>(); + + QMLEnumInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) { + if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) { + for (IQmlObjectMember member : obj.getBody().getMembers()) { + if (builder.ensureNode(member, IQmlPropertyBinding.class)) { + IQmlPropertyBinding prop = (IQmlPropertyBinding) member; + switch (prop.getIdentifier().getName()) { + case PROPERTY_NAME: + this.name = builder.getStringBinding(prop); + break; + case PROPERTY_VALUE: + if (builder.ensureNode(prop.getBinding(), IQmlScriptBinding.class)) { + IQmlScriptBinding binding = ((IQmlScriptBinding) prop.getBinding()); + if (builder.ensureNode(binding.getScript(), IJSObjectExpression.class)) { + IJSObjectExpression objExpr = (IJSObjectExpression) binding.getScript(); + for (IJSProperty property : objExpr.getProperties()) { + Object value; + try { + value = QMLExpressionEvaluator.evaluateConstExpr(property.getValue()); + if (value instanceof Number) { + constantList.add(new EnumConst(property.getType(), ((Number) value).intValue())); + } + } catch (InvalidExpressionException e) { + builder.handleException(e); + } + } + } + } + break; + default: + } + } + } + } + constantList = Collections.unmodifiableList(constantList); + } + + public String getName() { + return name; + } + + public List<EnumConst> getConstants() { + return constantList; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLExportInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLExportInfo.java index 2a4707ed626..7fd83edf732 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLExportInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLExportInfo.java @@ -1,37 +1,37 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmltypes;
-
-public class QMLExportInfo {
- private String type;
- private String version;
-
- QMLExportInfo(QMLModelBuilder builder, String export) {
- String[] info = export.split("\\h+"); //$NON-NLS-1$
- switch (info.length) {
- case 2:
- this.type = info[0];
- this.version = info[1];
- break;
- case 1:
- this.type = info[0];
- break;
- }
- }
-
- public String getType() {
- return type;
- }
-
- public String getVersion() {
- return version;
- }
-}
+/******************************************************************************* + * 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.internal.qt.core.qmltypes; + +public class QMLExportInfo { + private String type; + private String version; + + QMLExportInfo(QMLModelBuilder builder, String export) { + String[] info = export.split("\\h+"); //$NON-NLS-1$ + switch (info.length) { + case 2: + this.type = info[0]; + this.version = info[1]; + break; + case 1: + this.type = info[0]; + break; + } + } + + public String getType() { + return type; + } + + public String getVersion() { + return version; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLMethodInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLMethodInfo.java index a09b6fd8f16..01a4c71ec62 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLMethodInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLMethodInfo.java @@ -1,69 +1,69 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmltypes;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition;
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember;
-import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding;
-
-public class QMLMethodInfo {
- static final String IDENTIFIER = "Method"; //$NON-NLS-1$
-
- static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ s
- static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$
- static final String PROPERTY_REVISION = "revision"; //$NON-NLS-1$
-
- private String name;
- private String type;
- private int revision;
- private List<QMLParameterInfo> parameterList = new ArrayList<>();
-
- QMLMethodInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) {
- if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) {
- for (IQmlObjectMember member : obj.getBody().getMembers()) {
- if (member instanceof IQmlPropertyBinding) {
- IQmlPropertyBinding prop = (IQmlPropertyBinding) member;
- switch (prop.getIdentifier().getName()) {
- case PROPERTY_NAME:
- this.name = builder.getStringBinding(prop);
- break;
- case PROPERTY_TYPE:
- this.type = builder.getStringBinding(prop);
- break;
- case PROPERTY_REVISION:
- this.revision = builder.getIntegerBinding(prop);
- break;
- default:
- }
- } else if (member instanceof IQmlObjectDefinition) {
- this.parameterList.add(new QMLParameterInfo(builder, (IQmlObjectDefinition) member));
- } else {
- builder.unexpectedNode(member);
- }
- }
- }
- }
-
- public String getName() {
- return name;
- }
-
- public String getType() {
- return type;
- }
-
- public int getRevision() {
- return revision;
- }
-}
+/******************************************************************************* + * 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.internal.qt.core.qmltypes; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition; +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember; +import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding; + +public class QMLMethodInfo { + static final String IDENTIFIER = "Method"; //$NON-NLS-1$ + + static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ s + static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$ + static final String PROPERTY_REVISION = "revision"; //$NON-NLS-1$ + + private String name; + private String type; + private int revision; + private List<QMLParameterInfo> parameterList = new ArrayList<>(); + + QMLMethodInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) { + if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) { + for (IQmlObjectMember member : obj.getBody().getMembers()) { + if (member instanceof IQmlPropertyBinding) { + IQmlPropertyBinding prop = (IQmlPropertyBinding) member; + switch (prop.getIdentifier().getName()) { + case PROPERTY_NAME: + this.name = builder.getStringBinding(prop); + break; + case PROPERTY_TYPE: + this.type = builder.getStringBinding(prop); + break; + case PROPERTY_REVISION: + this.revision = builder.getIntegerBinding(prop); + break; + default: + } + } else if (member instanceof IQmlObjectDefinition) { + this.parameterList.add(new QMLParameterInfo(builder, (IQmlObjectDefinition) member)); + } else { + builder.unexpectedNode(member); + } + } + } + } + + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public int getRevision() { + return revision; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModelBuilder.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModelBuilder.java index 401d941e4b5..f7dd6da11db 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModelBuilder.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModelBuilder.java @@ -1,191 +1,191 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmltypes;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.cdt.internal.qt.core.Activator;
-import org.eclipse.cdt.qt.core.qmljs.IJSArrayExpression;
-import org.eclipse.cdt.qt.core.qmljs.IJSExpression;
-import org.eclipse.cdt.qt.core.qmljs.IQmlASTNode;
-import org.eclipse.cdt.qt.core.qmljs.IQmlBinding;
-import org.eclipse.cdt.qt.core.qmljs.IQmlProgram;
-import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding;
-import org.eclipse.cdt.qt.core.qmljs.IQmlQualifiedID;
-import org.eclipse.cdt.qt.core.qmljs.IQmlRootObject;
-import org.eclipse.cdt.qt.core.qmljs.IQmlScriptBinding;
-import org.eclipse.cdt.qt.core.qmljs.QMLExpressionEvaluator;
-import org.eclipse.cdt.qt.core.qmljs.QMLExpressionEvaluator.InvalidExpressionException;
-
-public class QMLModelBuilder {
-
- private final Map<String, QMLModuleInfo> moduleMap = new HashMap<>();
-
- public QMLModelBuilder() {
- }
-
- public QMLModuleInfo addModule(String module, IQmlASTNode ast) {
- QMLModuleInfo info = moduleMap.get(module);
- if (!moduleMap.containsKey(module)) {
- if (ensureNode(ast, IQmlProgram.class)) {
- IQmlRootObject obj = ((IQmlProgram) ast).getRootObject();
- if (ensureNode(obj, IQmlRootObject.class)) {
- info = new QMLModuleInfo(this, obj);
- moduleMap.put(module, info);
- }
- }
- }
- return info;
- }
-
- public QMLModuleInfo getModule(String module) {
- return moduleMap.get(module);
- }
-
- public boolean hasModule(String module) {
- return moduleMap.get(module) != null;
- }
-
- boolean ensureIdentifier(IQmlQualifiedID actual, String expected) {
- if (!actual.getName().equals(expected)) {
- Activator.log("[QmlTypes] Unexpected node identifier: expected '" + expected + "', but was '" //$NON-NLS-1$ //$NON-NLS-2$
- + actual.getName() + "'"); //$NON-NLS-1$
- return false;
- }
- return true;
- }
-
- boolean ensureNode(IQmlASTNode actual, Class<? extends IQmlASTNode> expected) {
- if (!expected.isInstance(actual)) {
- Activator.log("[QmlTypes] Expected node '" + expected + "', but was '" + actual.getClass().getInterfaces()[0] + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return false;
- }
- return true;
- }
-
- boolean ensureValue(Object actual, Class<?> expected) {
- if (!expected.isInstance(actual)) {
- Activator.log("[QmlTypes] Unexpected value: expected '" + expected + "', but was '" //$NON-NLS-1$ //$NON-NLS-2$
- + actual.getClass().getInterfaces()[0] + "'"); //$NON-NLS-1$
- return false;
- }
- return true;
- }
-
- void unexpectedNode(IQmlASTNode node) {
- Activator.log("[QmlTypes] Unexpected node '" + node.getClass().getInterfaces()[0] + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- String getStringBinding(IQmlPropertyBinding prop) {
- IQmlBinding b = prop.getBinding();
- if (ensureNode(b, IQmlScriptBinding.class)) {
- IQmlScriptBinding sb = (IQmlScriptBinding) b;
- if (ensureNode(sb.getScript(), IJSExpression.class)) {
- try {
- Object value = QMLExpressionEvaluator.evaluateConstExpr((IJSExpression) sb.getScript());
- if (value instanceof String) {
- return (String) value;
- }
- } catch (InvalidExpressionException e) {
- handleException(e);
- }
- }
- }
- return null;
- }
-
- String[] getStringArrayBinding(IQmlPropertyBinding prop) {
- ArrayList<String> result = new ArrayList<>();
- IQmlBinding b = prop.getBinding();
- if (ensureNode(b, IQmlScriptBinding.class)) {
- IQmlScriptBinding sb = (IQmlScriptBinding) b;
- if (ensureNode(sb.getScript(), IJSArrayExpression.class)) {
- IJSArrayExpression arrExpr = (IJSArrayExpression) sb.getScript();
- for (IJSExpression expr : arrExpr.getElements()) {
- try {
- Object value = QMLExpressionEvaluator.evaluateConstExpr(expr);
- if (value instanceof String) {
- result.add((String) value);
- }
- } catch (InvalidExpressionException e) {
- handleException(e);
- }
- }
- }
- }
- return result.toArray(new String[result.size()]);
- }
-
- public Integer[] getIntegerArrayBinding(IQmlPropertyBinding prop) {
- ArrayList<Integer> result = new ArrayList<>();
- IQmlBinding b = prop.getBinding();
- if (ensureNode(b, IQmlScriptBinding.class)) {
- IQmlScriptBinding sb = (IQmlScriptBinding) b;
- if (ensureNode(sb.getScript(), IJSArrayExpression.class)) {
- IJSArrayExpression arrExpr = (IJSArrayExpression) sb.getScript();
- for (IJSExpression expr : arrExpr.getElements()) {
- try {
- Object value = QMLExpressionEvaluator.evaluateConstExpr(expr);
- if (value instanceof Number) {
- result.add(((Number) value).intValue());
- }
- } catch (InvalidExpressionException e) {
- handleException(e);
- }
- }
- }
- }
- return result.toArray(new Integer[result.size()]);
- }
-
- boolean getBooleanBinding(IQmlPropertyBinding prop) {
- IQmlBinding b = prop.getBinding();
- if (ensureNode(b, IQmlScriptBinding.class)) {
- IQmlScriptBinding sb = (IQmlScriptBinding) b;
- if (ensureNode(sb.getScript(), IJSExpression.class)) {
- try {
- Object value = QMLExpressionEvaluator.evaluateConstExpr((IJSExpression) sb.getScript());
- if (value instanceof Number) {
- return (Boolean) value;
- }
- } catch (InvalidExpressionException e) {
- handleException(e);
- }
- }
- }
- return false;
- }
-
- public Integer getIntegerBinding(IQmlPropertyBinding prop) {
- IQmlBinding b = prop.getBinding();
- if (ensureNode(b, IQmlScriptBinding.class)) {
- IQmlScriptBinding sb = (IQmlScriptBinding) b;
- if (ensureNode(sb.getScript(), IJSExpression.class)) {
- try {
- Object value = QMLExpressionEvaluator.evaluateConstExpr((IJSExpression) sb.getScript());
- if (value instanceof Number) {
- return ((Number) value).intValue();
- }
- } catch (InvalidExpressionException e) {
- handleException(e);
- }
- }
- }
- return 0;
- }
-
- public void handleException(Throwable t) {
- Activator.log("[QmlTypes] " + t.getMessage()); //$NON-NLS-1$
- }
-
-}
+/******************************************************************************* + * 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.internal.qt.core.qmltypes; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.internal.qt.core.Activator; +import org.eclipse.cdt.qt.core.qmljs.IJSArrayExpression; +import org.eclipse.cdt.qt.core.qmljs.IJSExpression; +import org.eclipse.cdt.qt.core.qmljs.IQmlASTNode; +import org.eclipse.cdt.qt.core.qmljs.IQmlBinding; +import org.eclipse.cdt.qt.core.qmljs.IQmlProgram; +import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding; +import org.eclipse.cdt.qt.core.qmljs.IQmlQualifiedID; +import org.eclipse.cdt.qt.core.qmljs.IQmlRootObject; +import org.eclipse.cdt.qt.core.qmljs.IQmlScriptBinding; +import org.eclipse.cdt.qt.core.qmljs.QMLExpressionEvaluator; +import org.eclipse.cdt.qt.core.qmljs.QMLExpressionEvaluator.InvalidExpressionException; + +public class QMLModelBuilder { + + private final Map<String, QMLModuleInfo> moduleMap = new HashMap<>(); + + public QMLModelBuilder() { + } + + public QMLModuleInfo addModule(String module, IQmlASTNode ast) { + QMLModuleInfo info = moduleMap.get(module); + if (!moduleMap.containsKey(module)) { + if (ensureNode(ast, IQmlProgram.class)) { + IQmlRootObject obj = ((IQmlProgram) ast).getRootObject(); + if (ensureNode(obj, IQmlRootObject.class)) { + info = new QMLModuleInfo(this, obj); + moduleMap.put(module, info); + } + } + } + return info; + } + + public QMLModuleInfo getModule(String module) { + return moduleMap.get(module); + } + + public boolean hasModule(String module) { + return moduleMap.get(module) != null; + } + + boolean ensureIdentifier(IQmlQualifiedID actual, String expected) { + if (!actual.getName().equals(expected)) { + Activator.log("[QmlTypes] Unexpected node identifier: expected '" + expected + "', but was '" //$NON-NLS-1$ //$NON-NLS-2$ + + actual.getName() + "'"); //$NON-NLS-1$ + return false; + } + return true; + } + + boolean ensureNode(IQmlASTNode actual, Class<? extends IQmlASTNode> expected) { + if (!expected.isInstance(actual)) { + Activator.log("[QmlTypes] Expected node '" + expected + "', but was '" + actual.getClass().getInterfaces()[0] + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return false; + } + return true; + } + + boolean ensureValue(Object actual, Class<?> expected) { + if (!expected.isInstance(actual)) { + Activator.log("[QmlTypes] Unexpected value: expected '" + expected + "', but was '" //$NON-NLS-1$ //$NON-NLS-2$ + + actual.getClass().getInterfaces()[0] + "'"); //$NON-NLS-1$ + return false; + } + return true; + } + + void unexpectedNode(IQmlASTNode node) { + Activator.log("[QmlTypes] Unexpected node '" + node.getClass().getInterfaces()[0] + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + String getStringBinding(IQmlPropertyBinding prop) { + IQmlBinding b = prop.getBinding(); + if (ensureNode(b, IQmlScriptBinding.class)) { + IQmlScriptBinding sb = (IQmlScriptBinding) b; + if (ensureNode(sb.getScript(), IJSExpression.class)) { + try { + Object value = QMLExpressionEvaluator.evaluateConstExpr((IJSExpression) sb.getScript()); + if (value instanceof String) { + return (String) value; + } + } catch (InvalidExpressionException e) { + handleException(e); + } + } + } + return null; + } + + String[] getStringArrayBinding(IQmlPropertyBinding prop) { + ArrayList<String> result = new ArrayList<>(); + IQmlBinding b = prop.getBinding(); + if (ensureNode(b, IQmlScriptBinding.class)) { + IQmlScriptBinding sb = (IQmlScriptBinding) b; + if (ensureNode(sb.getScript(), IJSArrayExpression.class)) { + IJSArrayExpression arrExpr = (IJSArrayExpression) sb.getScript(); + for (IJSExpression expr : arrExpr.getElements()) { + try { + Object value = QMLExpressionEvaluator.evaluateConstExpr(expr); + if (value instanceof String) { + result.add((String) value); + } + } catch (InvalidExpressionException e) { + handleException(e); + } + } + } + } + return result.toArray(new String[result.size()]); + } + + public Integer[] getIntegerArrayBinding(IQmlPropertyBinding prop) { + ArrayList<Integer> result = new ArrayList<>(); + IQmlBinding b = prop.getBinding(); + if (ensureNode(b, IQmlScriptBinding.class)) { + IQmlScriptBinding sb = (IQmlScriptBinding) b; + if (ensureNode(sb.getScript(), IJSArrayExpression.class)) { + IJSArrayExpression arrExpr = (IJSArrayExpression) sb.getScript(); + for (IJSExpression expr : arrExpr.getElements()) { + try { + Object value = QMLExpressionEvaluator.evaluateConstExpr(expr); + if (value instanceof Number) { + result.add(((Number) value).intValue()); + } + } catch (InvalidExpressionException e) { + handleException(e); + } + } + } + } + return result.toArray(new Integer[result.size()]); + } + + boolean getBooleanBinding(IQmlPropertyBinding prop) { + IQmlBinding b = prop.getBinding(); + if (ensureNode(b, IQmlScriptBinding.class)) { + IQmlScriptBinding sb = (IQmlScriptBinding) b; + if (ensureNode(sb.getScript(), IJSExpression.class)) { + try { + Object value = QMLExpressionEvaluator.evaluateConstExpr((IJSExpression) sb.getScript()); + if (value instanceof Number) { + return (Boolean) value; + } + } catch (InvalidExpressionException e) { + handleException(e); + } + } + } + return false; + } + + public Integer getIntegerBinding(IQmlPropertyBinding prop) { + IQmlBinding b = prop.getBinding(); + if (ensureNode(b, IQmlScriptBinding.class)) { + IQmlScriptBinding sb = (IQmlScriptBinding) b; + if (ensureNode(sb.getScript(), IJSExpression.class)) { + try { + Object value = QMLExpressionEvaluator.evaluateConstExpr((IJSExpression) sb.getScript()); + if (value instanceof Number) { + return ((Number) value).intValue(); + } + } catch (InvalidExpressionException e) { + handleException(e); + } + } + } + return 0; + } + + public void handleException(Throwable t) { + Activator.log("[QmlTypes] " + t.getMessage()); //$NON-NLS-1$ + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModuleInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModuleInfo.java index 83afa3e0e36..df54b9924f1 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModuleInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModuleInfo.java @@ -1,40 +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.internal.qt.core.qmltypes;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition;
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember;
-import org.eclipse.cdt.qt.core.qmljs.IQmlRootObject;
-
-public class QMLModuleInfo {
- static final String IDENTIFIER = "Module"; //$NON-NLS-1$
-
- private List<QMLComponentInfo> componentsList = new ArrayList<>();
-
- QMLModuleInfo(QMLModelBuilder builder, IQmlRootObject obj) {
- if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) {
- for (IQmlObjectMember member : obj.getBody().getMembers()) {
- if (builder.ensureNode(member, IQmlObjectDefinition.class)) {
- componentsList.add(new QMLComponentInfo(builder, (IQmlObjectDefinition) member));
- }
- }
- }
- componentsList = Collections.unmodifiableList(componentsList);
- }
-
- public List<QMLComponentInfo> getComponents() {
- return componentsList;
- }
-}
+/******************************************************************************* + * 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.internal.qt.core.qmltypes; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition; +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember; +import org.eclipse.cdt.qt.core.qmljs.IQmlRootObject; + +public class QMLModuleInfo { + static final String IDENTIFIER = "Module"; //$NON-NLS-1$ + + private List<QMLComponentInfo> componentsList = new ArrayList<>(); + + QMLModuleInfo(QMLModelBuilder builder, IQmlRootObject obj) { + if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) { + for (IQmlObjectMember member : obj.getBody().getMembers()) { + if (builder.ensureNode(member, IQmlObjectDefinition.class)) { + componentsList.add(new QMLComponentInfo(builder, (IQmlObjectDefinition) member)); + } + } + } + componentsList = Collections.unmodifiableList(componentsList); + } + + public List<QMLComponentInfo> getComponents() { + return componentsList; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLParameterInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLParameterInfo.java index b1d6ad7b04a..70918fb1e08 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLParameterInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLParameterInfo.java @@ -1,52 +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.internal.qt.core.qmltypes;
-
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition;
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember;
-import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding;
-
-public class QMLParameterInfo {
- static final String IDENTIFIER = "Parameter"; //$NON-NLS-1$
-
- static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
- static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$
-
- private String name;
- private String type;
-
- QMLParameterInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) {
- if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) {
- for (IQmlObjectMember member : obj.getBody().getMembers()) {
- if (builder.ensureNode(member, IQmlPropertyBinding.class)) {
- IQmlPropertyBinding prop = (IQmlPropertyBinding) member;
- switch (prop.getIdentifier().getName()) {
- case PROPERTY_NAME:
- this.name = builder.getStringBinding(prop);
- break;
- case PROPERTY_TYPE:
- this.type = builder.getStringBinding(prop);
- break;
- default:
- }
- }
- }
- }
- }
-
- public String getName() {
- return name;
- }
-
- public String getType() {
- return type;
- }
-}
+/******************************************************************************* + * 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.internal.qt.core.qmltypes; + +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition; +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember; +import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding; + +public class QMLParameterInfo { + static final String IDENTIFIER = "Parameter"; //$NON-NLS-1$ + + static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ + static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$ + + private String name; + private String type; + + QMLParameterInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) { + if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) { + for (IQmlObjectMember member : obj.getBody().getMembers()) { + if (builder.ensureNode(member, IQmlPropertyBinding.class)) { + IQmlPropertyBinding prop = (IQmlPropertyBinding) member; + switch (prop.getIdentifier().getName()) { + case PROPERTY_NAME: + this.name = builder.getStringBinding(prop); + break; + case PROPERTY_TYPE: + this.type = builder.getStringBinding(prop); + break; + default: + } + } + } + } + } + + public String getName() { + return name; + } + + public String getType() { + return type; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLPropertyInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLPropertyInfo.java index 704c3a55d44..c3f7d29b00f 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLPropertyInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLPropertyInfo.java @@ -1,88 +1,88 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmltypes;
-
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition;
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember;
-import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding;
-
-public class QMLPropertyInfo {
- static final String IDENTIFIER = "Property"; //$NON-NLS-1$
-
- static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
- static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$
- static final String PROPERTY_READONLY = "isReadonly"; //$NON-NLS-1$
- static final String PROPERTY_POINTER = "isPointer"; //$NON-NLS-1$
- static final String PROPERTY_LIST = "isList"; //$NON-NLS-1$
- static final String PROPERTY_REVISION = "revision"; //$NON-NLS-1$
-
- private String name;
- private String type;
- private boolean readonly = false;
- private boolean pointer = false;
- private boolean list = false;
- private int revision;
-
- QMLPropertyInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) {
- if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) {
- for (IQmlObjectMember member : obj.getBody().getMembers()) {
- if (builder.ensureNode(member, IQmlPropertyBinding.class)) {
- IQmlPropertyBinding prop = (IQmlPropertyBinding) member;
- switch (prop.getIdentifier().getName()) {
- case PROPERTY_NAME:
- this.name = builder.getStringBinding(prop);
- break;
- case PROPERTY_TYPE:
- this.type = builder.getStringBinding(prop);
- break;
- case PROPERTY_READONLY:
- this.readonly = builder.getBooleanBinding(prop);
- break;
- case PROPERTY_POINTER:
- this.pointer = builder.getBooleanBinding(prop);
- break;
- case PROPERTY_LIST:
- this.list = builder.getBooleanBinding(prop);
- break;
- case PROPERTY_REVISION:
- this.revision = builder.getIntegerBinding(prop);
- break;
- default:
- }
- }
- }
- }
- }
-
- public String getName() {
- return name;
- }
-
- public String getType() {
- return type;
- }
-
- public int getRevision() {
- return revision;
- }
-
- public boolean isReadonly() {
- return readonly;
- }
-
- public boolean isPointer() {
- return pointer;
- }
-
- public boolean isList() {
- return list;
- }
-}
+/******************************************************************************* + * 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.internal.qt.core.qmltypes; + +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition; +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember; +import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding; + +public class QMLPropertyInfo { + static final String IDENTIFIER = "Property"; //$NON-NLS-1$ + + static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ + static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$ + static final String PROPERTY_READONLY = "isReadonly"; //$NON-NLS-1$ + static final String PROPERTY_POINTER = "isPointer"; //$NON-NLS-1$ + static final String PROPERTY_LIST = "isList"; //$NON-NLS-1$ + static final String PROPERTY_REVISION = "revision"; //$NON-NLS-1$ + + private String name; + private String type; + private boolean readonly = false; + private boolean pointer = false; + private boolean list = false; + private int revision; + + QMLPropertyInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) { + if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) { + for (IQmlObjectMember member : obj.getBody().getMembers()) { + if (builder.ensureNode(member, IQmlPropertyBinding.class)) { + IQmlPropertyBinding prop = (IQmlPropertyBinding) member; + switch (prop.getIdentifier().getName()) { + case PROPERTY_NAME: + this.name = builder.getStringBinding(prop); + break; + case PROPERTY_TYPE: + this.type = builder.getStringBinding(prop); + break; + case PROPERTY_READONLY: + this.readonly = builder.getBooleanBinding(prop); + break; + case PROPERTY_POINTER: + this.pointer = builder.getBooleanBinding(prop); + break; + case PROPERTY_LIST: + this.list = builder.getBooleanBinding(prop); + break; + case PROPERTY_REVISION: + this.revision = builder.getIntegerBinding(prop); + break; + default: + } + } + } + } + } + + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public int getRevision() { + return revision; + } + + public boolean isReadonly() { + return readonly; + } + + public boolean isPointer() { + return pointer; + } + + public boolean isList() { + return list; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLSignalInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLSignalInfo.java index 70193b90d28..b56280fe5ea 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLSignalInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLSignalInfo.java @@ -1,69 +1,69 @@ -/*******************************************************************************
- * 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.internal.qt.core.qmltypes;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition;
-import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember;
-import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding;
-
-public class QMLSignalInfo {
- static final String IDENTIFIER = "Signal"; //$NON-NLS-1$
-
- static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ s
- static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$
- static final String PROPERTY_REVISION = "revision"; //$NON-NLS-1$
-
- private String name;
- private String type;
- private Integer revision;
- private List<QMLParameterInfo> parameterList = new ArrayList<>();
-
- QMLSignalInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) {
- if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) {
- for (IQmlObjectMember member : obj.getBody().getMembers()) {
- if (member instanceof IQmlPropertyBinding) {
- IQmlPropertyBinding prop = (IQmlPropertyBinding) member;
- switch (prop.getIdentifier().getName()) {
- case PROPERTY_NAME:
- this.name = builder.getStringBinding(prop);
- break;
- case PROPERTY_TYPE:
- this.type = builder.getStringBinding(prop);
- break;
- case PROPERTY_REVISION:
- this.revision = builder.getIntegerBinding(prop);
- break;
- default:
- }
- } else if (member instanceof IQmlObjectDefinition) {
- this.parameterList.add(new QMLParameterInfo(builder, (IQmlObjectDefinition) member));
- } else {
- builder.unexpectedNode(member);
- }
- }
- }
- }
-
- public String getName() {
- return name;
- }
-
- public String getType() {
- return type;
- }
-
- public int getRevision() {
- return revision;
- }
-}
+/******************************************************************************* + * 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.internal.qt.core.qmltypes; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectDefinition; +import org.eclipse.cdt.qt.core.qmljs.IQmlObjectMember; +import org.eclipse.cdt.qt.core.qmljs.IQmlPropertyBinding; + +public class QMLSignalInfo { + static final String IDENTIFIER = "Signal"; //$NON-NLS-1$ + + static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ s + static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$ + static final String PROPERTY_REVISION = "revision"; //$NON-NLS-1$ + + private String name; + private String type; + private Integer revision; + private List<QMLParameterInfo> parameterList = new ArrayList<>(); + + QMLSignalInfo(QMLModelBuilder builder, IQmlObjectDefinition obj) { + if (builder.ensureIdentifier(obj.getIdentifier(), IDENTIFIER)) { + for (IQmlObjectMember member : obj.getBody().getMembers()) { + if (member instanceof IQmlPropertyBinding) { + IQmlPropertyBinding prop = (IQmlPropertyBinding) member; + switch (prop.getIdentifier().getName()) { + case PROPERTY_NAME: + this.name = builder.getStringBinding(prop); + break; + case PROPERTY_TYPE: + this.type = builder.getStringBinding(prop); + break; + case PROPERTY_REVISION: + this.revision = builder.getIntegerBinding(prop); + break; + default: + } + } else if (member instanceof IQmlObjectDefinition) { + this.parameterList.add(new QMLParameterInfo(builder, (IQmlObjectDefinition) member)); + } else { + builder.unexpectedNode(member); + } + } + } + } + + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public int getRevision() { + return revision; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQMLAnalyzer.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQMLAnalyzer.java index 6c8343f110f..877243c5933 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQMLAnalyzer.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQMLAnalyzer.java @@ -1,46 +1,46 @@ -/*******************************************************************************
- * 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;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
-import javax.script.Bindings;
-import javax.script.ScriptException;
-
-import org.eclipse.cdt.qt.core.qmljs.IQmlASTNode;
-
-public interface IQMLAnalyzer {
-
- void addFile(String fileName, String code) throws NoSuchMethodException, ScriptException;
-
- void deleteFile(String fileName) throws NoSuchMethodException, ScriptException;
-
- IQmlASTNode parseFile(String fileName, String text) throws NoSuchMethodException, ScriptException;
-
- IQmlASTNode parseString(String text) throws NoSuchMethodException, ScriptException;
-
- IQmlASTNode parseString(String text, String mode, boolean locations, boolean ranges)
- throws NoSuchMethodException, ScriptException;
-
- Collection<QMLTernCompletion> getCompletions(String fileName, String text, int pos)
- throws NoSuchMethodException, ScriptException;
-
- Collection<QMLTernCompletion> getCompletions(String fileName, String text, int pos, boolean includeKeywords)
- throws NoSuchMethodException, ScriptException;
-
- List<Bindings> getDefinition(String identifier, String fileName, String text, int pos)
- throws NoSuchMethodException, ScriptException;
-
- void load() throws ScriptException, IOException, NoSuchMethodException;
-
+/******************************************************************************* + * 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; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import javax.script.Bindings; +import javax.script.ScriptException; + +import org.eclipse.cdt.qt.core.qmljs.IQmlASTNode; + +public interface IQMLAnalyzer { + + void addFile(String fileName, String code) throws NoSuchMethodException, ScriptException; + + void deleteFile(String fileName) throws NoSuchMethodException, ScriptException; + + IQmlASTNode parseFile(String fileName, String text) throws NoSuchMethodException, ScriptException; + + IQmlASTNode parseString(String text) throws NoSuchMethodException, ScriptException; + + IQmlASTNode parseString(String text, String mode, boolean locations, boolean ranges) + throws NoSuchMethodException, ScriptException; + + Collection<QMLTernCompletion> getCompletions(String fileName, String text, int pos) + throws NoSuchMethodException, ScriptException; + + Collection<QMLTernCompletion> getCompletions(String fileName, String text, int pos, boolean includeKeywords) + throws NoSuchMethodException, ScriptException; + + List<Bindings> getDefinition(String identifier, String fileName, String text, int pos) + throws NoSuchMethodException, ScriptException; + + void load() throws ScriptException, IOException, NoSuchMethodException; + }
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java index 024a91a9688..7e72da89438 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java @@ -1,38 +1,38 @@ -/*******************************************************************************
- * Copyright (c) 2016 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
- *******************************************************************************/
-package org.eclipse.cdt.qt.core;
-
-import java.nio.file.Path;
-
-import org.eclipse.cdt.core.build.ICBuildConfiguration;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Qt specific build configuration settings.
- *
- * @noimplement
- */
-public interface IQtBuildConfiguration extends ICBuildConfiguration {
-
- Path getBuildDirectory() throws CoreException;
-
- Path getQmakeCommand();
-
- String[] getQmakeConfig();
-
- /**
- * @deprecated use getBuildOutput() instead
- */
- @Deprecated
- Path getProgramPath() throws CoreException;
-
- String getLaunchMode();
-
- IQtInstall getQtInstall();
-
-}
+/******************************************************************************* + * Copyright (c) 2016 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 + *******************************************************************************/ +package org.eclipse.cdt.qt.core; + +import java.nio.file.Path; + +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.core.runtime.CoreException; + +/** + * Qt specific build configuration settings. + * + * @noimplement + */ +public interface IQtBuildConfiguration extends ICBuildConfiguration { + + Path getBuildDirectory() throws CoreException; + + Path getQmakeCommand(); + + String[] getQmakeConfig(); + + /** + * @deprecated use getBuildOutput() instead + */ + @Deprecated + Path getProgramPath() throws CoreException; + + String getLaunchMode(); + + IQtInstall getQtInstall(); + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/IPosition.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/IPosition.java index e4f98f7df53..48d635a5b08 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/IPosition.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/IPosition.java @@ -1,30 +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.location;
-
-/**
- * Stores a line/offset pair as integers.
- */
-public interface IPosition {
- /**
- * Gets the one-indexed line number indicated by this <code>IPosition</code>
- *
- * @return the line number
- */
- public int getLine();
-
- /**
- * Gets the zero-indexed column indicated by this <code>IPosition</code>
- *
- * @return the column
- */
- public int getColumn();
-}
+/******************************************************************************* + * 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.location; + +/** + * Stores a line/offset pair as integers. + */ +public interface IPosition { + /** + * Gets the one-indexed line number indicated by this <code>IPosition</code> + * + * @return the line number + */ + public int getLine(); + + /** + * Gets the zero-indexed column indicated by this <code>IPosition</code> + * + * @return the column + */ + public int getColumn(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/ISourceLocation.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/ISourceLocation.java index 98383ff1c19..07f441e1623 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/ISourceLocation.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/ISourceLocation.java @@ -1,38 +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.location;
-
-/**
- * Represents a location in a source file. Uses the {@link IPosition} interface to store the start and end locations as a
- * line/offset pair.
- */
-public interface ISourceLocation {
- /**
- * Gets the String representing the source of this <code>ISourceLocation</code>
- *
- * @return the source or <code>null</code> if not available
- */
- public String getSource();
-
- /**
- * Gets the zero-indexed offset indicating the start of this <code>ISourceLocation</code>
- *
- * @return the start offset
- */
- public IPosition getStart();
-
- /**
- * Gets the zero-indexed offset indicating the end of this <code>ISourceLocation</code>
- *
- * @return the end offset
- */
- public IPosition getEnd();
-}
+/******************************************************************************* + * 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.location; + +/** + * Represents a location in a source file. Uses the {@link IPosition} interface to store the start and end locations as a + * line/offset pair. + */ +public interface ISourceLocation { + /** + * Gets the String representing the source of this <code>ISourceLocation</code> + * + * @return the source or <code>null</code> if not available + */ + public String getSource(); + + /** + * Gets the zero-indexed offset indicating the start of this <code>ISourceLocation</code> + * + * @return the start offset + */ + public IPosition getStart(); + + /** + * Gets the zero-indexed offset indicating the end of this <code>ISourceLocation</code> + * + * @return the end offset + */ + public IPosition getEnd(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirAST.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirAST.java index 314614a2333..cb9bcaf3eed 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirAST.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirAST.java @@ -1,26 +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.qmldir;
-
-import java.util.List;
-
-/**
- * The main entry point into the qmldir AST. This interface contains a list of Commands specified within the qmldir file that it
- * represents.
- */
-public interface IQDirAST extends IQDirASTNode {
- /**
- * Gets the list of commands in the qmldir file that this <code>IQDirAST</code> represents.
- *
- * @return the list of all commands in the qmldir file
- */
- public List<IQDirCommand> getCommands();
-}
+/******************************************************************************* + * 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.qmldir; + +import java.util.List; + +/** + * The main entry point into the qmldir AST. This interface contains a list of Commands specified within the qmldir file that it + * represents. + */ +public interface IQDirAST extends IQDirASTNode { + /** + * Gets the list of commands in the qmldir file that this <code>IQDirAST</code> represents. + * + * @return the list of all commands in the qmldir file + */ + public List<IQDirCommand> getCommands(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirASTNode.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirASTNode.java index 2dd877e6b1f..37b364b7d4f 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirASTNode.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirASTNode.java @@ -1,41 +1,41 @@ -/*******************************************************************************
- * 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.qmldir;
-
-import org.eclipse.cdt.qt.core.location.ISourceLocation;
-
-/**
- * The base type for all qmldir AST nodes. Contains methods for retrieving a node's positional information.
- */
-public interface IQDirASTNode {
- /**
- * 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.
- *
- * @return the {@link ISourceLocation} representing this node's location in the source
- */
- public ISourceLocation getLocation();
-
- /**
- * Gets the zero-indexed offset indicating the start of this node in the source.
- *
- * @return the node's start offset
- */
- public int getStart();
-
- /**
- * Gets the zero-indexed offset indicating the end of this node in the source.
- *
- * @return the node's end offset
- */
- public int getEnd();
-}
+/******************************************************************************* + * 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.qmldir; + +import org.eclipse.cdt.qt.core.location.ISourceLocation; + +/** + * The base type for all qmldir AST nodes. Contains methods for retrieving a node's positional information. + */ +public interface IQDirASTNode { + /** + * 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. + * + * @return the {@link ISourceLocation} representing this node's location in the source + */ + public ISourceLocation getLocation(); + + /** + * Gets the zero-indexed offset indicating the start of this node in the source. + * + * @return the node's start offset + */ + public int getStart(); + + /** + * Gets the zero-indexed offset indicating the end of this node in the source. + * + * @return the node's end offset + */ + public int getEnd(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirClassnameCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirClassnameCommand.java index 13ce512dea8..5018b691412 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirClassnameCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirClassnameCommand.java @@ -1,25 +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.qmldir;
-
-/**
- * An AST Node representing a Classname Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirClassnameCommand extends IQDirCommand {
- /**
- * Gets the <code>IQDirWord</code> representing the identifier for the classname.
- *
- * @return the identifier for the classname
- */
- public IQDirWord getIdentifier();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a Classname Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirClassnameCommand extends IQDirCommand { + /** + * Gets the <code>IQDirWord</code> representing the identifier for the classname. + * + * @return the identifier for the classname + */ + public IQDirWord getIdentifier(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommand.java index 7a785aed919..75b6c154a92 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommand.java @@ -1,19 +1,19 @@ -/*******************************************************************************
- * 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.qmldir;
-
-/**
- * The base interface for all qmldir AST nodes that function as commands.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirCommand extends IQDirASTNode {
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * The base interface for all qmldir AST nodes that function as commands. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirCommand extends IQDirASTNode { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommentCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommentCommand.java index cec1c25531f..87f269faf28 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommentCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommentCommand.java @@ -1,25 +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.qmldir;
-
-/**
- * An AST Node representing a Comment Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirCommentCommand extends IQDirCommand {
- /**
- * Gets the String representation of this comment as it appears in the qmldir file.
- *
- * @return the String representation of this comment
- */
- public String getText();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a Comment Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirCommentCommand extends IQDirCommand { + /** + * Gets the String representation of this comment as it appears in the qmldir file. + * + * @return the String representation of this comment + */ + public String getText(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDependsCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDependsCommand.java index 0e6fbcc6bcd..93cb7728bc7 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDependsCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDependsCommand.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * 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.qmldir;
-
-/**
- * An AST Node representing a Depends Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirDependsCommand extends IQDirCommand {
- /**
- * Gets the <code>IQDirWord</code> representing the module identifier that this qmldir module depends on.
- *
- * @return the module identifier
- */
- public IQDirWord getModuleIdentifier();
-
- /**
- * Gets the <code>IQDirVersion</code> representing the initial version of the module that this qmldir module depends on.
- *
- * @return the initial version
- */
- public IQDirVersion getInitialVersion();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a Depends Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirDependsCommand extends IQDirCommand { + /** + * Gets the <code>IQDirWord</code> representing the module identifier that this qmldir module depends on. + * + * @return the module identifier + */ + public IQDirWord getModuleIdentifier(); + + /** + * Gets the <code>IQDirVersion</code> representing the initial version of the module that this qmldir module depends on. + * + * @return the initial version + */ + public IQDirVersion getInitialVersion(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDesignerSupportedCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDesignerSupportedCommand.java index 1619501ac44..09e905aebfd 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDesignerSupportedCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDesignerSupportedCommand.java @@ -1,19 +1,19 @@ -/*******************************************************************************
- * 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.qmldir;
-
-/**
- * An AST Node representing a Designer Supported Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirDesignerSupportedCommand extends IQDirCommand {
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a Designer Supported Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirDesignerSupportedCommand extends IQDirCommand { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirInternalCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirInternalCommand.java index 0af6388e6b7..5608afcd8d1 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirInternalCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirInternalCommand.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * 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.qmldir;
-
-/**
- * An AST Node representing an Internal Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirInternalCommand extends IQDirCommand {
- /**
- * Gets the <code>IQDirWord</code> representing the type name of the internal type.
- *
- * @return the type names
- */
- public IQDirWord getTypeName();
-
- /**
- * Gets the <code>IQDirWord</code> representing the filename of the internal type.
- *
- * @return the filename
- */
- public IQDirWord getFile();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing an Internal Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirInternalCommand extends IQDirCommand { + /** + * Gets the <code>IQDirWord</code> representing the type name of the internal type. + * + * @return the type names + */ + public IQDirWord getTypeName(); + + /** + * Gets the <code>IQDirWord</code> representing the filename of the internal type. + * + * @return the filename + */ + public IQDirWord getFile(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirModuleCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirModuleCommand.java index 6ad218e970a..90dfaddd80f 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirModuleCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirModuleCommand.java @@ -1,25 +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.qmldir;
-
-/**
- * An AST Node representing a Module Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirModuleCommand extends IQDirCommand {
- /**
- * Gets the <code>IQDirWord</code> representing the identifier for the module.
- *
- * @return the identifier for the module
- */
- public IQDirWord getModuleIdentifier();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a Module Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirModuleCommand extends IQDirCommand { + /** + * Gets the <code>IQDirWord</code> representing the identifier for the module. + * + * @return the identifier for the module + */ + public IQDirWord getModuleIdentifier(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirPluginCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirPluginCommand.java index bd1c4279cb6..87b044bf7bf 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirPluginCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirPluginCommand.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * 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.qmldir;
-
-/**
- * An AST Node representing a Plugin Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirPluginCommand extends IQDirCommand {
- /**
- * Gets the <code>IQDirWord</code> representing the name of the plugin.
- *
- * @return the plugin name
- */
- public IQDirWord getName();
-
- /**
- * Gets the <code>IQDirWord</code> representing the path to the plugin if it was given.
- *
- * @return the path to the plugin or <code>null</code> if not available
- */
- public IQDirWord getPath();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a Plugin Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirPluginCommand extends IQDirCommand { + /** + * Gets the <code>IQDirWord</code> representing the name of the plugin. + * + * @return the plugin name + */ + public IQDirWord getName(); + + /** + * Gets the <code>IQDirWord</code> representing the path to the plugin if it was given. + * + * @return the path to the plugin or <code>null</code> if not available + */ + public IQDirWord getPath(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirResourceCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirResourceCommand.java index d92838d2da4..5288fd732e3 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirResourceCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirResourceCommand.java @@ -1,39 +1,39 @@ -/*******************************************************************************
- * 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.qmldir;
-
-/**
- * An AST Node representing a Resource Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirResourceCommand extends IQDirCommand {
- /**
- * Gets the <code>IQDirWord</code> representing the identifier of the resource.
- *
- * @return the identifier of the resource
- */
- public IQDirWord getResourceIdentifier();
-
- /**
- * Gets the <code>IQDirVersion</code> representing the initial version of the resource.
- *
- * @return the initial version
- */
- public IQDirVersion getInitialVersion();
-
- /**
- * Gets the <code>IQDirWord</code> representing the filename of the resource.
- *
- * @return the filename
- */
- public IQDirWord getFile();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a Resource Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirResourceCommand extends IQDirCommand { + /** + * Gets the <code>IQDirWord</code> representing the identifier of the resource. + * + * @return the identifier of the resource + */ + public IQDirWord getResourceIdentifier(); + + /** + * Gets the <code>IQDirVersion</code> representing the initial version of the resource. + * + * @return the initial version + */ + public IQDirVersion getInitialVersion(); + + /** + * Gets the <code>IQDirWord</code> representing the filename of the resource. + * + * @return the filename + */ + public IQDirWord getFile(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSingletonCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSingletonCommand.java index 7d5547cf4ae..f9e4c246e9f 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSingletonCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSingletonCommand.java @@ -1,39 +1,39 @@ -/*******************************************************************************
- * 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.qmldir;
-
-/**
- * An AST Node representing a Singleton Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirSingletonCommand extends IQDirCommand {
- /**
- * Gets the <code>IQDirWord</code> representing the type name of the singleton type.
- *
- * @return the type name
- */
- public IQDirWord getTypeName();
-
- /**
- * Gets the <code>IQDirVersion</code> representing the initial version of the singleton type.
- *
- * @return the initial version
- */
- public IQDirVersion getInitialVersion();
-
- /**
- * Gets the <code>IQDirWord</code> representing the filename of the singleton type.
- *
- * @return the filename
- */
- public IQDirWord getFile();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a Singleton Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirSingletonCommand extends IQDirCommand { + /** + * Gets the <code>IQDirWord</code> representing the type name of the singleton type. + * + * @return the type name + */ + public IQDirWord getTypeName(); + + /** + * Gets the <code>IQDirVersion</code> representing the initial version of the singleton type. + * + * @return the initial version + */ + public IQDirVersion getInitialVersion(); + + /** + * Gets the <code>IQDirWord</code> representing the filename of the singleton type. + * + * @return the filename + */ + public IQDirWord getFile(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSyntaxError.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSyntaxError.java index 142a125f95c..5417bc8ee6e 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSyntaxError.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSyntaxError.java @@ -1,43 +1,43 @@ -/*******************************************************************************
- * 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.qmldir;
-
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.Token;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryParser.SyntaxError;
-
-/**
- * An AST Node representing a syntax error in a qmldir file. Due to the fact that the qmldir file is so simple, a syntax error will
- * only occur at the command level while the parser jumps to the next line to recover.
- */
-public interface IQDirSyntaxError extends IQDirCommand {
- /**
- * Gets the token that caused the parser to fail. This is a helper method equivalent to
- * <code>getSyntaxError.getOffendingToken()</code>.
- *
- * @return the offending token.
- */
- public Token getOffendingToken();
-
- /**
- * Gets the node that the parser was working on before it failed (if available). This is a helper method equivalent to
- * <code>getSyntaxError.getIncompleteNode()</code>.
- *
- * @return the incomplete node or <code>null</code> if not available
- */
- public IQDirASTNode getIncompleteNode();
-
- /**
- * Gets the syntax error that occurred.
- *
- * @return the syntax error
- */
- public SyntaxError getSyntaxError();
-}
+/******************************************************************************* + * 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.qmldir; + +import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.Token; +import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryParser.SyntaxError; + +/** + * An AST Node representing a syntax error in a qmldir file. Due to the fact that the qmldir file is so simple, a syntax error will + * only occur at the command level while the parser jumps to the next line to recover. + */ +public interface IQDirSyntaxError extends IQDirCommand { + /** + * Gets the token that caused the parser to fail. This is a helper method equivalent to + * <code>getSyntaxError.getOffendingToken()</code>. + * + * @return the offending token. + */ + public Token getOffendingToken(); + + /** + * Gets the node that the parser was working on before it failed (if available). This is a helper method equivalent to + * <code>getSyntaxError.getIncompleteNode()</code>. + * + * @return the incomplete node or <code>null</code> if not available + */ + public IQDirASTNode getIncompleteNode(); + + /** + * Gets the syntax error that occurred. + * + * @return the syntax error + */ + public SyntaxError getSyntaxError(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirTypeInfoCommand.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirTypeInfoCommand.java index 943690d8a98..6ddd9dae8f3 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirTypeInfoCommand.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirTypeInfoCommand.java @@ -1,25 +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.qmldir;
-
-/**
- * An AST Node representing a Type Info Command in a qmldir file.
- *
- * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a>
- */
-public interface IQDirTypeInfoCommand extends IQDirCommand {
- /**
- * Gets the <code>IQDirWord</code> representing the filename of the type info file.
- *
- * @return the filename of the type info file
- */
- public IQDirWord getFile();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a Type Info Command in a qmldir file. + * + * @see <a href="http://doc.qt.io/qt-5/qtqml-modules-qmldir.html">Module Definition qmldir Files</a> + */ +public interface IQDirTypeInfoCommand extends IQDirCommand { + /** + * Gets the <code>IQDirWord</code> representing the filename of the type info file. + * + * @return the filename of the type info file + */ + public IQDirWord getFile(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirVersion.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirVersion.java index f8f715277d3..a65c55d179d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirVersion.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirVersion.java @@ -1,23 +1,23 @@ -/*******************************************************************************
- * 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.qmldir;
-
-/**
- * An AST Node representing a version String of the form <MajorVersion>.<MinorVersion>
- */
-public interface IQDirVersion extends IQDirASTNode {
- /**
- * Gets the String value of this version. The result will always be of the form "<MajorVersion>.<MinorVersion>"
- *
- * @return a string value of this version
- */
- public String getVersionString();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a version String of the form <MajorVersion>.<MinorVersion> + */ +public interface IQDirVersion extends IQDirASTNode { + /** + * Gets the String value of this version. The result will always be of the form "<MajorVersion>.<MinorVersion>" + * + * @return a string value of this version + */ + public String getVersionString(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirWord.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirWord.java index 2afa6e005ce..e7e61712245 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirWord.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirWord.java @@ -1,27 +1,27 @@ -/*******************************************************************************
- * 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.qmldir;
-
-/**
- * An AST Node representing a set of characters that does not contain whitespace and does not start with a digit. This encompasses
- * the syntax for Identifiers, Qualified IDs, Paths, and File Names all in one parser rule.
- */
-public interface IQDirWord extends IQDirASTNode {
- /**
- * Gets the String representing this word as it appears in the qmldir file.<br>
- * <br>
- * <b>Note:</b> The text is not modified or validated in any way when it is parsed. It is necessary for the caller to perform
- * semantic validation of the returned value to ensure it represents a valid identifier, filename, or path.
- *
- * @return a string representing this word
- */
- public String getText();
-}
+/******************************************************************************* + * 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.qmldir; + +/** + * An AST Node representing a set of characters that does not contain whitespace and does not start with a digit. This encompasses + * the syntax for Identifiers, Qualified IDs, Paths, and File Names all in one parser rule. + */ +public interface IQDirWord extends IQDirASTNode { + /** + * Gets the String representing this word as it appears in the qmldir file.<br> + * <br> + * <b>Note:</b> The text is not modified or validated in any way when it is parsed. It is necessary for the caller to perform + * semantic validation of the returned value to ensure it represents a valid identifier, filename, or path. + * + * @return a string representing this word + */ + public String getText(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryInfo.java index be70e0c39cd..8451a64c6b9 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryInfo.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryInfo.java @@ -1,180 +1,180 @@ -/*******************************************************************************
- * 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.qmldir;
-
-import java.io.InputStream;
-import java.nio.file.InvalidPathException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-
-import org.eclipse.cdt.internal.qt.core.Activator;
-
-public class QMLDirectoryInfo {
- public static class Module {
- private final String name;
- private final String initialVersion;
-
- public Module(String name, String ver) {
- this.name = name;
- this.initialVersion = ver;
- }
-
- public String getName() {
- return name;
- }
-
- public String getInitialVersion() {
- return initialVersion;
- }
- }
-
- public static class Plugin {
- private final String name;
- private final Path path;
-
- private Plugin(String name, String path) {
- this.name = name;
- Path p = null;
- if (path != null) {
- try {
- p = Paths.get(path);
- } catch (InvalidPathException e) {
- Activator.log(e);
- }
- }
- this.path = p;
- }
-
- public String getName() {
- return name;
- }
-
- public Path getRelativePath() {
- return path;
- }
- }
-
- public static class ResourceFile {
- private final String name;
- private final boolean internal;
- private final boolean singleton;
- private final String initialVersion;
-
- private ResourceFile(String name, String ver, boolean internal, boolean singleton) {
- this.name = name;
- this.initialVersion = ver;
- this.internal = internal;
- this.singleton = singleton;
- }
-
- public String getName() {
- return name;
- }
-
- public String getInitialVersion() {
- return initialVersion;
- }
-
- public boolean isSingleton() {
- return singleton;
- }
-
- public boolean isInternal() {
- return internal;
- }
- }
-
- private String moduleIdentifier;
- private Plugin plugin;
- private String classname;
- private String typeInfo;
- private final Collection<Module> depends;
- private final Collection<ResourceFile> resources;
- private boolean designersupported;
-
- public QMLDirectoryInfo(InputStream input) {
- this.depends = new LinkedList<>();
- this.resources = new LinkedList<>();
-
- IQDirAST ast = new QMLDirectoryParser().parse(input);
- for (IQDirCommand c : ast.getCommands()) {
- if (c instanceof IQDirModuleCommand) {
- if (moduleIdentifier == null) {
- moduleIdentifier = ((IQDirModuleCommand) c).getModuleIdentifier().getText();
- }
- } else if (c instanceof IQDirPluginCommand) {
- if (plugin == null) {
- IQDirPluginCommand pc = (IQDirPluginCommand) c;
- plugin = new Plugin(pc.getName().getText(), pc.getPath() != null ? pc.getPath().getText() : null);
- }
- } else if (c instanceof IQDirTypeInfoCommand) {
- if (typeInfo == null) {
- typeInfo = ((IQDirTypeInfoCommand) c).getFile().getText();
- }
- } else if (c instanceof IQDirResourceCommand) {
- IQDirResourceCommand rc = (IQDirResourceCommand) c;
- resources.add(new ResourceFile(rc.getFile().getText(),
- rc.getInitialVersion().getVersionString(),
- false, false));
- } else if (c instanceof IQDirInternalCommand) {
- IQDirInternalCommand rc = (IQDirInternalCommand) c;
- resources.add(new ResourceFile(rc.getFile().getText(),
- null, true, false));
- } else if (c instanceof IQDirSingletonCommand) {
- IQDirSingletonCommand rc = (IQDirSingletonCommand) c;
- resources.add(new ResourceFile(rc.getFile().getText(),
- rc.getInitialVersion().getVersionString(),
- false, true));
- } else if (c instanceof IQDirDependsCommand) {
- IQDirDependsCommand dc = (IQDirDependsCommand) c;
- depends.add(new Module(dc.getModuleIdentifier().getText(),
- dc.getInitialVersion().getVersionString()));
- } else if (c instanceof IQDirClassnameCommand) {
- if (classname == null) {
- classname = ((IQDirClassnameCommand) c).getIdentifier().getText();
- }
- } else if (c instanceof IQDirDesignerSupportedCommand) {
- designersupported = true;
- }
- }
- }
-
- public String getModuleIdentifier() {
- return moduleIdentifier;
- }
-
- public Plugin getPlugin() {
- return plugin;
- }
-
- public String getClassname() {
- return classname;
- }
-
- public String getTypesFileName() {
- return typeInfo;
- }
-
- public Collection<Module> getDependentModules() {
- return Collections.unmodifiableCollection(depends);
- }
-
- public Collection<ResourceFile> getResources() {
- return Collections.unmodifiableCollection(resources);
- }
-
- public boolean isDesignersupported() {
- return designersupported;
- }
-}
+/******************************************************************************* + * 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.qmldir; + +import java.io.InputStream; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; + +import org.eclipse.cdt.internal.qt.core.Activator; + +public class QMLDirectoryInfo { + public static class Module { + private final String name; + private final String initialVersion; + + public Module(String name, String ver) { + this.name = name; + this.initialVersion = ver; + } + + public String getName() { + return name; + } + + public String getInitialVersion() { + return initialVersion; + } + } + + public static class Plugin { + private final String name; + private final Path path; + + private Plugin(String name, String path) { + this.name = name; + Path p = null; + if (path != null) { + try { + p = Paths.get(path); + } catch (InvalidPathException e) { + Activator.log(e); + } + } + this.path = p; + } + + public String getName() { + return name; + } + + public Path getRelativePath() { + return path; + } + } + + public static class ResourceFile { + private final String name; + private final boolean internal; + private final boolean singleton; + private final String initialVersion; + + private ResourceFile(String name, String ver, boolean internal, boolean singleton) { + this.name = name; + this.initialVersion = ver; + this.internal = internal; + this.singleton = singleton; + } + + public String getName() { + return name; + } + + public String getInitialVersion() { + return initialVersion; + } + + public boolean isSingleton() { + return singleton; + } + + public boolean isInternal() { + return internal; + } + } + + private String moduleIdentifier; + private Plugin plugin; + private String classname; + private String typeInfo; + private final Collection<Module> depends; + private final Collection<ResourceFile> resources; + private boolean designersupported; + + public QMLDirectoryInfo(InputStream input) { + this.depends = new LinkedList<>(); + this.resources = new LinkedList<>(); + + IQDirAST ast = new QMLDirectoryParser().parse(input); + for (IQDirCommand c : ast.getCommands()) { + if (c instanceof IQDirModuleCommand) { + if (moduleIdentifier == null) { + moduleIdentifier = ((IQDirModuleCommand) c).getModuleIdentifier().getText(); + } + } else if (c instanceof IQDirPluginCommand) { + if (plugin == null) { + IQDirPluginCommand pc = (IQDirPluginCommand) c; + plugin = new Plugin(pc.getName().getText(), pc.getPath() != null ? pc.getPath().getText() : null); + } + } else if (c instanceof IQDirTypeInfoCommand) { + if (typeInfo == null) { + typeInfo = ((IQDirTypeInfoCommand) c).getFile().getText(); + } + } else if (c instanceof IQDirResourceCommand) { + IQDirResourceCommand rc = (IQDirResourceCommand) c; + resources.add(new ResourceFile(rc.getFile().getText(), + rc.getInitialVersion().getVersionString(), + false, false)); + } else if (c instanceof IQDirInternalCommand) { + IQDirInternalCommand rc = (IQDirInternalCommand) c; + resources.add(new ResourceFile(rc.getFile().getText(), + null, true, false)); + } else if (c instanceof IQDirSingletonCommand) { + IQDirSingletonCommand rc = (IQDirSingletonCommand) c; + resources.add(new ResourceFile(rc.getFile().getText(), + rc.getInitialVersion().getVersionString(), + false, true)); + } else if (c instanceof IQDirDependsCommand) { + IQDirDependsCommand dc = (IQDirDependsCommand) c; + depends.add(new Module(dc.getModuleIdentifier().getText(), + dc.getInitialVersion().getVersionString())); + } else if (c instanceof IQDirClassnameCommand) { + if (classname == null) { + classname = ((IQDirClassnameCommand) c).getIdentifier().getText(); + } + } else if (c instanceof IQDirDesignerSupportedCommand) { + designersupported = true; + } + } + } + + public String getModuleIdentifier() { + return moduleIdentifier; + } + + public Plugin getPlugin() { + return plugin; + } + + public String getClassname() { + return classname; + } + + public String getTypesFileName() { + return typeInfo; + } + + public Collection<Module> getDependentModules() { + return Collections.unmodifiableCollection(depends); + } + + public Collection<ResourceFile> getResources() { + return Collections.unmodifiableCollection(resources); + } + + public boolean isDesignersupported() { + return designersupported; + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryLexer.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryLexer.java index 0e0756e718b..7e15fbfb31a 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryLexer.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryLexer.java @@ -1,252 +1,252 @@ -/*******************************************************************************
- * 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.qmldir;
-
-import java.io.InputStream;
-import java.util.Scanner;
-import java.util.regex.MatchResult;
-import java.util.regex.Pattern;
-
-import org.eclipse.cdt.internal.qt.core.location.Position;
-import org.eclipse.cdt.internal.qt.core.location.SourceLocation;
-import org.eclipse.cdt.qt.core.location.ISourceLocation;
-
-/**
- * Converts an <code>InputStream</code> representing a qmldir file into a stream of tokens through successive calls to
- * <code>nextToken</code>. This lexer uses regular expressions to match its 16 valid token types:
- * <ul>
- * <li><b>COMMENT</b>: A single line comment that begins with '#'
- * <li><b>MODULE</b>: Keyword 'module'
- * <li><b>TYPEINFO</b>: The keyword 'typeinfo'
- * <li><b>SINGLETON</b>: The keyword 'singleton'
- * <li><b>INTERNAL</b>: The keyword 'internal'
- * <li><b>PLUGIN</b>: The keyword 'plugin'
- * <li><b>CLASSNAME</b>: The keyword 'classname'
- * <li><b>DEPENDS</b>: The keyword 'depends'
- * <li><b>DESIGNERSUPPORTED</b>: The keyword 'designersupported'
- * <li><b>WORD</b>: A group of characters that form an identifier, filename, or path
- * <li><b>DECIMAL</b>: A number of the form [0-9]+ '.' [0-9]+
- * <li><b>INTEGER</b>: An integer of the form [0-9]+
- * <li><b>WHITESPACE</b>: A group of whitespace characters (not including newlines)
- * <li><b>COMMAND_END</b>: A newline character
- * <li><b>UNKNOWN</b>: A group of characters that does not match any of the preceding tokens
- * <li><b>EOF</b>: End of File
- * </ul>
- */
-public class QMLDirectoryLexer {
- /**
- * A single matched token returned by a <code>QMLDirectoryLexer</code>. A <code>Token</code> stores information on how it was
- * matched including the type of token, the exact text that was matched, and its position in the <code>InputStream</code> .
- */
- public static class Token {
- private final TokenType tokType;
- private final String raw;
- private final ISourceLocation location;
- private final int start;
- private final int end;
-
- private Token(TokenType type, MatchResult match, int line, int lineStart) {
- this(type, match.group(), match.start(), match.end(), line, lineStart);
- }
-
- private Token(TokenType type, String raw, int start, int end, int line, int lineStart) {
- this.tokType = type;
- raw = raw.replaceAll("\n", "\\\\n"); //$NON-NLS-1$ //$NON-NLS-2$
- raw = raw.replaceAll("\r", "\\\\r"); //$NON-NLS-1$ //$NON-NLS-2$
- this.raw = raw;
- this.start = start;
- this.end = end;
- this.location = new SourceLocation(null,
- new Position(line, start - lineStart),
- new Position(line, end - lineStart));
- }
-
- /**
- * Get the type of token that was matched.
- *
- * @return the type of token
- */
- public TokenType getType() {
- return tokType;
- }
-
- /**
- * Gets the raw text that this token was matched with.
- *
- * @return a String representing the matched text
- */
- public String getText() {
- return raw;
- }
-
- /**
- * Gets a more detailed description of this token's location in the <code>InputStream</code> than {@link Token#getStart()}
- * and {@link Token#getEnd()}. This method allows the retrieval of line and column information in order to make output for
- * syntax errors and the like more human-readable.
- *
- * @return the {@link ISourceLocation} representing this token's location in the <code>InputStream</code>
- */
- public ISourceLocation getLocation() {
- return location;
- }
-
- /**
- * Gets the zero-indexed offset indicating the start of this token in the <code>InputStream</code>.
- *
- * @return the token's start offset
- */
- public int getStart() {
- return start;
- }
-
- /**
- * Gets the zero-indexed offset indicating the end of this token in the <code>InputStream</code>.
- *
- * @return the token's end offset
- */
- public int getEnd() {
- return end;
- }
- }
-
- /**
- * An Enumeration encompassing the 16 possible types of tokens returned by a <code>QMLDirectoryLexer</code>.
- *
- * @see org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer
- */
- public static enum TokenType {
- COMMENT("#.*$"), //$NON-NLS-1$
- MODULE("module(?=\\s|$)"), //$NON-NLS-1$
- TYPEINFO("typeinfo(?=\\s|$)"), //$NON-NLS-1$
- SINGLETON("singleton(?=\\s|$)"), //$NON-NLS-1$
- INTERNAL("internal(?=\\s|$)"), //$NON-NLS-1$
- PLUGIN("plugin(?=\\s|$)"), //$NON-NLS-1$
- CLASSNAME("classname(?=\\s|$)"), //$NON-NLS-1$
- DEPENDS("depends(?=\\s|$)"), //$NON-NLS-1$
- DESIGNERSUPPORTED("designersupported(?=\\s|$)"), //$NON-NLS-1$
- WORD("[^0-9\\s][^\\s]*"), //$NON-NLS-1$
- DECIMAL("[0-9]+\\.[0-9]+"), //$NON-NLS-1$
- INTEGER("[0-9]+"), //$NON-NLS-1$
- WHITESPACE("\\h+"), //$NON-NLS-1$
- COMMAND_END("(?:\r\n)|\n"), //$NON-NLS-1$
- UNKNOWN(".+"), //$NON-NLS-1$
- EOF(null);
-
- private static Pattern pattern;
-
- private static Pattern patternForAllTerminals() {
- if (pattern == null) {
- String regex = ""; //$NON-NLS-1$
- TokenType[] tokens = TokenType.values();
- for (int i = 0; i < TokenType.values().length; i++) {
- TokenType tok = tokens[i];
- if (tok.regex != null) {
- if (i != 0) {
- regex += "|"; //$NON-NLS-1$
- }
- regex += "(" + tok.regex + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- pattern = Pattern.compile(regex, Pattern.MULTILINE);
- }
- return pattern;
- }
-
- private final String regex;
-
- private TokenType(String regex) {
- this.regex = regex;
- }
- }
-
- private Scanner input;
- private MatchResult lastMatch;
- private int currentLine;
- private int currentLineStart;
-
- /**
- * Creates a new <code>QMLDirectoryLexer</code> without initializing any of the its internal state. A call to
- * <code>setInput</code> is necessary to fully initialize the lexer before any calls to <code>nextToken</code>.
- */
- public QMLDirectoryLexer() {
- }
-
- /**
- * Prepares for lexical analysis by giving the lexer an <code>InputStream</code> to retrieve text from.
- *
- * @param input
- * the input to perform lexical analysis on
- */
- public void setInput(InputStream input) {
- this.input = new Scanner(input);
- this.lastMatch = null;
- this.currentLine = 1;
- this.currentLineStart = 0;
- }
-
- /**
- * Retrieves the next valid token from the <code>InputStream</code> given by <code>setInput</code>. This is a helper method to
- * skip whitespace that is equivalent to <code>QMLDirectoryLexer.nextToken(true)</code>.
- *
- * @return the next token in the <code>InputStream</code>
- * @throws IllegalArgumentException
- * if <code>setInput</code> has not been called
- */
- public Token nextToken() throws IllegalArgumentException {
- return nextToken(true);
- }
-
- /**
- * Retrieves the next valid token from the <code>InputStream</code> given by <code>setInput</code>. This method has the ability
- * to skip over whitespace tokens by setting <code>skipWhitespace</code> to <code>true</code>.
- *
- * @param skipWhitespace
- * whether or not the lexer should skip whitespace tokens
- * @return the next token in the <code>InputStream</code>
- * @throws IllegalArgumentException
- * if <code>setInput</code> has not been called
- */
- public Token nextToken(boolean skipWhitespace) throws IllegalArgumentException {
- if (input == null) {
- throw new IllegalArgumentException("Input cannot be null"); //$NON-NLS-1$
- }
- if (input.findWithinHorizon(TokenType.patternForAllTerminals(), 0) == null) {
- if (lastMatch != null) {
- return new Token(TokenType.EOF, "", lastMatch.end(), lastMatch.end(), currentLine, currentLineStart); //$NON-NLS-1$
- } else {
- return new Token(TokenType.EOF, "", 0, 0, 1, 0); //$NON-NLS-1$
- }
- } else {
- int groupNo = 1;
- for (TokenType t : TokenType.values()) {
- if (t.regex != null) {
- if (input.match().start(groupNo) != -1) {
- lastMatch = input.match();
- Token next = null;
- if (!(t.equals(TokenType.WHITESPACE) && skipWhitespace)) {
- next = new Token(t, input.match(), currentLine, currentLineStart);
- } else {
- next = nextToken(skipWhitespace);
- }
- if (t.equals(TokenType.COMMAND_END)) {
- // Advance the line number information
- currentLine++;
- currentLineStart = input.match().end();
- }
- return next;
- }
- groupNo++;
- }
- }
- return new Token(TokenType.UNKNOWN, input.match(), currentLine, currentLineStart);
- }
- }
-}
+/******************************************************************************* + * 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.qmldir; + +import java.io.InputStream; +import java.util.Scanner; +import java.util.regex.MatchResult; +import java.util.regex.Pattern; + +import org.eclipse.cdt.internal.qt.core.location.Position; +import org.eclipse.cdt.internal.qt.core.location.SourceLocation; +import org.eclipse.cdt.qt.core.location.ISourceLocation; + +/** + * Converts an <code>InputStream</code> representing a qmldir file into a stream of tokens through successive calls to + * <code>nextToken</code>. This lexer uses regular expressions to match its 16 valid token types: + * <ul> + * <li><b>COMMENT</b>: A single line comment that begins with '#' + * <li><b>MODULE</b>: Keyword 'module' + * <li><b>TYPEINFO</b>: The keyword 'typeinfo' + * <li><b>SINGLETON</b>: The keyword 'singleton' + * <li><b>INTERNAL</b>: The keyword 'internal' + * <li><b>PLUGIN</b>: The keyword 'plugin' + * <li><b>CLASSNAME</b>: The keyword 'classname' + * <li><b>DEPENDS</b>: The keyword 'depends' + * <li><b>DESIGNERSUPPORTED</b>: The keyword 'designersupported' + * <li><b>WORD</b>: A group of characters that form an identifier, filename, or path + * <li><b>DECIMAL</b>: A number of the form [0-9]+ '.' [0-9]+ + * <li><b>INTEGER</b>: An integer of the form [0-9]+ + * <li><b>WHITESPACE</b>: A group of whitespace characters (not including newlines) + * <li><b>COMMAND_END</b>: A newline character + * <li><b>UNKNOWN</b>: A group of characters that does not match any of the preceding tokens + * <li><b>EOF</b>: End of File + * </ul> + */ +public class QMLDirectoryLexer { + /** + * A single matched token returned by a <code>QMLDirectoryLexer</code>. A <code>Token</code> stores information on how it was + * matched including the type of token, the exact text that was matched, and its position in the <code>InputStream</code> . + */ + public static class Token { + private final TokenType tokType; + private final String raw; + private final ISourceLocation location; + private final int start; + private final int end; + + private Token(TokenType type, MatchResult match, int line, int lineStart) { + this(type, match.group(), match.start(), match.end(), line, lineStart); + } + + private Token(TokenType type, String raw, int start, int end, int line, int lineStart) { + this.tokType = type; + raw = raw.replaceAll("\n", "\\\\n"); //$NON-NLS-1$ //$NON-NLS-2$ + raw = raw.replaceAll("\r", "\\\\r"); //$NON-NLS-1$ //$NON-NLS-2$ + this.raw = raw; + this.start = start; + this.end = end; + this.location = new SourceLocation(null, + new Position(line, start - lineStart), + new Position(line, end - lineStart)); + } + + /** + * Get the type of token that was matched. + * + * @return the type of token + */ + public TokenType getType() { + return tokType; + } + + /** + * Gets the raw text that this token was matched with. + * + * @return a String representing the matched text + */ + public String getText() { + return raw; + } + + /** + * Gets a more detailed description of this token's location in the <code>InputStream</code> than {@link Token#getStart()} + * and {@link Token#getEnd()}. This method allows the retrieval of line and column information in order to make output for + * syntax errors and the like more human-readable. + * + * @return the {@link ISourceLocation} representing this token's location in the <code>InputStream</code> + */ + public ISourceLocation getLocation() { + return location; + } + + /** + * Gets the zero-indexed offset indicating the start of this token in the <code>InputStream</code>. + * + * @return the token's start offset + */ + public int getStart() { + return start; + } + + /** + * Gets the zero-indexed offset indicating the end of this token in the <code>InputStream</code>. + * + * @return the token's end offset + */ + public int getEnd() { + return end; + } + } + + /** + * An Enumeration encompassing the 16 possible types of tokens returned by a <code>QMLDirectoryLexer</code>. + * + * @see org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer + */ + public static enum TokenType { + COMMENT("#.*$"), //$NON-NLS-1$ + MODULE("module(?=\\s|$)"), //$NON-NLS-1$ + TYPEINFO("typeinfo(?=\\s|$)"), //$NON-NLS-1$ + SINGLETON("singleton(?=\\s|$)"), //$NON-NLS-1$ + INTERNAL("internal(?=\\s|$)"), //$NON-NLS-1$ + PLUGIN("plugin(?=\\s|$)"), //$NON-NLS-1$ + CLASSNAME("classname(?=\\s|$)"), //$NON-NLS-1$ + DEPENDS("depends(?=\\s|$)"), //$NON-NLS-1$ + DESIGNERSUPPORTED("designersupported(?=\\s|$)"), //$NON-NLS-1$ + WORD("[^0-9\\s][^\\s]*"), //$NON-NLS-1$ + DECIMAL("[0-9]+\\.[0-9]+"), //$NON-NLS-1$ + INTEGER("[0-9]+"), //$NON-NLS-1$ + WHITESPACE("\\h+"), //$NON-NLS-1$ + COMMAND_END("(?:\r\n)|\n"), //$NON-NLS-1$ + UNKNOWN(".+"), //$NON-NLS-1$ + EOF(null); + + private static Pattern pattern; + + private static Pattern patternForAllTerminals() { + if (pattern == null) { + String regex = ""; //$NON-NLS-1$ + TokenType[] tokens = TokenType.values(); + for (int i = 0; i < TokenType.values().length; i++) { + TokenType tok = tokens[i]; + if (tok.regex != null) { + if (i != 0) { + regex += "|"; //$NON-NLS-1$ + } + regex += "(" + tok.regex + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + } + } + pattern = Pattern.compile(regex, Pattern.MULTILINE); + } + return pattern; + } + + private final String regex; + + private TokenType(String regex) { + this.regex = regex; + } + } + + private Scanner input; + private MatchResult lastMatch; + private int currentLine; + private int currentLineStart; + + /** + * Creates a new <code>QMLDirectoryLexer</code> without initializing any of the its internal state. A call to + * <code>setInput</code> is necessary to fully initialize the lexer before any calls to <code>nextToken</code>. + */ + public QMLDirectoryLexer() { + } + + /** + * Prepares for lexical analysis by giving the lexer an <code>InputStream</code> to retrieve text from. + * + * @param input + * the input to perform lexical analysis on + */ + public void setInput(InputStream input) { + this.input = new Scanner(input); + this.lastMatch = null; + this.currentLine = 1; + this.currentLineStart = 0; + } + + /** + * Retrieves the next valid token from the <code>InputStream</code> given by <code>setInput</code>. This is a helper method to + * skip whitespace that is equivalent to <code>QMLDirectoryLexer.nextToken(true)</code>. + * + * @return the next token in the <code>InputStream</code> + * @throws IllegalArgumentException + * if <code>setInput</code> has not been called + */ + public Token nextToken() throws IllegalArgumentException { + return nextToken(true); + } + + /** + * Retrieves the next valid token from the <code>InputStream</code> given by <code>setInput</code>. This method has the ability + * to skip over whitespace tokens by setting <code>skipWhitespace</code> to <code>true</code>. + * + * @param skipWhitespace + * whether or not the lexer should skip whitespace tokens + * @return the next token in the <code>InputStream</code> + * @throws IllegalArgumentException + * if <code>setInput</code> has not been called + */ + public Token nextToken(boolean skipWhitespace) throws IllegalArgumentException { + if (input == null) { + throw new IllegalArgumentException("Input cannot be null"); //$NON-NLS-1$ + } + if (input.findWithinHorizon(TokenType.patternForAllTerminals(), 0) == null) { + if (lastMatch != null) { + return new Token(TokenType.EOF, "", lastMatch.end(), lastMatch.end(), currentLine, currentLineStart); //$NON-NLS-1$ + } else { + return new Token(TokenType.EOF, "", 0, 0, 1, 0); //$NON-NLS-1$ + } + } else { + int groupNo = 1; + for (TokenType t : TokenType.values()) { + if (t.regex != null) { + if (input.match().start(groupNo) != -1) { + lastMatch = input.match(); + Token next = null; + if (!(t.equals(TokenType.WHITESPACE) && skipWhitespace)) { + next = new Token(t, input.match(), currentLine, currentLineStart); + } else { + next = nextToken(skipWhitespace); + } + if (t.equals(TokenType.COMMAND_END)) { + // Advance the line number information + currentLine++; + currentLineStart = input.match().end(); + } + return next; + } + groupNo++; + } + } + return new Token(TokenType.UNKNOWN, input.match(), currentLine, currentLineStart); + } + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryParser.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryParser.java index 5af75b43669..98ac4f8b037 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryParser.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryParser.java @@ -1,423 +1,423 @@ -/*******************************************************************************
- * 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.qmldir;
-
-import java.io.InputStream;
-import java.util.Stack;
-
-import org.eclipse.cdt.internal.qt.core.location.SourceLocation;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirAST;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirASTNode;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirClassnameCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirCommentCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirDependsCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirDesignerSupportedCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirInternalCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirModuleCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirPluginCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirResourceCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirSingletonCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirSyntaxError;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirTypeInfoCommand;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirVersion;
-import org.eclipse.cdt.internal.qt.core.qmldir.QDirWord;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.Token;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.TokenType;
-
-/**
- * Converts an <code>InputStream</code> representing a qmldir file into an Abstract Syntax Tree. Uses the {@link QMLDirectoryLexer}
- * under the hood to match tokens which it then uses to construct the AST. Also, a <code>QMLDirectoryParser</code> has the ability
- * to skip over syntax errors and include them in its AST rather than returning upon the first error.
- */
-public class QMLDirectoryParser {
- /**
- * An exception thrown when a <code>QMLDirectoryParser</code> encounters a syntax error. This class stores information on the
- * offending token as well as the node the parser was working on before it failed (if available).
- */
- public static class SyntaxError extends RuntimeException {
- private static final long serialVersionUID = 6608815552297970623L;
-
- private final IQDirASTNode incompleteNode;
- private final Token offendingToken;
-
- /**
- * Creates a new <code>SyntaxError</code>.
- *
- * @param node
- * the incomplete working node
- * @param token
- * the offending token
- * @param message
- * the message to display
- */
- public SyntaxError(IQDirASTNode node, Token token, String message) {
- super(message);
- this.incompleteNode = node;
- this.offendingToken = token;
- }
-
- /**
- * Gets the token that caused the parser to fail.
- *
- * @return the offending token
- */
- public Token getOffendingToken() {
- return offendingToken;
- }
-
- /**
- * Gets the last node that the parser was working on before it failed or null if that information isn't present.
- *
- * @return the incomplete node or <code>null</code> if not available
- */
- public IQDirASTNode getIncompleteNode() {
- return incompleteNode;
- }
- }
-
- private final QMLDirectoryLexer lexer;
- private final Stack<QDirASTNode> workingNodes;
- private Token tok;
-
- /**
- * Initializes a new <code>QMLDirectoryParser</code> capable of parsing an <code>InputStream</code> and returning an AST.
- */
- public QMLDirectoryParser() {
- this.lexer = new QMLDirectoryLexer();
- this.workingNodes = new Stack<>();
- }
-
- /**
- * Parses the given <code>InputStream</code> into an Abstract Syntax Tree. This is a helper method equivalent to
- * <code>parse(input, true)</code>. That is, the parser will attempt to recover once it hits an error and include an
- * {@link IQDirSyntaxError} node in the AST.
- *
- * @param input
- * the input to parse
- * @return the Abstract Syntax Tree representing the input
- * @see QMLDirectoryParser#parse(InputStream, boolean)
- */
- public IQDirAST parse(InputStream input) {
- return parse(input, true);
- }
-
- /**
- * Parses the given <code>InputStream</code> into an Abstract Syntax Tree. If <code>tolerateErrors</code> is <code>true</code>,
- * any syntax errors will be included in the AST as a separate {@link IQDirSyntaxErrorCommand}. The parser will then attempt to
- * recover by jumping to the next line and continue parsing. A value of </code>false</code> tells the parser to throw a
- * {@link SyntaxError} on the first problem it encounters.
- *
- * @param input
- * the input to parse
- * @param tolerateErrors
- * whether or not the parser should be error tolerant
- * @return the Abstract Syntax Tree representing the input
- */
- public IQDirAST parse(InputStream input, boolean tolerateErrors) {
- // Clear out any leftover state
- this.lexer.setInput(input);
- this.workingNodes.clear();
-
- QDirAST ast = new QDirAST();
- nextToken();
- while (tok.getType() != TokenType.EOF) {
- try {
- switch (tok.getType()) {
- case MODULE:
- ast.addCommand(parseModuleCommand());
- break;
- case SINGLETON:
- ast.addCommand(parseSingletonCommand());
- break;
- case INTERNAL:
- ast.addCommand(parseInternalCommand());
- break;
- case WORD:
- ast.addCommand(parseResourceCommand());
- break;
- case PLUGIN:
- ast.addCommand(parsePluginCommand());
- break;
- case CLASSNAME:
- ast.addCommand(parseClassnameCommand());
- break;
- case TYPEINFO:
- ast.addCommand(parseTypeInfoCommand());
- break;
- case DEPENDS:
- ast.addCommand(parseDependsCommand());
- break;
- case DESIGNERSUPPORTED:
- ast.addCommand(parseDesignerSupportedCommand());
- break;
- case COMMENT:
- ast.addCommand(parseCommentCommand());
- break;
- case COMMAND_END:
- // This is just an empty line that should be ignored
- nextToken();
- break;
- default:
- throw unexpectedToken();
- }
- } catch (SyntaxError e) {
- if (!tolerateErrors) {
- throw e;
- }
- // Add the syntax error to the AST and jump to the next line
- QDirSyntaxError errNode = new QDirSyntaxError(e);
- markStart(errNode);
- IQDirASTNode node = e.getIncompleteNode();
- if (node != null) {
- errNode.setLocation((SourceLocation) node.getLocation());
- errNode.setStart(node.getStart());
- errNode.setEnd(node.getEnd());
- }
- while (!eat(TokenType.COMMAND_END) && !eat(TokenType.EOF)) {
- nextToken();
- }
- markEnd();
- ast.addCommand(errNode);
- }
- }
- return ast;
- }
-
- private void nextToken() {
- nextToken(true);
- }
-
- private void nextToken(boolean skipWhitespace) {
- tok = lexer.nextToken(skipWhitespace);
- }
-
- private void markStart(QDirASTNode node) {
- workingNodes.push(node);
- node.setStart(tok.getStart());
- node.setLocation(new SourceLocation());
- node.getLocation().setStart(tok.getLocation().getStart());
- }
-
- private void markEnd() {
- QDirASTNode node = workingNodes.pop();
- node.setEnd(tok.getEnd());
- node.getLocation().setEnd(tok.getLocation().getEnd());
- }
-
- private boolean eat(TokenType type) {
- if (tok.getType() == type) {
- nextToken();
- return true;
- }
- return false;
- }
-
- private SyntaxError syntaxError(String message) {
- return new SyntaxError(workingNodes.peek(), tok, message + " " + tok.getLocation().getStart().toString()); //$NON-NLS-1$
- }
-
- private SyntaxError unexpectedToken() {
- String tokenText = tok.getText();
- if (tok.getType() == TokenType.EOF) {
- tokenText = "EOF"; //$NON-NLS-1$
- }
- return syntaxError("Unexpected token '" + tokenText + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private void expect(TokenType type) {
- if (tok.getType() != type) {
- throw unexpectedToken();
- }
- nextToken();
- }
-
- private void expectCommandEnd() {
- // Allow EOF to be substituted for COMMAND_END
- if (tok.getType() == TokenType.EOF) {
- nextToken();
- return;
- }
- if (tok.getType() != TokenType.COMMAND_END) {
- throw syntaxError("Expected token '\\n' or 'EOF', but saw '" + tok.getText() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- nextToken();
- }
-
- private QDirModuleCommand parseModuleCommand() {
- QDirModuleCommand node = new QDirModuleCommand();
- markStart(node);
- expect(TokenType.MODULE);
- if (tok.getType() == TokenType.WORD) {
- node.setModuleIdentifier(parseWord());
- expectCommandEnd();
- markEnd();
- return node;
- }
- throw unexpectedToken();
- }
-
- private QDirSingletonCommand parseSingletonCommand() {
- QDirSingletonCommand node = new QDirSingletonCommand();
- markStart(node);
- expect(TokenType.SINGLETON);
- if (tok.getType() == TokenType.WORD) {
- node.setTypeName(parseWord());
- if (tok.getType() == TokenType.DECIMAL) {
- node.setInitialVersion(parseVersion());
- if (tok.getType() == TokenType.WORD) {
- node.setFile(parseWord());
- expectCommandEnd();
- markEnd();
- return node;
- }
- }
- }
- throw unexpectedToken();
- };
-
- private QDirInternalCommand parseInternalCommand() {
- QDirInternalCommand node = new QDirInternalCommand();
- markStart(node);
- expect(TokenType.INTERNAL);
- if (tok.getType() == TokenType.WORD) {
- node.setTypeName(parseWord());
- if (tok.getType() == TokenType.WORD) {
- node.setFile(parseWord());
- expectCommandEnd();
- markEnd();
- return node;
- }
- }
- throw unexpectedToken();
- }
-
- private QDirResourceCommand parseResourceCommand() {
- QDirResourceCommand node = new QDirResourceCommand();
- markStart(node);
- if (tok.getType() == TokenType.WORD) {
- node.setResourceIdentifier(parseWord());
- if (tok.getType() == TokenType.DECIMAL) {
- node.setInitialVersion(parseVersion());
- if (tok.getType() == TokenType.WORD) {
- node.setFile(parseWord());
- expectCommandEnd();
- markEnd();
- return node;
- }
- }
- }
- throw unexpectedToken();
- }
-
- private QDirPluginCommand parsePluginCommand() {
- QDirPluginCommand node = new QDirPluginCommand();
- markStart(node);
- expect(TokenType.PLUGIN);
- if (tok.getType() == TokenType.WORD) {
- node.setName(parseWord());
- if (tok.getType() == TokenType.WORD) {
- node.setPath(parseWord());
- }
- expectCommandEnd();
- markEnd();
- return node;
- }
- throw unexpectedToken();
- }
-
- private QDirClassnameCommand parseClassnameCommand() {
- QDirClassnameCommand node = new QDirClassnameCommand();
- markStart(node);
- expect(TokenType.CLASSNAME);
- if (tok.getType() == TokenType.WORD) {
- node.setIdentifier(parseWord());
- expectCommandEnd();
- markEnd();
- return node;
- }
- throw unexpectedToken();
- }
-
- private QDirTypeInfoCommand parseTypeInfoCommand() {
- QDirTypeInfoCommand node = new QDirTypeInfoCommand();
- markStart(node);
- expect(TokenType.TYPEINFO);
- if (tok.getType() == TokenType.WORD) {
- node.setFile(parseWord());
- expectCommandEnd();
- markEnd();
- return node;
- }
- throw unexpectedToken();
- }
-
- private QDirDependsCommand parseDependsCommand() {
- QDirDependsCommand node = new QDirDependsCommand();
- markStart(node);
- expect(TokenType.DEPENDS);
- if (tok.getType() == TokenType.WORD) {
- node.setModuleIdentifier(parseWord());
- if (tok.getType() == TokenType.DECIMAL) {
- node.setInitialVersion(parseVersion());
- expectCommandEnd();
- markEnd();
- return node;
- }
- }
- throw unexpectedToken();
- }
-
- private QDirDesignerSupportedCommand parseDesignerSupportedCommand() {
- QDirDesignerSupportedCommand node = new QDirDesignerSupportedCommand();
- markStart(node);
- expect(TokenType.DESIGNERSUPPORTED);
- expectCommandEnd();
- markEnd();
- return node;
- }
-
- private QDirCommentCommand parseCommentCommand() {
- QDirCommentCommand node = new QDirCommentCommand();
- markStart(node);
- if (tok.getType() == TokenType.COMMENT) {
- node.setText(tok.getText());
- nextToken();
- expectCommandEnd();
- markEnd();
- return node;
- }
- throw unexpectedToken();
- }
-
- private QDirVersion parseVersion() {
- QDirVersion node = new QDirVersion();
- markStart(node);
- if (tok.getType() == TokenType.DECIMAL) {
- node.setVersionString(tok.getText());
- nextToken();
- markEnd();
- return node;
- }
- throw unexpectedToken();
- }
-
- private QDirWord parseWord() {
- QDirWord node = new QDirWord();
- markStart(node);
- if (tok.getType() == TokenType.WORD) {
- node.setText(tok.getText());
- nextToken();
- markEnd();
- return node;
- }
- throw unexpectedToken();
- }
-}
+/******************************************************************************* + * 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.qmldir; + +import java.io.InputStream; +import java.util.Stack; + +import org.eclipse.cdt.internal.qt.core.location.SourceLocation; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirAST; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirASTNode; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirClassnameCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirCommentCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirDependsCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirDesignerSupportedCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirInternalCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirModuleCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirPluginCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirResourceCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirSingletonCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirSyntaxError; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirTypeInfoCommand; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirVersion; +import org.eclipse.cdt.internal.qt.core.qmldir.QDirWord; +import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.Token; +import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.TokenType; + +/** + * Converts an <code>InputStream</code> representing a qmldir file into an Abstract Syntax Tree. Uses the {@link QMLDirectoryLexer} + * under the hood to match tokens which it then uses to construct the AST. Also, a <code>QMLDirectoryParser</code> has the ability + * to skip over syntax errors and include them in its AST rather than returning upon the first error. + */ +public class QMLDirectoryParser { + /** + * An exception thrown when a <code>QMLDirectoryParser</code> encounters a syntax error. This class stores information on the + * offending token as well as the node the parser was working on before it failed (if available). + */ + public static class SyntaxError extends RuntimeException { + private static final long serialVersionUID = 6608815552297970623L; + + private final IQDirASTNode incompleteNode; + private final Token offendingToken; + + /** + * Creates a new <code>SyntaxError</code>. + * + * @param node + * the incomplete working node + * @param token + * the offending token + * @param message + * the message to display + */ + public SyntaxError(IQDirASTNode node, Token token, String message) { + super(message); + this.incompleteNode = node; + this.offendingToken = token; + } + + /** + * Gets the token that caused the parser to fail. + * + * @return the offending token + */ + public Token getOffendingToken() { + return offendingToken; + } + + /** + * Gets the last node that the parser was working on before it failed or null if that information isn't present. + * + * @return the incomplete node or <code>null</code> if not available + */ + public IQDirASTNode getIncompleteNode() { + return incompleteNode; + } + } + + private final QMLDirectoryLexer lexer; + private final Stack<QDirASTNode> workingNodes; + private Token tok; + + /** + * Initializes a new <code>QMLDirectoryParser</code> capable of parsing an <code>InputStream</code> and returning an AST. + */ + public QMLDirectoryParser() { + this.lexer = new QMLDirectoryLexer(); + this.workingNodes = new Stack<>(); + } + + /** + * Parses the given <code>InputStream</code> into an Abstract Syntax Tree. This is a helper method equivalent to + * <code>parse(input, true)</code>. That is, the parser will attempt to recover once it hits an error and include an + * {@link IQDirSyntaxError} node in the AST. + * + * @param input + * the input to parse + * @return the Abstract Syntax Tree representing the input + * @see QMLDirectoryParser#parse(InputStream, boolean) + */ + public IQDirAST parse(InputStream input) { + return parse(input, true); + } + + /** + * Parses the given <code>InputStream</code> into an Abstract Syntax Tree. If <code>tolerateErrors</code> is <code>true</code>, + * any syntax errors will be included in the AST as a separate {@link IQDirSyntaxErrorCommand}. The parser will then attempt to + * recover by jumping to the next line and continue parsing. A value of </code>false</code> tells the parser to throw a + * {@link SyntaxError} on the first problem it encounters. + * + * @param input + * the input to parse + * @param tolerateErrors + * whether or not the parser should be error tolerant + * @return the Abstract Syntax Tree representing the input + */ + public IQDirAST parse(InputStream input, boolean tolerateErrors) { + // Clear out any leftover state + this.lexer.setInput(input); + this.workingNodes.clear(); + + QDirAST ast = new QDirAST(); + nextToken(); + while (tok.getType() != TokenType.EOF) { + try { + switch (tok.getType()) { + case MODULE: + ast.addCommand(parseModuleCommand()); + break; + case SINGLETON: + ast.addCommand(parseSingletonCommand()); + break; + case INTERNAL: + ast.addCommand(parseInternalCommand()); + break; + case WORD: + ast.addCommand(parseResourceCommand()); + break; + case PLUGIN: + ast.addCommand(parsePluginCommand()); + break; + case CLASSNAME: + ast.addCommand(parseClassnameCommand()); + break; + case TYPEINFO: + ast.addCommand(parseTypeInfoCommand()); + break; + case DEPENDS: + ast.addCommand(parseDependsCommand()); + break; + case DESIGNERSUPPORTED: + ast.addCommand(parseDesignerSupportedCommand()); + break; + case COMMENT: + ast.addCommand(parseCommentCommand()); + break; + case COMMAND_END: + // This is just an empty line that should be ignored + nextToken(); + break; + default: + throw unexpectedToken(); + } + } catch (SyntaxError e) { + if (!tolerateErrors) { + throw e; + } + // Add the syntax error to the AST and jump to the next line + QDirSyntaxError errNode = new QDirSyntaxError(e); + markStart(errNode); + IQDirASTNode node = e.getIncompleteNode(); + if (node != null) { + errNode.setLocation((SourceLocation) node.getLocation()); + errNode.setStart(node.getStart()); + errNode.setEnd(node.getEnd()); + } + while (!eat(TokenType.COMMAND_END) && !eat(TokenType.EOF)) { + nextToken(); + } + markEnd(); + ast.addCommand(errNode); + } + } + return ast; + } + + private void nextToken() { + nextToken(true); + } + + private void nextToken(boolean skipWhitespace) { + tok = lexer.nextToken(skipWhitespace); + } + + private void markStart(QDirASTNode node) { + workingNodes.push(node); + node.setStart(tok.getStart()); + node.setLocation(new SourceLocation()); + node.getLocation().setStart(tok.getLocation().getStart()); + } + + private void markEnd() { + QDirASTNode node = workingNodes.pop(); + node.setEnd(tok.getEnd()); + node.getLocation().setEnd(tok.getLocation().getEnd()); + } + + private boolean eat(TokenType type) { + if (tok.getType() == type) { + nextToken(); + return true; + } + return false; + } + + private SyntaxError syntaxError(String message) { + return new SyntaxError(workingNodes.peek(), tok, message + " " + tok.getLocation().getStart().toString()); //$NON-NLS-1$ + } + + private SyntaxError unexpectedToken() { + String tokenText = tok.getText(); + if (tok.getType() == TokenType.EOF) { + tokenText = "EOF"; //$NON-NLS-1$ + } + return syntaxError("Unexpected token '" + tokenText + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + private void expect(TokenType type) { + if (tok.getType() != type) { + throw unexpectedToken(); + } + nextToken(); + } + + private void expectCommandEnd() { + // Allow EOF to be substituted for COMMAND_END + if (tok.getType() == TokenType.EOF) { + nextToken(); + return; + } + if (tok.getType() != TokenType.COMMAND_END) { + throw syntaxError("Expected token '\\n' or 'EOF', but saw '" + tok.getText() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + } + nextToken(); + } + + private QDirModuleCommand parseModuleCommand() { + QDirModuleCommand node = new QDirModuleCommand(); + markStart(node); + expect(TokenType.MODULE); + if (tok.getType() == TokenType.WORD) { + node.setModuleIdentifier(parseWord()); + expectCommandEnd(); + markEnd(); + return node; + } + throw unexpectedToken(); + } + + private QDirSingletonCommand parseSingletonCommand() { + QDirSingletonCommand node = new QDirSingletonCommand(); + markStart(node); + expect(TokenType.SINGLETON); + if (tok.getType() == TokenType.WORD) { + node.setTypeName(parseWord()); + if (tok.getType() == TokenType.DECIMAL) { + node.setInitialVersion(parseVersion()); + if (tok.getType() == TokenType.WORD) { + node.setFile(parseWord()); + expectCommandEnd(); + markEnd(); + return node; + } + } + } + throw unexpectedToken(); + }; + + private QDirInternalCommand parseInternalCommand() { + QDirInternalCommand node = new QDirInternalCommand(); + markStart(node); + expect(TokenType.INTERNAL); + if (tok.getType() == TokenType.WORD) { + node.setTypeName(parseWord()); + if (tok.getType() == TokenType.WORD) { + node.setFile(parseWord()); + expectCommandEnd(); + markEnd(); + return node; + } + } + throw unexpectedToken(); + } + + private QDirResourceCommand parseResourceCommand() { + QDirResourceCommand node = new QDirResourceCommand(); + markStart(node); + if (tok.getType() == TokenType.WORD) { + node.setResourceIdentifier(parseWord()); + if (tok.getType() == TokenType.DECIMAL) { + node.setInitialVersion(parseVersion()); + if (tok.getType() == TokenType.WORD) { + node.setFile(parseWord()); + expectCommandEnd(); + markEnd(); + return node; + } + } + } + throw unexpectedToken(); + } + + private QDirPluginCommand parsePluginCommand() { + QDirPluginCommand node = new QDirPluginCommand(); + markStart(node); + expect(TokenType.PLUGIN); + if (tok.getType() == TokenType.WORD) { + node.setName(parseWord()); + if (tok.getType() == TokenType.WORD) { + node.setPath(parseWord()); + } + expectCommandEnd(); + markEnd(); + return node; + } + throw unexpectedToken(); + } + + private QDirClassnameCommand parseClassnameCommand() { + QDirClassnameCommand node = new QDirClassnameCommand(); + markStart(node); + expect(TokenType.CLASSNAME); + if (tok.getType() == TokenType.WORD) { + node.setIdentifier(parseWord()); + expectCommandEnd(); + markEnd(); + return node; + } + throw unexpectedToken(); + } + + private QDirTypeInfoCommand parseTypeInfoCommand() { + QDirTypeInfoCommand node = new QDirTypeInfoCommand(); + markStart(node); + expect(TokenType.TYPEINFO); + if (tok.getType() == TokenType.WORD) { + node.setFile(parseWord()); + expectCommandEnd(); + markEnd(); + return node; + } + throw unexpectedToken(); + } + + private QDirDependsCommand parseDependsCommand() { + QDirDependsCommand node = new QDirDependsCommand(); + markStart(node); + expect(TokenType.DEPENDS); + if (tok.getType() == TokenType.WORD) { + node.setModuleIdentifier(parseWord()); + if (tok.getType() == TokenType.DECIMAL) { + node.setInitialVersion(parseVersion()); + expectCommandEnd(); + markEnd(); + return node; + } + } + throw unexpectedToken(); + } + + private QDirDesignerSupportedCommand parseDesignerSupportedCommand() { + QDirDesignerSupportedCommand node = new QDirDesignerSupportedCommand(); + markStart(node); + expect(TokenType.DESIGNERSUPPORTED); + expectCommandEnd(); + markEnd(); + return node; + } + + private QDirCommentCommand parseCommentCommand() { + QDirCommentCommand node = new QDirCommentCommand(); + markStart(node); + if (tok.getType() == TokenType.COMMENT) { + node.setText(tok.getText()); + nextToken(); + expectCommandEnd(); + markEnd(); + return node; + } + throw unexpectedToken(); + } + + private QDirVersion parseVersion() { + QDirVersion node = new QDirVersion(); + markStart(node); + if (tok.getType() == TokenType.DECIMAL) { + node.setVersionString(tok.getText()); + nextToken(); + markEnd(); + return node; + } + throw unexpectedToken(); + } + + private QDirWord parseWord() { + QDirWord node = new QDirWord(); + markStart(node); + if (tok.getType() == TokenType.WORD) { + node.setText(tok.getText()); + nextToken(); + markEnd(); + return node; + } + throw unexpectedToken(); + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSArrayExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSArrayExpression.java index 34251ab0882..1a6eb0a6a0a 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSArrayExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSArrayExpression.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSAssignmentExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSAssignmentExpression.java index 0bd47ba92be..a828dd5379b 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSAssignmentExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSAssignmentExpression.java @@ -1,68 +1,68 @@ -/*******************************************************************************
- * 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$
-
- public static AssignmentOperator fromObject(Object obj) {
- if (obj instanceof String) {
- for (AssignmentOperator op : AssignmentOperator.values()) {
- if (obj.equals(op.toString())) {
- return op;
- }
- }
- }
- return null;
- }
-
- 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();
-}
+/******************************************************************************* + * 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$ + + public static AssignmentOperator fromObject(Object obj) { + if (obj instanceof String) { + for (AssignmentOperator op : AssignmentOperator.values()) { + if (obj.equals(op.toString())) { + return op; + } + } + } + return null; + } + + 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBinaryExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBinaryExpression.java index 37958a8ce76..a112fd6cba2 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBinaryExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBinaryExpression.java @@ -1,76 +1,76 @@ -/*******************************************************************************
- * 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$
-
- public static BinaryOperator fromObject(Object obj) {
- if (obj instanceof String) {
- for (BinaryOperator op : BinaryOperator.values()) {
- if (obj.equals(op.toString())) {
- return op;
- }
- }
- }
- return null;
- }
-
- private final String op;
-
- private BinaryOperator(String op) {
- this.op = op;
- }
-
- @Override
- public String toString() {
- return this.op;
- }
- }
-
- @Override
- default String getType() {
- return "BinaryExpression"; //$NON-NLS-1$
- }
-
- public BinaryOperator getOperator();
-
- public IJSExpression getLeft();
-
- public IJSExpression getRight();
-}
+/******************************************************************************* + * 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$ + + public static BinaryOperator fromObject(Object obj) { + if (obj instanceof String) { + for (BinaryOperator op : BinaryOperator.values()) { + if (obj.equals(op.toString())) { + return op; + } + } + } + return null; + } + + private final String op; + + private BinaryOperator(String op) { + this.op = op; + } + + @Override + public String toString() { + return this.op; + } + } + + @Override + default String getType() { + return "BinaryExpression"; //$NON-NLS-1$ + } + + public BinaryOperator getOperator(); + + public IJSExpression getLeft(); + + public IJSExpression getRight(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBlockStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBlockStatement.java index b055638f13c..08861ae2873 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBlockStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBlockStatement.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBreakStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBreakStatement.java index 4dbf9fbbfdf..9242b1706ae 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBreakStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBreakStatement.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCallExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCallExpression.java index dc534d9a917..c835dab9d6c 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCallExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCallExpression.java @@ -1,28 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCatchClause.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCatchClause.java index 68d6076c6c4..6232f46f882 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCatchClause.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCatchClause.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSConditionalExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSConditionalExpression.java index 385f85404ac..bf3ba3df3cf 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSConditionalExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSConditionalExpression.java @@ -1,28 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSContinueStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSContinueStatement.java index 3943169e5ab..26f8cb5328b 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSContinueStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSContinueStatement.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDebuggerStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDebuggerStatement.java index 74ac14b6a0d..293ffec779d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDebuggerStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDebuggerStatement.java @@ -1,22 +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$
- }
-}
+/******************************************************************************* + * 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$ + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDeclaration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDeclaration.java index 8a03246a8dc..b0fd10c6f3b 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDeclaration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDeclaration.java @@ -1,18 +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 {
-}
+/******************************************************************************* + * 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 { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDoWhileStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDoWhileStatement.java index ac2a1cf916e..f21ed0a30c1 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDoWhileStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDoWhileStatement.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSEmptyStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSEmptyStatement.java index fa6b54597e9..55e806696be 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSEmptyStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSEmptyStatement.java @@ -1,22 +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$
- }
-}
+/******************************************************************************* + * 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$ + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpression.java index 8f1f70e5557..3154196c360 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpression.java @@ -1,18 +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 {
-}
+/******************************************************************************* + * 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 { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpressionStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpressionStatement.java index 988dba7ef28..c51fa3e8c98 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpressionStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpressionStatement.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForInStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForInStatement.java index d113f2ae136..b2767bed6de 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForInStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForInStatement.java @@ -1,31 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForStatement.java index 7686b10bf03..fe239336c83 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForStatement.java @@ -1,33 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunction.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunction.java index 3cd8224bead..6e2e7e0ec16 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunction.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunction.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionDeclaration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionDeclaration.java index e0dae44c456..a68d6d3c376 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionDeclaration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionDeclaration.java @@ -1,25 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionExpression.java index 0d196f2bdf6..31a75072427 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionExpression.java @@ -1,22 +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$
- }
-}
+/******************************************************************************* + * 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$ + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIdentifier.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIdentifier.java index 9549c22000e..1fb4c389b17 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIdentifier.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIdentifier.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIfStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIfStatement.java index a0b58d0dd29..ece38a0bc64 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIfStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIfStatement.java @@ -1,28 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLabeledStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLabeledStatement.java index ddde2ea014e..ca8a20c00ec 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLabeledStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLabeledStatement.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLiteral.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLiteral.java index 2e4e2fab37a..c68ab78e640 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLiteral.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLiteral.java @@ -1,28 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLogicalExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLogicalExpression.java index b79c83caddf..4ed414706e3 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLogicalExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLogicalExpression.java @@ -1,58 +1,58 @@ -/*******************************************************************************
- * 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$
-
- public static LogicalOperator fromObject(Object obj) {
- if (obj instanceof String) {
- for (LogicalOperator op : LogicalOperator.values()) {
- if (obj.equals(op.toString())) {
- return op;
- }
- }
- }
- return null;
- }
-
- 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();
-}
+/******************************************************************************* + * 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$ + + public static LogicalOperator fromObject(Object obj) { + if (obj instanceof String) { + for (LogicalOperator op : LogicalOperator.values()) { + if (obj.equals(op.toString())) { + return op; + } + } + } + return null; + } + + 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSMemberExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSMemberExpression.java index bc7b4d1d859..bc29a6c8e47 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSMemberExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSMemberExpression.java @@ -1,28 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSNewExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSNewExpression.java index b23f20cac0a..ea6c67a5649 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSNewExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSNewExpression.java @@ -1,22 +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$
- }
-}
+/******************************************************************************* + * 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$ + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSObjectExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSObjectExpression.java index 997c437e87a..a481834ee36 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSObjectExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSObjectExpression.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSPattern.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSPattern.java index 83930954d54..9918113f17c 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSPattern.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSPattern.java @@ -1,17 +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 {
-}
+/******************************************************************************* + * 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 { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProgram.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProgram.java index 105e69d331a..a7a7fafdc4f 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProgram.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProgram.java @@ -1,25 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProperty.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProperty.java index d8d20ba0028..b5b1d8438ae 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProperty.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProperty.java @@ -1,31 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSRegExpLiteral.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSRegExpLiteral.java index 304d7e2bb46..942790564fe 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSRegExpLiteral.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSRegExpLiteral.java @@ -1,40 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSReturnStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSReturnStatement.java index 6b6c58e553c..9276b25f418 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSReturnStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSReturnStatement.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSequenceExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSequenceExpression.java index 4cdd2baa9e1..8241ace5970 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSequenceExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSequenceExpression.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSStatement.java index a2617e3c939..937c5335c77 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSStatement.java @@ -1,18 +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 {
-}
+/******************************************************************************* + * 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 { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchCase.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchCase.java index 6247a01d4e9..3fd8b5d2e36 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchCase.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchCase.java @@ -1,28 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchStatement.java index 9c0ca91a98f..024784b8a6e 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchStatement.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThisExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThisExpression.java index 1cc3fbe1b6c..3e6d4535630 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThisExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThisExpression.java @@ -1,22 +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$
- }
-}
+/******************************************************************************* + * 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$ + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThrowStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThrowStatement.java index f3ddf6e1022..86489618d03 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThrowStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThrowStatement.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSTryStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSTryStatement.java index a89fede7b49..0c10968bb59 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSTryStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSTryStatement.java @@ -1,28 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUnaryExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUnaryExpression.java index 389a2a7f8bc..87924083976 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUnaryExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUnaryExpression.java @@ -1,63 +1,63 @@ -/*******************************************************************************
- * 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$
-
- public static UnaryOperator fromObject(Object obj) {
- if (obj instanceof String) {
- for (UnaryOperator op : UnaryOperator.values()) {
- if (obj.equals(op.toString())) {
- return op;
- }
- }
- }
- return null;
- }
-
- 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();
-}
+/******************************************************************************* + * 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$ + + public static UnaryOperator fromObject(Object obj) { + if (obj instanceof String) { + for (UnaryOperator op : UnaryOperator.values()) { + if (obj.equals(op.toString())) { + return op; + } + } + } + return null; + } + + 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUpdateExpression.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUpdateExpression.java index 3a771f7fdc7..ca4c0aa4731 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUpdateExpression.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUpdateExpression.java @@ -1,58 +1,58 @@ -/*******************************************************************************
- * 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$
-
- public static UpdateOperator fromObject(Object obj) {
- if (obj instanceof String) {
- for (UpdateOperator op : UpdateOperator.values()) {
- if (obj.equals(op.toString())) {
- return op;
- }
- }
- }
- return null;
- }
-
- 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();
-}
+/******************************************************************************* + * 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$ + + public static UpdateOperator fromObject(Object obj) { + if (obj instanceof String) { + for (UpdateOperator op : UpdateOperator.values()) { + if (obj.equals(op.toString())) { + return op; + } + } + } + return null; + } + + 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclaration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclaration.java index ec35a257ce5..ab36873bfed 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclaration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclaration.java @@ -1,30 +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$
- }
-}
+/******************************************************************************* + * 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$ + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclarator.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclarator.java index 93b81adbbdd..711a8759ddd 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclarator.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclarator.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWhileStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWhileStatement.java index 4b1393aca3b..54b0fef967d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWhileStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWhileStatement.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWithStatement.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWithStatement.java index 1e1586b7b2c..464f27f53cb 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWithStatement.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWithStatement.java @@ -1,26 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlASTNode.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlASTNode.java index 3e85efee2b2..e71869e4e04 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlASTNode.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlASTNode.java @@ -1,80 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlArrayBinding.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlArrayBinding.java index e37ddebd15e..76259e16b41 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlArrayBinding.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlArrayBinding.java @@ -1,22 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlBinding.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlBinding.java index a860c6994c7..e894ed4e466 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlBinding.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlBinding.java @@ -1,14 +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 {
-}
+/******************************************************************************* + * 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 { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItem.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItem.java index dc0c606eb32..62051007426 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItem.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItem.java @@ -1,14 +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 {
-}
+/******************************************************************************* + * 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 { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItemList.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItemList.java index 617b60388b2..873878fccfc 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItemList.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItemList.java @@ -1,17 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlImport.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlImport.java index cbbcc327b4f..2f6e5a7cc69 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlImport.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlImport.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlModule.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlModule.java index 46b8dc05ee0..752270e27ef 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlModule.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlModule.java @@ -1,17 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectBinding.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectBinding.java index 61c51077248..80e325b4949 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectBinding.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectBinding.java @@ -1,22 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectDefinition.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectDefinition.java index 5af2289ed37..854b7bf6402 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectDefinition.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectDefinition.java @@ -1,22 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectInitializer.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectInitializer.java index 0ced8b072d6..70d2b338f7d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectInitializer.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectInitializer.java @@ -1,22 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectMember.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectMember.java index f026675cfa4..bd824a8b577 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectMember.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectMember.java @@ -1,14 +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 {
-}
+/******************************************************************************* + * 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 { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlParameter.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlParameter.java index f1d413cc450..9c1318bd2d0 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlParameter.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlParameter.java @@ -1,22 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPragma.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPragma.java index 440a8818fad..4b969077525 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPragma.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPragma.java @@ -1,20 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlProgram.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlProgram.java index 75d7ac137ea..8bd87421386 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlProgram.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlProgram.java @@ -1,38 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyBinding.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyBinding.java index 58da5d517a3..ffd1d7e0fb4 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyBinding.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyBinding.java @@ -1,22 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyDeclaration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyDeclaration.java index 5f5f1c17522..f4b8eef67e8 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyDeclaration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyDeclaration.java @@ -1,30 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyType.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyType.java index 133dfa2f681..817c1bbf479 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyType.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyType.java @@ -1,22 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifiedID.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifiedID.java index 42d947e0a51..536eb5d2c72 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifiedID.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifiedID.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifier.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifier.java index 7b3f01b3a9a..2302dc002a4 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifier.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifier.java @@ -1,20 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlRootObject.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlRootObject.java index e2fa2fcdc4c..3e20a82a201 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlRootObject.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlRootObject.java @@ -1,14 +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 {
-}
+/******************************************************************************* + * 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 { +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlScriptBinding.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlScriptBinding.java index fb73eafde36..15b93d072d1 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlScriptBinding.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlScriptBinding.java @@ -1,25 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlSignalDefinition.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlSignalDefinition.java index 478beb3d499..33e3abb64db 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlSignalDefinition.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlSignalDefinition.java @@ -1,24 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlStatementBlock.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlStatementBlock.java index e575a115f14..f2b051be052 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlStatementBlock.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlStatementBlock.java @@ -1,22 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlVersionLiteral.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlVersionLiteral.java index 7ce574997f8..8fd74dc5857 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlVersionLiteral.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlVersionLiteral.java @@ -1,22 +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();
-}
+/******************************************************************************* + * 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(); +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/QMLExpressionEvaluator.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/QMLExpressionEvaluator.java index 4a83edaeb5f..030ce91a50d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/QMLExpressionEvaluator.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/QMLExpressionEvaluator.java @@ -1,120 +1,120 @@ -/*******************************************************************************
- * 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 final class QMLExpressionEvaluator {
- private QMLExpressionEvaluator() {
- }
-
- public static class InvalidExpressionException extends Exception {
-
- private static final long serialVersionUID = 4803923632666457229L;
-
- private IJSExpression offendingExpression;
-
- public InvalidExpressionException(String msg, IJSExpression expr) {
- super(msg);
- this.offendingExpression = expr;
- }
-
- public IJSExpression getOffendingExpression() {
- return offendingExpression;
- }
- }
-
- /**
- * Evaluates the given {@link IJSExpression} as a constant expression and returns the result. At the moment this only supports
- * very simple expressions involving unary operators and literals alone. Support for more complex expressions will be added as
- * needed.
- *
- * @param expr
- * the expression to be evaluated
- *
- * @throws InvalidExpressionException
- * if the given expression can't be reduced to a single constant
- */
- public static Object evaluateConstExpr(IJSExpression expr) throws InvalidExpressionException {
- if (expr instanceof IJSLiteral) {
- return ((IJSLiteral) expr).getValue();
- } else if (expr instanceof IJSUnaryExpression) {
- IJSUnaryExpression unary = (IJSUnaryExpression) expr;
- Object arg = evaluateConstExpr(unary.getArgument());
- switch (unary.getOperator()) {
- case Plus:
- return unaryPlus(arg, unary.getArgument());
- case Negation:
- return unaryNegate(arg, unary.getArgument());
- case BitwiseNot:
- return unaryBitwiseNot(arg, unary.getArgument());
- case Not:
- return unaryNot(arg, unary.getArgument());
- default:
- }
- }
- throw new InvalidExpressionException("Cannot reduce '" + expr + "' to a constant", expr); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static Object unaryPlus(Object object, IJSExpression expr) throws InvalidExpressionException {
- if (object instanceof Byte) {
- return +((Byte) object);
- } else if (object instanceof Short) {
- return +((Short) object);
- } else if (object instanceof Integer) {
- return +((Integer) object);
- } else if (object instanceof Long) {
- return +((Long) object);
- } else if (object instanceof Float) {
- return +((Float) object);
- } else if (object instanceof Double) {
- return +((Double) object);
- }
- throw new InvalidExpressionException("Cannot perform unary plus operation on a non-number", expr); //$NON-NLS-1$
- }
-
- private static Object unaryNegate(Object object, IJSExpression expr) throws InvalidExpressionException {
- if (object instanceof Byte) {
- return -((Byte) object);
- } else if (object instanceof Short) {
- return -((Short) object);
- } else if (object instanceof Integer) {
- return -((Integer) object);
- } else if (object instanceof Long) {
- return -((Long) object);
- } else if (object instanceof Float) {
- return -((Float) object);
- } else if (object instanceof Double) {
- return -((Double) object);
- }
- throw new InvalidExpressionException("Cannot perform unary negation operation on a non-number", expr); //$NON-NLS-1$
- }
-
- private static Object unaryBitwiseNot(Object object, IJSExpression expr) throws InvalidExpressionException {
- if (object instanceof Byte) {
- return ~((Byte) object);
- } else if (object instanceof Short) {
- return ~((Short) object);
- } else if (object instanceof Integer) {
- return ~((Integer) object);
- } else if (object instanceof Long) {
- return ~((Long) object);
- } else if (object instanceof Float || object instanceof Double) {
- return ~((Number) object).longValue();
- }
- throw new InvalidExpressionException("Cannot perform binary not operation on a non-number", expr); //$NON-NLS-1$
- }
-
- private static Object unaryNot(Object object, IJSExpression expr) throws InvalidExpressionException {
- if (object instanceof Boolean) {
- return !((Boolean) object);
- }
- throw new InvalidExpressionException("Cannot perform unary not operation on a non-boolean", expr); //$NON-NLS-1$
- }
-}
+/******************************************************************************* + * 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 final class QMLExpressionEvaluator { + private QMLExpressionEvaluator() { + } + + public static class InvalidExpressionException extends Exception { + + private static final long serialVersionUID = 4803923632666457229L; + + private IJSExpression offendingExpression; + + public InvalidExpressionException(String msg, IJSExpression expr) { + super(msg); + this.offendingExpression = expr; + } + + public IJSExpression getOffendingExpression() { + return offendingExpression; + } + } + + /** + * Evaluates the given {@link IJSExpression} as a constant expression and returns the result. At the moment this only supports + * very simple expressions involving unary operators and literals alone. Support for more complex expressions will be added as + * needed. + * + * @param expr + * the expression to be evaluated + * + * @throws InvalidExpressionException + * if the given expression can't be reduced to a single constant + */ + public static Object evaluateConstExpr(IJSExpression expr) throws InvalidExpressionException { + if (expr instanceof IJSLiteral) { + return ((IJSLiteral) expr).getValue(); + } else if (expr instanceof IJSUnaryExpression) { + IJSUnaryExpression unary = (IJSUnaryExpression) expr; + Object arg = evaluateConstExpr(unary.getArgument()); + switch (unary.getOperator()) { + case Plus: + return unaryPlus(arg, unary.getArgument()); + case Negation: + return unaryNegate(arg, unary.getArgument()); + case BitwiseNot: + return unaryBitwiseNot(arg, unary.getArgument()); + case Not: + return unaryNot(arg, unary.getArgument()); + default: + } + } + throw new InvalidExpressionException("Cannot reduce '" + expr + "' to a constant", expr); //$NON-NLS-1$ //$NON-NLS-2$ + } + + private static Object unaryPlus(Object object, IJSExpression expr) throws InvalidExpressionException { + if (object instanceof Byte) { + return +((Byte) object); + } else if (object instanceof Short) { + return +((Short) object); + } else if (object instanceof Integer) { + return +((Integer) object); + } else if (object instanceof Long) { + return +((Long) object); + } else if (object instanceof Float) { + return +((Float) object); + } else if (object instanceof Double) { + return +((Double) object); + } + throw new InvalidExpressionException("Cannot perform unary plus operation on a non-number", expr); //$NON-NLS-1$ + } + + private static Object unaryNegate(Object object, IJSExpression expr) throws InvalidExpressionException { + if (object instanceof Byte) { + return -((Byte) object); + } else if (object instanceof Short) { + return -((Short) object); + } else if (object instanceof Integer) { + return -((Integer) object); + } else if (object instanceof Long) { + return -((Long) object); + } else if (object instanceof Float) { + return -((Float) object); + } else if (object instanceof Double) { + return -((Double) object); + } + throw new InvalidExpressionException("Cannot perform unary negation operation on a non-number", expr); //$NON-NLS-1$ + } + + private static Object unaryBitwiseNot(Object object, IJSExpression expr) throws InvalidExpressionException { + if (object instanceof Byte) { + return ~((Byte) object); + } else if (object instanceof Short) { + return ~((Short) object); + } else if (object instanceof Integer) { + return ~((Integer) object); + } else if (object instanceof Long) { + return ~((Long) object); + } else if (object instanceof Float || object instanceof Double) { + return ~((Number) object).longValue(); + } + throw new InvalidExpressionException("Cannot perform binary not operation on a non-number", expr); //$NON-NLS-1$ + } + + private static Object unaryNot(Object object, IJSExpression expr) throws InvalidExpressionException { + if (object instanceof Boolean) { + return !((Boolean) object); + } + throw new InvalidExpressionException("Cannot perform unary not operation on a non-boolean", expr); //$NON-NLS-1$ + } +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/tern/ITernScope.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/tern/ITernScope.java index 5463f4899ee..65972055a69 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/tern/ITernScope.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/tern/ITernScope.java @@ -1,15 +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
-}
+/******************************************************************************* + * 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 +} diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/.npmignore b/qt/org.eclipse.cdt.qt.core/tern-qml/.npmignore index ebc5ac557a4..5ac75016525 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/.npmignore +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/.npmignore @@ -1,5 +1,5 @@ -/test
-/node_modules
-/.settings
-.project
+/test +/node_modules +/.settings +.project .tern-project
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/demo/defs/ecma5.json.js b/qt/org.eclipse.cdt.qt.core/tern-qml/demo/defs/ecma5.json.js index ed9f62e03de..41391c6ebcf 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/demo/defs/ecma5.json.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/demo/defs/ecma5.json.js @@ -1,966 +1,966 @@ -var ecma5 = {
- "!name": "ecma5",
- "!define": {"Error.prototype": "Error.prototype"},
- "Infinity": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Infinity",
- "!doc": "A numeric value representing infinity."
- },
- "undefined": {
- "!type": "?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/undefined",
- "!doc": "The value undefined."
- },
- "NaN": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/NaN",
- "!doc": "A value representing Not-A-Number."
- },
- "Object": {
- "!type": "fn()",
- "getPrototypeOf": {
- "!type": "fn(obj: ?) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getPrototypeOf",
- "!doc": "Returns the prototype (i.e. the internal prototype) of the specified object."
- },
- "create": {
- "!type": "fn(proto: ?) -> !custom:Object_create",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create",
- "!doc": "Creates a new object with the specified prototype object and properties."
- },
- "defineProperty": {
- "!type": "fn(obj: ?, prop: string, desc: ?) -> !custom:Object_defineProperty",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty",
- "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article."
- },
- "defineProperties": {
- "!type": "fn(obj: ?, props: ?) -> !custom:Object_defineProperties",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty",
- "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article."
- },
- "getOwnPropertyDescriptor": {
- "!type": "fn(obj: ?, prop: string) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor",
- "!doc": "Returns a property descriptor for an own property (that is, one directly present on an object, not present by dint of being along an object's prototype chain) of a given object."
- },
- "keys": {
- "!type": "fn(obj: ?) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys",
- "!doc": "Returns an array of a given object's own enumerable properties, in the same order as that provided by a for-in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well)."
- },
- "getOwnPropertyNames": {
- "!type": "fn(obj: ?) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames",
- "!doc": "Returns an array of all properties (enumerable or not) found directly upon a given object."
- },
- "seal": {
- "!type": "fn(obj: ?)",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/seal",
- "!doc": "Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable."
- },
- "isSealed": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isSealed",
- "!doc": "Determine if an object is sealed."
- },
- "freeze": {
- "!type": "fn(obj: ?) -> !0",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/freeze",
- "!doc": "Freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed. In essence the object is made effectively immutable. The method returns the object being frozen."
- },
- "isFrozen": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isFrozen",
- "!doc": "Determine if an object is frozen."
- },
- "preventExtensions": {
- "!type": "fn(obj: ?)",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions",
- "!doc": "Prevents new properties from ever being added to an object."
- },
- "isExtensible": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible",
- "!doc": "The Object.isExtensible() method determines if an object is extensible (whether it can have new properties added to it)."
- },
- "prototype": {
- "!stdProto": "Object",
- "toString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toString",
- "!doc": "Returns a string representing the object."
- },
- "toLocaleString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toLocaleString",
- "!doc": "Returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes."
- },
- "valueOf": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/valueOf",
- "!doc": "Returns the primitive value of the specified object"
- },
- "hasOwnProperty": {
- "!type": "fn(prop: string) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/hasOwnProperty",
- "!doc": "Returns a boolean indicating whether the object has the specified property."
- },
- "propertyIsEnumerable": {
- "!type": "fn(prop: string) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable",
- "!doc": "Returns a Boolean indicating whether the specified property is enumerable."
- },
- "isPrototypeOf": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf",
- "!doc": "Tests for an object in another object's prototype chain."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object",
- "!doc": "Creates an object wrapper."
- },
- "Function": {
- "!type": "fn(body: string) -> fn()",
- "prototype": {
- "!stdProto": "Function",
- "apply": {
- "!type": "fn(this: ?, args: [?])",
- "!effects": [
- "call and return !this this=!0 !1.<i> !1.<i> !1.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply",
- "!doc": "Calls a function with a given this value and arguments provided as an array (or an array like object)."
- },
- "call": {
- "!type": "fn(this: ?, args?: ?) -> !this.!ret",
- "!effects": [
- "call and return !this this=!0 !1 !2 !3 !4"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/call",
- "!doc": "Calls a function with a given this value and arguments provided individually."
- },
- "bind": {
- "!type": "fn(this: ?, args?: ?) -> !custom:Function_bind",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind",
- "!doc": "Creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function was called."
- },
- "prototype": "?"
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function",
- "!doc": "Every function in JavaScript is actually a Function object."
- },
- "Array": {
- "!type": "fn(size: number) -> !custom:Array_ctor",
- "isArray": {
- "!type": "fn(value: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/isArray",
- "!doc": "Returns true if an object is an array, false if it is not."
- },
- "prototype": {
- "!stdProto": "Array",
- "length": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/length",
- "!doc": "An unsigned, 32-bit integer that specifies the number of elements in an array."
- },
- "concat": {
- "!type": "fn(other: [?]) -> !this",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat",
- "!doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s)."
- },
- "join": {
- "!type": "fn(separator?: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/join",
- "!doc": "Joins all elements of an array into a string."
- },
- "splice": {
- "!type": "fn(pos: number, amount: number)",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/splice",
- "!doc": "Changes the content of an array, adding new elements while removing old elements."
- },
- "pop": {
- "!type": "fn() -> !this.<i>",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/pop",
- "!doc": "Removes the last element from an array and returns that element."
- },
- "push": {
- "!type": "fn(newelt: ?) -> number",
- "!effects": [
- "propagate !0 !this.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/push",
- "!doc": "Mutates an array by appending the given elements and returning the new length of the array."
- },
- "shift": {
- "!type": "fn() -> !this.<i>",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/shift",
- "!doc": "Removes the first element from an array and returns that element. This method changes the length of the array."
- },
- "unshift": {
- "!type": "fn(newelt: ?) -> number",
- "!effects": [
- "propagate !0 !this.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/unshift",
- "!doc": "Adds one or more elements to the beginning of an array and returns the new length of the array."
- },
- "slice": {
- "!type": "fn(from: number, to?: number) -> !this",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/slice",
- "!doc": "Returns a shallow copy of a portion of an array."
- },
- "reverse": {
- "!type": "fn()",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/reverse",
- "!doc": "Reverses an array in place. The first array element becomes the last and the last becomes the first."
- },
- "sort": {
- "!type": "fn(compare?: fn(a: ?, b: ?) -> number)",
- "!effects": [
- "call !0 !this.<i> !this.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort",
- "!doc": "Sorts the elements of an array in place and returns the array."
- },
- "indexOf": {
- "!type": "fn(elt: ?, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf",
- "!doc": "Returns the first index at which a given element can be found in the array, or -1 if it is not present."
- },
- "lastIndexOf": {
- "!type": "fn(elt: ?, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/lastIndexOf",
- "!doc": "Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex."
- },
- "every": {
- "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every",
- "!doc": "Tests whether all elements in the array pass the test implemented by the provided function."
- },
- "some": {
- "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/some",
- "!doc": "Tests whether some element in the array passes the test implemented by the provided function."
- },
- "filter": {
- "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> !this",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter",
- "!doc": "Creates a new array with all elements that pass the test implemented by the provided function."
- },
- "forEach": {
- "!type": "fn(f: fn(elt: ?, i: number), context?: ?)",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach",
- "!doc": "Executes a provided function once per array element."
- },
- "map": {
- "!type": "fn(f: fn(elt: ?, i: number) -> ?, context?: ?) -> [!0.!ret]",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map",
- "!doc": "Creates a new array with the results of calling a provided function on every element in this array."
- },
- "reduce": {
- "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret",
- "!effects": [
- "call !0 !1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce",
- "!doc": "Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value."
- },
- "reduceRight": {
- "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret",
- "!effects": [
- "call !0 !1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/ReduceRight",
- "!doc": "Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array",
- "!doc": "The JavaScript Array global object is a constructor for arrays, which are high-level, list-like objects."
- },
- "String": {
- "!type": "fn(value: ?) -> string",
- "fromCharCode": {
- "!type": "fn(code: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/fromCharCode",
- "!doc": "Returns a string created by using the specified sequence of Unicode values."
- },
- "prototype": {
- "!stdProto": "String",
- "length": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/String/length",
- "!doc": "Represents the length of a string."
- },
- "<i>": "string",
- "charAt": {
- "!type": "fn(i: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charAt",
- "!doc": "Returns the specified character from a string."
- },
- "charCodeAt": {
- "!type": "fn(i: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charCodeAt",
- "!doc": "Returns the numeric Unicode value of the character at the given index (except for unicode codepoints > 0x10000)."
- },
- "indexOf": {
- "!type": "fn(char: string, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/indexOf",
- "!doc": "Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex,\nreturns -1 if the value is not found."
- },
- "lastIndexOf": {
- "!type": "fn(char: string, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/lastIndexOf",
- "!doc": "Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex."
- },
- "substring": {
- "!type": "fn(from: number, to?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substring",
- "!doc": "Returns a subset of a string between one index and another, or through the end of the string."
- },
- "substr": {
- "!type": "fn(from: number, length?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substr",
- "!doc": "Returns the characters in a string beginning at the specified location through the specified number of characters."
- },
- "slice": {
- "!type": "fn(from: number, to?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/slice",
- "!doc": "Extracts a section of a string and returns a new string."
- },
- "trim": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim",
- "!doc": "Removes whitespace from both ends of the string."
- },
- "toUpperCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toUpperCase",
- "!doc": "Returns the calling string value converted to uppercase."
- },
- "toLowerCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLowerCase",
- "!doc": "Returns the calling string value converted to lowercase."
- },
- "toLocaleUpperCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase",
- "!doc": "Returns the calling string value converted to upper case, according to any locale-specific case mappings."
- },
- "toLocaleLowerCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase",
- "!doc": "Returns the calling string value converted to lower case, according to any locale-specific case mappings."
- },
- "split": {
- "!type": "fn(pattern: string) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split",
- "!doc": "Splits a String object into an array of strings by separating the string into substrings."
- },
- "concat": {
- "!type": "fn(other: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/concat",
- "!doc": "Combines the text of two or more strings and returns a new string."
- },
- "localeCompare": {
- "!type": "fn(other: string) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/localeCompare",
- "!doc": "Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order."
- },
- "match": {
- "!type": "fn(pattern: +RegExp) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/match",
- "!doc": "Used to retrieve the matches when matching a string against a regular expression."
- },
- "replace": {
- "!type": "fn(pattern: string|+RegExp, replacement: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace",
- "!doc": "Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match."
- },
- "search": {
- "!type": "fn(pattern: +RegExp) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search",
- "!doc": "Executes the search for a match between a regular expression and this String object."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String",
- "!doc": "The String global object is a constructor for strings, or a sequence of characters."
- },
- "Number": {
- "!type": "fn(value: ?) -> number",
- "MAX_VALUE": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MAX_VALUE",
- "!doc": "The maximum numeric value representable in JavaScript."
- },
- "MIN_VALUE": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MIN_VALUE",
- "!doc": "The smallest positive numeric value representable in JavaScript."
- },
- "POSITIVE_INFINITY": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY",
- "!doc": "A value representing the positive Infinity value."
- },
- "NEGATIVE_INFINITY": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY",
- "!doc": "A value representing the negative Infinity value."
- },
- "prototype": {
- "!stdProto": "Number",
- "toString": {
- "!type": "fn(radix?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toString",
- "!doc": "Returns a string representing the specified Number object"
- },
- "toFixed": {
- "!type": "fn(digits: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed",
- "!doc": "Formats a number using fixed-point notation"
- },
- "toExponential": {
- "!type": "fn(digits: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toExponential",
- "!doc": "Returns a string representing the Number object in exponential notation"
- },
- "toPrecision": {
- "!type": "fn(digits: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toPrecision",
- "!doc": "The toPrecision() method returns a string representing the number to the specified precision."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number",
- "!doc": "The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor."
- },
- "Boolean": {
- "!type": "fn(value: ?) -> bool",
- "prototype": {
- "!stdProto": "Boolean"
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean",
- "!doc": "The Boolean object is an object wrapper for a boolean value."
- },
- "RegExp": {
- "!type": "fn(source: string, flags?: string)",
- "prototype": {
- "!stdProto": "RegExp",
- "exec": {
- "!type": "fn(input: string) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec",
- "!doc": "Executes a search for a match in a specified string. Returns a result array, or null."
- },
- "test": {
- "!type": "fn(input: string) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/test",
- "!doc": "Executes the search for a match between a regular expression and a specified string. Returns true or false."
- },
- "global": {
- "!type": "bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
- "!doc": "Creates a regular expression object for matching text with a pattern."
- },
- "ignoreCase": {
- "!type": "bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
- "!doc": "Creates a regular expression object for matching text with a pattern."
- },
- "multiline": {
- "!type": "bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/multiline",
- "!doc": "Reflects whether or not to search in strings across multiple lines.\n"
- },
- "source": {
- "!type": "string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/source",
- "!doc": "A read-only property that contains the text of the pattern, excluding the forward slashes.\n"
- },
- "lastIndex": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/lastIndex",
- "!doc": "A read/write integer property that specifies the index at which to start the next match."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
- "!doc": "Creates a regular expression object for matching text with a pattern."
- },
- "Date": {
- "!type": "fn(ms: number)",
- "parse": {
- "!type": "fn(source: string) -> +Date",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/parse",
- "!doc": "Parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC."
- },
- "UTC": {
- "!type": "fn(year: number, month: number, date: number, hour?: number, min?: number, sec?: number, ms?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/UTC",
- "!doc": "Accepts the same parameters as the longest form of the constructor, and returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time."
- },
- "now": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now",
- "!doc": "Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC."
- },
- "prototype": {
- "toUTCString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toUTCString",
- "!doc": "Converts a date to a string, using the universal time convention."
- },
- "toISOString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString",
- "!doc": "JavaScript provides a direct way to convert a date object into a string in ISO format, the ISO 8601 Extended Format."
- },
- "toDateString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toDateString",
- "!doc": "Returns the date portion of a Date object in human readable form in American English."
- },
- "toTimeString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toTimeString",
- "!doc": "Returns the time portion of a Date object in human readable form in American English."
- },
- "toLocaleDateString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleDateString",
- "!doc": "Converts a date to a string, returning the \"date\" portion using the operating system's locale's conventions.\n"
- },
- "toLocaleTimeString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString",
- "!doc": "Converts a date to a string, returning the \"time\" portion using the current locale's conventions."
- },
- "getTime": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTime",
- "!doc": "Returns the numeric value corresponding to the time for the specified date according to universal time."
- },
- "getFullYear": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getFullYear",
- "!doc": "Returns the year of the specified date according to local time."
- },
- "getYear": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getYear",
- "!doc": "Returns the year in the specified date according to local time."
- },
- "getMonth": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMonth",
- "!doc": "Returns the month in the specified date according to local time."
- },
- "getUTCMonth": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMonth",
- "!doc": "Returns the month of the specified date according to universal time.\n"
- },
- "getDate": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDate",
- "!doc": "Returns the day of the month for the specified date according to local time."
- },
- "getUTCDate": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDate",
- "!doc": "Returns the day (date) of the month in the specified date according to universal time.\n"
- },
- "getDay": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDay",
- "!doc": "Returns the day of the week for the specified date according to local time."
- },
- "getUTCDay": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDay",
- "!doc": "Returns the day of the week in the specified date according to universal time.\n"
- },
- "getHours": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getHours",
- "!doc": "Returns the hour for the specified date according to local time."
- },
- "getUTCHours": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCHours",
- "!doc": "Returns the hours in the specified date according to universal time.\n"
- },
- "getMinutes": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMinutes",
- "!doc": "Returns the minutes in the specified date according to local time."
- },
- "getUTCMinutes": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date",
- "!doc": "Creates JavaScript Date instances which let you work with dates and times."
- },
- "getSeconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getSeconds",
- "!doc": "Returns the seconds in the specified date according to local time."
- },
- "getUTCSeconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCSeconds",
- "!doc": "Returns the seconds in the specified date according to universal time.\n"
- },
- "getMilliseconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMilliseconds",
- "!doc": "Returns the milliseconds in the specified date according to local time."
- },
- "getUTCMilliseconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds",
- "!doc": "Returns the milliseconds in the specified date according to universal time.\n"
- },
- "getTimezoneOffset": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset",
- "!doc": "Returns the time-zone offset from UTC, in minutes, for the current locale."
- },
- "setTime": {
- "!type": "fn(date: +Date) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setTime",
- "!doc": "Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.\n"
- },
- "setFullYear": {
- "!type": "fn(year: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setFullYear",
- "!doc": "Sets the full year for a specified date according to local time.\n"
- },
- "setUTCFullYear": {
- "!type": "fn(year: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCFullYear",
- "!doc": "Sets the full year for a specified date according to universal time.\n"
- },
- "setMonth": {
- "!type": "fn(month: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMonth",
- "!doc": "Set the month for a specified date according to local time."
- },
- "setUTCMonth": {
- "!type": "fn(month: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMonth",
- "!doc": "Sets the month for a specified date according to universal time.\n"
- },
- "setDate": {
- "!type": "fn(day: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setDate",
- "!doc": "Sets the day of the month for a specified date according to local time."
- },
- "setUTCDate": {
- "!type": "fn(day: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCDate",
- "!doc": "Sets the day of the month for a specified date according to universal time.\n"
- },
- "setHours": {
- "!type": "fn(hour: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setHours",
- "!doc": "Sets the hours for a specified date according to local time, and returns the number of milliseconds since 1 January 1970 00:00:00 UTC until the time represented by the updated Date instance."
- },
- "setUTCHours": {
- "!type": "fn(hour: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCHours",
- "!doc": "Sets the hour for a specified date according to universal time.\n"
- },
- "setMinutes": {
- "!type": "fn(min: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMinutes",
- "!doc": "Sets the minutes for a specified date according to local time."
- },
- "setUTCMinutes": {
- "!type": "fn(min: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMinutes",
- "!doc": "Sets the minutes for a specified date according to universal time.\n"
- },
- "setSeconds": {
- "!type": "fn(sec: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setSeconds",
- "!doc": "Sets the seconds for a specified date according to local time."
- },
- "setUTCSeconds": {
- "!type": "fn(sec: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCSeconds",
- "!doc": "Sets the seconds for a specified date according to universal time.\n"
- },
- "setMilliseconds": {
- "!type": "fn(ms: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMilliseconds",
- "!doc": "Sets the milliseconds for a specified date according to local time.\n"
- },
- "setUTCMilliseconds": {
- "!type": "fn(ms: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds",
- "!doc": "Sets the milliseconds for a specified date according to universal time.\n"
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date",
- "!doc": "Creates JavaScript Date instances which let you work with dates and times."
- },
- "Error": {
- "!type": "fn(message: string)",
- "prototype": {
- "name": {
- "!type": "string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/name",
- "!doc": "A name for the type of error."
- },
- "message": {
- "!type": "string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/message",
- "!doc": "A human-readable description of the error."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error",
- "!doc": "Creates an error object."
- },
- "SyntaxError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/SyntaxError",
- "!doc": "Represents an error when trying to interpret syntactically invalid code."
- },
- "ReferenceError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/ReferenceError",
- "!doc": "Represents an error when a non-existent variable is referenced."
- },
- "URIError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/URIError",
- "!doc": "Represents an error when a malformed URI is encountered."
- },
- "EvalError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/EvalError",
- "!doc": "Represents an error regarding the eval function."
- },
- "RangeError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RangeError",
- "!doc": "Represents an error when a number is not within the correct range allowed."
- },
- "TypeError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/TypeError",
- "!doc": "Represents an error an error when a value is not of the expected type."
- },
- "parseInt": {
- "!type": "fn(string: string, radix?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt",
- "!doc": "Parses a string argument and returns an integer of the specified radix or base."
- },
- "parseFloat": {
- "!type": "fn(string: string) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseFloat",
- "!doc": "Parses a string argument and returns a floating point number."
- },
- "isNaN": {
- "!type": "fn(value: number) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isNaN",
- "!doc": "Determines whether a value is NaN or not. Be careful, this function is broken. You may be interested in ECMAScript 6 Number.isNaN."
- },
- "isFinite": {
- "!type": "fn(value: number) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isFinite",
- "!doc": "Determines whether the passed value is a finite number."
- },
- "eval": {
- "!type": "fn(code: string) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval",
- "!doc": "Evaluates JavaScript code represented as a string."
- },
- "encodeURI": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI",
- "!doc": "Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)."
- },
- "encodeURIComponent": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent",
- "!doc": "Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)."
- },
- "decodeURI": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURI",
- "!doc": "Decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine."
- },
- "decodeURIComponent": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURIComponent",
- "!doc": "Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine."
- },
- "Math": {
- "E": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/E",
- "!doc": "The base of natural logarithms, e, approximately 2.718."
- },
- "LN2": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN2",
- "!doc": "The natural logarithm of 2, approximately 0.693."
- },
- "LN10": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN10",
- "!doc": "The natural logarithm of 10, approximately 2.302."
- },
- "LOG2E": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG2E",
- "!doc": "The base 2 logarithm of E (approximately 1.442)."
- },
- "LOG10E": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG10E",
- "!doc": "The base 10 logarithm of E (approximately 0.434)."
- },
- "SQRT1_2": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT1_2",
- "!doc": "The square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707."
- },
- "SQRT2": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT2",
- "!doc": "The square root of 2, approximately 1.414."
- },
- "PI": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/PI",
- "!doc": "The ratio of the circumference of a circle to its diameter, approximately 3.14159."
- },
- "abs": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/abs",
- "!doc": "Returns the absolute value of a number."
- },
- "cos": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/cos",
- "!doc": "Returns the cosine of a number."
- },
- "sin": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sin",
- "!doc": "Returns the sine of a number."
- },
- "tan": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/tan",
- "!doc": "Returns the tangent of a number."
- },
- "acos": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/acos",
- "!doc": "Returns the arccosine (in radians) of a number."
- },
- "asin": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/asin",
- "!doc": "Returns the arcsine (in radians) of a number."
- },
- "atan": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan",
- "!doc": "Returns the arctangent (in radians) of a number."
- },
- "atan2": {
- "!type": "fn(y: number, x: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2",
- "!doc": "Returns the arctangent of the quotient of its arguments."
- },
- "ceil": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil",
- "!doc": "Returns the smallest integer greater than or equal to a number."
- },
- "floor": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/floor",
- "!doc": "Returns the largest integer less than or equal to a number."
- },
- "round": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/round",
- "!doc": "Returns the value of a number rounded to the nearest integer."
- },
- "exp": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/exp",
- "!doc": "Returns Ex, where x is the argument, and E is Euler's constant, the base of the natural logarithms."
- },
- "log": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/log",
- "!doc": "Returns the natural logarithm (base E) of a number."
- },
- "sqrt": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sqrt",
- "!doc": "Returns the square root of a number."
- },
- "pow": {
- "!type": "fn(number, number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/pow",
- "!doc": "Returns base to the exponent power, that is, baseexponent."
- },
- "max": {
- "!type": "fn(number, number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/max",
- "!doc": "Returns the largest of zero or more numbers."
- },
- "min": {
- "!type": "fn(number, number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/min",
- "!doc": "Returns the smallest of zero or more numbers."
- },
- "random": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random",
- "!doc": "Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range."
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math",
- "!doc": "A built-in object that has properties and methods for mathematical constants and functions."
- },
- "JSON": {
- "parse": {
- "!type": "fn(json: string) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/parse",
- "!doc": "Parse a string as JSON, optionally transforming the value produced by parsing."
- },
- "stringify": {
- "!type": "fn(value: ?) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify",
- "!doc": "Convert a value to JSON, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified."
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JSON",
- "!doc": "JSON (JavaScript Object Notation) is a data-interchange format. It closely resembles a subset of JavaScript syntax, although it is not a strict subset. (See JSON in the JavaScript Reference for full details.) It is useful when writing any kind of JavaScript-based application, including websites and browser extensions. For example, you might store user information in JSON format in a cookie, or you might store extension preferences in JSON in a string-valued browser preference."
- }
+var ecma5 = { + "!name": "ecma5", + "!define": {"Error.prototype": "Error.prototype"}, + "Infinity": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Infinity", + "!doc": "A numeric value representing infinity." + }, + "undefined": { + "!type": "?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/undefined", + "!doc": "The value undefined." + }, + "NaN": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/NaN", + "!doc": "A value representing Not-A-Number." + }, + "Object": { + "!type": "fn()", + "getPrototypeOf": { + "!type": "fn(obj: ?) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getPrototypeOf", + "!doc": "Returns the prototype (i.e. the internal prototype) of the specified object." + }, + "create": { + "!type": "fn(proto: ?) -> !custom:Object_create", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create", + "!doc": "Creates a new object with the specified prototype object and properties." + }, + "defineProperty": { + "!type": "fn(obj: ?, prop: string, desc: ?) -> !custom:Object_defineProperty", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty", + "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article." + }, + "defineProperties": { + "!type": "fn(obj: ?, props: ?) -> !custom:Object_defineProperties", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty", + "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article." + }, + "getOwnPropertyDescriptor": { + "!type": "fn(obj: ?, prop: string) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor", + "!doc": "Returns a property descriptor for an own property (that is, one directly present on an object, not present by dint of being along an object's prototype chain) of a given object." + }, + "keys": { + "!type": "fn(obj: ?) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys", + "!doc": "Returns an array of a given object's own enumerable properties, in the same order as that provided by a for-in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well)." + }, + "getOwnPropertyNames": { + "!type": "fn(obj: ?) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames", + "!doc": "Returns an array of all properties (enumerable or not) found directly upon a given object." + }, + "seal": { + "!type": "fn(obj: ?)", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/seal", + "!doc": "Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable." + }, + "isSealed": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isSealed", + "!doc": "Determine if an object is sealed." + }, + "freeze": { + "!type": "fn(obj: ?) -> !0", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/freeze", + "!doc": "Freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed. In essence the object is made effectively immutable. The method returns the object being frozen." + }, + "isFrozen": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isFrozen", + "!doc": "Determine if an object is frozen." + }, + "preventExtensions": { + "!type": "fn(obj: ?)", + "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions", + "!doc": "Prevents new properties from ever being added to an object." + }, + "isExtensible": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible", + "!doc": "The Object.isExtensible() method determines if an object is extensible (whether it can have new properties added to it)." + }, + "prototype": { + "!stdProto": "Object", + "toString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toString", + "!doc": "Returns a string representing the object." + }, + "toLocaleString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toLocaleString", + "!doc": "Returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes." + }, + "valueOf": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/valueOf", + "!doc": "Returns the primitive value of the specified object" + }, + "hasOwnProperty": { + "!type": "fn(prop: string) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/hasOwnProperty", + "!doc": "Returns a boolean indicating whether the object has the specified property." + }, + "propertyIsEnumerable": { + "!type": "fn(prop: string) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable", + "!doc": "Returns a Boolean indicating whether the specified property is enumerable." + }, + "isPrototypeOf": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf", + "!doc": "Tests for an object in another object's prototype chain." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object", + "!doc": "Creates an object wrapper." + }, + "Function": { + "!type": "fn(body: string) -> fn()", + "prototype": { + "!stdProto": "Function", + "apply": { + "!type": "fn(this: ?, args: [?])", + "!effects": [ + "call and return !this this=!0 !1.<i> !1.<i> !1.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply", + "!doc": "Calls a function with a given this value and arguments provided as an array (or an array like object)." + }, + "call": { + "!type": "fn(this: ?, args?: ?) -> !this.!ret", + "!effects": [ + "call and return !this this=!0 !1 !2 !3 !4" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/call", + "!doc": "Calls a function with a given this value and arguments provided individually." + }, + "bind": { + "!type": "fn(this: ?, args?: ?) -> !custom:Function_bind", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind", + "!doc": "Creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function was called." + }, + "prototype": "?" + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function", + "!doc": "Every function in JavaScript is actually a Function object." + }, + "Array": { + "!type": "fn(size: number) -> !custom:Array_ctor", + "isArray": { + "!type": "fn(value: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/isArray", + "!doc": "Returns true if an object is an array, false if it is not." + }, + "prototype": { + "!stdProto": "Array", + "length": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/length", + "!doc": "An unsigned, 32-bit integer that specifies the number of elements in an array." + }, + "concat": { + "!type": "fn(other: [?]) -> !this", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat", + "!doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s)." + }, + "join": { + "!type": "fn(separator?: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/join", + "!doc": "Joins all elements of an array into a string." + }, + "splice": { + "!type": "fn(pos: number, amount: number)", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/splice", + "!doc": "Changes the content of an array, adding new elements while removing old elements." + }, + "pop": { + "!type": "fn() -> !this.<i>", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/pop", + "!doc": "Removes the last element from an array and returns that element." + }, + "push": { + "!type": "fn(newelt: ?) -> number", + "!effects": [ + "propagate !0 !this.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/push", + "!doc": "Mutates an array by appending the given elements and returning the new length of the array." + }, + "shift": { + "!type": "fn() -> !this.<i>", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/shift", + "!doc": "Removes the first element from an array and returns that element. This method changes the length of the array." + }, + "unshift": { + "!type": "fn(newelt: ?) -> number", + "!effects": [ + "propagate !0 !this.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/unshift", + "!doc": "Adds one or more elements to the beginning of an array and returns the new length of the array." + }, + "slice": { + "!type": "fn(from: number, to?: number) -> !this", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/slice", + "!doc": "Returns a shallow copy of a portion of an array." + }, + "reverse": { + "!type": "fn()", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/reverse", + "!doc": "Reverses an array in place. The first array element becomes the last and the last becomes the first." + }, + "sort": { + "!type": "fn(compare?: fn(a: ?, b: ?) -> number)", + "!effects": [ + "call !0 !this.<i> !this.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort", + "!doc": "Sorts the elements of an array in place and returns the array." + }, + "indexOf": { + "!type": "fn(elt: ?, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf", + "!doc": "Returns the first index at which a given element can be found in the array, or -1 if it is not present." + }, + "lastIndexOf": { + "!type": "fn(elt: ?, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/lastIndexOf", + "!doc": "Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex." + }, + "every": { + "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every", + "!doc": "Tests whether all elements in the array pass the test implemented by the provided function." + }, + "some": { + "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/some", + "!doc": "Tests whether some element in the array passes the test implemented by the provided function." + }, + "filter": { + "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> !this", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter", + "!doc": "Creates a new array with all elements that pass the test implemented by the provided function." + }, + "forEach": { + "!type": "fn(f: fn(elt: ?, i: number), context?: ?)", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach", + "!doc": "Executes a provided function once per array element." + }, + "map": { + "!type": "fn(f: fn(elt: ?, i: number) -> ?, context?: ?) -> [!0.!ret]", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map", + "!doc": "Creates a new array with the results of calling a provided function on every element in this array." + }, + "reduce": { + "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret", + "!effects": [ + "call !0 !1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce", + "!doc": "Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value." + }, + "reduceRight": { + "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret", + "!effects": [ + "call !0 !1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/ReduceRight", + "!doc": "Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array", + "!doc": "The JavaScript Array global object is a constructor for arrays, which are high-level, list-like objects." + }, + "String": { + "!type": "fn(value: ?) -> string", + "fromCharCode": { + "!type": "fn(code: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/fromCharCode", + "!doc": "Returns a string created by using the specified sequence of Unicode values." + }, + "prototype": { + "!stdProto": "String", + "length": { + "!type": "number", + "!url": "https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/String/length", + "!doc": "Represents the length of a string." + }, + "<i>": "string", + "charAt": { + "!type": "fn(i: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charAt", + "!doc": "Returns the specified character from a string." + }, + "charCodeAt": { + "!type": "fn(i: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charCodeAt", + "!doc": "Returns the numeric Unicode value of the character at the given index (except for unicode codepoints > 0x10000)." + }, + "indexOf": { + "!type": "fn(char: string, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/indexOf", + "!doc": "Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex,\nreturns -1 if the value is not found." + }, + "lastIndexOf": { + "!type": "fn(char: string, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/lastIndexOf", + "!doc": "Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex." + }, + "substring": { + "!type": "fn(from: number, to?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substring", + "!doc": "Returns a subset of a string between one index and another, or through the end of the string." + }, + "substr": { + "!type": "fn(from: number, length?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substr", + "!doc": "Returns the characters in a string beginning at the specified location through the specified number of characters." + }, + "slice": { + "!type": "fn(from: number, to?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/slice", + "!doc": "Extracts a section of a string and returns a new string." + }, + "trim": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim", + "!doc": "Removes whitespace from both ends of the string." + }, + "toUpperCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toUpperCase", + "!doc": "Returns the calling string value converted to uppercase." + }, + "toLowerCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLowerCase", + "!doc": "Returns the calling string value converted to lowercase." + }, + "toLocaleUpperCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase", + "!doc": "Returns the calling string value converted to upper case, according to any locale-specific case mappings." + }, + "toLocaleLowerCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase", + "!doc": "Returns the calling string value converted to lower case, according to any locale-specific case mappings." + }, + "split": { + "!type": "fn(pattern: string) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split", + "!doc": "Splits a String object into an array of strings by separating the string into substrings." + }, + "concat": { + "!type": "fn(other: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/concat", + "!doc": "Combines the text of two or more strings and returns a new string." + }, + "localeCompare": { + "!type": "fn(other: string) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/localeCompare", + "!doc": "Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order." + }, + "match": { + "!type": "fn(pattern: +RegExp) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/match", + "!doc": "Used to retrieve the matches when matching a string against a regular expression." + }, + "replace": { + "!type": "fn(pattern: string|+RegExp, replacement: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace", + "!doc": "Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match." + }, + "search": { + "!type": "fn(pattern: +RegExp) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search", + "!doc": "Executes the search for a match between a regular expression and this String object." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String", + "!doc": "The String global object is a constructor for strings, or a sequence of characters." + }, + "Number": { + "!type": "fn(value: ?) -> number", + "MAX_VALUE": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MAX_VALUE", + "!doc": "The maximum numeric value representable in JavaScript." + }, + "MIN_VALUE": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MIN_VALUE", + "!doc": "The smallest positive numeric value representable in JavaScript." + }, + "POSITIVE_INFINITY": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY", + "!doc": "A value representing the positive Infinity value." + }, + "NEGATIVE_INFINITY": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY", + "!doc": "A value representing the negative Infinity value." + }, + "prototype": { + "!stdProto": "Number", + "toString": { + "!type": "fn(radix?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toString", + "!doc": "Returns a string representing the specified Number object" + }, + "toFixed": { + "!type": "fn(digits: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed", + "!doc": "Formats a number using fixed-point notation" + }, + "toExponential": { + "!type": "fn(digits: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toExponential", + "!doc": "Returns a string representing the Number object in exponential notation" + }, + "toPrecision": { + "!type": "fn(digits: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toPrecision", + "!doc": "The toPrecision() method returns a string representing the number to the specified precision." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number", + "!doc": "The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor." + }, + "Boolean": { + "!type": "fn(value: ?) -> bool", + "prototype": { + "!stdProto": "Boolean" + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean", + "!doc": "The Boolean object is an object wrapper for a boolean value." + }, + "RegExp": { + "!type": "fn(source: string, flags?: string)", + "prototype": { + "!stdProto": "RegExp", + "exec": { + "!type": "fn(input: string) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec", + "!doc": "Executes a search for a match in a specified string. Returns a result array, or null." + }, + "test": { + "!type": "fn(input: string) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/test", + "!doc": "Executes the search for a match between a regular expression and a specified string. Returns true or false." + }, + "global": { + "!type": "bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp", + "!doc": "Creates a regular expression object for matching text with a pattern." + }, + "ignoreCase": { + "!type": "bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp", + "!doc": "Creates a regular expression object for matching text with a pattern." + }, + "multiline": { + "!type": "bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/multiline", + "!doc": "Reflects whether or not to search in strings across multiple lines.\n" + }, + "source": { + "!type": "string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/source", + "!doc": "A read-only property that contains the text of the pattern, excluding the forward slashes.\n" + }, + "lastIndex": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/lastIndex", + "!doc": "A read/write integer property that specifies the index at which to start the next match." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp", + "!doc": "Creates a regular expression object for matching text with a pattern." + }, + "Date": { + "!type": "fn(ms: number)", + "parse": { + "!type": "fn(source: string) -> +Date", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/parse", + "!doc": "Parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC." + }, + "UTC": { + "!type": "fn(year: number, month: number, date: number, hour?: number, min?: number, sec?: number, ms?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/UTC", + "!doc": "Accepts the same parameters as the longest form of the constructor, and returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time." + }, + "now": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now", + "!doc": "Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC." + }, + "prototype": { + "toUTCString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toUTCString", + "!doc": "Converts a date to a string, using the universal time convention." + }, + "toISOString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString", + "!doc": "JavaScript provides a direct way to convert a date object into a string in ISO format, the ISO 8601 Extended Format." + }, + "toDateString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toDateString", + "!doc": "Returns the date portion of a Date object in human readable form in American English." + }, + "toTimeString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toTimeString", + "!doc": "Returns the time portion of a Date object in human readable form in American English." + }, + "toLocaleDateString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleDateString", + "!doc": "Converts a date to a string, returning the \"date\" portion using the operating system's locale's conventions.\n" + }, + "toLocaleTimeString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString", + "!doc": "Converts a date to a string, returning the \"time\" portion using the current locale's conventions." + }, + "getTime": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTime", + "!doc": "Returns the numeric value corresponding to the time for the specified date according to universal time." + }, + "getFullYear": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getFullYear", + "!doc": "Returns the year of the specified date according to local time." + }, + "getYear": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getYear", + "!doc": "Returns the year in the specified date according to local time." + }, + "getMonth": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMonth", + "!doc": "Returns the month in the specified date according to local time." + }, + "getUTCMonth": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMonth", + "!doc": "Returns the month of the specified date according to universal time.\n" + }, + "getDate": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDate", + "!doc": "Returns the day of the month for the specified date according to local time." + }, + "getUTCDate": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDate", + "!doc": "Returns the day (date) of the month in the specified date according to universal time.\n" + }, + "getDay": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDay", + "!doc": "Returns the day of the week for the specified date according to local time." + }, + "getUTCDay": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDay", + "!doc": "Returns the day of the week in the specified date according to universal time.\n" + }, + "getHours": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getHours", + "!doc": "Returns the hour for the specified date according to local time." + }, + "getUTCHours": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCHours", + "!doc": "Returns the hours in the specified date according to universal time.\n" + }, + "getMinutes": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMinutes", + "!doc": "Returns the minutes in the specified date according to local time." + }, + "getUTCMinutes": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date", + "!doc": "Creates JavaScript Date instances which let you work with dates and times." + }, + "getSeconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getSeconds", + "!doc": "Returns the seconds in the specified date according to local time." + }, + "getUTCSeconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCSeconds", + "!doc": "Returns the seconds in the specified date according to universal time.\n" + }, + "getMilliseconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMilliseconds", + "!doc": "Returns the milliseconds in the specified date according to local time." + }, + "getUTCMilliseconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds", + "!doc": "Returns the milliseconds in the specified date according to universal time.\n" + }, + "getTimezoneOffset": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset", + "!doc": "Returns the time-zone offset from UTC, in minutes, for the current locale." + }, + "setTime": { + "!type": "fn(date: +Date) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setTime", + "!doc": "Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.\n" + }, + "setFullYear": { + "!type": "fn(year: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setFullYear", + "!doc": "Sets the full year for a specified date according to local time.\n" + }, + "setUTCFullYear": { + "!type": "fn(year: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCFullYear", + "!doc": "Sets the full year for a specified date according to universal time.\n" + }, + "setMonth": { + "!type": "fn(month: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMonth", + "!doc": "Set the month for a specified date according to local time." + }, + "setUTCMonth": { + "!type": "fn(month: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMonth", + "!doc": "Sets the month for a specified date according to universal time.\n" + }, + "setDate": { + "!type": "fn(day: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setDate", + "!doc": "Sets the day of the month for a specified date according to local time." + }, + "setUTCDate": { + "!type": "fn(day: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCDate", + "!doc": "Sets the day of the month for a specified date according to universal time.\n" + }, + "setHours": { + "!type": "fn(hour: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setHours", + "!doc": "Sets the hours for a specified date according to local time, and returns the number of milliseconds since 1 January 1970 00:00:00 UTC until the time represented by the updated Date instance." + }, + "setUTCHours": { + "!type": "fn(hour: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCHours", + "!doc": "Sets the hour for a specified date according to universal time.\n" + }, + "setMinutes": { + "!type": "fn(min: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMinutes", + "!doc": "Sets the minutes for a specified date according to local time." + }, + "setUTCMinutes": { + "!type": "fn(min: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMinutes", + "!doc": "Sets the minutes for a specified date according to universal time.\n" + }, + "setSeconds": { + "!type": "fn(sec: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setSeconds", + "!doc": "Sets the seconds for a specified date according to local time." + }, + "setUTCSeconds": { + "!type": "fn(sec: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCSeconds", + "!doc": "Sets the seconds for a specified date according to universal time.\n" + }, + "setMilliseconds": { + "!type": "fn(ms: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMilliseconds", + "!doc": "Sets the milliseconds for a specified date according to local time.\n" + }, + "setUTCMilliseconds": { + "!type": "fn(ms: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds", + "!doc": "Sets the milliseconds for a specified date according to universal time.\n" + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date", + "!doc": "Creates JavaScript Date instances which let you work with dates and times." + }, + "Error": { + "!type": "fn(message: string)", + "prototype": { + "name": { + "!type": "string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/name", + "!doc": "A name for the type of error." + }, + "message": { + "!type": "string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/message", + "!doc": "A human-readable description of the error." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error", + "!doc": "Creates an error object." + }, + "SyntaxError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/SyntaxError", + "!doc": "Represents an error when trying to interpret syntactically invalid code." + }, + "ReferenceError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/ReferenceError", + "!doc": "Represents an error when a non-existent variable is referenced." + }, + "URIError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/URIError", + "!doc": "Represents an error when a malformed URI is encountered." + }, + "EvalError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/EvalError", + "!doc": "Represents an error regarding the eval function." + }, + "RangeError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RangeError", + "!doc": "Represents an error when a number is not within the correct range allowed." + }, + "TypeError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/TypeError", + "!doc": "Represents an error an error when a value is not of the expected type." + }, + "parseInt": { + "!type": "fn(string: string, radix?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt", + "!doc": "Parses a string argument and returns an integer of the specified radix or base." + }, + "parseFloat": { + "!type": "fn(string: string) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseFloat", + "!doc": "Parses a string argument and returns a floating point number." + }, + "isNaN": { + "!type": "fn(value: number) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isNaN", + "!doc": "Determines whether a value is NaN or not. Be careful, this function is broken. You may be interested in ECMAScript 6 Number.isNaN." + }, + "isFinite": { + "!type": "fn(value: number) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isFinite", + "!doc": "Determines whether the passed value is a finite number." + }, + "eval": { + "!type": "fn(code: string) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval", + "!doc": "Evaluates JavaScript code represented as a string." + }, + "encodeURI": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI", + "!doc": "Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)." + }, + "encodeURIComponent": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent", + "!doc": "Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)." + }, + "decodeURI": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURI", + "!doc": "Decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine." + }, + "decodeURIComponent": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURIComponent", + "!doc": "Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine." + }, + "Math": { + "E": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/E", + "!doc": "The base of natural logarithms, e, approximately 2.718." + }, + "LN2": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN2", + "!doc": "The natural logarithm of 2, approximately 0.693." + }, + "LN10": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN10", + "!doc": "The natural logarithm of 10, approximately 2.302." + }, + "LOG2E": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG2E", + "!doc": "The base 2 logarithm of E (approximately 1.442)." + }, + "LOG10E": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG10E", + "!doc": "The base 10 logarithm of E (approximately 0.434)." + }, + "SQRT1_2": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT1_2", + "!doc": "The square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707." + }, + "SQRT2": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT2", + "!doc": "The square root of 2, approximately 1.414." + }, + "PI": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/PI", + "!doc": "The ratio of the circumference of a circle to its diameter, approximately 3.14159." + }, + "abs": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/abs", + "!doc": "Returns the absolute value of a number." + }, + "cos": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/cos", + "!doc": "Returns the cosine of a number." + }, + "sin": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sin", + "!doc": "Returns the sine of a number." + }, + "tan": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/tan", + "!doc": "Returns the tangent of a number." + }, + "acos": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/acos", + "!doc": "Returns the arccosine (in radians) of a number." + }, + "asin": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/asin", + "!doc": "Returns the arcsine (in radians) of a number." + }, + "atan": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan", + "!doc": "Returns the arctangent (in radians) of a number." + }, + "atan2": { + "!type": "fn(y: number, x: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2", + "!doc": "Returns the arctangent of the quotient of its arguments." + }, + "ceil": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil", + "!doc": "Returns the smallest integer greater than or equal to a number." + }, + "floor": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/floor", + "!doc": "Returns the largest integer less than or equal to a number." + }, + "round": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/round", + "!doc": "Returns the value of a number rounded to the nearest integer." + }, + "exp": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/exp", + "!doc": "Returns Ex, where x is the argument, and E is Euler's constant, the base of the natural logarithms." + }, + "log": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/log", + "!doc": "Returns the natural logarithm (base E) of a number." + }, + "sqrt": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sqrt", + "!doc": "Returns the square root of a number." + }, + "pow": { + "!type": "fn(number, number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/pow", + "!doc": "Returns base to the exponent power, that is, baseexponent." + }, + "max": { + "!type": "fn(number, number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/max", + "!doc": "Returns the largest of zero or more numbers." + }, + "min": { + "!type": "fn(number, number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/min", + "!doc": "Returns the smallest of zero or more numbers." + }, + "random": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random", + "!doc": "Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range." + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math", + "!doc": "A built-in object that has properties and methods for mathematical constants and functions." + }, + "JSON": { + "parse": { + "!type": "fn(json: string) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/parse", + "!doc": "Parse a string as JSON, optionally transforming the value produced by parsing." + }, + "stringify": { + "!type": "fn(value: ?) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify", + "!doc": "Convert a value to JSON, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified." + }, + "!url": "https://developer.mozilla.org/en-US/docs/JSON", + "!doc": "JSON (JavaScript Object Notation) is a data-interchange format. It closely resembles a subset of JavaScript syntax, although it is not a strict subset. (See JSON in the JavaScript Reference for full details.) It is useful when writing any kind of JavaScript-based application, including websites and browser extensions. For example, you might store user information in JSON format in a cookie, or you might store extension preferences in JSON in a string-valued browser preference." + } }
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/demo/qml-demo.html b/qt/org.eclipse.cdt.qt.core/tern-qml/demo/qml-demo.html index 75be78a1bef..91c778754b0 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/demo/qml-demo.html +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/demo/qml-demo.html @@ -1,254 +1,254 @@ -<!doctype html>
-<html>
-
-<head>
- <meta charset="utf-8">
- <title>Tern QML Demo</title>
-
- <!-- CodeMirror Stylesheets -->
- <link rel=stylesheet href="../node_modules/codemirror/lib/codemirror.css">
- <link rel="stylesheet" href="../node_modules/codemirror/theme/eclipse.css">
- <link rel="stylesheet" href="../node_modules/codemirror/addon/dialog/dialog.css">
-
- <!-- CodeMirror-JavaScript Stylesheets -->
- <link rel="stylesheet" href="../node_modules/codemirror-javascript/addon/hint/tern/tern-extension.css">
-
- <!-- CodeMirror-Extension Stylesheets -->
- <link rel="stylesheet" href="../node_modules/codemirror-extension/addon/hover/text-hover.css">
- <link rel="stylesheet" href="../node_modules/codemirror-extension/addon/hint/templates-hint.css">
- <link rel="stylesheet" href="../node_modules/codemirror-extension/addon/hint/show-hint-eclipse.css">
- <link rel="stylesheet" href="../node_modules/codemirror-extension/addon/hint/show-context-info.css">
-
- <!-- Demo Specific Stylesheets -->
- <link rel=stylesheet href="./docs.css">
- <link rel=stylesheet href="./demo.css">
-</head>
-
-<body>
- <h1>Demo with QML Tern plugin </h1>
- <title>QML Tern Demo</title>
-
- <!-- CodeMirror -->
- <script src="../node_modules/codemirror/lib/codemirror.js"></script>
- <script src="../node_modules/codemirror/addon/hint/show-hint.js"></script>
- <script src="../node_modules/codemirror/addon/edit/closetag.js"></script>
- <script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
- <script src="../node_modules/codemirror/addon/edit/matchbrackets.js"></script>
- <script src="../node_modules/codemirror/addon/selection/active-line.js"></script>
- <script src="../node_modules/codemirror/mode/javascript/javascript.js"></script>
-
- <!-- Acorn -->
- <script src="../node_modules/acorn/dist/acorn.js"></script>
- <script src="../node_modules/acorn/dist/acorn_loose.js"></script>
- <script src="../node_modules/acorn/dist/walk.js"></script>
- <script src="../node_modules/acorn-qml/inject.js"></script>
- <script src="../node_modules/acorn-qml/index.js"></script>
- <script src="../node_modules/acorn-qml/loose/inject.js"></script>
- <script src="../node_modules/acorn-qml/loose/index.js"></script>
- <script src="../node_modules/acorn-qml/walk/index.js"></script>
-
- <!-- Tern JS -->
- <script src="../node_modules/tern/lib/signal.js"></script>
- <script src="../node_modules/tern/lib/tern.js"></script>
- <script src="../node_modules/tern/lib/def.js"></script>
- <script src="../node_modules/tern/lib/comment.js"></script>
- <script src="../node_modules/tern/lib/infer.js"></script>
- <script src="../qml.js"></script>
-
- <!-- Official CodeMirror Tern addon -->
- <script src="../node_modules/codemirror/addon/tern/tern.js"></script>
-
- <!-- ECMA 5th Edition Definitions File -->
- <script src="defs/ecma5.json.js"></script>
-
- <!-- CodeMirror Extension -->
- <script src="../node_modules/codemirror-extension/addon/hint/show-context-info.js"></script>
- <script src="../node_modules/codemirror-extension/addon/hint/templates-hint.js"></script>
-
- <!-- CodeMirror Javascript -->
- <script src="../node_modules/codemirror-javascript/addon/hint/javascript/javascript-templates.js"></script>
-
- <!-- Tern Hover -->
- <script src="../node_modules/codemirror-extension/addon/hover/text-hover.js"></script>
- <script src="../node_modules/codemirror-javascript/addon/hint/tern/tern-hover.js"></script>
-
- <!-- Extra script to control project logic -->
- <script src="./demo.js"></script>
-
- <div style="position: relative" id="demospace">
- <div id="menus">
- <select id="commands">
- <option>commands...</option>
- <option value="complete">Autocomplete (Ctrl-Space)</option>
- <option value="jumptodef">Jump to definition (ctrl-J)</option>
- <option value="finddocs">Describe (Ctrl-O)</option>
- <option value="findtype">Find type of (Ctrl-I)</option>
- <option value="rename">Rename variable (Ctrl-Q)</option>
- <option value="addfile">Add a new file</option>
- <option value="delfile">Remove this file</option>
- </select>
- </div>
- <form id="place">
- <ul class="tabs">
- <li class="selected">test</li>
- </ul>
- <div class="CodeMirror cm-s-default">
- <div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5px; left: 40px;">
- <textarea autocorrect="off" autocapitalize="off" spellcheck="false" style="position: absolute; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea>
- </div>
- <div class="CodeMirror-vscrollbar" cm-not-content="true" style="display: block; bottom: 0px;">
- <div style="min-width: 1px; height: 580px;"></div>
- </div>
- <div class="CodeMirror-hscrollbar" cm-not-content="true">
- <div style="height: 100%; min-height: 1px; width: 0px;"></div>
- </div>
- <div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div>
- <div class="CodeMirror-gutter-filler" cm-not-content="true"></div>
- <div class="CodeMirror-scroll" tabindex="-1">
- <div class="CodeMirror-sizer" style="margin-left: 30px; margin-bottom: -21px; border-right-width: 9px; min-height: 580px; min-width: 531.891px; padding-right: 21px; padding-bottom: 0px;">
- <div style="position: relative; top: 0px;">
- <div class="CodeMirror-lines">
- <div style="position: relative; outline: none;">
- <div class="CodeMirror-measure"><span><span>​</span>x</span>
- </div>
- <div class="CodeMirror-measure"></div>
- <div style="position: relative; z-index: 1;"></div>
- <div class="CodeMirror-cursors">
- <div class="CodeMirror-cursor" style="left: 9px; top: 0px; height: 22px;"> </div>
- </div>
- <div class="CodeMirror-code">
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">1</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// Use ctrl-space to complete something</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">2</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-variable">co</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">3</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-variable">document</span>.<span class="cm-property">body</span>.<span class="cm-property">a</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">4</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">5</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// Put the cursor in or after an expression, press ctrl-i to</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">6</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// find its type</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">7</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">8</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-keyword">var</span> <span class="cm-def">foo</span> <span class="cm-operator">=</span> [<span class="cm-string">"array"</span>, <span class="cm-string">"of"</span>, <span class="cm-string">"strings"</span>]</span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">9</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-keyword">var</span> <span class="cm-def">bar</span> <span class="cm-operator">=</span> <span class="cm-variable">foo</span>.<span class="cm-property">slice</span>(<span class="cm-number">0</span>, <span class="cm-number">2</span>).<span class="cm-property">join</span>(<span class="cm-string">""</span>).<span class="cm-property">split</span>(<span class="cm-string">"a"</span>)[<span class="cm-number">0</span>]</span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">10</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">11</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// Works for locally defined types too.</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">12</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">13</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-keyword">function</span> <span class="cm-def">CTor</span>() { <span class="cm-keyword">this</span>.<span class="cm-property">size</span> <span class="cm-operator">=</span> <span class="cm-number">10</span> }</span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">14</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-variable">CTor</span>.<span class="cm-property">prototype</span>.<span class="cm-property">hallo</span> <span class="cm-operator">=</span> <span class="cm-string">"hallo"</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">15</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">16</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-keyword">var</span> <span class="cm-def">baz</span> <span class="cm-operator">=</span> <span class="cm-keyword">new</span> <span class="cm-variable">CTor</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">17</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-variable">baz</span>.</span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">18</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">19</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// You can press ctrl-q when the cursor is on a variable</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">20</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// name to rename it. Try it with CTor...</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">21</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">22</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// When the cursor is in an argument list, the arguments</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">23</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// are shown below the editor.</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">24</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">25</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;">[<span class="cm-number">1</span>].<span class="cm-property">reduce</span>( )</span></pre></div>
- <div style="position: relative;">
- <div class="CodeMirror-gutter-wrapper" style="left: -30px;">
- <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">26</div>
- </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div style="position: absolute; height: 9px; width: 1px; top: 580px;"></div>
- <div class="CodeMirror-gutters" style="height: 589px;">
- <div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 29px;"></div>
- </div>
- </div>
- </div>
- </form>
- </div>
-
-<div style="display: none" id="projects">
-<project id="simple" data-plugins="qml">
-<pre id="main.qml">MyButton {
-
-}
-</pre>
-<pre id="MyButton.qml">Button {
- property int width;
- property int height;
- property var parent;
-}
-</pre>
-</project>
-</div>
-</body>
-
+<!doctype html> +<html> + +<head> + <meta charset="utf-8"> + <title>Tern QML Demo</title> + + <!-- CodeMirror Stylesheets --> + <link rel=stylesheet href="../node_modules/codemirror/lib/codemirror.css"> + <link rel="stylesheet" href="../node_modules/codemirror/theme/eclipse.css"> + <link rel="stylesheet" href="../node_modules/codemirror/addon/dialog/dialog.css"> + + <!-- CodeMirror-JavaScript Stylesheets --> + <link rel="stylesheet" href="../node_modules/codemirror-javascript/addon/hint/tern/tern-extension.css"> + + <!-- CodeMirror-Extension Stylesheets --> + <link rel="stylesheet" href="../node_modules/codemirror-extension/addon/hover/text-hover.css"> + <link rel="stylesheet" href="../node_modules/codemirror-extension/addon/hint/templates-hint.css"> + <link rel="stylesheet" href="../node_modules/codemirror-extension/addon/hint/show-hint-eclipse.css"> + <link rel="stylesheet" href="../node_modules/codemirror-extension/addon/hint/show-context-info.css"> + + <!-- Demo Specific Stylesheets --> + <link rel=stylesheet href="./docs.css"> + <link rel=stylesheet href="./demo.css"> +</head> + +<body> + <h1>Demo with QML Tern plugin </h1> + <title>QML Tern Demo</title> + + <!-- CodeMirror --> + <script src="../node_modules/codemirror/lib/codemirror.js"></script> + <script src="../node_modules/codemirror/addon/hint/show-hint.js"></script> + <script src="../node_modules/codemirror/addon/edit/closetag.js"></script> + <script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script> + <script src="../node_modules/codemirror/addon/edit/matchbrackets.js"></script> + <script src="../node_modules/codemirror/addon/selection/active-line.js"></script> + <script src="../node_modules/codemirror/mode/javascript/javascript.js"></script> + + <!-- Acorn --> + <script src="../node_modules/acorn/dist/acorn.js"></script> + <script src="../node_modules/acorn/dist/acorn_loose.js"></script> + <script src="../node_modules/acorn/dist/walk.js"></script> + <script src="../node_modules/acorn-qml/inject.js"></script> + <script src="../node_modules/acorn-qml/index.js"></script> + <script src="../node_modules/acorn-qml/loose/inject.js"></script> + <script src="../node_modules/acorn-qml/loose/index.js"></script> + <script src="../node_modules/acorn-qml/walk/index.js"></script> + + <!-- Tern JS --> + <script src="../node_modules/tern/lib/signal.js"></script> + <script src="../node_modules/tern/lib/tern.js"></script> + <script src="../node_modules/tern/lib/def.js"></script> + <script src="../node_modules/tern/lib/comment.js"></script> + <script src="../node_modules/tern/lib/infer.js"></script> + <script src="../qml.js"></script> + + <!-- Official CodeMirror Tern addon --> + <script src="../node_modules/codemirror/addon/tern/tern.js"></script> + + <!-- ECMA 5th Edition Definitions File --> + <script src="defs/ecma5.json.js"></script> + + <!-- CodeMirror Extension --> + <script src="../node_modules/codemirror-extension/addon/hint/show-context-info.js"></script> + <script src="../node_modules/codemirror-extension/addon/hint/templates-hint.js"></script> + + <!-- CodeMirror Javascript --> + <script src="../node_modules/codemirror-javascript/addon/hint/javascript/javascript-templates.js"></script> + + <!-- Tern Hover --> + <script src="../node_modules/codemirror-extension/addon/hover/text-hover.js"></script> + <script src="../node_modules/codemirror-javascript/addon/hint/tern/tern-hover.js"></script> + + <!-- Extra script to control project logic --> + <script src="./demo.js"></script> + + <div style="position: relative" id="demospace"> + <div id="menus"> + <select id="commands"> + <option>commands...</option> + <option value="complete">Autocomplete (Ctrl-Space)</option> + <option value="jumptodef">Jump to definition (ctrl-J)</option> + <option value="finddocs">Describe (Ctrl-O)</option> + <option value="findtype">Find type of (Ctrl-I)</option> + <option value="rename">Rename variable (Ctrl-Q)</option> + <option value="addfile">Add a new file</option> + <option value="delfile">Remove this file</option> + </select> + </div> + <form id="place"> + <ul class="tabs"> + <li class="selected">test</li> + </ul> + <div class="CodeMirror cm-s-default"> + <div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5px; left: 40px;"> + <textarea autocorrect="off" autocapitalize="off" spellcheck="false" style="position: absolute; padding: 0px; width: 1000px; height: 1em; outline: none;" tabindex="0"></textarea> + </div> + <div class="CodeMirror-vscrollbar" cm-not-content="true" style="display: block; bottom: 0px;"> + <div style="min-width: 1px; height: 580px;"></div> + </div> + <div class="CodeMirror-hscrollbar" cm-not-content="true"> + <div style="height: 100%; min-height: 1px; width: 0px;"></div> + </div> + <div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div> + <div class="CodeMirror-gutter-filler" cm-not-content="true"></div> + <div class="CodeMirror-scroll" tabindex="-1"> + <div class="CodeMirror-sizer" style="margin-left: 30px; margin-bottom: -21px; border-right-width: 9px; min-height: 580px; min-width: 531.891px; padding-right: 21px; padding-bottom: 0px;"> + <div style="position: relative; top: 0px;"> + <div class="CodeMirror-lines"> + <div style="position: relative; outline: none;"> + <div class="CodeMirror-measure"><span><span>​</span>x</span> + </div> + <div class="CodeMirror-measure"></div> + <div style="position: relative; z-index: 1;"></div> + <div class="CodeMirror-cursors"> + <div class="CodeMirror-cursor" style="left: 9px; top: 0px; height: 22px;"> </div> + </div> + <div class="CodeMirror-code"> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">1</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// Use ctrl-space to complete something</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">2</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-variable">co</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">3</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-variable">document</span>.<span class="cm-property">body</span>.<span class="cm-property">a</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">4</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">5</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// Put the cursor in or after an expression, press ctrl-i to</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">6</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// find its type</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">7</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">8</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-keyword">var</span> <span class="cm-def">foo</span> <span class="cm-operator">=</span> [<span class="cm-string">"array"</span>, <span class="cm-string">"of"</span>, <span class="cm-string">"strings"</span>]</span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">9</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-keyword">var</span> <span class="cm-def">bar</span> <span class="cm-operator">=</span> <span class="cm-variable">foo</span>.<span class="cm-property">slice</span>(<span class="cm-number">0</span>, <span class="cm-number">2</span>).<span class="cm-property">join</span>(<span class="cm-string">""</span>).<span class="cm-property">split</span>(<span class="cm-string">"a"</span>)[<span class="cm-number">0</span>]</span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">10</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">11</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// Works for locally defined types too.</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">12</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">13</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-keyword">function</span> <span class="cm-def">CTor</span>() { <span class="cm-keyword">this</span>.<span class="cm-property">size</span> <span class="cm-operator">=</span> <span class="cm-number">10</span> }</span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">14</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-variable">CTor</span>.<span class="cm-property">prototype</span>.<span class="cm-property">hallo</span> <span class="cm-operator">=</span> <span class="cm-string">"hallo"</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">15</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">16</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-keyword">var</span> <span class="cm-def">baz</span> <span class="cm-operator">=</span> <span class="cm-keyword">new</span> <span class="cm-variable">CTor</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">17</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-variable">baz</span>.</span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">18</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">19</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// You can press ctrl-q when the cursor is on a variable</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">20</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// name to rename it. Try it with CTor...</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">21</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">22</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// When the cursor is in an argument list, the arguments</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">23</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span class="cm-comment">// are shown below the editor.</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">24</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">25</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;">[<span class="cm-number">1</span>].<span class="cm-property">reduce</span>( )</span></pre></div> + <div style="position: relative;"> + <div class="CodeMirror-gutter-wrapper" style="left: -30px;"> + <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">26</div> + </div><pre class=" CodeMirror-line "><span style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre></div> + </div> + </div> + </div> + </div> + </div> + <div style="position: absolute; height: 9px; width: 1px; top: 580px;"></div> + <div class="CodeMirror-gutters" style="height: 589px;"> + <div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 29px;"></div> + </div> + </div> + </div> + </form> + </div> + +<div style="display: none" id="projects"> +<project id="simple" data-plugins="qml"> +<pre id="main.qml">MyButton { + +} +</pre> +<pre id="MyButton.qml">Button { + property int width; + property int height; + property var parent; +} +</pre> +</project> +</div> +</body> + </html>
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/ecma5-defs.js b/qt/org.eclipse.cdt.qt.core/tern-qml/ecma5-defs.js index dae3e5eca43..216c7160a2e 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/ecma5-defs.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/ecma5-defs.js @@ -1,975 +1,975 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-ecma5defs = {
- "!name": "ecma5",
- "!define": {
- "Error.prototype": "Error.prototype"
- },
- "Infinity": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Infinity",
- "!doc": "A numeric value representing infinity."
- },
- "undefined": {
- "!type": "?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/undefined",
- "!doc": "The value undefined."
- },
- "NaN": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/NaN",
- "!doc": "A value representing Not-A-Number."
- },
- "Object": {
- "!type": "fn()",
- "getPrototypeOf": {
- "!type": "fn(obj: ?) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getPrototypeOf",
- "!doc": "Returns the prototype (i.e. the internal prototype) of the specified object."
- },
- "create": {
- "!type": "fn(proto: ?) -> !custom:Object_create",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create",
- "!doc": "Creates a new object with the specified prototype object and properties."
- },
- "defineProperty": {
- "!type": "fn(obj: ?, prop: string, desc: ?) -> !custom:Object_defineProperty",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty",
- "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article."
- },
- "defineProperties": {
- "!type": "fn(obj: ?, props: ?) -> !custom:Object_defineProperties",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty",
- "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article."
- },
- "getOwnPropertyDescriptor": {
- "!type": "fn(obj: ?, prop: string) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor",
- "!doc": "Returns a property descriptor for an own property (that is, one directly present on an object, not present by dint of being along an object's prototype chain) of a given object."
- },
- "keys": {
- "!type": "fn(obj: ?) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys",
- "!doc": "Returns an array of a given object's own enumerable properties, in the same order as that provided by a for-in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well)."
- },
- "getOwnPropertyNames": {
- "!type": "fn(obj: ?) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames",
- "!doc": "Returns an array of all properties (enumerable or not) found directly upon a given object."
- },
- "seal": {
- "!type": "fn(obj: ?)",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/seal",
- "!doc": "Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable."
- },
- "isSealed": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isSealed",
- "!doc": "Determine if an object is sealed."
- },
- "freeze": {
- "!type": "fn(obj: ?) -> !0",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/freeze",
- "!doc": "Freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed. In essence the object is made effectively immutable. The method returns the object being frozen."
- },
- "isFrozen": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isFrozen",
- "!doc": "Determine if an object is frozen."
- },
- "preventExtensions": {
- "!type": "fn(obj: ?)",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions",
- "!doc": "Prevents new properties from ever being added to an object."
- },
- "isExtensible": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible",
- "!doc": "The Object.isExtensible() method determines if an object is extensible (whether it can have new properties added to it)."
- },
- "prototype": {
- "!stdProto": "Object",
- "toString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toString",
- "!doc": "Returns a string representing the object."
- },
- "toLocaleString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toLocaleString",
- "!doc": "Returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes."
- },
- "valueOf": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/valueOf",
- "!doc": "Returns the primitive value of the specified object"
- },
- "hasOwnProperty": {
- "!type": "fn(prop: string) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/hasOwnProperty",
- "!doc": "Returns a boolean indicating whether the object has the specified property."
- },
- "propertyIsEnumerable": {
- "!type": "fn(prop: string) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable",
- "!doc": "Returns a Boolean indicating whether the specified property is enumerable."
- },
- "isPrototypeOf": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf",
- "!doc": "Tests for an object in another object's prototype chain."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object",
- "!doc": "Creates an object wrapper."
- },
- "Function": {
- "!type": "fn(body: string) -> fn()",
- "prototype": {
- "!stdProto": "Function",
- "apply": {
- "!type": "fn(this: ?, args: [?])",
- "!effects": [
- "call and return !this this=!0 !1.<i> !1.<i> !1.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply",
- "!doc": "Calls a function with a given this value and arguments provided as an array (or an array like object)."
- },
- "call": {
- "!type": "fn(this: ?, args?: ?) -> !this.!ret",
- "!effects": [
- "call and return !this this=!0 !1 !2 !3 !4"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/call",
- "!doc": "Calls a function with a given this value and arguments provided individually."
- },
- "bind": {
- "!type": "fn(this: ?, args?: ?) -> !custom:Function_bind",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind",
- "!doc": "Creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function was called."
- },
- "prototype": "?"
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function",
- "!doc": "Every function in JavaScript is actually a Function object."
- },
- "Array": {
- "!type": "fn(size: number) -> !custom:Array_ctor",
- "isArray": {
- "!type": "fn(value: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/isArray",
- "!doc": "Returns true if an object is an array, false if it is not."
- },
- "prototype": {
- "!stdProto": "Array",
- "length": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/length",
- "!doc": "An unsigned, 32-bit integer that specifies the number of elements in an array."
- },
- "concat": {
- "!type": "fn(other: [?]) -> !this",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat",
- "!doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s)."
- },
- "join": {
- "!type": "fn(separator?: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/join",
- "!doc": "Joins all elements of an array into a string."
- },
- "splice": {
- "!type": "fn(pos: number, amount: number)",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/splice",
- "!doc": "Changes the content of an array, adding new elements while removing old elements."
- },
- "pop": {
- "!type": "fn() -> !this.<i>",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/pop",
- "!doc": "Removes the last element from an array and returns that element."
- },
- "push": {
- "!type": "fn(newelt: ?) -> number",
- "!effects": [
- "propagate !0 !this.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/push",
- "!doc": "Mutates an array by appending the given elements and returning the new length of the array."
- },
- "shift": {
- "!type": "fn() -> !this.<i>",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/shift",
- "!doc": "Removes the first element from an array and returns that element. This method changes the length of the array."
- },
- "unshift": {
- "!type": "fn(newelt: ?) -> number",
- "!effects": [
- "propagate !0 !this.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/unshift",
- "!doc": "Adds one or more elements to the beginning of an array and returns the new length of the array."
- },
- "slice": {
- "!type": "fn(from: number, to?: number) -> !this",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/slice",
- "!doc": "Returns a shallow copy of a portion of an array."
- },
- "reverse": {
- "!type": "fn()",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/reverse",
- "!doc": "Reverses an array in place. The first array element becomes the last and the last becomes the first."
- },
- "sort": {
- "!type": "fn(compare?: fn(a: ?, b: ?) -> number)",
- "!effects": [
- "call !0 !this.<i> !this.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort",
- "!doc": "Sorts the elements of an array in place and returns the array."
- },
- "indexOf": {
- "!type": "fn(elt: ?, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf",
- "!doc": "Returns the first index at which a given element can be found in the array, or -1 if it is not present."
- },
- "lastIndexOf": {
- "!type": "fn(elt: ?, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/lastIndexOf",
- "!doc": "Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex."
- },
- "every": {
- "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every",
- "!doc": "Tests whether all elements in the array pass the test implemented by the provided function."
- },
- "some": {
- "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/some",
- "!doc": "Tests whether some element in the array passes the test implemented by the provided function."
- },
- "filter": {
- "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> !this",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter",
- "!doc": "Creates a new array with all elements that pass the test implemented by the provided function."
- },
- "forEach": {
- "!type": "fn(f: fn(elt: ?, i: number), context?: ?)",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach",
- "!doc": "Executes a provided function once per array element."
- },
- "map": {
- "!type": "fn(f: fn(elt: ?, i: number) -> ?, context?: ?) -> [!0.!ret]",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map",
- "!doc": "Creates a new array with the results of calling a provided function on every element in this array."
- },
- "reduce": {
- "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret",
- "!effects": [
- "call !0 !1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce",
- "!doc": "Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value."
- },
- "reduceRight": {
- "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret",
- "!effects": [
- "call !0 !1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/ReduceRight",
- "!doc": "Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array",
- "!doc": "The JavaScript Array global object is a constructor for arrays, which are high-level, list-like objects."
- },
- "String": {
- "!type": "fn(value: ?) -> string",
- "fromCharCode": {
- "!type": "fn(code: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/fromCharCode",
- "!doc": "Returns a string created by using the specified sequence of Unicode values."
- },
- "prototype": {
- "!stdProto": "String",
- "length": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/String/length",
- "!doc": "Represents the length of a string."
- },
- "<i>": "string",
- "charAt": {
- "!type": "fn(i: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charAt",
- "!doc": "Returns the specified character from a string."
- },
- "charCodeAt": {
- "!type": "fn(i: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charCodeAt",
- "!doc": "Returns the numeric Unicode value of the character at the given index (except for unicode codepoints > 0x10000)."
- },
- "indexOf": {
- "!type": "fn(char: string, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/indexOf",
- "!doc": "Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex,\nreturns -1 if the value is not found."
- },
- "lastIndexOf": {
- "!type": "fn(char: string, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/lastIndexOf",
- "!doc": "Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex."
- },
- "substring": {
- "!type": "fn(from: number, to?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substring",
- "!doc": "Returns a subset of a string between one index and another, or through the end of the string."
- },
- "substr": {
- "!type": "fn(from: number, length?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substr",
- "!doc": "Returns the characters in a string beginning at the specified location through the specified number of characters."
- },
- "slice": {
- "!type": "fn(from: number, to?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/slice",
- "!doc": "Extracts a section of a string and returns a new string."
- },
- "trim": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim",
- "!doc": "Removes whitespace from both ends of the string."
- },
- "toUpperCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toUpperCase",
- "!doc": "Returns the calling string value converted to uppercase."
- },
- "toLowerCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLowerCase",
- "!doc": "Returns the calling string value converted to lowercase."
- },
- "toLocaleUpperCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase",
- "!doc": "Returns the calling string value converted to upper case, according to any locale-specific case mappings."
- },
- "toLocaleLowerCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase",
- "!doc": "Returns the calling string value converted to lower case, according to any locale-specific case mappings."
- },
- "split": {
- "!type": "fn(pattern: string) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split",
- "!doc": "Splits a String object into an array of strings by separating the string into substrings."
- },
- "concat": {
- "!type": "fn(other: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/concat",
- "!doc": "Combines the text of two or more strings and returns a new string."
- },
- "localeCompare": {
- "!type": "fn(other: string) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/localeCompare",
- "!doc": "Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order."
- },
- "match": {
- "!type": "fn(pattern: +RegExp) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/match",
- "!doc": "Used to retrieve the matches when matching a string against a regular expression."
- },
- "replace": {
- "!type": "fn(pattern: string|+RegExp, replacement: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace",
- "!doc": "Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match."
- },
- "search": {
- "!type": "fn(pattern: +RegExp) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search",
- "!doc": "Executes the search for a match between a regular expression and this String object."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String",
- "!doc": "The String global object is a constructor for strings, or a sequence of characters."
- },
- "Number": {
- "!type": "fn(value: ?) -> number",
- "MAX_VALUE": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MAX_VALUE",
- "!doc": "The maximum numeric value representable in JavaScript."
- },
- "MIN_VALUE": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MIN_VALUE",
- "!doc": "The smallest positive numeric value representable in JavaScript."
- },
- "POSITIVE_INFINITY": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY",
- "!doc": "A value representing the positive Infinity value."
- },
- "NEGATIVE_INFINITY": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY",
- "!doc": "A value representing the negative Infinity value."
- },
- "prototype": {
- "!stdProto": "Number",
- "toString": {
- "!type": "fn(radix?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toString",
- "!doc": "Returns a string representing the specified Number object"
- },
- "toFixed": {
- "!type": "fn(digits: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed",
- "!doc": "Formats a number using fixed-point notation"
- },
- "toExponential": {
- "!type": "fn(digits: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toExponential",
- "!doc": "Returns a string representing the Number object in exponential notation"
- },
- "toPrecision": {
- "!type": "fn(digits: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toPrecision",
- "!doc": "The toPrecision() method returns a string representing the number to the specified precision."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number",
- "!doc": "The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor."
- },
- "Boolean": {
- "!type": "fn(value: ?) -> bool",
- "prototype": {
- "!stdProto": "Boolean"
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean",
- "!doc": "The Boolean object is an object wrapper for a boolean value."
- },
- "RegExp": {
- "!type": "fn(source: string, flags?: string)",
- "prototype": {
- "!stdProto": "RegExp",
- "exec": {
- "!type": "fn(input: string) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec",
- "!doc": "Executes a search for a match in a specified string. Returns a result array, or null."
- },
- "test": {
- "!type": "fn(input: string) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/test",
- "!doc": "Executes the search for a match between a regular expression and a specified string. Returns true or false."
- },
- "global": {
- "!type": "bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
- "!doc": "Creates a regular expression object for matching text with a pattern."
- },
- "ignoreCase": {
- "!type": "bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
- "!doc": "Creates a regular expression object for matching text with a pattern."
- },
- "multiline": {
- "!type": "bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/multiline",
- "!doc": "Reflects whether or not to search in strings across multiple lines.\n"
- },
- "source": {
- "!type": "string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/source",
- "!doc": "A read-only property that contains the text of the pattern, excluding the forward slashes.\n"
- },
- "lastIndex": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/lastIndex",
- "!doc": "A read/write integer property that specifies the index at which to start the next match."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
- "!doc": "Creates a regular expression object for matching text with a pattern."
- },
- "Date": {
- "!type": "fn(ms: number)",
- "parse": {
- "!type": "fn(source: string) -> +Date",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/parse",
- "!doc": "Parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC."
- },
- "UTC": {
- "!type": "fn(year: number, month: number, date: number, hour?: number, min?: number, sec?: number, ms?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/UTC",
- "!doc": "Accepts the same parameters as the longest form of the constructor, and returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time."
- },
- "now": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now",
- "!doc": "Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC."
- },
- "prototype": {
- "toUTCString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toUTCString",
- "!doc": "Converts a date to a string, using the universal time convention."
- },
- "toISOString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString",
- "!doc": "JavaScript provides a direct way to convert a date object into a string in ISO format, the ISO 8601 Extended Format."
- },
- "toDateString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toDateString",
- "!doc": "Returns the date portion of a Date object in human readable form in American English."
- },
- "toTimeString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toTimeString",
- "!doc": "Returns the time portion of a Date object in human readable form in American English."
- },
- "toLocaleDateString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleDateString",
- "!doc": "Converts a date to a string, returning the \"date\" portion using the operating system's locale's conventions.\n"
- },
- "toLocaleTimeString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString",
- "!doc": "Converts a date to a string, returning the \"time\" portion using the current locale's conventions."
- },
- "getTime": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTime",
- "!doc": "Returns the numeric value corresponding to the time for the specified date according to universal time."
- },
- "getFullYear": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getFullYear",
- "!doc": "Returns the year of the specified date according to local time."
- },
- "getYear": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getYear",
- "!doc": "Returns the year in the specified date according to local time."
- },
- "getMonth": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMonth",
- "!doc": "Returns the month in the specified date according to local time."
- },
- "getUTCMonth": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMonth",
- "!doc": "Returns the month of the specified date according to universal time.\n"
- },
- "getDate": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDate",
- "!doc": "Returns the day of the month for the specified date according to local time."
- },
- "getUTCDate": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDate",
- "!doc": "Returns the day (date) of the month in the specified date according to universal time.\n"
- },
- "getDay": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDay",
- "!doc": "Returns the day of the week for the specified date according to local time."
- },
- "getUTCDay": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDay",
- "!doc": "Returns the day of the week in the specified date according to universal time.\n"
- },
- "getHours": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getHours",
- "!doc": "Returns the hour for the specified date according to local time."
- },
- "getUTCHours": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCHours",
- "!doc": "Returns the hours in the specified date according to universal time.\n"
- },
- "getMinutes": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMinutes",
- "!doc": "Returns the minutes in the specified date according to local time."
- },
- "getUTCMinutes": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date",
- "!doc": "Creates JavaScript Date instances which let you work with dates and times."
- },
- "getSeconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getSeconds",
- "!doc": "Returns the seconds in the specified date according to local time."
- },
- "getUTCSeconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCSeconds",
- "!doc": "Returns the seconds in the specified date according to universal time.\n"
- },
- "getMilliseconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMilliseconds",
- "!doc": "Returns the milliseconds in the specified date according to local time."
- },
- "getUTCMilliseconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds",
- "!doc": "Returns the milliseconds in the specified date according to universal time.\n"
- },
- "getTimezoneOffset": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset",
- "!doc": "Returns the time-zone offset from UTC, in minutes, for the current locale."
- },
- "setTime": {
- "!type": "fn(date: +Date) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setTime",
- "!doc": "Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.\n"
- },
- "setFullYear": {
- "!type": "fn(year: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setFullYear",
- "!doc": "Sets the full year for a specified date according to local time.\n"
- },
- "setUTCFullYear": {
- "!type": "fn(year: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCFullYear",
- "!doc": "Sets the full year for a specified date according to universal time.\n"
- },
- "setMonth": {
- "!type": "fn(month: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMonth",
- "!doc": "Set the month for a specified date according to local time."
- },
- "setUTCMonth": {
- "!type": "fn(month: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMonth",
- "!doc": "Sets the month for a specified date according to universal time.\n"
- },
- "setDate": {
- "!type": "fn(day: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setDate",
- "!doc": "Sets the day of the month for a specified date according to local time."
- },
- "setUTCDate": {
- "!type": "fn(day: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCDate",
- "!doc": "Sets the day of the month for a specified date according to universal time.\n"
- },
- "setHours": {
- "!type": "fn(hour: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setHours",
- "!doc": "Sets the hours for a specified date according to local time, and returns the number of milliseconds since 1 January 1970 00:00:00 UTC until the time represented by the updated Date instance."
- },
- "setUTCHours": {
- "!type": "fn(hour: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCHours",
- "!doc": "Sets the hour for a specified date according to universal time.\n"
- },
- "setMinutes": {
- "!type": "fn(min: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMinutes",
- "!doc": "Sets the minutes for a specified date according to local time."
- },
- "setUTCMinutes": {
- "!type": "fn(min: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMinutes",
- "!doc": "Sets the minutes for a specified date according to universal time.\n"
- },
- "setSeconds": {
- "!type": "fn(sec: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setSeconds",
- "!doc": "Sets the seconds for a specified date according to local time."
- },
- "setUTCSeconds": {
- "!type": "fn(sec: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCSeconds",
- "!doc": "Sets the seconds for a specified date according to universal time.\n"
- },
- "setMilliseconds": {
- "!type": "fn(ms: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMilliseconds",
- "!doc": "Sets the milliseconds for a specified date according to local time.\n"
- },
- "setUTCMilliseconds": {
- "!type": "fn(ms: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds",
- "!doc": "Sets the milliseconds for a specified date according to universal time.\n"
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date",
- "!doc": "Creates JavaScript Date instances which let you work with dates and times."
- },
- "Error": {
- "!type": "fn(message: string)",
- "prototype": {
- "name": {
- "!type": "string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/name",
- "!doc": "A name for the type of error."
- },
- "message": {
- "!type": "string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/message",
- "!doc": "A human-readable description of the error."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error",
- "!doc": "Creates an error object."
- },
- "SyntaxError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/SyntaxError",
- "!doc": "Represents an error when trying to interpret syntactically invalid code."
- },
- "ReferenceError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/ReferenceError",
- "!doc": "Represents an error when a non-existent variable is referenced."
- },
- "URIError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/URIError",
- "!doc": "Represents an error when a malformed URI is encountered."
- },
- "EvalError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/EvalError",
- "!doc": "Represents an error regarding the eval function."
- },
- "RangeError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RangeError",
- "!doc": "Represents an error when a number is not within the correct range allowed."
- },
- "TypeError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/TypeError",
- "!doc": "Represents an error an error when a value is not of the expected type."
- },
- "parseInt": {
- "!type": "fn(string: string, radix?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt",
- "!doc": "Parses a string argument and returns an integer of the specified radix or base."
- },
- "parseFloat": {
- "!type": "fn(string: string) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseFloat",
- "!doc": "Parses a string argument and returns a floating point number."
- },
- "isNaN": {
- "!type": "fn(value: number) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isNaN",
- "!doc": "Determines whether a value is NaN or not. Be careful, this function is broken. You may be interested in ECMAScript 6 Number.isNaN."
- },
- "isFinite": {
- "!type": "fn(value: number) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isFinite",
- "!doc": "Determines whether the passed value is a finite number."
- },
- "eval": {
- "!type": "fn(code: string) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval",
- "!doc": "Evaluates JavaScript code represented as a string."
- },
- "encodeURI": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI",
- "!doc": "Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)."
- },
- "encodeURIComponent": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent",
- "!doc": "Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)."
- },
- "decodeURI": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURI",
- "!doc": "Decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine."
- },
- "decodeURIComponent": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURIComponent",
- "!doc": "Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine."
- },
- "Math": {
- "E": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/E",
- "!doc": "The base of natural logarithms, e, approximately 2.718."
- },
- "LN2": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN2",
- "!doc": "The natural logarithm of 2, approximately 0.693."
- },
- "LN10": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN10",
- "!doc": "The natural logarithm of 10, approximately 2.302."
- },
- "LOG2E": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG2E",
- "!doc": "The base 2 logarithm of E (approximately 1.442)."
- },
- "LOG10E": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG10E",
- "!doc": "The base 10 logarithm of E (approximately 0.434)."
- },
- "SQRT1_2": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT1_2",
- "!doc": "The square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707."
- },
- "SQRT2": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT2",
- "!doc": "The square root of 2, approximately 1.414."
- },
- "PI": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/PI",
- "!doc": "The ratio of the circumference of a circle to its diameter, approximately 3.14159."
- },
- "abs": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/abs",
- "!doc": "Returns the absolute value of a number."
- },
- "cos": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/cos",
- "!doc": "Returns the cosine of a number."
- },
- "sin": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sin",
- "!doc": "Returns the sine of a number."
- },
- "tan": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/tan",
- "!doc": "Returns the tangent of a number."
- },
- "acos": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/acos",
- "!doc": "Returns the arccosine (in radians) of a number."
- },
- "asin": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/asin",
- "!doc": "Returns the arcsine (in radians) of a number."
- },
- "atan": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan",
- "!doc": "Returns the arctangent (in radians) of a number."
- },
- "atan2": {
- "!type": "fn(y: number, x: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2",
- "!doc": "Returns the arctangent of the quotient of its arguments."
- },
- "ceil": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil",
- "!doc": "Returns the smallest integer greater than or equal to a number."
- },
- "floor": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/floor",
- "!doc": "Returns the largest integer less than or equal to a number."
- },
- "round": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/round",
- "!doc": "Returns the value of a number rounded to the nearest integer."
- },
- "exp": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/exp",
- "!doc": "Returns Ex, where x is the argument, and E is Euler's constant, the base of the natural logarithms."
- },
- "log": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/log",
- "!doc": "Returns the natural logarithm (base E) of a number."
- },
- "sqrt": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sqrt",
- "!doc": "Returns the square root of a number."
- },
- "pow": {
- "!type": "fn(number, number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/pow",
- "!doc": "Returns base to the exponent power, that is, baseexponent."
- },
- "max": {
- "!type": "fn(number, number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/max",
- "!doc": "Returns the largest of zero or more numbers."
- },
- "min": {
- "!type": "fn(number, number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/min",
- "!doc": "Returns the smallest of zero or more numbers."
- },
- "random": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random",
- "!doc": "Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range."
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math",
- "!doc": "A built-in object that has properties and methods for mathematical constants and functions."
- },
- "JSON": {
- "parse": {
- "!type": "fn(json: string) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/parse",
- "!doc": "Parse a string as JSON, optionally transforming the value produced by parsing."
- },
- "stringify": {
- "!type": "fn(value: ?) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify",
- "!doc": "Convert a value to JSON, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified."
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JSON",
- "!doc": "JSON (JavaScript Object Notation) is a data-interchange format. It closely resembles a subset of JavaScript syntax, although it is not a strict subset. (See JSON in the JavaScript Reference for full details.) It is useful when writing any kind of JavaScript-based application, including websites and browser extensions. For example, you might store user information in JSON format in a cookie, or you might store extension preferences in JSON in a string-valued browser preference."
- }
-};
+/******************************************************************************* + * 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 + *******************************************************************************/ +ecma5defs = { + "!name": "ecma5", + "!define": { + "Error.prototype": "Error.prototype" + }, + "Infinity": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Infinity", + "!doc": "A numeric value representing infinity." + }, + "undefined": { + "!type": "?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/undefined", + "!doc": "The value undefined." + }, + "NaN": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/NaN", + "!doc": "A value representing Not-A-Number." + }, + "Object": { + "!type": "fn()", + "getPrototypeOf": { + "!type": "fn(obj: ?) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getPrototypeOf", + "!doc": "Returns the prototype (i.e. the internal prototype) of the specified object." + }, + "create": { + "!type": "fn(proto: ?) -> !custom:Object_create", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create", + "!doc": "Creates a new object with the specified prototype object and properties." + }, + "defineProperty": { + "!type": "fn(obj: ?, prop: string, desc: ?) -> !custom:Object_defineProperty", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty", + "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article." + }, + "defineProperties": { + "!type": "fn(obj: ?, props: ?) -> !custom:Object_defineProperties", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty", + "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article." + }, + "getOwnPropertyDescriptor": { + "!type": "fn(obj: ?, prop: string) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor", + "!doc": "Returns a property descriptor for an own property (that is, one directly present on an object, not present by dint of being along an object's prototype chain) of a given object." + }, + "keys": { + "!type": "fn(obj: ?) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys", + "!doc": "Returns an array of a given object's own enumerable properties, in the same order as that provided by a for-in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well)." + }, + "getOwnPropertyNames": { + "!type": "fn(obj: ?) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames", + "!doc": "Returns an array of all properties (enumerable or not) found directly upon a given object." + }, + "seal": { + "!type": "fn(obj: ?)", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/seal", + "!doc": "Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable." + }, + "isSealed": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isSealed", + "!doc": "Determine if an object is sealed." + }, + "freeze": { + "!type": "fn(obj: ?) -> !0", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/freeze", + "!doc": "Freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed. In essence the object is made effectively immutable. The method returns the object being frozen." + }, + "isFrozen": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isFrozen", + "!doc": "Determine if an object is frozen." + }, + "preventExtensions": { + "!type": "fn(obj: ?)", + "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions", + "!doc": "Prevents new properties from ever being added to an object." + }, + "isExtensible": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible", + "!doc": "The Object.isExtensible() method determines if an object is extensible (whether it can have new properties added to it)." + }, + "prototype": { + "!stdProto": "Object", + "toString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toString", + "!doc": "Returns a string representing the object." + }, + "toLocaleString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toLocaleString", + "!doc": "Returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes." + }, + "valueOf": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/valueOf", + "!doc": "Returns the primitive value of the specified object" + }, + "hasOwnProperty": { + "!type": "fn(prop: string) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/hasOwnProperty", + "!doc": "Returns a boolean indicating whether the object has the specified property." + }, + "propertyIsEnumerable": { + "!type": "fn(prop: string) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable", + "!doc": "Returns a Boolean indicating whether the specified property is enumerable." + }, + "isPrototypeOf": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf", + "!doc": "Tests for an object in another object's prototype chain." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object", + "!doc": "Creates an object wrapper." + }, + "Function": { + "!type": "fn(body: string) -> fn()", + "prototype": { + "!stdProto": "Function", + "apply": { + "!type": "fn(this: ?, args: [?])", + "!effects": [ + "call and return !this this=!0 !1.<i> !1.<i> !1.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply", + "!doc": "Calls a function with a given this value and arguments provided as an array (or an array like object)." + }, + "call": { + "!type": "fn(this: ?, args?: ?) -> !this.!ret", + "!effects": [ + "call and return !this this=!0 !1 !2 !3 !4" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/call", + "!doc": "Calls a function with a given this value and arguments provided individually." + }, + "bind": { + "!type": "fn(this: ?, args?: ?) -> !custom:Function_bind", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind", + "!doc": "Creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function was called." + }, + "prototype": "?" + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function", + "!doc": "Every function in JavaScript is actually a Function object." + }, + "Array": { + "!type": "fn(size: number) -> !custom:Array_ctor", + "isArray": { + "!type": "fn(value: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/isArray", + "!doc": "Returns true if an object is an array, false if it is not." + }, + "prototype": { + "!stdProto": "Array", + "length": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/length", + "!doc": "An unsigned, 32-bit integer that specifies the number of elements in an array." + }, + "concat": { + "!type": "fn(other: [?]) -> !this", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat", + "!doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s)." + }, + "join": { + "!type": "fn(separator?: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/join", + "!doc": "Joins all elements of an array into a string." + }, + "splice": { + "!type": "fn(pos: number, amount: number)", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/splice", + "!doc": "Changes the content of an array, adding new elements while removing old elements." + }, + "pop": { + "!type": "fn() -> !this.<i>", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/pop", + "!doc": "Removes the last element from an array and returns that element." + }, + "push": { + "!type": "fn(newelt: ?) -> number", + "!effects": [ + "propagate !0 !this.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/push", + "!doc": "Mutates an array by appending the given elements and returning the new length of the array." + }, + "shift": { + "!type": "fn() -> !this.<i>", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/shift", + "!doc": "Removes the first element from an array and returns that element. This method changes the length of the array." + }, + "unshift": { + "!type": "fn(newelt: ?) -> number", + "!effects": [ + "propagate !0 !this.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/unshift", + "!doc": "Adds one or more elements to the beginning of an array and returns the new length of the array." + }, + "slice": { + "!type": "fn(from: number, to?: number) -> !this", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/slice", + "!doc": "Returns a shallow copy of a portion of an array." + }, + "reverse": { + "!type": "fn()", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/reverse", + "!doc": "Reverses an array in place. The first array element becomes the last and the last becomes the first." + }, + "sort": { + "!type": "fn(compare?: fn(a: ?, b: ?) -> number)", + "!effects": [ + "call !0 !this.<i> !this.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort", + "!doc": "Sorts the elements of an array in place and returns the array." + }, + "indexOf": { + "!type": "fn(elt: ?, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf", + "!doc": "Returns the first index at which a given element can be found in the array, or -1 if it is not present." + }, + "lastIndexOf": { + "!type": "fn(elt: ?, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/lastIndexOf", + "!doc": "Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex." + }, + "every": { + "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every", + "!doc": "Tests whether all elements in the array pass the test implemented by the provided function." + }, + "some": { + "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/some", + "!doc": "Tests whether some element in the array passes the test implemented by the provided function." + }, + "filter": { + "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> !this", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter", + "!doc": "Creates a new array with all elements that pass the test implemented by the provided function." + }, + "forEach": { + "!type": "fn(f: fn(elt: ?, i: number), context?: ?)", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach", + "!doc": "Executes a provided function once per array element." + }, + "map": { + "!type": "fn(f: fn(elt: ?, i: number) -> ?, context?: ?) -> [!0.!ret]", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map", + "!doc": "Creates a new array with the results of calling a provided function on every element in this array." + }, + "reduce": { + "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret", + "!effects": [ + "call !0 !1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce", + "!doc": "Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value." + }, + "reduceRight": { + "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret", + "!effects": [ + "call !0 !1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/ReduceRight", + "!doc": "Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array", + "!doc": "The JavaScript Array global object is a constructor for arrays, which are high-level, list-like objects." + }, + "String": { + "!type": "fn(value: ?) -> string", + "fromCharCode": { + "!type": "fn(code: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/fromCharCode", + "!doc": "Returns a string created by using the specified sequence of Unicode values." + }, + "prototype": { + "!stdProto": "String", + "length": { + "!type": "number", + "!url": "https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/String/length", + "!doc": "Represents the length of a string." + }, + "<i>": "string", + "charAt": { + "!type": "fn(i: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charAt", + "!doc": "Returns the specified character from a string." + }, + "charCodeAt": { + "!type": "fn(i: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charCodeAt", + "!doc": "Returns the numeric Unicode value of the character at the given index (except for unicode codepoints > 0x10000)." + }, + "indexOf": { + "!type": "fn(char: string, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/indexOf", + "!doc": "Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex,\nreturns -1 if the value is not found." + }, + "lastIndexOf": { + "!type": "fn(char: string, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/lastIndexOf", + "!doc": "Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex." + }, + "substring": { + "!type": "fn(from: number, to?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substring", + "!doc": "Returns a subset of a string between one index and another, or through the end of the string." + }, + "substr": { + "!type": "fn(from: number, length?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substr", + "!doc": "Returns the characters in a string beginning at the specified location through the specified number of characters." + }, + "slice": { + "!type": "fn(from: number, to?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/slice", + "!doc": "Extracts a section of a string and returns a new string." + }, + "trim": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim", + "!doc": "Removes whitespace from both ends of the string." + }, + "toUpperCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toUpperCase", + "!doc": "Returns the calling string value converted to uppercase." + }, + "toLowerCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLowerCase", + "!doc": "Returns the calling string value converted to lowercase." + }, + "toLocaleUpperCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase", + "!doc": "Returns the calling string value converted to upper case, according to any locale-specific case mappings." + }, + "toLocaleLowerCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase", + "!doc": "Returns the calling string value converted to lower case, according to any locale-specific case mappings." + }, + "split": { + "!type": "fn(pattern: string) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split", + "!doc": "Splits a String object into an array of strings by separating the string into substrings." + }, + "concat": { + "!type": "fn(other: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/concat", + "!doc": "Combines the text of two or more strings and returns a new string." + }, + "localeCompare": { + "!type": "fn(other: string) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/localeCompare", + "!doc": "Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order." + }, + "match": { + "!type": "fn(pattern: +RegExp) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/match", + "!doc": "Used to retrieve the matches when matching a string against a regular expression." + }, + "replace": { + "!type": "fn(pattern: string|+RegExp, replacement: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace", + "!doc": "Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match." + }, + "search": { + "!type": "fn(pattern: +RegExp) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search", + "!doc": "Executes the search for a match between a regular expression and this String object." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String", + "!doc": "The String global object is a constructor for strings, or a sequence of characters." + }, + "Number": { + "!type": "fn(value: ?) -> number", + "MAX_VALUE": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MAX_VALUE", + "!doc": "The maximum numeric value representable in JavaScript." + }, + "MIN_VALUE": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MIN_VALUE", + "!doc": "The smallest positive numeric value representable in JavaScript." + }, + "POSITIVE_INFINITY": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY", + "!doc": "A value representing the positive Infinity value." + }, + "NEGATIVE_INFINITY": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY", + "!doc": "A value representing the negative Infinity value." + }, + "prototype": { + "!stdProto": "Number", + "toString": { + "!type": "fn(radix?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toString", + "!doc": "Returns a string representing the specified Number object" + }, + "toFixed": { + "!type": "fn(digits: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed", + "!doc": "Formats a number using fixed-point notation" + }, + "toExponential": { + "!type": "fn(digits: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toExponential", + "!doc": "Returns a string representing the Number object in exponential notation" + }, + "toPrecision": { + "!type": "fn(digits: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toPrecision", + "!doc": "The toPrecision() method returns a string representing the number to the specified precision." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number", + "!doc": "The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor." + }, + "Boolean": { + "!type": "fn(value: ?) -> bool", + "prototype": { + "!stdProto": "Boolean" + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean", + "!doc": "The Boolean object is an object wrapper for a boolean value." + }, + "RegExp": { + "!type": "fn(source: string, flags?: string)", + "prototype": { + "!stdProto": "RegExp", + "exec": { + "!type": "fn(input: string) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec", + "!doc": "Executes a search for a match in a specified string. Returns a result array, or null." + }, + "test": { + "!type": "fn(input: string) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/test", + "!doc": "Executes the search for a match between a regular expression and a specified string. Returns true or false." + }, + "global": { + "!type": "bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp", + "!doc": "Creates a regular expression object for matching text with a pattern." + }, + "ignoreCase": { + "!type": "bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp", + "!doc": "Creates a regular expression object for matching text with a pattern." + }, + "multiline": { + "!type": "bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/multiline", + "!doc": "Reflects whether or not to search in strings across multiple lines.\n" + }, + "source": { + "!type": "string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/source", + "!doc": "A read-only property that contains the text of the pattern, excluding the forward slashes.\n" + }, + "lastIndex": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/lastIndex", + "!doc": "A read/write integer property that specifies the index at which to start the next match." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp", + "!doc": "Creates a regular expression object for matching text with a pattern." + }, + "Date": { + "!type": "fn(ms: number)", + "parse": { + "!type": "fn(source: string) -> +Date", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/parse", + "!doc": "Parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC." + }, + "UTC": { + "!type": "fn(year: number, month: number, date: number, hour?: number, min?: number, sec?: number, ms?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/UTC", + "!doc": "Accepts the same parameters as the longest form of the constructor, and returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time." + }, + "now": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now", + "!doc": "Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC." + }, + "prototype": { + "toUTCString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toUTCString", + "!doc": "Converts a date to a string, using the universal time convention." + }, + "toISOString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString", + "!doc": "JavaScript provides a direct way to convert a date object into a string in ISO format, the ISO 8601 Extended Format." + }, + "toDateString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toDateString", + "!doc": "Returns the date portion of a Date object in human readable form in American English." + }, + "toTimeString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toTimeString", + "!doc": "Returns the time portion of a Date object in human readable form in American English." + }, + "toLocaleDateString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleDateString", + "!doc": "Converts a date to a string, returning the \"date\" portion using the operating system's locale's conventions.\n" + }, + "toLocaleTimeString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString", + "!doc": "Converts a date to a string, returning the \"time\" portion using the current locale's conventions." + }, + "getTime": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTime", + "!doc": "Returns the numeric value corresponding to the time for the specified date according to universal time." + }, + "getFullYear": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getFullYear", + "!doc": "Returns the year of the specified date according to local time." + }, + "getYear": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getYear", + "!doc": "Returns the year in the specified date according to local time." + }, + "getMonth": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMonth", + "!doc": "Returns the month in the specified date according to local time." + }, + "getUTCMonth": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMonth", + "!doc": "Returns the month of the specified date according to universal time.\n" + }, + "getDate": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDate", + "!doc": "Returns the day of the month for the specified date according to local time." + }, + "getUTCDate": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDate", + "!doc": "Returns the day (date) of the month in the specified date according to universal time.\n" + }, + "getDay": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDay", + "!doc": "Returns the day of the week for the specified date according to local time." + }, + "getUTCDay": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDay", + "!doc": "Returns the day of the week in the specified date according to universal time.\n" + }, + "getHours": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getHours", + "!doc": "Returns the hour for the specified date according to local time." + }, + "getUTCHours": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCHours", + "!doc": "Returns the hours in the specified date according to universal time.\n" + }, + "getMinutes": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMinutes", + "!doc": "Returns the minutes in the specified date according to local time." + }, + "getUTCMinutes": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date", + "!doc": "Creates JavaScript Date instances which let you work with dates and times." + }, + "getSeconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getSeconds", + "!doc": "Returns the seconds in the specified date according to local time." + }, + "getUTCSeconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCSeconds", + "!doc": "Returns the seconds in the specified date according to universal time.\n" + }, + "getMilliseconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMilliseconds", + "!doc": "Returns the milliseconds in the specified date according to local time." + }, + "getUTCMilliseconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds", + "!doc": "Returns the milliseconds in the specified date according to universal time.\n" + }, + "getTimezoneOffset": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset", + "!doc": "Returns the time-zone offset from UTC, in minutes, for the current locale." + }, + "setTime": { + "!type": "fn(date: +Date) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setTime", + "!doc": "Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.\n" + }, + "setFullYear": { + "!type": "fn(year: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setFullYear", + "!doc": "Sets the full year for a specified date according to local time.\n" + }, + "setUTCFullYear": { + "!type": "fn(year: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCFullYear", + "!doc": "Sets the full year for a specified date according to universal time.\n" + }, + "setMonth": { + "!type": "fn(month: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMonth", + "!doc": "Set the month for a specified date according to local time." + }, + "setUTCMonth": { + "!type": "fn(month: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMonth", + "!doc": "Sets the month for a specified date according to universal time.\n" + }, + "setDate": { + "!type": "fn(day: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setDate", + "!doc": "Sets the day of the month for a specified date according to local time." + }, + "setUTCDate": { + "!type": "fn(day: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCDate", + "!doc": "Sets the day of the month for a specified date according to universal time.\n" + }, + "setHours": { + "!type": "fn(hour: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setHours", + "!doc": "Sets the hours for a specified date according to local time, and returns the number of milliseconds since 1 January 1970 00:00:00 UTC until the time represented by the updated Date instance." + }, + "setUTCHours": { + "!type": "fn(hour: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCHours", + "!doc": "Sets the hour for a specified date according to universal time.\n" + }, + "setMinutes": { + "!type": "fn(min: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMinutes", + "!doc": "Sets the minutes for a specified date according to local time." + }, + "setUTCMinutes": { + "!type": "fn(min: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMinutes", + "!doc": "Sets the minutes for a specified date according to universal time.\n" + }, + "setSeconds": { + "!type": "fn(sec: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setSeconds", + "!doc": "Sets the seconds for a specified date according to local time." + }, + "setUTCSeconds": { + "!type": "fn(sec: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCSeconds", + "!doc": "Sets the seconds for a specified date according to universal time.\n" + }, + "setMilliseconds": { + "!type": "fn(ms: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMilliseconds", + "!doc": "Sets the milliseconds for a specified date according to local time.\n" + }, + "setUTCMilliseconds": { + "!type": "fn(ms: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds", + "!doc": "Sets the milliseconds for a specified date according to universal time.\n" + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date", + "!doc": "Creates JavaScript Date instances which let you work with dates and times." + }, + "Error": { + "!type": "fn(message: string)", + "prototype": { + "name": { + "!type": "string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/name", + "!doc": "A name for the type of error." + }, + "message": { + "!type": "string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/message", + "!doc": "A human-readable description of the error." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error", + "!doc": "Creates an error object." + }, + "SyntaxError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/SyntaxError", + "!doc": "Represents an error when trying to interpret syntactically invalid code." + }, + "ReferenceError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/ReferenceError", + "!doc": "Represents an error when a non-existent variable is referenced." + }, + "URIError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/URIError", + "!doc": "Represents an error when a malformed URI is encountered." + }, + "EvalError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/EvalError", + "!doc": "Represents an error regarding the eval function." + }, + "RangeError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RangeError", + "!doc": "Represents an error when a number is not within the correct range allowed." + }, + "TypeError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/TypeError", + "!doc": "Represents an error an error when a value is not of the expected type." + }, + "parseInt": { + "!type": "fn(string: string, radix?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt", + "!doc": "Parses a string argument and returns an integer of the specified radix or base." + }, + "parseFloat": { + "!type": "fn(string: string) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseFloat", + "!doc": "Parses a string argument and returns a floating point number." + }, + "isNaN": { + "!type": "fn(value: number) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isNaN", + "!doc": "Determines whether a value is NaN or not. Be careful, this function is broken. You may be interested in ECMAScript 6 Number.isNaN." + }, + "isFinite": { + "!type": "fn(value: number) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isFinite", + "!doc": "Determines whether the passed value is a finite number." + }, + "eval": { + "!type": "fn(code: string) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval", + "!doc": "Evaluates JavaScript code represented as a string." + }, + "encodeURI": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI", + "!doc": "Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)." + }, + "encodeURIComponent": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent", + "!doc": "Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)." + }, + "decodeURI": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURI", + "!doc": "Decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine." + }, + "decodeURIComponent": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURIComponent", + "!doc": "Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine." + }, + "Math": { + "E": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/E", + "!doc": "The base of natural logarithms, e, approximately 2.718." + }, + "LN2": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN2", + "!doc": "The natural logarithm of 2, approximately 0.693." + }, + "LN10": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN10", + "!doc": "The natural logarithm of 10, approximately 2.302." + }, + "LOG2E": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG2E", + "!doc": "The base 2 logarithm of E (approximately 1.442)." + }, + "LOG10E": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG10E", + "!doc": "The base 10 logarithm of E (approximately 0.434)." + }, + "SQRT1_2": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT1_2", + "!doc": "The square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707." + }, + "SQRT2": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT2", + "!doc": "The square root of 2, approximately 1.414." + }, + "PI": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/PI", + "!doc": "The ratio of the circumference of a circle to its diameter, approximately 3.14159." + }, + "abs": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/abs", + "!doc": "Returns the absolute value of a number." + }, + "cos": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/cos", + "!doc": "Returns the cosine of a number." + }, + "sin": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sin", + "!doc": "Returns the sine of a number." + }, + "tan": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/tan", + "!doc": "Returns the tangent of a number." + }, + "acos": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/acos", + "!doc": "Returns the arccosine (in radians) of a number." + }, + "asin": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/asin", + "!doc": "Returns the arcsine (in radians) of a number." + }, + "atan": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan", + "!doc": "Returns the arctangent (in radians) of a number." + }, + "atan2": { + "!type": "fn(y: number, x: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2", + "!doc": "Returns the arctangent of the quotient of its arguments." + }, + "ceil": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil", + "!doc": "Returns the smallest integer greater than or equal to a number." + }, + "floor": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/floor", + "!doc": "Returns the largest integer less than or equal to a number." + }, + "round": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/round", + "!doc": "Returns the value of a number rounded to the nearest integer." + }, + "exp": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/exp", + "!doc": "Returns Ex, where x is the argument, and E is Euler's constant, the base of the natural logarithms." + }, + "log": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/log", + "!doc": "Returns the natural logarithm (base E) of a number." + }, + "sqrt": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sqrt", + "!doc": "Returns the square root of a number." + }, + "pow": { + "!type": "fn(number, number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/pow", + "!doc": "Returns base to the exponent power, that is, baseexponent." + }, + "max": { + "!type": "fn(number, number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/max", + "!doc": "Returns the largest of zero or more numbers." + }, + "min": { + "!type": "fn(number, number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/min", + "!doc": "Returns the smallest of zero or more numbers." + }, + "random": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random", + "!doc": "Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range." + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math", + "!doc": "A built-in object that has properties and methods for mathematical constants and functions." + }, + "JSON": { + "parse": { + "!type": "fn(json: string) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/parse", + "!doc": "Parse a string as JSON, optionally transforming the value produced by parsing." + }, + "stringify": { + "!type": "fn(value: ?) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify", + "!doc": "Convert a value to JSON, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified." + }, + "!url": "https://developer.mozilla.org/en-US/docs/JSON", + "!doc": "JSON (JavaScript Object Notation) is a data-interchange format. It closely resembles a subset of JavaScript syntax, although it is not a strict subset. (See JSON in the JavaScript Reference for full details.) It is useful when writing any kind of JavaScript-based application, including websites and browser extensions. For example, you might store user information in JSON format in a cookie, or you might store extension preferences in JSON in a string-valued browser preference." + } +}; diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/package.json b/qt/org.eclipse.cdt.qt.core/tern-qml/package.json index 785e0766026..a4009deafdb 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/package.json +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/package.json @@ -1,20 +1,20 @@ -{
- "name": "tern-qt",
- "description": "Tern Qt Plugin",
- "version": "0.0.0",
- "license": "EPL-1.0",
- "scripts": {
- "test": "node test/run.js"
- },
- "dependencies": {
- "tern": "^0.16.0",
- "acorn": "^2.6.4",
- "acorn-qml": "../acorn-qml"
- },
- "devDependencies": {
- "test": ">=0.0.5",
- "codemirror": "^5.6.0",
- "codemirror-extension": "^0.1.0",
- "codemirror-javascript": "^0.1.0"
- }
+{ + "name": "tern-qt", + "description": "Tern Qt Plugin", + "version": "0.0.0", + "license": "EPL-1.0", + "scripts": { + "test": "node test/run.js" + }, + "dependencies": { + "tern": "^0.16.0", + "acorn": "^2.6.4", + "acorn-qml": "../acorn-qml" + }, + "devDependencies": { + "test": ">=0.0.5", + "codemirror": "^5.6.0", + "codemirror-extension": "^0.1.0", + "codemirror-javascript": "^0.1.0" + } }
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/qml.js b/qt/org.eclipse.cdt.qt.core/tern-qml/qml.js index 9aaf81bcfd1..2706b63e281 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/qml.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/qml.js @@ -1,1033 +1,1033 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-(function (root, mod) {
- if (typeof exports === "object" && typeof module === "object") // CommonJS
- return mod(exports, require("acorn"), require("acorn/dist/acorn_loose"), require("acorn/dist/walk"),
- require("acorn-qml"), require("acorn-qml/loose"), require("acorn-qml/walk"), require("tern"),
- require("tern/lib/infer"), require("tern/lib/signal"));
- if (typeof define === "function" && define.amd) // AMD
- return define(["exports", "acorn/dist/acorn", "acorn/dist/acorn_loose", "acorn/dist/walk", "acorn-qml",
- "acorn-qml/loose", "acorn-qml/walk", "tern", "tern/lib/infer", "tern/lib/signal"], mod);
- mod(root.ternQML || (root.ternQML = {}), acorn, acorn, acorn.walk, acorn, acorn, acorn.walk, tern, tern, tern.signal); // Plain browser env
-})(this, function (exports, acorn, acornLoose, walk, acornQML, acornQMLLoose, acornQMLWalk, tern, infer, signal) {
- 'use strict';
-
- // Grab 'def' from 'infer' (used for jsDefs)
- var def = infer.def;
-
- // 'extend' taken from infer.js
- function extend(proto, props) {
- var obj = Object.create(proto);
- if (props) {
- for (var prop in props) obj[prop] = props[prop];
- }
- return obj;
- }
-
- // QML Import Handler
- var qmlImportHandler = exports.importHandler = null;
- var ImportHandler = function (server) {
- this.server = server;
- this.imports = null;
- };
- ImportHandler.prototype = {
- reset: function () {
- this.imports = null;
- },
- resolveDirectory: function (file, path) {
- var impl = this.server.options.resolveDirectory;
- if (impl) {
- return impl(file, path);
- }
- // Getting to this point means that we were unable to find an implementation of
- // the 'resolveDirectory' method. The only time this should happen is during
- // a test case which we expect to have an import of the style "./ ..." and nothing
- // else. This method will simply remove the './', add the file's base, and return.
- if (!path) {
- // If no path was specified, return the base directory of the file
- var dir = file.name;
- dir = dir.substring(0, dir.lastIndexOf("/") + 1);
- return dir;
- }
- if (path.substring(0, 2) === "./") {
- path = file.directory + path.substring(2);
- }
- if (path.substr(path.length - 1, 1) !== "/") {
- path = path + "/";
- }
- return path;
- },
- resolveModule: function (module) {
- var impl = this.server.options.resolveModule;
- if (impl) {
- return impl(module);
- }
- },
- updateDirectoryImportList: function () {
- if (!this.imports) {
- this.imports = {};
- }
- var dir, f;
- var seenDirs = {};
- for (var i = 0; i < this.server.files.length; i++) {
- var file = this.server.files[i];
- dir = file.directory;
- f = file.nameExt;
- if (!dir) {
- // Resolve the directory name and file name/extension
- dir = file.directory = this.resolveDirectory(file, null);
- f = file.nameExt = this.getFileNameAndExtension(file);
- }
- seenDirs[dir] = true;
- // No file scope means the file was recently added/changed and we should
- // update its import reference
- if (!file.scope) {
- // Check for a valid QML Object Identifier
- if (f.extension === "qml") {
- var ch = f.name.charAt(0);
- if (ch.toUpperCase() === ch && f.name.indexOf(".") === -1) {
- // Create the array for this directory if necessary
- if (!this.imports[dir]) {
- this.imports[dir] = {};
- }
-
- // Create an Obj to represent this import
- var obj = new infer.Obj(null, f.name);
- obj.origin = file.name;
- this.imports[dir][f.name] = obj;
- }
- }
- }
- }
- for (dir in this.imports) {
- if (!(dir in seenDirs)) {
- this.imports[dir] = undefined;
- }
- }
- },
- getFileNameAndExtension: function (file) {
- var fileName = file.name.substring(file.name.lastIndexOf("/") + 1);
- var dot = fileName.lastIndexOf(".");
- return {
- name: dot >= 0 ? fileName.substring(0, dot) : fileName,
- extension: fileName.substring(dot + 1)
- };
- },
- resolveObject: function (loc, name) {
- return loc[name];
- },
- defineImport: function (scope, loc, name, obj) {
- var prop = scope.defProp(name);
- var objRef = new ObjRef(loc, name, this);
- prop.objType = objRef;
- objRef.propagate(prop);
- },
- defineImports: function (file, scope) {
- scope = scope || file.scope;
-
- // Add any imports from the current directory
- var imports = this.imports[file.directory];
- var f = file.nameExt;
- if (imports) {
- for (var name in imports) {
- if (f.name !== name) {
- this.defineImport(scope, imports, name, imports[name]);
- }
- }
- }
-
- // Walk the AST for any imports
- var ih = this;
- walk.simple(file.ast, {
- QMLImport: function (node) {
- var prop = null;
- var scope = file.scope;
- if (node.qualifier) {
- prop = file.scope.defProp(node.qualifier.id.name, node.qualifier.id);
- prop.origin = file.name;
- var obj = new infer.Obj(null, node.qualifier.id.name);
- obj.propagate(prop);
- prop.objType = obj;
- scope = obj;
- }
- if (node.directory) {
- var dir = ih.resolveDirectory(file, node.directory.value);
- var imports = ih.imports[dir];
- if (imports) {
- for (var name in imports) {
- ih.defineImport(scope, imports, name, imports[name]);
- }
- }
- }
- }
- });
- },
- createQMLObjectType: function (file, node, isRoot) {
- // Find the imported object
- var obj = this.getQMLObjectType(file, node.id);
- // If this is the root, connect the imported object to the root object
- if (isRoot) {
- var tmp = this.getRootQMLObjectType(file, node.id);
- if (tmp) {
- // Hook up the Obj Reference
- tmp.proto = obj;
- obj = tmp;
- obj.originNode = node.id;
-
- // Break any cyclic dependencies
- while ((tmp = tmp.proto)) {
- if (tmp.resolve() == obj.resolve()) {
- tmp.proto = null;
- }
- }
- }
- }
- return obj;
- },
- getQMLObjectType: function (file, qid) {
- var prop = findProp(qid, file.scope);
- if (prop) {
- return prop.objType;
- }
- return new infer.Obj(null, qid.name);
- },
- getRootQMLObjectType: function (file, qid) {
- var f = file.nameExt;
- var imports = this.imports[file.directory];
- if (imports && imports[f.name]) {
- return imports[f.name];
- }
- return new infer.Obj(null, qid.name);
- }
- };
-
- // 'isInteger' taken from infer.js
- function isInteger(str) {
- var c0 = str.charCodeAt(0);
- if (c0 >= 48 && c0 <= 57) return !/\D/.test(str);
- else return false;
- }
-
- /*
- * We have to redefine 'hasProp' to make it work with our scoping. The original 'hasProp'
- * function checked proto.props instead of using proto.hasProp.
- */
- infer.Obj.prototype.hasProp = function (prop, searchProto) {
- if (isInteger(prop)) prop = this.normalizeIntegerProp(prop);
- var found = this.props[prop];
- if (searchProto !== false && this.proto && !found)
- found = this.proto.hasProp(prop, true);
- return found;
- };
-
- // Creating a resolve function on 'infer.Obj' so we can simplify some of our 'ObjRef' logic
- infer.Obj.prototype.resolve = function () {
- return this;
- };
-
- /*
- * QML Object Reference
- *
- * An ObjRef behaves exactly the same as an ordinary 'infer.Obj' object, except that it
- * mirrors its internal state to a referenced object. This object is resolved by the QML
- * Import Handler each time the ObjRef is accessed (including getting and setting internal
- * variables). In theory this means we don't have to know at runtime whether or not an
- * object is an ObjRef or an infer.Obj.
- */
- var ObjRef = function (loc, lookup, ih) {
- // Using underscores for property names so we don't accidentally collide with any
- // 'infer.Obj' property names (which would cause a stack overflow if we were to
- // try to access them here).
- this._loc = loc;
- this._objLookup = lookup;
- this._ih = ih;
- var obj = this.resolve();
- // Use Object.defineProperty to setup getter and setter methods that delegate
- // to the resolved object's properties. We only need to do this once since all
- // 'infer.Obj' objects should have the same set of property names.
- for (var propertyName in obj) {
- if (!(obj[propertyName] instanceof Function)) {
- (function () {
- var prop = propertyName;
- Object.defineProperty(this, prop, {
- enumerable: true,
- get: function () {
- return this.resolve()[prop];
- },
- set: function (value) {
- this.resolve()[prop] = value;
- }
- });
- }).call(this);
- }
- }
- };
- ObjRef.prototype = extend(infer.Type.prototype, {
- resolve: function () {
- return this._ih.resolveObject(this._loc, this._objLookup);
- }
- });
- (function () {
- // Wire up all base functions to use the resolved object's implementation
- for (var _func in infer.Obj.prototype) {
- if (_func !== "resolve") {
- (function () {
- var fn = _func;
- ObjRef.prototype[fn] = function () {
- return this.resolve()[fn](arguments[0], arguments[1], arguments[2], arguments[3]);
- };
- })();
- }
- }
- })();
-
- /*
- * QML Object Scope (inherits methods from infer.Scope)
- *
- * A QML Object Scope does not contain its own properties. Instead, its properties
- * are defined in its given Object Type and resolved from there. Any properties
- * defined within the Object Type are visible without qualifier to any downstream
- * scopes.
- */
- var QMLObjScope = exports.QMLObjScope = function (prev, originNode, objType) {
- infer.Scope.call(this, prev, originNode, false);
- this.objType = objType;
- };
- QMLObjScope.prototype = extend(infer.Scope.prototype, {
- hasProp: function (prop, searchProto) {
- // Search for a property in the Object type.
- // Always search the Object Type's prototype as well
- var found = this.objType.hasProp(prop, true);
- if (found) {
- return found;
- }
-
- // Search for a property in the prototype (previous scope)
- if (this.proto && searchProto !== false) {
- return this.proto.hasProp(prop, searchProto);
- }
- },
- defProp: function (prop, originNode) {
- return this.objType.defProp(prop, originNode);
- },
- removeProp: function (prop) {
- return this.objType.removeProp(prop);
- },
- gatherProperties: function (f, depth) {
- // Gather properties from the Object Type and its prototype(s)
- var obj = this.objType;
- var callback = function (prop, obj, d) {
- f(prop, obj, depth);
- };
- while (obj) {
- obj.gatherProperties(callback, depth);
- obj = obj.proto;
- }
- // gather properties from the prototype (previous scope)
- if (this.proto) {
- this.proto.gatherProperties(f, depth + 1);
- }
- }
- });
-
- /*
- * QML Member Scope (inherits methods from infer.Scope)
- *
- * A QML Member Scope is a bit of a special case when it comes to QML scoping. Like
- * the QML Object Scope, it does not contain any properties of its own. The reason
- * that it is special is it only gathers properties from its immediate predecessor
- * that aren't functions (i.e. They don't have the 'isFunction' flag set. The
- * 'isFunction' flag is created by QML signal properties and JavaScript functions
- * that are QML Members.)
- */
- var QMLMemScope = exports.QMLMemScope = function (prev, originNode, fileScope) {
- infer.Scope.call(this, prev, originNode, false);
- this.fileScope = fileScope;
- };
- QMLMemScope.prototype = extend(infer.Scope.prototype, {
- hasProp: function (prop, searchProto) {
- // Search for a property in the prototype
- var found = null;
- if (this.proto) {
- // Don't continue searching after the previous scope
- found = this.proto.hasProp(prop, false);
- if (found && !found.isFunction) {
- return found;
- }
- }
-
- // Search for a property in the file Scope
- if (this.fileScope) {
- return this.fileScope.hasProp(prop, searchProto);
- }
- },
- defProp: function (prop, originNode) {
- return this.prev.defProp(prop, originNode);
- },
- removeProp: function (prop) {
- return this.prev.removeProp(prop);
- },
- gatherProperties: function (f, depth) {
- // Gather properties from the prototype (previous scope)
- var found = null;
- if (this.proto) {
- this.proto.gatherProperties(function (prop, obj, d) {
- // Don't continue passed the predecessor by checking depth
- if (d === depth) {
- var propObj = obj.hasProp(prop);
- if (propObj && !propObj.isFunction) {
- f(prop, obj, d);
- }
- }
- }, depth);
- }
- // Gather properties from the file Scope
- this.fileScope.gatherProperties(f, depth);
- }
- });
-
- /*
- * QML JavaScript Scope (inherits methods from infer.Scope)
- *
- * A QML JavaScript Scope also contains references to the file's ID Scope, the global
- * JavaScript Scope, and a possible function parameter scope. Most likely, this
- * scope will not contain its own properties. The resolution order for 'getProp' and
- * 'hasProp' are:
- * 1. The ID Scope
- * 2. This Scope's properties
- * 3. The Function Scope (if it exists)
- * 4. The JavaScript Scope
- * 5. The Previous Scope in the chain
- */
- var QMLJSScope = exports.QMLJSScope = function (prev, originNode, idScope, jsScope, fnScope) {
- infer.Scope.call(this, prev, originNode, false);
- this.idScope = idScope;
- this.jsScope = jsScope;
- this.fnScope = fnScope;
- };
- QMLJSScope.prototype = extend(infer.Scope.prototype, {
- hasProp: function (prop, searchProto) {
- if (isInteger(prop)) {
- prop = this.normalizeIntegerProp(prop);
- }
- // Search the ID scope
- var found = null;
- if (this.idScope) {
- found = this.idScope.hasProp(prop, searchProto);
- }
- // Search the current scope
- if (!found) {
- found = this.props[prop];
- }
- // Search the Function Scope
- if (!found && this.fnScope) {
- found = this.fnScope.hasProp(prop, searchProto);
- }
- // Search the JavaScript Scope
- if (!found && this.jsScope) {
- found = this.jsScope.hasProp(prop, searchProto);
- }
- // Search the prototype (previous scope)
- if (!found && this.proto && searchProto !== false) {
- found = this.proto.hasProp(prop, searchProto);
- }
- return found;
- },
- gatherProperties: function (f, depth) {
- // Gather from the ID Scope
- if (this.idScope) {
- this.idScope.gatherProperties(f, depth);
- }
- // Gather from the current scope
- for (var prop in this.props) {
- f(prop, this, depth);
- }
- // Gather from the Function Scope
- if (this.fnScope) {
- this.fnScope.gatherProperties(f, depth);
- }
- // Gather from the JS Scope
- if (this.jsScope) {
- this.jsScope.gatherProperties(f, depth);
- }
- // Gather from the prototype (previous scope)
- if (this.proto) {
- this.proto.gatherProperties(f, depth + 1);
- }
- }
- });
-
- // QML Scope Builder
- var ScopeBuilder = function (file, jsDefs) {
- // File Scope
- this.scope = file.scope;
- this.file = file;
- // ID Scope
- this.idScope = new infer.Scope();
- this.idScope.name = "<qml-id>";
- // JavaScript Scope
- this.jsScope = new infer.Scope();
- this.jsScope.name = "<qml-js>";
- var curOrigin = infer.cx().curOrigin;
- for (var i = 0; i < jsDefs.length; ++i) {
- def.load(jsDefs[i], this.jsScope);
- }
- infer.cx().curOrigin = curOrigin;
- };
- ScopeBuilder.prototype = {
- newObjScope: function (node) {
- var obj = qmlImportHandler.createQMLObjectType(this.file, node, !this.rootScope);
- var scope = new QMLObjScope(this.rootScope || this.scope, node, obj);
- scope.name = "<qml-obj>";
- if (!this.rootScope) {
- this.rootScope = scope;
- }
- return scope;
- },
- getIDScope: function () {
- return this.idScope;
- },
- newMemberScope: function (objScope, node) {
- var memScope = new QMLMemScope(objScope, node, this.scope);
- memScope.name = "<qml-member>";
- return memScope;
- },
- newJSScope: function (scope, node, fnScope) {
- var jsScope = new QMLJSScope(scope, node, this.idScope, this.jsScope, fnScope);
- jsScope.name = "<qml-js>";
- return jsScope;
- },
- };
-
- // Helper for adding a variable to a scope.
- function addVar(scope, node) {
- return scope.defProp(node.name, node);
- }
-
- // Helper for finding a property in a scope.
- function findProp(node, scope, pos) {
- if (pos === null || pos === undefined || pos < 0) {
- pos = Number.MAX_VALUE;
- }
- if (node.type === "QMLQualifiedID") {
- return (function recurse(i, prop) {
- if (i >= node.parts.length || pos < node.parts[i].start) {
- return prop;
- }
- if (!prop) {
- prop = scope.hasProp(node.parts[i].name);
- if (prop) {
- return recurse(i + 1, prop);
- }
- } else {
- var obj = prop.getType();
- if (obj) {
- var p = obj.hasProp(node.parts[i].name);
- if (p) {
- return recurse(i + 1, p);
- }
- }
- }
- return null;
- })(0, null);
- } else if (node.type === "Identifier") {
- return scope.hasProp(node.name);
- }
- return null;
- }
-
- // Helper for getting the current context's scope builder
- function getScopeBuilder() {
- return infer.cx().qmlScopeBuilder;
- }
-
- // 'infer' taken from infer.js
- function inf(node, scope, out, name) {
- var handler = infer.inferExprVisitor[node.type];
- return handler ? handler(node, scope, out, name) : infer.ANull;
- }
-
- // Infers the property's type from its given primitive value
- function infKind(kind, out) {
- // 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;
- }
- }
- }
-
- // 'ret' taken from infer.js
- function ret(f) {
- return function (node, scope, out, name) {
- var r = f(node, scope, name);
- if (out) r.propagate(out);
- return r;
- };
- }
-
- // 'fill' taken from infer.js
- function fill(f) {
- return function (node, scope, out, name) {
- if (!out) out = new infer.AVal();
- f(node, scope, out, name);
- return out;
- };
- }
-
- // Helper method to get the last index of an array
- function getLastIndex(arr) {
- return arr[arr.length - 1];
- }
-
- // Helper method to get the signal handler name of a signal function
- function getSignalHandlerName(str) {
- return "on" + str.charAt(0).toUpperCase() + str.slice(1);
- }
-
- // Object which holds two scopes. Used to store both the Member Scope and Object
- // Scope for QML Property Bindings and Declarations.
- function Scopes(obj, mem) {
- this.object = obj;
- this.member = mem;
- }
-
- // Helper to add functionality to a set of walk methods
- function extendWalk(walker, funcs) {
- for (var prop in funcs) {
- walker[prop] = funcs[prop];
- }
- }
-
- function extendTernScopeGatherer(scopeGatherer) {
- // Extend the Tern scopeGatherer to build up our custom QML scoping
- extendWalk(scopeGatherer, {
- QMLObjectDefinition: function (node, scope, c) {
- var inner = node.scope = getScopeBuilder().newObjScope(node);
- c(node.body, inner);
- },
- 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];
- if (member.type === "FunctionDeclaration") {
- c(member, scope);
-
- // Insert the JavaScript scope after the Function has had a chance to build it's own scope
- var jsScope = getScopeBuilder().newJSScope(scope, member, member.scope);
- jsScope.fnType = member.scope.fnType;
- member.scope.prev = member.scope.proto = null;
- member.scope = jsScope;
-
- // Indicate that the property is a function
- var prop = scope.hasProp(member.id.name);
- if (prop) {
- prop.isFunction = true;
- }
- } else if (member.type === "QMLPropertyDeclaration" || member.type === "QMLPropertyBinding") {
- c(member, new Scopes(scope, memScope));
- } else {
- c(member, scope);
- }
- }
- },
- QMLPropertyDeclaration: function (node, scopes, c) {
- var prop = addVar(scopes.member, node.id);
- if (node.binding) {
- c(node.binding, scopes.object);
- }
- },
- QMLPropertyBinding: function (node, scopes, c) {
- // Check for the 'id' property being set
- if (node.id.name == "id") {
- if (node.binding.type === "QMLScriptBinding") {
- var binding = node.binding;
- if (!binding.block && binding.script.type === "Identifier") {
- node.prop = addVar(getScopeBuilder().getIDScope(), binding.script);
- }
- }
- }
- // Delegate down to the expression
- c(node.binding, scopes.object);
- },
- QMLScriptBinding: function (node, scope, c) {
- var inner = node.scope = getScopeBuilder().newJSScope(scope, node);
- c(node.script, inner);
- },
- QMLStatementBlock: function (node, scope, c) {
- var inner = getScopeBuilder().newJSScope(scope, node);
- node.scope = inner;
- for (var i = 0; i < node.body.length; i++) {
- c(node.body[i], inner, "Statement");
- }
- },
- QMLSignalDefinition: function (node, scope, c) {
- // Scope Builder
- var sb = getScopeBuilder();
-
- // Define the signal arguments in their own separate scope
- var argNames = [];
- var argVals = [];
- var sigScope = new infer.Scope(null, node);
- for (var i = 0; i < node.params.length; i++) {
- var param = node.params[i];
- argNames.push(param.id.name);
- argVals.push(addVar(sigScope, param.id));
- }
-
- // Define the signal function type which can be referenced from JavaScript
- var sig = addVar(scope, node.id);
- sig.isFunction = true;
- sig.sigType = new infer.Fn(node.id.name, new infer.AVal(), argVals, argNames, infer.ANull);
- sig.sigType.sigScope = sigScope;
-
- // Define the signal handler property
- var handler = scope.defProp(getSignalHandlerName(node.id.name), node.id);
- handler.sig = sig.sigType;
- }
- });
- }
-
- function extendTernInferExprVisitor(inferExprVisitor) {
- // Extend the inferExprVisitor methods
- extendWalk(inferExprVisitor, {
- QMLStatementBlock: ret(function (node, scope, name) {
- return infer.ANull; // TODO: check return statements
- }),
- QMLScriptBinding: fill(function (node, scope, out, name) {
- return inf(node.script, node.scope, out, 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
- })
- });
- }
-
- function extendTernInferWrapper(inferWrapper) {
- // Extend the inferWrapper methods
- extendWalk(inferWrapper, {
- QMLObjectDefinition: function (node, scope, c) {
- c(node.body, node.scope);
- },
- 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") {
- c(member, new Scopes(scope, node.scope));
- } else {
- c(member, scope);
- }
- }
- },
- QMLPropertyDeclaration: function (node, scopes, c) {
- var prop = findProp(node.id, scopes.member);
- if (prop) {
- infKind(node.kind, prop);
- if (node.binding) {
- c(node.binding, scopes.object);
- inf(node.binding, scopes.object, prop, node.id.name);
- }
- }
- },
- QMLPropertyBinding: function (node, scopes, c) {
- c(node.binding, scopes.object);
- // Check for the 'id' property being set
- if (node.id.name === "id") {
- if (node.binding.type === "QMLScriptBinding") {
- var binding = node.binding;
- if (binding.script.type === "Identifier") {
- scopes.object.objType.propagate(node.prop);
- }
- }
- } else {
- var prop = findProp(node.id, scopes.member);
- if (prop) {
- if (prop.sig) {
- // This is a signal handler
- node.binding.scope.fnScope = prop.sig.sigScope;
- } else {
- inf(node.binding, scopes.object, prop, getLastIndex(node.id.parts));
- }
- }
- }
- },
- QMLScriptBinding: function (node, scope, c) {
- c(node.script, node.scope);
- },
- QMLStatementBlock: function (node, scope, c) {
- 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, sig.sigType.args[i]);
- }
- sig.sigType.retval = infer.ANull;
- sig.sigType.propagate(sig);
-
- var handler = scope.getProp(getSignalHandlerName(node.id.name));
- var obj = new infer.Obj(true, "Signal Handler");
- obj.propagate(handler);
- }
- });
- }
-
- function extendTernTypeFinder(typeFinder) {
- // Extend the type finder to return valid types for QML AST elements
- extendWalk(typeFinder, {
- QMLObjectDefinition: function (node, scope) {
- return node.scope.objType;
- },
- QMLObjectBinding: function (node, scope) {
- return node.scope.objType;
- },
- QMLObjectInitializer: function (node, scope) {
- return infer.ANull;
- },
- FunctionDeclaration: function (node, scope) {
- // Quick little hack to get 'findExprAt' to find a Function Declaration which
- // is a QML Object Member. All other Function Declarations are ignored.
- return scope.name === "<qml-obj>" ? infer.ANull : undefined;
- },
- QMLScriptBinding: function (node, scope) {
- // Trick Tern into thinking this node is a type so that it will use
- // this node's scope when handling improperly written script bindings
- return infer.ANull;
- },
- QMLQualifiedID: function (node, scope) {
- return findProp(node, scope) || infer.ANull;
- },
- QML_ID: function (node, scope) {
- // Reverse the hack from search visitor before finding the property in
- // the id scope
- node.type = "Identifier";
- return findProp(node, getScopeBuilder().getIDScope());
- }
- });
- }
-
- function extendTernSearchVisitor(searchVisitor) {
- // Extend the search visitor to traverse the scope properly
- extendWalk(searchVisitor, {
- QMLObjectDefinition: function (node, scope, c) {
- c(node.body, node.scope);
- },
- 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") {
- c(member, new Scopes(scope, node.scope));
- } else {
- c(member, scope);
- }
- }
- },
- QMLSignalDefinition: function (node, scope, c) {
- c(node.id, scope);
- },
- QMLPropertyDeclaration: function (node, scopes, c) {
- c(node.id, scopes.member);
- if (node.binding) {
- c(node.binding, scopes.object);
- }
- },
- QMLPropertyBinding: function (node, scopes, c) {
- if (node.id.name === "id") {
- if (node.binding.type === "QMLScriptBinding") {
- var binding = node.binding;
- if (binding.script.type === "Identifier") {
- // Hack to bypass Tern's type finding algorithm which uses node.type instead
- // of the overriden type.
- binding.script.type = "QML_ID";
- c(binding.script, binding.scope, "QML_ID");
- binding.script.type = "Identifier";
- }
- }
- var prop = findProp(node.id, scopes.member);
- if (!prop) {
- return;
- }
- }
- c(node.id, scopes.member);
- c(node.binding, scopes.object);
- },
- QMLScriptBinding: function (node, scope, c) {
- c(node.script, node.scope);
- },
- QML_ID: function (node, st, c) {
- // Ignore
- },
- QMLStatementBlock: function (node, scope, c) {
- for (var i = 0; i < node.body.length; i++) {
- c(node.body[i], node.scope, "Statement");
- }
- }
- });
- }
-
- /*
- * Prepares acorn to consume QML syntax rather than standard JavaScript
- */
- function preParse(text, options) {
- // Force ECMA Version to 5
- options.ecmaVersion = 5;
-
- // Register qml plugin with main parser
- var plugins = options.plugins;
- if (!plugins) plugins = options.plugins = {};
- plugins.qml = true;
-
- // Register qml plugin with loose parser
- var pluginsLoose = options.pluginsLoose;
- if (!pluginsLoose) pluginsLoose = options.pluginsLoose = {};
- pluginsLoose.qml = true;
- }
-
- /*
- * Initializes the file's top level scope and creates a ScopeBuilder to facilitate
- * the creation of QML scopes.
- */
- function beforeLoad(file) {
- // We dont care for the Context's top scope
- file.scope = null;
-
- // Update the ImportHandler
- qmlImportHandler.updateDirectoryImportList();
-
- // Create the file's top scope
- file.scope = new infer.Scope(infer.cx().topScope);
- var name = file.name;
- var end = file.name.lastIndexOf(".qml");
- file.scope.name = end > 0 ? name.substring(0, end) : name;
-
- // Get the ImportHandler to define imports for us
- qmlImportHandler.defineImports(file, file.scope);
-
- // Create the ScopeBuilder
- var sb = new ScopeBuilder(file, infer.cx().parent.jsDefs);
- infer.cx().qmlScopeBuilder = sb;
- }
-
- /*
- * Helper to reset some of the internal state of the QML plugin when the server
- * resets
- */
- function reset() {
- qmlImportHandler.reset();
- }
-
- /*
- * Called when a completions query is made to the server
- */
- function completions(file, query) {
- // We can get relatively simple completions on QML Object Types for free if we
- // update the Context.paths variable. Tern uses this variable to complete
- // non Member Expressions that contain a '.' character. Will be much more
- // accurate if we just roll our own completions for this in the future, but it
- // works relatively well for now.
- var cx = infer.cx();
- cx.paths = {};
- for (var prop in file.scope.props) {
- cx.paths[prop] = file.scope[prop];
- }
- }
-
- // Register the QML plugin in Tern
- tern.registerPlugin("qml", function (server) {
- // First we want to replace the top-level defs array with our own and save the
- // JavaScript specific defs to a new array 'jsDefs'. In order to make sure no
- // other plugins mess with the new defs after us, we override addDefs.
- server.jsDefs = server.defs;
- server.defs = [];
- server.addDefs = function (defs, toFront) {
- if (toFront) this.jsDefs.unshift(defs);
- else this.jsDefs.push(defs);
- if (this.cx) this.reset();
- };
-
- // Create a method on the server object that parses a string. We can't make this
- // a query due to the fact that tern always does its infer processing on every
- // query regardless of its contents.
- server.parseString = function (text, options, callback) {
- try {
- var opts = {
- allowReturnOutsideFunction: true,
- allowImportExportEverywhere: true,
- ecmaVersion: this.options.ecmaVersion
- };
- for (var opt in options) {
- opts[opt] = options[opt];
- }
- text = this.signalReturnFirst("preParse", text, opts) || text;
- var ast = infer.parse(text, opts);
- callback(null, {
- ast: ast
- });
- this.signal("postParse", ast, text);
- } catch (err) {
- callback(err, null);
- }
- };
-
- // Create the QML Import Handler
- qmlImportHandler = exports.importHandler = new ImportHandler(server);
-
- // Define the 'parseFile' query type.
- tern.defineQueryType("parseFile", {
- takesFile: true,
- run: function (srv, query, file) {
- return {
- ast: file.ast
- };
- }
- });
-
- // Hook into server signals
- server.on("preParse", preParse);
- server.on("beforeLoad", beforeLoad);
- server.on("postReset", reset);
- server.on("completion", completions);
-
- // Extend Tern's inferencing system to include QML syntax
- extendTernScopeGatherer(infer.scopeGatherer);
- extendTernInferExprVisitor(infer.inferExprVisitor);
- extendTernInferWrapper(infer.inferWrapper);
- extendTernTypeFinder(infer.typeFinder);
- extendTernSearchVisitor(infer.searchVisitor);
- });
+/******************************************************************************* + * 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 + *******************************************************************************/ +(function (root, mod) { + if (typeof exports === "object" && typeof module === "object") // CommonJS + return mod(exports, require("acorn"), require("acorn/dist/acorn_loose"), require("acorn/dist/walk"), + require("acorn-qml"), require("acorn-qml/loose"), require("acorn-qml/walk"), require("tern"), + require("tern/lib/infer"), require("tern/lib/signal")); + if (typeof define === "function" && define.amd) // AMD + return define(["exports", "acorn/dist/acorn", "acorn/dist/acorn_loose", "acorn/dist/walk", "acorn-qml", + "acorn-qml/loose", "acorn-qml/walk", "tern", "tern/lib/infer", "tern/lib/signal"], mod); + mod(root.ternQML || (root.ternQML = {}), acorn, acorn, acorn.walk, acorn, acorn, acorn.walk, tern, tern, tern.signal); // Plain browser env +})(this, function (exports, acorn, acornLoose, walk, acornQML, acornQMLLoose, acornQMLWalk, tern, infer, signal) { + 'use strict'; + + // Grab 'def' from 'infer' (used for jsDefs) + var def = infer.def; + + // 'extend' taken from infer.js + function extend(proto, props) { + var obj = Object.create(proto); + if (props) { + for (var prop in props) obj[prop] = props[prop]; + } + return obj; + } + + // QML Import Handler + var qmlImportHandler = exports.importHandler = null; + var ImportHandler = function (server) { + this.server = server; + this.imports = null; + }; + ImportHandler.prototype = { + reset: function () { + this.imports = null; + }, + resolveDirectory: function (file, path) { + var impl = this.server.options.resolveDirectory; + if (impl) { + return impl(file, path); + } + // Getting to this point means that we were unable to find an implementation of + // the 'resolveDirectory' method. The only time this should happen is during + // a test case which we expect to have an import of the style "./ ..." and nothing + // else. This method will simply remove the './', add the file's base, and return. + if (!path) { + // If no path was specified, return the base directory of the file + var dir = file.name; + dir = dir.substring(0, dir.lastIndexOf("/") + 1); + return dir; + } + if (path.substring(0, 2) === "./") { + path = file.directory + path.substring(2); + } + if (path.substr(path.length - 1, 1) !== "/") { + path = path + "/"; + } + return path; + }, + resolveModule: function (module) { + var impl = this.server.options.resolveModule; + if (impl) { + return impl(module); + } + }, + updateDirectoryImportList: function () { + if (!this.imports) { + this.imports = {}; + } + var dir, f; + var seenDirs = {}; + for (var i = 0; i < this.server.files.length; i++) { + var file = this.server.files[i]; + dir = file.directory; + f = file.nameExt; + if (!dir) { + // Resolve the directory name and file name/extension + dir = file.directory = this.resolveDirectory(file, null); + f = file.nameExt = this.getFileNameAndExtension(file); + } + seenDirs[dir] = true; + // No file scope means the file was recently added/changed and we should + // update its import reference + if (!file.scope) { + // Check for a valid QML Object Identifier + if (f.extension === "qml") { + var ch = f.name.charAt(0); + if (ch.toUpperCase() === ch && f.name.indexOf(".") === -1) { + // Create the array for this directory if necessary + if (!this.imports[dir]) { + this.imports[dir] = {}; + } + + // Create an Obj to represent this import + var obj = new infer.Obj(null, f.name); + obj.origin = file.name; + this.imports[dir][f.name] = obj; + } + } + } + } + for (dir in this.imports) { + if (!(dir in seenDirs)) { + this.imports[dir] = undefined; + } + } + }, + getFileNameAndExtension: function (file) { + var fileName = file.name.substring(file.name.lastIndexOf("/") + 1); + var dot = fileName.lastIndexOf("."); + return { + name: dot >= 0 ? fileName.substring(0, dot) : fileName, + extension: fileName.substring(dot + 1) + }; + }, + resolveObject: function (loc, name) { + return loc[name]; + }, + defineImport: function (scope, loc, name, obj) { + var prop = scope.defProp(name); + var objRef = new ObjRef(loc, name, this); + prop.objType = objRef; + objRef.propagate(prop); + }, + defineImports: function (file, scope) { + scope = scope || file.scope; + + // Add any imports from the current directory + var imports = this.imports[file.directory]; + var f = file.nameExt; + if (imports) { + for (var name in imports) { + if (f.name !== name) { + this.defineImport(scope, imports, name, imports[name]); + } + } + } + + // Walk the AST for any imports + var ih = this; + walk.simple(file.ast, { + QMLImport: function (node) { + var prop = null; + var scope = file.scope; + if (node.qualifier) { + prop = file.scope.defProp(node.qualifier.id.name, node.qualifier.id); + prop.origin = file.name; + var obj = new infer.Obj(null, node.qualifier.id.name); + obj.propagate(prop); + prop.objType = obj; + scope = obj; + } + if (node.directory) { + var dir = ih.resolveDirectory(file, node.directory.value); + var imports = ih.imports[dir]; + if (imports) { + for (var name in imports) { + ih.defineImport(scope, imports, name, imports[name]); + } + } + } + } + }); + }, + createQMLObjectType: function (file, node, isRoot) { + // Find the imported object + var obj = this.getQMLObjectType(file, node.id); + // If this is the root, connect the imported object to the root object + if (isRoot) { + var tmp = this.getRootQMLObjectType(file, node.id); + if (tmp) { + // Hook up the Obj Reference + tmp.proto = obj; + obj = tmp; + obj.originNode = node.id; + + // Break any cyclic dependencies + while ((tmp = tmp.proto)) { + if (tmp.resolve() == obj.resolve()) { + tmp.proto = null; + } + } + } + } + return obj; + }, + getQMLObjectType: function (file, qid) { + var prop = findProp(qid, file.scope); + if (prop) { + return prop.objType; + } + return new infer.Obj(null, qid.name); + }, + getRootQMLObjectType: function (file, qid) { + var f = file.nameExt; + var imports = this.imports[file.directory]; + if (imports && imports[f.name]) { + return imports[f.name]; + } + return new infer.Obj(null, qid.name); + } + }; + + // 'isInteger' taken from infer.js + function isInteger(str) { + var c0 = str.charCodeAt(0); + if (c0 >= 48 && c0 <= 57) return !/\D/.test(str); + else return false; + } + + /* + * We have to redefine 'hasProp' to make it work with our scoping. The original 'hasProp' + * function checked proto.props instead of using proto.hasProp. + */ + infer.Obj.prototype.hasProp = function (prop, searchProto) { + if (isInteger(prop)) prop = this.normalizeIntegerProp(prop); + var found = this.props[prop]; + if (searchProto !== false && this.proto && !found) + found = this.proto.hasProp(prop, true); + return found; + }; + + // Creating a resolve function on 'infer.Obj' so we can simplify some of our 'ObjRef' logic + infer.Obj.prototype.resolve = function () { + return this; + }; + + /* + * QML Object Reference + * + * An ObjRef behaves exactly the same as an ordinary 'infer.Obj' object, except that it + * mirrors its internal state to a referenced object. This object is resolved by the QML + * Import Handler each time the ObjRef is accessed (including getting and setting internal + * variables). In theory this means we don't have to know at runtime whether or not an + * object is an ObjRef or an infer.Obj. + */ + var ObjRef = function (loc, lookup, ih) { + // Using underscores for property names so we don't accidentally collide with any + // 'infer.Obj' property names (which would cause a stack overflow if we were to + // try to access them here). + this._loc = loc; + this._objLookup = lookup; + this._ih = ih; + var obj = this.resolve(); + // Use Object.defineProperty to setup getter and setter methods that delegate + // to the resolved object's properties. We only need to do this once since all + // 'infer.Obj' objects should have the same set of property names. + for (var propertyName in obj) { + if (!(obj[propertyName] instanceof Function)) { + (function () { + var prop = propertyName; + Object.defineProperty(this, prop, { + enumerable: true, + get: function () { + return this.resolve()[prop]; + }, + set: function (value) { + this.resolve()[prop] = value; + } + }); + }).call(this); + } + } + }; + ObjRef.prototype = extend(infer.Type.prototype, { + resolve: function () { + return this._ih.resolveObject(this._loc, this._objLookup); + } + }); + (function () { + // Wire up all base functions to use the resolved object's implementation + for (var _func in infer.Obj.prototype) { + if (_func !== "resolve") { + (function () { + var fn = _func; + ObjRef.prototype[fn] = function () { + return this.resolve()[fn](arguments[0], arguments[1], arguments[2], arguments[3]); + }; + })(); + } + } + })(); + + /* + * QML Object Scope (inherits methods from infer.Scope) + * + * A QML Object Scope does not contain its own properties. Instead, its properties + * are defined in its given Object Type and resolved from there. Any properties + * defined within the Object Type are visible without qualifier to any downstream + * scopes. + */ + var QMLObjScope = exports.QMLObjScope = function (prev, originNode, objType) { + infer.Scope.call(this, prev, originNode, false); + this.objType = objType; + }; + QMLObjScope.prototype = extend(infer.Scope.prototype, { + hasProp: function (prop, searchProto) { + // Search for a property in the Object type. + // Always search the Object Type's prototype as well + var found = this.objType.hasProp(prop, true); + if (found) { + return found; + } + + // Search for a property in the prototype (previous scope) + if (this.proto && searchProto !== false) { + return this.proto.hasProp(prop, searchProto); + } + }, + defProp: function (prop, originNode) { + return this.objType.defProp(prop, originNode); + }, + removeProp: function (prop) { + return this.objType.removeProp(prop); + }, + gatherProperties: function (f, depth) { + // Gather properties from the Object Type and its prototype(s) + var obj = this.objType; + var callback = function (prop, obj, d) { + f(prop, obj, depth); + }; + while (obj) { + obj.gatherProperties(callback, depth); + obj = obj.proto; + } + // gather properties from the prototype (previous scope) + if (this.proto) { + this.proto.gatherProperties(f, depth + 1); + } + } + }); + + /* + * QML Member Scope (inherits methods from infer.Scope) + * + * A QML Member Scope is a bit of a special case when it comes to QML scoping. Like + * the QML Object Scope, it does not contain any properties of its own. The reason + * that it is special is it only gathers properties from its immediate predecessor + * that aren't functions (i.e. They don't have the 'isFunction' flag set. The + * 'isFunction' flag is created by QML signal properties and JavaScript functions + * that are QML Members.) + */ + var QMLMemScope = exports.QMLMemScope = function (prev, originNode, fileScope) { + infer.Scope.call(this, prev, originNode, false); + this.fileScope = fileScope; + }; + QMLMemScope.prototype = extend(infer.Scope.prototype, { + hasProp: function (prop, searchProto) { + // Search for a property in the prototype + var found = null; + if (this.proto) { + // Don't continue searching after the previous scope + found = this.proto.hasProp(prop, false); + if (found && !found.isFunction) { + return found; + } + } + + // Search for a property in the file Scope + if (this.fileScope) { + return this.fileScope.hasProp(prop, searchProto); + } + }, + defProp: function (prop, originNode) { + return this.prev.defProp(prop, originNode); + }, + removeProp: function (prop) { + return this.prev.removeProp(prop); + }, + gatherProperties: function (f, depth) { + // Gather properties from the prototype (previous scope) + var found = null; + if (this.proto) { + this.proto.gatherProperties(function (prop, obj, d) { + // Don't continue passed the predecessor by checking depth + if (d === depth) { + var propObj = obj.hasProp(prop); + if (propObj && !propObj.isFunction) { + f(prop, obj, d); + } + } + }, depth); + } + // Gather properties from the file Scope + this.fileScope.gatherProperties(f, depth); + } + }); + + /* + * QML JavaScript Scope (inherits methods from infer.Scope) + * + * A QML JavaScript Scope also contains references to the file's ID Scope, the global + * JavaScript Scope, and a possible function parameter scope. Most likely, this + * scope will not contain its own properties. The resolution order for 'getProp' and + * 'hasProp' are: + * 1. The ID Scope + * 2. This Scope's properties + * 3. The Function Scope (if it exists) + * 4. The JavaScript Scope + * 5. The Previous Scope in the chain + */ + var QMLJSScope = exports.QMLJSScope = function (prev, originNode, idScope, jsScope, fnScope) { + infer.Scope.call(this, prev, originNode, false); + this.idScope = idScope; + this.jsScope = jsScope; + this.fnScope = fnScope; + }; + QMLJSScope.prototype = extend(infer.Scope.prototype, { + hasProp: function (prop, searchProto) { + if (isInteger(prop)) { + prop = this.normalizeIntegerProp(prop); + } + // Search the ID scope + var found = null; + if (this.idScope) { + found = this.idScope.hasProp(prop, searchProto); + } + // Search the current scope + if (!found) { + found = this.props[prop]; + } + // Search the Function Scope + if (!found && this.fnScope) { + found = this.fnScope.hasProp(prop, searchProto); + } + // Search the JavaScript Scope + if (!found && this.jsScope) { + found = this.jsScope.hasProp(prop, searchProto); + } + // Search the prototype (previous scope) + if (!found && this.proto && searchProto !== false) { + found = this.proto.hasProp(prop, searchProto); + } + return found; + }, + gatherProperties: function (f, depth) { + // Gather from the ID Scope + if (this.idScope) { + this.idScope.gatherProperties(f, depth); + } + // Gather from the current scope + for (var prop in this.props) { + f(prop, this, depth); + } + // Gather from the Function Scope + if (this.fnScope) { + this.fnScope.gatherProperties(f, depth); + } + // Gather from the JS Scope + if (this.jsScope) { + this.jsScope.gatherProperties(f, depth); + } + // Gather from the prototype (previous scope) + if (this.proto) { + this.proto.gatherProperties(f, depth + 1); + } + } + }); + + // QML Scope Builder + var ScopeBuilder = function (file, jsDefs) { + // File Scope + this.scope = file.scope; + this.file = file; + // ID Scope + this.idScope = new infer.Scope(); + this.idScope.name = "<qml-id>"; + // JavaScript Scope + this.jsScope = new infer.Scope(); + this.jsScope.name = "<qml-js>"; + var curOrigin = infer.cx().curOrigin; + for (var i = 0; i < jsDefs.length; ++i) { + def.load(jsDefs[i], this.jsScope); + } + infer.cx().curOrigin = curOrigin; + }; + ScopeBuilder.prototype = { + newObjScope: function (node) { + var obj = qmlImportHandler.createQMLObjectType(this.file, node, !this.rootScope); + var scope = new QMLObjScope(this.rootScope || this.scope, node, obj); + scope.name = "<qml-obj>"; + if (!this.rootScope) { + this.rootScope = scope; + } + return scope; + }, + getIDScope: function () { + return this.idScope; + }, + newMemberScope: function (objScope, node) { + var memScope = new QMLMemScope(objScope, node, this.scope); + memScope.name = "<qml-member>"; + return memScope; + }, + newJSScope: function (scope, node, fnScope) { + var jsScope = new QMLJSScope(scope, node, this.idScope, this.jsScope, fnScope); + jsScope.name = "<qml-js>"; + return jsScope; + }, + }; + + // Helper for adding a variable to a scope. + function addVar(scope, node) { + return scope.defProp(node.name, node); + } + + // Helper for finding a property in a scope. + function findProp(node, scope, pos) { + if (pos === null || pos === undefined || pos < 0) { + pos = Number.MAX_VALUE; + } + if (node.type === "QMLQualifiedID") { + return (function recurse(i, prop) { + if (i >= node.parts.length || pos < node.parts[i].start) { + return prop; + } + if (!prop) { + prop = scope.hasProp(node.parts[i].name); + if (prop) { + return recurse(i + 1, prop); + } + } else { + var obj = prop.getType(); + if (obj) { + var p = obj.hasProp(node.parts[i].name); + if (p) { + return recurse(i + 1, p); + } + } + } + return null; + })(0, null); + } else if (node.type === "Identifier") { + return scope.hasProp(node.name); + } + return null; + } + + // Helper for getting the current context's scope builder + function getScopeBuilder() { + return infer.cx().qmlScopeBuilder; + } + + // 'infer' taken from infer.js + function inf(node, scope, out, name) { + var handler = infer.inferExprVisitor[node.type]; + return handler ? handler(node, scope, out, name) : infer.ANull; + } + + // Infers the property's type from its given primitive value + function infKind(kind, out) { + // 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; + } + } + } + + // 'ret' taken from infer.js + function ret(f) { + return function (node, scope, out, name) { + var r = f(node, scope, name); + if (out) r.propagate(out); + return r; + }; + } + + // 'fill' taken from infer.js + function fill(f) { + return function (node, scope, out, name) { + if (!out) out = new infer.AVal(); + f(node, scope, out, name); + return out; + }; + } + + // Helper method to get the last index of an array + function getLastIndex(arr) { + return arr[arr.length - 1]; + } + + // Helper method to get the signal handler name of a signal function + function getSignalHandlerName(str) { + return "on" + str.charAt(0).toUpperCase() + str.slice(1); + } + + // Object which holds two scopes. Used to store both the Member Scope and Object + // Scope for QML Property Bindings and Declarations. + function Scopes(obj, mem) { + this.object = obj; + this.member = mem; + } + + // Helper to add functionality to a set of walk methods + function extendWalk(walker, funcs) { + for (var prop in funcs) { + walker[prop] = funcs[prop]; + } + } + + function extendTernScopeGatherer(scopeGatherer) { + // Extend the Tern scopeGatherer to build up our custom QML scoping + extendWalk(scopeGatherer, { + QMLObjectDefinition: function (node, scope, c) { + var inner = node.scope = getScopeBuilder().newObjScope(node); + c(node.body, inner); + }, + 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]; + if (member.type === "FunctionDeclaration") { + c(member, scope); + + // Insert the JavaScript scope after the Function has had a chance to build it's own scope + var jsScope = getScopeBuilder().newJSScope(scope, member, member.scope); + jsScope.fnType = member.scope.fnType; + member.scope.prev = member.scope.proto = null; + member.scope = jsScope; + + // Indicate that the property is a function + var prop = scope.hasProp(member.id.name); + if (prop) { + prop.isFunction = true; + } + } else if (member.type === "QMLPropertyDeclaration" || member.type === "QMLPropertyBinding") { + c(member, new Scopes(scope, memScope)); + } else { + c(member, scope); + } + } + }, + QMLPropertyDeclaration: function (node, scopes, c) { + var prop = addVar(scopes.member, node.id); + if (node.binding) { + c(node.binding, scopes.object); + } + }, + QMLPropertyBinding: function (node, scopes, c) { + // Check for the 'id' property being set + if (node.id.name == "id") { + if (node.binding.type === "QMLScriptBinding") { + var binding = node.binding; + if (!binding.block && binding.script.type === "Identifier") { + node.prop = addVar(getScopeBuilder().getIDScope(), binding.script); + } + } + } + // Delegate down to the expression + c(node.binding, scopes.object); + }, + QMLScriptBinding: function (node, scope, c) { + var inner = node.scope = getScopeBuilder().newJSScope(scope, node); + c(node.script, inner); + }, + QMLStatementBlock: function (node, scope, c) { + var inner = getScopeBuilder().newJSScope(scope, node); + node.scope = inner; + for (var i = 0; i < node.body.length; i++) { + c(node.body[i], inner, "Statement"); + } + }, + QMLSignalDefinition: function (node, scope, c) { + // Scope Builder + var sb = getScopeBuilder(); + + // Define the signal arguments in their own separate scope + var argNames = []; + var argVals = []; + var sigScope = new infer.Scope(null, node); + for (var i = 0; i < node.params.length; i++) { + var param = node.params[i]; + argNames.push(param.id.name); + argVals.push(addVar(sigScope, param.id)); + } + + // Define the signal function type which can be referenced from JavaScript + var sig = addVar(scope, node.id); + sig.isFunction = true; + sig.sigType = new infer.Fn(node.id.name, new infer.AVal(), argVals, argNames, infer.ANull); + sig.sigType.sigScope = sigScope; + + // Define the signal handler property + var handler = scope.defProp(getSignalHandlerName(node.id.name), node.id); + handler.sig = sig.sigType; + } + }); + } + + function extendTernInferExprVisitor(inferExprVisitor) { + // Extend the inferExprVisitor methods + extendWalk(inferExprVisitor, { + QMLStatementBlock: ret(function (node, scope, name) { + return infer.ANull; // TODO: check return statements + }), + QMLScriptBinding: fill(function (node, scope, out, name) { + return inf(node.script, node.scope, out, 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 + }) + }); + } + + function extendTernInferWrapper(inferWrapper) { + // Extend the inferWrapper methods + extendWalk(inferWrapper, { + QMLObjectDefinition: function (node, scope, c) { + c(node.body, node.scope); + }, + 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") { + c(member, new Scopes(scope, node.scope)); + } else { + c(member, scope); + } + } + }, + QMLPropertyDeclaration: function (node, scopes, c) { + var prop = findProp(node.id, scopes.member); + if (prop) { + infKind(node.kind, prop); + if (node.binding) { + c(node.binding, scopes.object); + inf(node.binding, scopes.object, prop, node.id.name); + } + } + }, + QMLPropertyBinding: function (node, scopes, c) { + c(node.binding, scopes.object); + // Check for the 'id' property being set + if (node.id.name === "id") { + if (node.binding.type === "QMLScriptBinding") { + var binding = node.binding; + if (binding.script.type === "Identifier") { + scopes.object.objType.propagate(node.prop); + } + } + } else { + var prop = findProp(node.id, scopes.member); + if (prop) { + if (prop.sig) { + // This is a signal handler + node.binding.scope.fnScope = prop.sig.sigScope; + } else { + inf(node.binding, scopes.object, prop, getLastIndex(node.id.parts)); + } + } + } + }, + QMLScriptBinding: function (node, scope, c) { + c(node.script, node.scope); + }, + QMLStatementBlock: function (node, scope, c) { + 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, sig.sigType.args[i]); + } + sig.sigType.retval = infer.ANull; + sig.sigType.propagate(sig); + + var handler = scope.getProp(getSignalHandlerName(node.id.name)); + var obj = new infer.Obj(true, "Signal Handler"); + obj.propagate(handler); + } + }); + } + + function extendTernTypeFinder(typeFinder) { + // Extend the type finder to return valid types for QML AST elements + extendWalk(typeFinder, { + QMLObjectDefinition: function (node, scope) { + return node.scope.objType; + }, + QMLObjectBinding: function (node, scope) { + return node.scope.objType; + }, + QMLObjectInitializer: function (node, scope) { + return infer.ANull; + }, + FunctionDeclaration: function (node, scope) { + // Quick little hack to get 'findExprAt' to find a Function Declaration which + // is a QML Object Member. All other Function Declarations are ignored. + return scope.name === "<qml-obj>" ? infer.ANull : undefined; + }, + QMLScriptBinding: function (node, scope) { + // Trick Tern into thinking this node is a type so that it will use + // this node's scope when handling improperly written script bindings + return infer.ANull; + }, + QMLQualifiedID: function (node, scope) { + return findProp(node, scope) || infer.ANull; + }, + QML_ID: function (node, scope) { + // Reverse the hack from search visitor before finding the property in + // the id scope + node.type = "Identifier"; + return findProp(node, getScopeBuilder().getIDScope()); + } + }); + } + + function extendTernSearchVisitor(searchVisitor) { + // Extend the search visitor to traverse the scope properly + extendWalk(searchVisitor, { + QMLObjectDefinition: function (node, scope, c) { + c(node.body, node.scope); + }, + 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") { + c(member, new Scopes(scope, node.scope)); + } else { + c(member, scope); + } + } + }, + QMLSignalDefinition: function (node, scope, c) { + c(node.id, scope); + }, + QMLPropertyDeclaration: function (node, scopes, c) { + c(node.id, scopes.member); + if (node.binding) { + c(node.binding, scopes.object); + } + }, + QMLPropertyBinding: function (node, scopes, c) { + if (node.id.name === "id") { + if (node.binding.type === "QMLScriptBinding") { + var binding = node.binding; + if (binding.script.type === "Identifier") { + // Hack to bypass Tern's type finding algorithm which uses node.type instead + // of the overriden type. + binding.script.type = "QML_ID"; + c(binding.script, binding.scope, "QML_ID"); + binding.script.type = "Identifier"; + } + } + var prop = findProp(node.id, scopes.member); + if (!prop) { + return; + } + } + c(node.id, scopes.member); + c(node.binding, scopes.object); + }, + QMLScriptBinding: function (node, scope, c) { + c(node.script, node.scope); + }, + QML_ID: function (node, st, c) { + // Ignore + }, + QMLStatementBlock: function (node, scope, c) { + for (var i = 0; i < node.body.length; i++) { + c(node.body[i], node.scope, "Statement"); + } + } + }); + } + + /* + * Prepares acorn to consume QML syntax rather than standard JavaScript + */ + function preParse(text, options) { + // Force ECMA Version to 5 + options.ecmaVersion = 5; + + // Register qml plugin with main parser + var plugins = options.plugins; + if (!plugins) plugins = options.plugins = {}; + plugins.qml = true; + + // Register qml plugin with loose parser + var pluginsLoose = options.pluginsLoose; + if (!pluginsLoose) pluginsLoose = options.pluginsLoose = {}; + pluginsLoose.qml = true; + } + + /* + * Initializes the file's top level scope and creates a ScopeBuilder to facilitate + * the creation of QML scopes. + */ + function beforeLoad(file) { + // We dont care for the Context's top scope + file.scope = null; + + // Update the ImportHandler + qmlImportHandler.updateDirectoryImportList(); + + // Create the file's top scope + file.scope = new infer.Scope(infer.cx().topScope); + var name = file.name; + var end = file.name.lastIndexOf(".qml"); + file.scope.name = end > 0 ? name.substring(0, end) : name; + + // Get the ImportHandler to define imports for us + qmlImportHandler.defineImports(file, file.scope); + + // Create the ScopeBuilder + var sb = new ScopeBuilder(file, infer.cx().parent.jsDefs); + infer.cx().qmlScopeBuilder = sb; + } + + /* + * Helper to reset some of the internal state of the QML plugin when the server + * resets + */ + function reset() { + qmlImportHandler.reset(); + } + + /* + * Called when a completions query is made to the server + */ + function completions(file, query) { + // We can get relatively simple completions on QML Object Types for free if we + // update the Context.paths variable. Tern uses this variable to complete + // non Member Expressions that contain a '.' character. Will be much more + // accurate if we just roll our own completions for this in the future, but it + // works relatively well for now. + var cx = infer.cx(); + cx.paths = {}; + for (var prop in file.scope.props) { + cx.paths[prop] = file.scope[prop]; + } + } + + // Register the QML plugin in Tern + tern.registerPlugin("qml", function (server) { + // First we want to replace the top-level defs array with our own and save the + // JavaScript specific defs to a new array 'jsDefs'. In order to make sure no + // other plugins mess with the new defs after us, we override addDefs. + server.jsDefs = server.defs; + server.defs = []; + server.addDefs = function (defs, toFront) { + if (toFront) this.jsDefs.unshift(defs); + else this.jsDefs.push(defs); + if (this.cx) this.reset(); + }; + + // Create a method on the server object that parses a string. We can't make this + // a query due to the fact that tern always does its infer processing on every + // query regardless of its contents. + server.parseString = function (text, options, callback) { + try { + var opts = { + allowReturnOutsideFunction: true, + allowImportExportEverywhere: true, + ecmaVersion: this.options.ecmaVersion + }; + for (var opt in options) { + opts[opt] = options[opt]; + } + text = this.signalReturnFirst("preParse", text, opts) || text; + var ast = infer.parse(text, opts); + callback(null, { + ast: ast + }); + this.signal("postParse", ast, text); + } catch (err) { + callback(err, null); + } + }; + + // Create the QML Import Handler + qmlImportHandler = exports.importHandler = new ImportHandler(server); + + // Define the 'parseFile' query type. + tern.defineQueryType("parseFile", { + takesFile: true, + run: function (srv, query, file) { + return { + ast: file.ast + }; + } + }); + + // Hook into server signals + server.on("preParse", preParse); + server.on("beforeLoad", beforeLoad); + server.on("postReset", reset); + server.on("completion", completions); + + // Extend Tern's inferencing system to include QML syntax + extendTernScopeGatherer(infer.scopeGatherer); + extendTernInferExprVisitor(infer.inferExprVisitor); + extendTernInferWrapper(infer.inferWrapper); + extendTernTypeFinder(infer.typeFinder); + extendTernSearchVisitor(infer.searchVisitor); + }); });
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/test/driver.js b/qt/org.eclipse.cdt.qt.core/tern-qml/test/driver.js index 6abf37e0961..7a7736e8413 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/test/driver.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/test/driver.js @@ -1,210 +1,210 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-var fs = require("fs"), path = require("path");
-var ternQML = require("../qml.js");
-var tern = require("tern");
-
-var projectDir = path.resolve(__dirname, "..");
-var resolve = function (pth) {
- return path.resolve(projectDir, pth);
-};
-var testCases = [];
-var groupName;
-
-function TestCase(group, code, run) {
- this.code = code;
- this.group = group;
- this.runTest = run || function (server, callback, code) {
- callback("fail", this.code, "runTest function was not provided.");
- };
-}
-
-exports.isolate = function (code) {
- for (var i = 0; i < testCases.length; i++) {
- var test = testCases[i];
- if (test.group === groupName && test.code !== code) {
- testCases.splice(i, 1);
- i--;
- }
- }
-};
-
-exports.groupStart = function (group) {
- groupName = group;
-};
-
-exports.groupEnd = function () {
- groupName = undefined;
-};
-
-exports.test = function (code, runTest) {
- testCases.push(new TestCase(groupName || "Default", code, runTest));
-};
-
-exports.testCompletion = function (code, expected, beforeTest) {
- testCases.push(new TestCase(groupName || "Default", code, function (server, callback) {
- var trimmedCode = code;
- // Extract the cursor position
- var pos = code.indexOf("|");
- var split = code.split("|");
- trimmedCode = split[0] + split[1];
-
- if (beforeTest) {
- beforeTest(server);
- }
- assertCompletion(server, trimmedCode, expected, pos, function (mis) {
- if (mis) {
- callback("fail", code, mis);
- } else {
- callback("ok", code);
- }
- });
- }, beforeTest));
-};
-
-exports.testDefinition = function (code, expected, beforeTest) {
- testCases.push(new TestCase(groupName || "Default", code, function (server, callback) {
- var trimmedCode = code;
- // Extract the cursor position
- var pos = code.indexOf("|");
- var split = code.split("|");
- trimmedCode = split[0] + split[1];
-
- if (beforeTest) {
- beforeTest(server);
- }
- assertDefinition(server, trimmedCode, expected, pos, function (mis) {
- if (mis) {
- callback("fail", code, mis);
- } else {
- callback("ok", code);
- }
- });
- }, beforeTest));
-};
-
-exports.runTests = function (config, callback) {
- for (var i = 0; i < testCases.length; ++i) {
- var test = testCases[i];
- if (test.group === config.group) {
- var server = createServer();
- test.runTest(server, callback, test.code);
- }
- }
-};
-
-function createServer(defs) {
- var plugins = {};
- plugins.qml = true;
- var server = new tern.Server({
- ecmaVersion: 5,
- plugins: plugins,
- defs: [ require("./ecma5-defs.js") ]
- });
- return server;
-}
-
-var assertCompletion = exports.assertCompletion = function (server, code, expected, pos, callback) {
- server.addFile("main.qml", code);
- server.request({
- files: [
- {
- name: "main.qml",
- text: code,
- type: "full"
- }
- ],
- query: {
- type: "completions",
- file: "main.qml",
- end: pos,
- types: true,
- docs: false,
- urls: false,
- origins: true,
- caseInsensitive: true,
- lineCharPositions: true,
- expandWordForward: false,
- guess: false
- }
- }, function (err, resp) {
- if (err) {
- throw err;
- }
- var mis = misMatch(expected, resp);
- callback(mis);
- });
-};
-
-var assertDefinition = exports.assertDefinition = function (server, code, expected, pos, callback) {
- server.request({
- files: [
- {
- name: "main.qml",
- text: code,
- type: "full"
- }
- ],
- query: {
- type: "definition",
- file: "main.qml",
- end: pos,
- types: true,
- docs: false,
- urls: false,
- origins: true,
- caseInsensitive: true,
- lineCharPositions: true,
- expandWordForward: false,
- guess: false
- }
- }, function (err, resp) {
- if (err) {
- throw err;
- }
- var mis = misMatch(expected, resp);
- callback(mis);
- });
-};
-
-function ppJSON(v) {
- return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2);
-}
-
-function addPath(str, pt) {
- if (str.charAt(str.length - 1) == ")")
- return str.slice(0, str.length - 1) + "/" + pt + ")";
- return str + " (" + pt + ")";
-}
-
-var misMatch = exports.misMatch = function (exp, act) {
- var mis = null;
- if (!exp || !act || (typeof exp != "object") || (typeof act != "object")) {
- if (exp !== act) return ppJSON(exp) + " !== " + ppJSON(act);
- } else if (exp instanceof RegExp || act instanceof RegExp) {
- var left = ppJSON(exp), right = ppJSON(act);
- if (left !== right) return left + " !== " + right;
- } else if (exp.splice) {
- if (!act.slice) return ppJSON(exp) + " != " + ppJSON(act);
- if (act.length != exp.length) return "array length mismatch " + exp.length + " != " + act.length;
- for (var i = 0; i < act.length; ++i) {
- mis = misMatch(exp[i], act[i]);
- if (mis) return addPath(mis, i);
- }
- } else {
- for (var prop in exp) {
- mis = misMatch(exp[prop], act[prop]);
- if (mis) return addPath(mis, prop);
- }
- }
+/******************************************************************************* + * 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 + *******************************************************************************/ +"use strict"; + +var fs = require("fs"), path = require("path"); +var ternQML = require("../qml.js"); +var tern = require("tern"); + +var projectDir = path.resolve(__dirname, ".."); +var resolve = function (pth) { + return path.resolve(projectDir, pth); +}; +var testCases = []; +var groupName; + +function TestCase(group, code, run) { + this.code = code; + this.group = group; + this.runTest = run || function (server, callback, code) { + callback("fail", this.code, "runTest function was not provided."); + }; +} + +exports.isolate = function (code) { + for (var i = 0; i < testCases.length; i++) { + var test = testCases[i]; + if (test.group === groupName && test.code !== code) { + testCases.splice(i, 1); + i--; + } + } +}; + +exports.groupStart = function (group) { + groupName = group; +}; + +exports.groupEnd = function () { + groupName = undefined; +}; + +exports.test = function (code, runTest) { + testCases.push(new TestCase(groupName || "Default", code, runTest)); +}; + +exports.testCompletion = function (code, expected, beforeTest) { + testCases.push(new TestCase(groupName || "Default", code, function (server, callback) { + var trimmedCode = code; + // Extract the cursor position + var pos = code.indexOf("|"); + var split = code.split("|"); + trimmedCode = split[0] + split[1]; + + if (beforeTest) { + beforeTest(server); + } + assertCompletion(server, trimmedCode, expected, pos, function (mis) { + if (mis) { + callback("fail", code, mis); + } else { + callback("ok", code); + } + }); + }, beforeTest)); +}; + +exports.testDefinition = function (code, expected, beforeTest) { + testCases.push(new TestCase(groupName || "Default", code, function (server, callback) { + var trimmedCode = code; + // Extract the cursor position + var pos = code.indexOf("|"); + var split = code.split("|"); + trimmedCode = split[0] + split[1]; + + if (beforeTest) { + beforeTest(server); + } + assertDefinition(server, trimmedCode, expected, pos, function (mis) { + if (mis) { + callback("fail", code, mis); + } else { + callback("ok", code); + } + }); + }, beforeTest)); +}; + +exports.runTests = function (config, callback) { + for (var i = 0; i < testCases.length; ++i) { + var test = testCases[i]; + if (test.group === config.group) { + var server = createServer(); + test.runTest(server, callback, test.code); + } + } +}; + +function createServer(defs) { + var plugins = {}; + plugins.qml = true; + var server = new tern.Server({ + ecmaVersion: 5, + plugins: plugins, + defs: [ require("./ecma5-defs.js") ] + }); + return server; +} + +var assertCompletion = exports.assertCompletion = function (server, code, expected, pos, callback) { + server.addFile("main.qml", code); + server.request({ + files: [ + { + name: "main.qml", + text: code, + type: "full" + } + ], + query: { + type: "completions", + file: "main.qml", + end: pos, + types: true, + docs: false, + urls: false, + origins: true, + caseInsensitive: true, + lineCharPositions: true, + expandWordForward: false, + guess: false + } + }, function (err, resp) { + if (err) { + throw err; + } + var mis = misMatch(expected, resp); + callback(mis); + }); +}; + +var assertDefinition = exports.assertDefinition = function (server, code, expected, pos, callback) { + server.request({ + files: [ + { + name: "main.qml", + text: code, + type: "full" + } + ], + query: { + type: "definition", + file: "main.qml", + end: pos, + types: true, + docs: false, + urls: false, + origins: true, + caseInsensitive: true, + lineCharPositions: true, + expandWordForward: false, + guess: false + } + }, function (err, resp) { + if (err) { + throw err; + } + var mis = misMatch(expected, resp); + callback(mis); + }); +}; + +function ppJSON(v) { + return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2); +} + +function addPath(str, pt) { + if (str.charAt(str.length - 1) == ")") + return str.slice(0, str.length - 1) + "/" + pt + ")"; + return str + " (" + pt + ")"; +} + +var misMatch = exports.misMatch = function (exp, act) { + var mis = null; + if (!exp || !act || (typeof exp != "object") || (typeof act != "object")) { + if (exp !== act) return ppJSON(exp) + " !== " + ppJSON(act); + } else if (exp instanceof RegExp || act instanceof RegExp) { + var left = ppJSON(exp), right = ppJSON(act); + if (left !== right) return left + " !== " + right; + } else if (exp.splice) { + if (!act.slice) return ppJSON(exp) + " != " + ppJSON(act); + if (act.length != exp.length) return "array length mismatch " + exp.length + " != " + act.length; + for (var i = 0; i < act.length; ++i) { + mis = misMatch(exp[i], act[i]); + if (mis) return addPath(mis, i); + } + } else { + for (var prop in exp) { + mis = misMatch(exp[prop], act[prop]); + if (mis) return addPath(mis, prop); + } + } };
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/test/ecma5-defs.js b/qt/org.eclipse.cdt.qt.core/tern-qml/test/ecma5-defs.js index 58fb3b127f4..c307033fc5a 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/test/ecma5-defs.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/test/ecma5-defs.js @@ -1,980 +1,980 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-module.exports = {
- "!name": "ecma5",
- "!define": {
- "Error.prototype": "Error.prototype"
- },
- "Infinity": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Infinity",
- "!doc": "A numeric value representing infinity."
- },
- "undefined": {
- "!type": "?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/undefined",
- "!doc": "The value undefined."
- },
- "NaN": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/NaN",
- "!doc": "A value representing Not-A-Number."
- },
- "Object": {
- "!type": "fn()",
- "getPrototypeOf": {
- "!type": "fn(obj: ?) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getPrototypeOf",
- "!doc": "Returns the prototype (i.e. the internal prototype) of the specified object."
- },
- "create": {
- "!type": "fn(proto: ?) -> !custom:Object_create",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create",
- "!doc": "Creates a new object with the specified prototype object and properties."
- },
- "defineProperty": {
- "!type": "fn(obj: ?, prop: string, desc: ?) -> !custom:Object_defineProperty",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty",
- "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article."
- },
- "defineProperties": {
- "!type": "fn(obj: ?, props: ?) -> !custom:Object_defineProperties",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty",
- "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article."
- },
- "getOwnPropertyDescriptor": {
- "!type": "fn(obj: ?, prop: string) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor",
- "!doc": "Returns a property descriptor for an own property (that is, one directly present on an object, not present by dint of being along an object's prototype chain) of a given object."
- },
- "keys": {
- "!type": "fn(obj: ?) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys",
- "!doc": "Returns an array of a given object's own enumerable properties, in the same order as that provided by a for-in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well)."
- },
- "getOwnPropertyNames": {
- "!type": "fn(obj: ?) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames",
- "!doc": "Returns an array of all properties (enumerable or not) found directly upon a given object."
- },
- "seal": {
- "!type": "fn(obj: ?)",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/seal",
- "!doc": "Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable."
- },
- "isSealed": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isSealed",
- "!doc": "Determine if an object is sealed."
- },
- "freeze": {
- "!type": "fn(obj: ?) -> !0",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/freeze",
- "!doc": "Freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed. In essence the object is made effectively immutable. The method returns the object being frozen."
- },
- "isFrozen": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isFrozen",
- "!doc": "Determine if an object is frozen."
- },
- "preventExtensions": {
- "!type": "fn(obj: ?)",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions",
- "!doc": "Prevents new properties from ever being added to an object."
- },
- "isExtensible": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible",
- "!doc": "The Object.isExtensible() method determines if an object is extensible (whether it can have new properties added to it)."
- },
- "prototype": {
- "!stdProto": "Object",
- "toString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toString",
- "!doc": "Returns a string representing the object."
- },
- "toLocaleString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toLocaleString",
- "!doc": "Returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes."
- },
- "valueOf": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/valueOf",
- "!doc": "Returns the primitive value of the specified object"
- },
- "hasOwnProperty": {
- "!type": "fn(prop: string) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/hasOwnProperty",
- "!doc": "Returns a boolean indicating whether the object has the specified property."
- },
- "propertyIsEnumerable": {
- "!type": "fn(prop: string) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable",
- "!doc": "Returns a Boolean indicating whether the specified property is enumerable."
- },
- "isPrototypeOf": {
- "!type": "fn(obj: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf",
- "!doc": "Tests for an object in another object's prototype chain."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object",
- "!doc": "Creates an object wrapper."
- },
- "Function": {
- "!type": "fn(body: string) -> fn()",
- "prototype": {
- "!stdProto": "Function",
- "apply": {
- "!type": "fn(this: ?, args: [?])",
- "!effects": [
- "call and return !this this=!0 !1.<i> !1.<i> !1.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply",
- "!doc": "Calls a function with a given this value and arguments provided as an array (or an array like object)."
- },
- "call": {
- "!type": "fn(this: ?, args?: ?) -> !this.!ret",
- "!effects": [
- "call and return !this this=!0 !1 !2 !3 !4"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/call",
- "!doc": "Calls a function with a given this value and arguments provided individually."
- },
- "bind": {
- "!type": "fn(this: ?, args?: ?) -> !custom:Function_bind",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind",
- "!doc": "Creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function was called."
- },
- "prototype": "?"
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function",
- "!doc": "Every function in JavaScript is actually a Function object."
- },
- "Array": {
- "!type": "fn(size: number) -> !custom:Array_ctor",
- "isArray": {
- "!type": "fn(value: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/isArray",
- "!doc": "Returns true if an object is an array, false if it is not."
- },
- "prototype": {
- "!stdProto": "Array",
- "length": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/length",
- "!doc": "An unsigned, 32-bit integer that specifies the number of elements in an array."
- },
- "concat": {
- "!type": "fn(other: [?]) -> !this",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat",
- "!doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s)."
- },
- "join": {
- "!type": "fn(separator?: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/join",
- "!doc": "Joins all elements of an array into a string."
- },
- "splice": {
- "!type": "fn(pos: number, amount: number)",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/splice",
- "!doc": "Changes the content of an array, adding new elements while removing old elements."
- },
- "pop": {
- "!type": "fn() -> !this.<i>",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/pop",
- "!doc": "Removes the last element from an array and returns that element."
- },
- "push": {
- "!type": "fn(newelt: ?) -> number",
- "!effects": [
- "propagate !0 !this.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/push",
- "!doc": "Mutates an array by appending the given elements and returning the new length of the array."
- },
- "shift": {
- "!type": "fn() -> !this.<i>",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/shift",
- "!doc": "Removes the first element from an array and returns that element. This method changes the length of the array."
- },
- "unshift": {
- "!type": "fn(newelt: ?) -> number",
- "!effects": [
- "propagate !0 !this.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/unshift",
- "!doc": "Adds one or more elements to the beginning of an array and returns the new length of the array."
- },
- "slice": {
- "!type": "fn(from: number, to?: number) -> !this",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/slice",
- "!doc": "Returns a shallow copy of a portion of an array."
- },
- "reverse": {
- "!type": "fn()",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/reverse",
- "!doc": "Reverses an array in place. The first array element becomes the last and the last becomes the first."
- },
- "sort": {
- "!type": "fn(compare?: fn(a: ?, b: ?) -> number)",
- "!effects": [
- "call !0 !this.<i> !this.<i>"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort",
- "!doc": "Sorts the elements of an array in place and returns the array."
- },
- "indexOf": {
- "!type": "fn(elt: ?, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf",
- "!doc": "Returns the first index at which a given element can be found in the array, or -1 if it is not present."
- },
- "lastIndexOf": {
- "!type": "fn(elt: ?, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/lastIndexOf",
- "!doc": "Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex."
- },
- "every": {
- "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every",
- "!doc": "Tests whether all elements in the array pass the test implemented by the provided function."
- },
- "some": {
- "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/some",
- "!doc": "Tests whether some element in the array passes the test implemented by the provided function."
- },
- "filter": {
- "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> !this",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter",
- "!doc": "Creates a new array with all elements that pass the test implemented by the provided function."
- },
- "forEach": {
- "!type": "fn(f: fn(elt: ?, i: number), context?: ?)",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach",
- "!doc": "Executes a provided function once per array element."
- },
- "map": {
- "!type": "fn(f: fn(elt: ?, i: number) -> ?, context?: ?) -> [!0.!ret]",
- "!effects": [
- "call !0 this=!1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map",
- "!doc": "Creates a new array with the results of calling a provided function on every element in this array."
- },
- "reduce": {
- "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret",
- "!effects": [
- "call !0 !1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce",
- "!doc": "Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value."
- },
- "reduceRight": {
- "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret",
- "!effects": [
- "call !0 !1 !this.<i> number"
- ],
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/ReduceRight",
- "!doc": "Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array",
- "!doc": "The JavaScript Array global object is a constructor for arrays, which are high-level, list-like objects."
- },
- "String": {
- "!type": "fn(value: ?) -> string",
- "fromCharCode": {
- "!type": "fn(code: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/fromCharCode",
- "!doc": "Returns a string created by using the specified sequence of Unicode values."
- },
- "prototype": {
- "!stdProto": "String",
- "length": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/String/length",
- "!doc": "Represents the length of a string."
- },
- "<i>": "string",
- "charAt": {
- "!type": "fn(i: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charAt",
- "!doc": "Returns the specified character from a string."
- },
- "charCodeAt": {
- "!type": "fn(i: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charCodeAt",
- "!doc": "Returns the numeric Unicode value of the character at the given index (except for unicode codepoints > 0x10000)."
- },
- "indexOf": {
- "!type": "fn(char: string, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/indexOf",
- "!doc": "Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex,\nreturns -1 if the value is not found."
- },
- "lastIndexOf": {
- "!type": "fn(char: string, from?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/lastIndexOf",
- "!doc": "Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex."
- },
- "substring": {
- "!type": "fn(from: number, to?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substring",
- "!doc": "Returns a subset of a string between one index and another, or through the end of the string."
- },
- "substr": {
- "!type": "fn(from: number, length?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substr",
- "!doc": "Returns the characters in a string beginning at the specified location through the specified number of characters."
- },
- "slice": {
- "!type": "fn(from: number, to?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/slice",
- "!doc": "Extracts a section of a string and returns a new string."
- },
- "trim": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim",
- "!doc": "Removes whitespace from both ends of the string."
- },
- "toUpperCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toUpperCase",
- "!doc": "Returns the calling string value converted to uppercase."
- },
- "toLowerCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLowerCase",
- "!doc": "Returns the calling string value converted to lowercase."
- },
- "toLocaleUpperCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase",
- "!doc": "Returns the calling string value converted to upper case, according to any locale-specific case mappings."
- },
- "toLocaleLowerCase": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase",
- "!doc": "Returns the calling string value converted to lower case, according to any locale-specific case mappings."
- },
- "split": {
- "!type": "fn(pattern: string) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split",
- "!doc": "Splits a String object into an array of strings by separating the string into substrings."
- },
- "concat": {
- "!type": "fn(other: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/concat",
- "!doc": "Combines the text of two or more strings and returns a new string."
- },
- "localeCompare": {
- "!type": "fn(other: string) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/localeCompare",
- "!doc": "Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order."
- },
- "match": {
- "!type": "fn(pattern: +RegExp) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/match",
- "!doc": "Used to retrieve the matches when matching a string against a regular expression."
- },
- "replace": {
- "!type": "fn(pattern: string|+RegExp, replacement: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace",
- "!doc": "Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match."
- },
- "search": {
- "!type": "fn(pattern: +RegExp) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search",
- "!doc": "Executes the search for a match between a regular expression and this String object."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String",
- "!doc": "The String global object is a constructor for strings, or a sequence of characters."
- },
- "Number": {
- "!type": "fn(value: ?) -> number",
- "MAX_VALUE": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MAX_VALUE",
- "!doc": "The maximum numeric value representable in JavaScript."
- },
- "MIN_VALUE": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MIN_VALUE",
- "!doc": "The smallest positive numeric value representable in JavaScript."
- },
- "POSITIVE_INFINITY": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY",
- "!doc": "A value representing the positive Infinity value."
- },
- "NEGATIVE_INFINITY": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY",
- "!doc": "A value representing the negative Infinity value."
- },
- "prototype": {
- "!stdProto": "Number",
- "toString": {
- "!type": "fn(radix?: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toString",
- "!doc": "Returns a string representing the specified Number object"
- },
- "toFixed": {
- "!type": "fn(digits: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed",
- "!doc": "Formats a number using fixed-point notation"
- },
- "toExponential": {
- "!type": "fn(digits: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toExponential",
- "!doc": "Returns a string representing the Number object in exponential notation"
- },
- "toPrecision": {
- "!type": "fn(digits: number) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toPrecision",
- "!doc": "The toPrecision() method returns a string representing the number to the specified precision."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number",
- "!doc": "The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor."
- },
- "Boolean": {
- "!type": "fn(value: ?) -> bool",
- "prototype": {
- "!stdProto": "Boolean"
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean",
- "!doc": "The Boolean object is an object wrapper for a boolean value."
- },
- "RegExp": {
- "!type": "fn(source: string, flags?: string)",
- "prototype": {
- "!stdProto": "RegExp",
- "exec": {
- "!type": "fn(input: string) -> [string]",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec",
- "!doc": "Executes a search for a match in a specified string. Returns a result array, or null."
- },
- "test": {
- "!type": "fn(input: string) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/test",
- "!doc": "Executes the search for a match between a regular expression and a specified string. Returns true or false."
- },
- "global": {
- "!type": "bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
- "!doc": "Creates a regular expression object for matching text with a pattern."
- },
- "ignoreCase": {
- "!type": "bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
- "!doc": "Creates a regular expression object for matching text with a pattern."
- },
- "multiline": {
- "!type": "bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/multiline",
- "!doc": "Reflects whether or not to search in strings across multiple lines.\n"
- },
- "source": {
- "!type": "string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/source",
- "!doc": "A read-only property that contains the text of the pattern, excluding the forward slashes.\n"
- },
- "lastIndex": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/lastIndex",
- "!doc": "A read/write integer property that specifies the index at which to start the next match."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp",
- "!doc": "Creates a regular expression object for matching text with a pattern."
- },
- "Date": {
- "!type": "fn(ms: number)",
- "parse": {
- "!type": "fn(source: string) -> +Date",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/parse",
- "!doc": "Parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC."
- },
- "UTC": {
- "!type": "fn(year: number, month: number, date: number, hour?: number, min?: number, sec?: number, ms?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/UTC",
- "!doc": "Accepts the same parameters as the longest form of the constructor, and returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time."
- },
- "now": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now",
- "!doc": "Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC."
- },
- "prototype": {
- "toUTCString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toUTCString",
- "!doc": "Converts a date to a string, using the universal time convention."
- },
- "toISOString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString",
- "!doc": "JavaScript provides a direct way to convert a date object into a string in ISO format, the ISO 8601 Extended Format."
- },
- "toDateString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toDateString",
- "!doc": "Returns the date portion of a Date object in human readable form in American English."
- },
- "toTimeString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toTimeString",
- "!doc": "Returns the time portion of a Date object in human readable form in American English."
- },
- "toLocaleDateString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleDateString",
- "!doc": "Converts a date to a string, returning the \"date\" portion using the operating system's locale's conventions.\n"
- },
- "toLocaleTimeString": {
- "!type": "fn() -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString",
- "!doc": "Converts a date to a string, returning the \"time\" portion using the current locale's conventions."
- },
- "getTime": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTime",
- "!doc": "Returns the numeric value corresponding to the time for the specified date according to universal time."
- },
- "getFullYear": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getFullYear",
- "!doc": "Returns the year of the specified date according to local time."
- },
- "getYear": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getYear",
- "!doc": "Returns the year in the specified date according to local time."
- },
- "getMonth": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMonth",
- "!doc": "Returns the month in the specified date according to local time."
- },
- "getUTCMonth": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMonth",
- "!doc": "Returns the month of the specified date according to universal time.\n"
- },
- "getDate": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDate",
- "!doc": "Returns the day of the month for the specified date according to local time."
- },
- "getUTCDate": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDate",
- "!doc": "Returns the day (date) of the month in the specified date according to universal time.\n"
- },
- "getDay": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDay",
- "!doc": "Returns the day of the week for the specified date according to local time."
- },
- "getUTCDay": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDay",
- "!doc": "Returns the day of the week in the specified date according to universal time.\n"
- },
- "getHours": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getHours",
- "!doc": "Returns the hour for the specified date according to local time."
- },
- "getUTCHours": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCHours",
- "!doc": "Returns the hours in the specified date according to universal time.\n"
- },
- "getMinutes": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMinutes",
- "!doc": "Returns the minutes in the specified date according to local time."
- },
- "getUTCMinutes": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date",
- "!doc": "Creates JavaScript Date instances which let you work with dates and times."
- },
- "getSeconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getSeconds",
- "!doc": "Returns the seconds in the specified date according to local time."
- },
- "getUTCSeconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCSeconds",
- "!doc": "Returns the seconds in the specified date according to universal time.\n"
- },
- "getMilliseconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMilliseconds",
- "!doc": "Returns the milliseconds in the specified date according to local time."
- },
- "getUTCMilliseconds": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds",
- "!doc": "Returns the milliseconds in the specified date according to universal time.\n"
- },
- "getTimezoneOffset": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset",
- "!doc": "Returns the time-zone offset from UTC, in minutes, for the current locale."
- },
- "setTime": {
- "!type": "fn(date: +Date) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setTime",
- "!doc": "Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.\n"
- },
- "setFullYear": {
- "!type": "fn(year: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setFullYear",
- "!doc": "Sets the full year for a specified date according to local time.\n"
- },
- "setUTCFullYear": {
- "!type": "fn(year: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCFullYear",
- "!doc": "Sets the full year for a specified date according to universal time.\n"
- },
- "setMonth": {
- "!type": "fn(month: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMonth",
- "!doc": "Set the month for a specified date according to local time."
- },
- "setUTCMonth": {
- "!type": "fn(month: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMonth",
- "!doc": "Sets the month for a specified date according to universal time.\n"
- },
- "setDate": {
- "!type": "fn(day: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setDate",
- "!doc": "Sets the day of the month for a specified date according to local time."
- },
- "setUTCDate": {
- "!type": "fn(day: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCDate",
- "!doc": "Sets the day of the month for a specified date according to universal time.\n"
- },
- "setHours": {
- "!type": "fn(hour: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setHours",
- "!doc": "Sets the hours for a specified date according to local time, and returns the number of milliseconds since 1 January 1970 00:00:00 UTC until the time represented by the updated Date instance."
- },
- "setUTCHours": {
- "!type": "fn(hour: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCHours",
- "!doc": "Sets the hour for a specified date according to universal time.\n"
- },
- "setMinutes": {
- "!type": "fn(min: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMinutes",
- "!doc": "Sets the minutes for a specified date according to local time."
- },
- "setUTCMinutes": {
- "!type": "fn(min: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMinutes",
- "!doc": "Sets the minutes for a specified date according to universal time.\n"
- },
- "setSeconds": {
- "!type": "fn(sec: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setSeconds",
- "!doc": "Sets the seconds for a specified date according to local time."
- },
- "setUTCSeconds": {
- "!type": "fn(sec: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCSeconds",
- "!doc": "Sets the seconds for a specified date according to universal time.\n"
- },
- "setMilliseconds": {
- "!type": "fn(ms: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMilliseconds",
- "!doc": "Sets the milliseconds for a specified date according to local time.\n"
- },
- "setUTCMilliseconds": {
- "!type": "fn(ms: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds",
- "!doc": "Sets the milliseconds for a specified date according to universal time.\n"
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date",
- "!doc": "Creates JavaScript Date instances which let you work with dates and times."
- },
- "Error": {
- "!type": "fn(message: string)",
- "prototype": {
- "name": {
- "!type": "string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/name",
- "!doc": "A name for the type of error."
- },
- "message": {
- "!type": "string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/message",
- "!doc": "A human-readable description of the error."
- }
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error",
- "!doc": "Creates an error object."
- },
- "SyntaxError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/SyntaxError",
- "!doc": "Represents an error when trying to interpret syntactically invalid code."
- },
- "ReferenceError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/ReferenceError",
- "!doc": "Represents an error when a non-existent variable is referenced."
- },
- "URIError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/URIError",
- "!doc": "Represents an error when a malformed URI is encountered."
- },
- "EvalError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/EvalError",
- "!doc": "Represents an error regarding the eval function."
- },
- "RangeError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RangeError",
- "!doc": "Represents an error when a number is not within the correct range allowed."
- },
- "TypeError": {
- "!type": "fn(message: string)",
- "prototype": "Error.prototype",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/TypeError",
- "!doc": "Represents an error an error when a value is not of the expected type."
- },
- "parseInt": {
- "!type": "fn(string: string, radix?: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt",
- "!doc": "Parses a string argument and returns an integer of the specified radix or base."
- },
- "parseFloat": {
- "!type": "fn(string: string) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseFloat",
- "!doc": "Parses a string argument and returns a floating point number."
- },
- "isNaN": {
- "!type": "fn(value: number) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isNaN",
- "!doc": "Determines whether a value is NaN or not. Be careful, this function is broken. You may be interested in ECMAScript 6 Number.isNaN."
- },
- "isFinite": {
- "!type": "fn(value: number) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isFinite",
- "!doc": "Determines whether the passed value is a finite number."
- },
- "eval": {
- "!type": "fn(code: string) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval",
- "!doc": "Evaluates JavaScript code represented as a string."
- },
- "encodeURI": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI",
- "!doc": "Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)."
- },
- "encodeURIComponent": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent",
- "!doc": "Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)."
- },
- "decodeURI": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURI",
- "!doc": "Decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine."
- },
- "decodeURIComponent": {
- "!type": "fn(uri: string) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURIComponent",
- "!doc": "Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine."
- },
- "Math": {
- "E": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/E",
- "!doc": "The base of natural logarithms, e, approximately 2.718."
- },
- "LN2": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN2",
- "!doc": "The natural logarithm of 2, approximately 0.693."
- },
- "LN10": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN10",
- "!doc": "The natural logarithm of 10, approximately 2.302."
- },
- "LOG2E": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG2E",
- "!doc": "The base 2 logarithm of E (approximately 1.442)."
- },
- "LOG10E": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG10E",
- "!doc": "The base 10 logarithm of E (approximately 0.434)."
- },
- "SQRT1_2": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT1_2",
- "!doc": "The square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707."
- },
- "SQRT2": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT2",
- "!doc": "The square root of 2, approximately 1.414."
- },
- "PI": {
- "!type": "number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/PI",
- "!doc": "The ratio of the circumference of a circle to its diameter, approximately 3.14159."
- },
- "abs": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/abs",
- "!doc": "Returns the absolute value of a number."
- },
- "cos": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/cos",
- "!doc": "Returns the cosine of a number."
- },
- "sin": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sin",
- "!doc": "Returns the sine of a number."
- },
- "tan": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/tan",
- "!doc": "Returns the tangent of a number."
- },
- "acos": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/acos",
- "!doc": "Returns the arccosine (in radians) of a number."
- },
- "asin": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/asin",
- "!doc": "Returns the arcsine (in radians) of a number."
- },
- "atan": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan",
- "!doc": "Returns the arctangent (in radians) of a number."
- },
- "atan2": {
- "!type": "fn(y: number, x: number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2",
- "!doc": "Returns the arctangent of the quotient of its arguments."
- },
- "ceil": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil",
- "!doc": "Returns the smallest integer greater than or equal to a number."
- },
- "floor": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/floor",
- "!doc": "Returns the largest integer less than or equal to a number."
- },
- "round": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/round",
- "!doc": "Returns the value of a number rounded to the nearest integer."
- },
- "exp": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/exp",
- "!doc": "Returns Ex, where x is the argument, and E is Euler's constant, the base of the natural logarithms."
- },
- "log": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/log",
- "!doc": "Returns the natural logarithm (base E) of a number."
- },
- "sqrt": {
- "!type": "fn(number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sqrt",
- "!doc": "Returns the square root of a number."
- },
- "pow": {
- "!type": "fn(number, number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/pow",
- "!doc": "Returns base to the exponent power, that is, baseexponent."
- },
- "max": {
- "!type": "fn(number, number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/max",
- "!doc": "Returns the largest of zero or more numbers."
- },
- "min": {
- "!type": "fn(number, number) -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/min",
- "!doc": "Returns the smallest of zero or more numbers."
- },
- "random": {
- "!type": "fn() -> number",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random",
- "!doc": "Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range."
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math",
- "!doc": "A built-in object that has properties and methods for mathematical constants and functions."
- },
- "JSON": {
- "parse": {
- "!type": "fn(json: string) -> ?",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/parse",
- "!doc": "Parse a string as JSON, optionally transforming the value produced by parsing."
- },
- "stringify": {
- "!type": "fn(value: ?) -> string",
- "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify",
- "!doc": "Convert a value to JSON, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified."
- },
- "!url": "https://developer.mozilla.org/en-US/docs/JSON",
- "!doc": "JSON (JavaScript Object Notation) is a data-interchange format. It closely resembles a subset of JavaScript syntax, although it is not a strict subset. (See JSON in the JavaScript Reference for full details.) It is useful when writing any kind of JavaScript-based application, including websites and browser extensions. For example, you might store user information in JSON format in a cookie, or you might store extension preferences in JSON in a string-valued browser preference."
- }
+/******************************************************************************* + * 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 + *******************************************************************************/ +"use strict"; + +module.exports = { + "!name": "ecma5", + "!define": { + "Error.prototype": "Error.prototype" + }, + "Infinity": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Infinity", + "!doc": "A numeric value representing infinity." + }, + "undefined": { + "!type": "?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/undefined", + "!doc": "The value undefined." + }, + "NaN": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/NaN", + "!doc": "A value representing Not-A-Number." + }, + "Object": { + "!type": "fn()", + "getPrototypeOf": { + "!type": "fn(obj: ?) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getPrototypeOf", + "!doc": "Returns the prototype (i.e. the internal prototype) of the specified object." + }, + "create": { + "!type": "fn(proto: ?) -> !custom:Object_create", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create", + "!doc": "Creates a new object with the specified prototype object and properties." + }, + "defineProperty": { + "!type": "fn(obj: ?, prop: string, desc: ?) -> !custom:Object_defineProperty", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty", + "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article." + }, + "defineProperties": { + "!type": "fn(obj: ?, props: ?) -> !custom:Object_defineProperties", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty", + "!doc": "Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. If you want to see how to use the Object.defineProperty method with a binary-flags-like syntax, see this article." + }, + "getOwnPropertyDescriptor": { + "!type": "fn(obj: ?, prop: string) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor", + "!doc": "Returns a property descriptor for an own property (that is, one directly present on an object, not present by dint of being along an object's prototype chain) of a given object." + }, + "keys": { + "!type": "fn(obj: ?) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys", + "!doc": "Returns an array of a given object's own enumerable properties, in the same order as that provided by a for-in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well)." + }, + "getOwnPropertyNames": { + "!type": "fn(obj: ?) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames", + "!doc": "Returns an array of all properties (enumerable or not) found directly upon a given object." + }, + "seal": { + "!type": "fn(obj: ?)", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/seal", + "!doc": "Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable." + }, + "isSealed": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isSealed", + "!doc": "Determine if an object is sealed." + }, + "freeze": { + "!type": "fn(obj: ?) -> !0", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/freeze", + "!doc": "Freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed. In essence the object is made effectively immutable. The method returns the object being frozen." + }, + "isFrozen": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isFrozen", + "!doc": "Determine if an object is frozen." + }, + "preventExtensions": { + "!type": "fn(obj: ?)", + "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions", + "!doc": "Prevents new properties from ever being added to an object." + }, + "isExtensible": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible", + "!doc": "The Object.isExtensible() method determines if an object is extensible (whether it can have new properties added to it)." + }, + "prototype": { + "!stdProto": "Object", + "toString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toString", + "!doc": "Returns a string representing the object." + }, + "toLocaleString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/toLocaleString", + "!doc": "Returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes." + }, + "valueOf": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/valueOf", + "!doc": "Returns the primitive value of the specified object" + }, + "hasOwnProperty": { + "!type": "fn(prop: string) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/hasOwnProperty", + "!doc": "Returns a boolean indicating whether the object has the specified property." + }, + "propertyIsEnumerable": { + "!type": "fn(prop: string) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable", + "!doc": "Returns a Boolean indicating whether the specified property is enumerable." + }, + "isPrototypeOf": { + "!type": "fn(obj: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf", + "!doc": "Tests for an object in another object's prototype chain." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object", + "!doc": "Creates an object wrapper." + }, + "Function": { + "!type": "fn(body: string) -> fn()", + "prototype": { + "!stdProto": "Function", + "apply": { + "!type": "fn(this: ?, args: [?])", + "!effects": [ + "call and return !this this=!0 !1.<i> !1.<i> !1.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply", + "!doc": "Calls a function with a given this value and arguments provided as an array (or an array like object)." + }, + "call": { + "!type": "fn(this: ?, args?: ?) -> !this.!ret", + "!effects": [ + "call and return !this this=!0 !1 !2 !3 !4" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/call", + "!doc": "Calls a function with a given this value and arguments provided individually." + }, + "bind": { + "!type": "fn(this: ?, args?: ?) -> !custom:Function_bind", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind", + "!doc": "Creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function was called." + }, + "prototype": "?" + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function", + "!doc": "Every function in JavaScript is actually a Function object." + }, + "Array": { + "!type": "fn(size: number) -> !custom:Array_ctor", + "isArray": { + "!type": "fn(value: ?) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/isArray", + "!doc": "Returns true if an object is an array, false if it is not." + }, + "prototype": { + "!stdProto": "Array", + "length": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/length", + "!doc": "An unsigned, 32-bit integer that specifies the number of elements in an array." + }, + "concat": { + "!type": "fn(other: [?]) -> !this", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat", + "!doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s)." + }, + "join": { + "!type": "fn(separator?: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/join", + "!doc": "Joins all elements of an array into a string." + }, + "splice": { + "!type": "fn(pos: number, amount: number)", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/splice", + "!doc": "Changes the content of an array, adding new elements while removing old elements." + }, + "pop": { + "!type": "fn() -> !this.<i>", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/pop", + "!doc": "Removes the last element from an array and returns that element." + }, + "push": { + "!type": "fn(newelt: ?) -> number", + "!effects": [ + "propagate !0 !this.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/push", + "!doc": "Mutates an array by appending the given elements and returning the new length of the array." + }, + "shift": { + "!type": "fn() -> !this.<i>", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/shift", + "!doc": "Removes the first element from an array and returns that element. This method changes the length of the array." + }, + "unshift": { + "!type": "fn(newelt: ?) -> number", + "!effects": [ + "propagate !0 !this.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/unshift", + "!doc": "Adds one or more elements to the beginning of an array and returns the new length of the array." + }, + "slice": { + "!type": "fn(from: number, to?: number) -> !this", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/slice", + "!doc": "Returns a shallow copy of a portion of an array." + }, + "reverse": { + "!type": "fn()", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/reverse", + "!doc": "Reverses an array in place. The first array element becomes the last and the last becomes the first." + }, + "sort": { + "!type": "fn(compare?: fn(a: ?, b: ?) -> number)", + "!effects": [ + "call !0 !this.<i> !this.<i>" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort", + "!doc": "Sorts the elements of an array in place and returns the array." + }, + "indexOf": { + "!type": "fn(elt: ?, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf", + "!doc": "Returns the first index at which a given element can be found in the array, or -1 if it is not present." + }, + "lastIndexOf": { + "!type": "fn(elt: ?, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/lastIndexOf", + "!doc": "Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex." + }, + "every": { + "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every", + "!doc": "Tests whether all elements in the array pass the test implemented by the provided function." + }, + "some": { + "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/some", + "!doc": "Tests whether some element in the array passes the test implemented by the provided function." + }, + "filter": { + "!type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> !this", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/filter", + "!doc": "Creates a new array with all elements that pass the test implemented by the provided function." + }, + "forEach": { + "!type": "fn(f: fn(elt: ?, i: number), context?: ?)", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach", + "!doc": "Executes a provided function once per array element." + }, + "map": { + "!type": "fn(f: fn(elt: ?, i: number) -> ?, context?: ?) -> [!0.!ret]", + "!effects": [ + "call !0 this=!1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map", + "!doc": "Creates a new array with the results of calling a provided function on every element in this array." + }, + "reduce": { + "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret", + "!effects": [ + "call !0 !1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/Reduce", + "!doc": "Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value." + }, + "reduceRight": { + "!type": "fn(combine: fn(sum: ?, elt: ?, i: number) -> ?, init?: ?) -> !0.!ret", + "!effects": [ + "call !0 !1 !this.<i> number" + ], + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/ReduceRight", + "!doc": "Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array", + "!doc": "The JavaScript Array global object is a constructor for arrays, which are high-level, list-like objects." + }, + "String": { + "!type": "fn(value: ?) -> string", + "fromCharCode": { + "!type": "fn(code: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/fromCharCode", + "!doc": "Returns a string created by using the specified sequence of Unicode values." + }, + "prototype": { + "!stdProto": "String", + "length": { + "!type": "number", + "!url": "https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/String/length", + "!doc": "Represents the length of a string." + }, + "<i>": "string", + "charAt": { + "!type": "fn(i: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charAt", + "!doc": "Returns the specified character from a string." + }, + "charCodeAt": { + "!type": "fn(i: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charCodeAt", + "!doc": "Returns the numeric Unicode value of the character at the given index (except for unicode codepoints > 0x10000)." + }, + "indexOf": { + "!type": "fn(char: string, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/indexOf", + "!doc": "Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex,\nreturns -1 if the value is not found." + }, + "lastIndexOf": { + "!type": "fn(char: string, from?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/lastIndexOf", + "!doc": "Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex." + }, + "substring": { + "!type": "fn(from: number, to?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substring", + "!doc": "Returns a subset of a string between one index and another, or through the end of the string." + }, + "substr": { + "!type": "fn(from: number, length?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/substr", + "!doc": "Returns the characters in a string beginning at the specified location through the specified number of characters." + }, + "slice": { + "!type": "fn(from: number, to?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/slice", + "!doc": "Extracts a section of a string and returns a new string." + }, + "trim": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim", + "!doc": "Removes whitespace from both ends of the string." + }, + "toUpperCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toUpperCase", + "!doc": "Returns the calling string value converted to uppercase." + }, + "toLowerCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLowerCase", + "!doc": "Returns the calling string value converted to lowercase." + }, + "toLocaleUpperCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase", + "!doc": "Returns the calling string value converted to upper case, according to any locale-specific case mappings." + }, + "toLocaleLowerCase": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase", + "!doc": "Returns the calling string value converted to lower case, according to any locale-specific case mappings." + }, + "split": { + "!type": "fn(pattern: string) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split", + "!doc": "Splits a String object into an array of strings by separating the string into substrings." + }, + "concat": { + "!type": "fn(other: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/concat", + "!doc": "Combines the text of two or more strings and returns a new string." + }, + "localeCompare": { + "!type": "fn(other: string) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/localeCompare", + "!doc": "Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order." + }, + "match": { + "!type": "fn(pattern: +RegExp) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/match", + "!doc": "Used to retrieve the matches when matching a string against a regular expression." + }, + "replace": { + "!type": "fn(pattern: string|+RegExp, replacement: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace", + "!doc": "Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match." + }, + "search": { + "!type": "fn(pattern: +RegExp) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search", + "!doc": "Executes the search for a match between a regular expression and this String object." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String", + "!doc": "The String global object is a constructor for strings, or a sequence of characters." + }, + "Number": { + "!type": "fn(value: ?) -> number", + "MAX_VALUE": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MAX_VALUE", + "!doc": "The maximum numeric value representable in JavaScript." + }, + "MIN_VALUE": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/MIN_VALUE", + "!doc": "The smallest positive numeric value representable in JavaScript." + }, + "POSITIVE_INFINITY": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY", + "!doc": "A value representing the positive Infinity value." + }, + "NEGATIVE_INFINITY": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY", + "!doc": "A value representing the negative Infinity value." + }, + "prototype": { + "!stdProto": "Number", + "toString": { + "!type": "fn(radix?: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toString", + "!doc": "Returns a string representing the specified Number object" + }, + "toFixed": { + "!type": "fn(digits: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed", + "!doc": "Formats a number using fixed-point notation" + }, + "toExponential": { + "!type": "fn(digits: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toExponential", + "!doc": "Returns a string representing the Number object in exponential notation" + }, + "toPrecision": { + "!type": "fn(digits: number) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toPrecision", + "!doc": "The toPrecision() method returns a string representing the number to the specified precision." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number", + "!doc": "The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor." + }, + "Boolean": { + "!type": "fn(value: ?) -> bool", + "prototype": { + "!stdProto": "Boolean" + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean", + "!doc": "The Boolean object is an object wrapper for a boolean value." + }, + "RegExp": { + "!type": "fn(source: string, flags?: string)", + "prototype": { + "!stdProto": "RegExp", + "exec": { + "!type": "fn(input: string) -> [string]", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec", + "!doc": "Executes a search for a match in a specified string. Returns a result array, or null." + }, + "test": { + "!type": "fn(input: string) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/test", + "!doc": "Executes the search for a match between a regular expression and a specified string. Returns true or false." + }, + "global": { + "!type": "bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp", + "!doc": "Creates a regular expression object for matching text with a pattern." + }, + "ignoreCase": { + "!type": "bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp", + "!doc": "Creates a regular expression object for matching text with a pattern." + }, + "multiline": { + "!type": "bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/multiline", + "!doc": "Reflects whether or not to search in strings across multiple lines.\n" + }, + "source": { + "!type": "string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/source", + "!doc": "A read-only property that contains the text of the pattern, excluding the forward slashes.\n" + }, + "lastIndex": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/lastIndex", + "!doc": "A read/write integer property that specifies the index at which to start the next match." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp", + "!doc": "Creates a regular expression object for matching text with a pattern." + }, + "Date": { + "!type": "fn(ms: number)", + "parse": { + "!type": "fn(source: string) -> +Date", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/parse", + "!doc": "Parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC." + }, + "UTC": { + "!type": "fn(year: number, month: number, date: number, hour?: number, min?: number, sec?: number, ms?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/UTC", + "!doc": "Accepts the same parameters as the longest form of the constructor, and returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time." + }, + "now": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now", + "!doc": "Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC." + }, + "prototype": { + "toUTCString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toUTCString", + "!doc": "Converts a date to a string, using the universal time convention." + }, + "toISOString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString", + "!doc": "JavaScript provides a direct way to convert a date object into a string in ISO format, the ISO 8601 Extended Format." + }, + "toDateString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toDateString", + "!doc": "Returns the date portion of a Date object in human readable form in American English." + }, + "toTimeString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toTimeString", + "!doc": "Returns the time portion of a Date object in human readable form in American English." + }, + "toLocaleDateString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleDateString", + "!doc": "Converts a date to a string, returning the \"date\" portion using the operating system's locale's conventions.\n" + }, + "toLocaleTimeString": { + "!type": "fn() -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString", + "!doc": "Converts a date to a string, returning the \"time\" portion using the current locale's conventions." + }, + "getTime": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTime", + "!doc": "Returns the numeric value corresponding to the time for the specified date according to universal time." + }, + "getFullYear": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getFullYear", + "!doc": "Returns the year of the specified date according to local time." + }, + "getYear": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getYear", + "!doc": "Returns the year in the specified date according to local time." + }, + "getMonth": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMonth", + "!doc": "Returns the month in the specified date according to local time." + }, + "getUTCMonth": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMonth", + "!doc": "Returns the month of the specified date according to universal time.\n" + }, + "getDate": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDate", + "!doc": "Returns the day of the month for the specified date according to local time." + }, + "getUTCDate": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDate", + "!doc": "Returns the day (date) of the month in the specified date according to universal time.\n" + }, + "getDay": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDay", + "!doc": "Returns the day of the week for the specified date according to local time." + }, + "getUTCDay": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCDay", + "!doc": "Returns the day of the week in the specified date according to universal time.\n" + }, + "getHours": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getHours", + "!doc": "Returns the hour for the specified date according to local time." + }, + "getUTCHours": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCHours", + "!doc": "Returns the hours in the specified date according to universal time.\n" + }, + "getMinutes": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMinutes", + "!doc": "Returns the minutes in the specified date according to local time." + }, + "getUTCMinutes": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date", + "!doc": "Creates JavaScript Date instances which let you work with dates and times." + }, + "getSeconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getSeconds", + "!doc": "Returns the seconds in the specified date according to local time." + }, + "getUTCSeconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCSeconds", + "!doc": "Returns the seconds in the specified date according to universal time.\n" + }, + "getMilliseconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMilliseconds", + "!doc": "Returns the milliseconds in the specified date according to local time." + }, + "getUTCMilliseconds": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds", + "!doc": "Returns the milliseconds in the specified date according to universal time.\n" + }, + "getTimezoneOffset": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset", + "!doc": "Returns the time-zone offset from UTC, in minutes, for the current locale." + }, + "setTime": { + "!type": "fn(date: +Date) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setTime", + "!doc": "Sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.\n" + }, + "setFullYear": { + "!type": "fn(year: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setFullYear", + "!doc": "Sets the full year for a specified date according to local time.\n" + }, + "setUTCFullYear": { + "!type": "fn(year: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCFullYear", + "!doc": "Sets the full year for a specified date according to universal time.\n" + }, + "setMonth": { + "!type": "fn(month: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMonth", + "!doc": "Set the month for a specified date according to local time." + }, + "setUTCMonth": { + "!type": "fn(month: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMonth", + "!doc": "Sets the month for a specified date according to universal time.\n" + }, + "setDate": { + "!type": "fn(day: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setDate", + "!doc": "Sets the day of the month for a specified date according to local time." + }, + "setUTCDate": { + "!type": "fn(day: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCDate", + "!doc": "Sets the day of the month for a specified date according to universal time.\n" + }, + "setHours": { + "!type": "fn(hour: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setHours", + "!doc": "Sets the hours for a specified date according to local time, and returns the number of milliseconds since 1 January 1970 00:00:00 UTC until the time represented by the updated Date instance." + }, + "setUTCHours": { + "!type": "fn(hour: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCHours", + "!doc": "Sets the hour for a specified date according to universal time.\n" + }, + "setMinutes": { + "!type": "fn(min: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMinutes", + "!doc": "Sets the minutes for a specified date according to local time." + }, + "setUTCMinutes": { + "!type": "fn(min: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMinutes", + "!doc": "Sets the minutes for a specified date according to universal time.\n" + }, + "setSeconds": { + "!type": "fn(sec: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setSeconds", + "!doc": "Sets the seconds for a specified date according to local time." + }, + "setUTCSeconds": { + "!type": "fn(sec: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCSeconds", + "!doc": "Sets the seconds for a specified date according to universal time.\n" + }, + "setMilliseconds": { + "!type": "fn(ms: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMilliseconds", + "!doc": "Sets the milliseconds for a specified date according to local time.\n" + }, + "setUTCMilliseconds": { + "!type": "fn(ms: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds", + "!doc": "Sets the milliseconds for a specified date according to universal time.\n" + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date", + "!doc": "Creates JavaScript Date instances which let you work with dates and times." + }, + "Error": { + "!type": "fn(message: string)", + "prototype": { + "name": { + "!type": "string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/name", + "!doc": "A name for the type of error." + }, + "message": { + "!type": "string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error/message", + "!doc": "A human-readable description of the error." + } + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error", + "!doc": "Creates an error object." + }, + "SyntaxError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/SyntaxError", + "!doc": "Represents an error when trying to interpret syntactically invalid code." + }, + "ReferenceError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/ReferenceError", + "!doc": "Represents an error when a non-existent variable is referenced." + }, + "URIError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/URIError", + "!doc": "Represents an error when a malformed URI is encountered." + }, + "EvalError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/EvalError", + "!doc": "Represents an error regarding the eval function." + }, + "RangeError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RangeError", + "!doc": "Represents an error when a number is not within the correct range allowed." + }, + "TypeError": { + "!type": "fn(message: string)", + "prototype": "Error.prototype", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/TypeError", + "!doc": "Represents an error an error when a value is not of the expected type." + }, + "parseInt": { + "!type": "fn(string: string, radix?: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt", + "!doc": "Parses a string argument and returns an integer of the specified radix or base." + }, + "parseFloat": { + "!type": "fn(string: string) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseFloat", + "!doc": "Parses a string argument and returns a floating point number." + }, + "isNaN": { + "!type": "fn(value: number) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isNaN", + "!doc": "Determines whether a value is NaN or not. Be careful, this function is broken. You may be interested in ECMAScript 6 Number.isNaN." + }, + "isFinite": { + "!type": "fn(value: number) -> bool", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/isFinite", + "!doc": "Determines whether the passed value is a finite number." + }, + "eval": { + "!type": "fn(code: string) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval", + "!doc": "Evaluates JavaScript code represented as a string." + }, + "encodeURI": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI", + "!doc": "Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)." + }, + "encodeURIComponent": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent", + "!doc": "Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters)." + }, + "decodeURI": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURI", + "!doc": "Decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine." + }, + "decodeURIComponent": { + "!type": "fn(uri: string) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/decodeURIComponent", + "!doc": "Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine." + }, + "Math": { + "E": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/E", + "!doc": "The base of natural logarithms, e, approximately 2.718." + }, + "LN2": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN2", + "!doc": "The natural logarithm of 2, approximately 0.693." + }, + "LN10": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LN10", + "!doc": "The natural logarithm of 10, approximately 2.302." + }, + "LOG2E": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG2E", + "!doc": "The base 2 logarithm of E (approximately 1.442)." + }, + "LOG10E": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/LOG10E", + "!doc": "The base 10 logarithm of E (approximately 0.434)." + }, + "SQRT1_2": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT1_2", + "!doc": "The square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707." + }, + "SQRT2": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/SQRT2", + "!doc": "The square root of 2, approximately 1.414." + }, + "PI": { + "!type": "number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/PI", + "!doc": "The ratio of the circumference of a circle to its diameter, approximately 3.14159." + }, + "abs": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/abs", + "!doc": "Returns the absolute value of a number." + }, + "cos": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/cos", + "!doc": "Returns the cosine of a number." + }, + "sin": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sin", + "!doc": "Returns the sine of a number." + }, + "tan": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/tan", + "!doc": "Returns the tangent of a number." + }, + "acos": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/acos", + "!doc": "Returns the arccosine (in radians) of a number." + }, + "asin": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/asin", + "!doc": "Returns the arcsine (in radians) of a number." + }, + "atan": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan", + "!doc": "Returns the arctangent (in radians) of a number." + }, + "atan2": { + "!type": "fn(y: number, x: number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2", + "!doc": "Returns the arctangent of the quotient of its arguments." + }, + "ceil": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil", + "!doc": "Returns the smallest integer greater than or equal to a number." + }, + "floor": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/floor", + "!doc": "Returns the largest integer less than or equal to a number." + }, + "round": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/round", + "!doc": "Returns the value of a number rounded to the nearest integer." + }, + "exp": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/exp", + "!doc": "Returns Ex, where x is the argument, and E is Euler's constant, the base of the natural logarithms." + }, + "log": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/log", + "!doc": "Returns the natural logarithm (base E) of a number." + }, + "sqrt": { + "!type": "fn(number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/sqrt", + "!doc": "Returns the square root of a number." + }, + "pow": { + "!type": "fn(number, number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/pow", + "!doc": "Returns base to the exponent power, that is, baseexponent." + }, + "max": { + "!type": "fn(number, number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/max", + "!doc": "Returns the largest of zero or more numbers." + }, + "min": { + "!type": "fn(number, number) -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/min", + "!doc": "Returns the smallest of zero or more numbers." + }, + "random": { + "!type": "fn() -> number", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random", + "!doc": "Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range." + }, + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math", + "!doc": "A built-in object that has properties and methods for mathematical constants and functions." + }, + "JSON": { + "parse": { + "!type": "fn(json: string) -> ?", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/parse", + "!doc": "Parse a string as JSON, optionally transforming the value produced by parsing." + }, + "stringify": { + "!type": "fn(value: ?) -> string", + "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify", + "!doc": "Convert a value to JSON, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified." + }, + "!url": "https://developer.mozilla.org/en-US/docs/JSON", + "!doc": "JSON (JavaScript Object Notation) is a data-interchange format. It closely resembles a subset of JavaScript syntax, although it is not a strict subset. (See JSON in the JavaScript Reference for full details.) It is useful when writing any kind of JavaScript-based application, including websites and browser extensions. For example, you might store user information in JSON format in a cookie, or you might store extension preferences in JSON in a string-valued browser preference." + } };
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/test/run.js b/qt/org.eclipse.cdt.qt.core/tern-qml/test/run.js index 0ab69213c8d..9e07a017776 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/test/run.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/test/run.js @@ -1,82 +1,82 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-var driver = require("./driver.js");
-
-function group(name) {
- if (typeof console === "object" && console.group) {
- console.group(name);
- }
-}
-
-function groupEnd() {
- if (typeof console === "object" && console.groupEnd) {
- console.groupEnd();
- }
-}
-
-function log(title, message) {
- if (typeof console === "object") console.log(title, message);
-}
-
-var stats, tests = [];
-tests.push(require("./test-scoping.js"));
-tests.push(require("./test-finddef.js"));
-tests.push(require("./test-completions.js"));
-tests.push(require("./test-parse.js"));
-
-function report(state, code, message) {
- if (state != "ok") {++stats.failed; log(code, message);}
- ++stats.testsRun;
-}
-
-group("Errors");
-
-for (var i = 0; i < tests.length; i++) {
- var test = tests[i];
- group(test.group);
- stats = test.stats = {testsRun: 0, failed: 0};
- var config = test.config || {};
- config.group = test.group;
- var t0 = +new Date();
- driver.runTests(config, report);
- test.stats.duration = +new Date() - t0;
- groupEnd();
-}
-
-groupEnd();
-
-function outputStats(name, stats) {
- log(name + ":", stats.testsRun + " tests run in " + stats.duration + "ms; " +
- (stats.failed ? stats.failed + " failures." : "all passed."));
-}
-
-var total = {testsRun: 0, failed: 0, duration: 0};
-
-group("Stats");
-
-for (var i = 0; i < tests.length; i++) {
- var test = tests[i];
- var stats = test.stats;
- outputStats(test.group, stats);
- for (var key in stats) total[key] += stats[key];
-}
-
-outputStats("Total", total);
-
-groupEnd();
-
-if (total.failed && typeof process === "object") {
- process.stdout.write("", function () {
- process.exit(1);
- });
+/******************************************************************************* + * 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 + *******************************************************************************/ +"use strict"; + +var driver = require("./driver.js"); + +function group(name) { + if (typeof console === "object" && console.group) { + console.group(name); + } +} + +function groupEnd() { + if (typeof console === "object" && console.groupEnd) { + console.groupEnd(); + } +} + +function log(title, message) { + if (typeof console === "object") console.log(title, message); +} + +var stats, tests = []; +tests.push(require("./test-scoping.js")); +tests.push(require("./test-finddef.js")); +tests.push(require("./test-completions.js")); +tests.push(require("./test-parse.js")); + +function report(state, code, message) { + if (state != "ok") {++stats.failed; log(code, message);} + ++stats.testsRun; +} + +group("Errors"); + +for (var i = 0; i < tests.length; i++) { + var test = tests[i]; + group(test.group); + stats = test.stats = {testsRun: 0, failed: 0}; + var config = test.config || {}; + config.group = test.group; + var t0 = +new Date(); + driver.runTests(config, report); + test.stats.duration = +new Date() - t0; + groupEnd(); +} + +groupEnd(); + +function outputStats(name, stats) { + log(name + ":", stats.testsRun + " tests run in " + stats.duration + "ms; " + + (stats.failed ? stats.failed + " failures." : "all passed.")); +} + +var total = {testsRun: 0, failed: 0, duration: 0}; + +group("Stats"); + +for (var i = 0; i < tests.length; i++) { + var test = tests[i]; + var stats = test.stats; + outputStats(test.group, stats); + for (var key in stats) total[key] += stats[key]; +} + +outputStats("Total", total); + +groupEnd(); + +if (total.failed && typeof process === "object") { + process.stdout.write("", function () { + process.exit(1); + }); }
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-completions.js b/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-completions.js index 56be852048c..c0198a83392 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-completions.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-completions.js @@ -1,711 +1,711 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-var driver = require("./driver.js");
-var test = driver.test;
-var testCompletion = driver.testCompletion;
-var assertCompletion = driver.assertCompletion;
-var groupStart = driver.groupStart;
-var groupEnd = driver.groupEnd;
-
-var group = exports.group = "Code Completion";
-groupStart(group);
-
-// Local Directory Completions
-testCompletion('My|', {
- start: { line: 0, ch: 0 },
- end: { line: 0, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "MyObject", type: "MyObject", origin: "MyObject.qml" }]
-}, function (server) {
- server.addFile("MyObject.qml", "Button {}");
-});
-
-testCompletion('import "./subdir/"\nSameDirTest {\n\t|\n}', {
- start: { line: 2, ch: 1 },
- end: { line: 2, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "obj", type: "?", origin: "subdir/Button.qml" },
- { name: "Button", type: "Button", origin: "subdir/Button.qml" },
- { name: "SameDirTest", type: "SameDirTest", origin: "subdir/SameDirTest.qml" }
- ]
-}, function (server) {
- server.addFile("subdir/SameDirTest.qml", "Button {}");
- server.addFile("subdir/Button.qml", "QtObject {property var obj}");
-});
-
-testCompletion('MyObject {\n\t|\n}', {
- start: { line: 1, ch: 1 },
- end: { line: 1, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "width", type: "number", origin: "MyObject.qml" },
- { name: "MyObject", type: "MyObject", origin: "MyObject.qml" }
- ]
-}, function (server) {
- server.addFile("MyObject.qml", "Button {\n\tproperty int width\n}");
-});
-
-testCompletion('MyObject {\n\tid: obj\n\ts: obj.|\n}', {
- start: { line: 2, ch: 8 },
- end: { line: 2, ch: 8 },
- isProperty: true,
- isObjectKey: false,
- completions: [{ name: "width", type: "number", origin: "MyObject.qml" }]
-}, function (server) {
- server.addFile("MyObject.qml", "Button {\n\tproperty int width\n}");
-});
-
-testCompletion('Button {\n\t|\n}', {
- start: { line: 1, ch: 1 },
- end: { line: 1, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "onClicked", type: "Signal Handler", origin: "Button.qml" },
- { name: "Button", type: "Button", origin: "Button.qml" }
- ]
-}, function (server) {
- server.addFile("Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}");
-});
-
-testCompletion('CButton {\n\t|\n}', {
- start: { line: 1, ch: 1 },
- end: { line: 1, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "height", type: "number", origin: "Button.qml" },
- { name: "numClicks", type: "number", origin: "CButton.qml" },
- { name: "text", type: "string", origin: "Button.qml" },
- { name: "width", type: "number", origin: "Button.qml" },
- { name: "Button", type: "Button", origin: "Button.qml" },
- { name: "CButton", type: "CButton", origin: "CButton.qml" }
- ]
-}, function (server) {
- server.addFile("CButton.qml", "Button {\n\tproperty int numClicks\n}");
- server.addFile("Button.qml", "QtObject {\n\tproperty string text\n\tproperty int width\n\tproperty int height\n}");
-});
-
-testCompletion('CButton {\n\tid:btn\n\ts: btn.|\n}', {
- start: { line: 2, ch: 8 },
- end: { line: 2, ch: 8 },
- isProperty: true,
- isObjectKey: false,
- completions: [
- { name: "height", type: "number", origin: "Button.qml" },
- { name: "numClicks", type: "number", origin: "CButton.qml" },
- { name: "text", type: "string", origin: "Button.qml" },
- { name: "width", type: "number", origin: "Button.qml" }
- ]
-}, function (server) {
- server.addFile("CButton.qml", "Button {\n\tproperty int numClicks\n}");
- server.addFile("Button.qml", "QtObject {\n\tproperty string text\n\tproperty int width\n\tproperty int height\n}");
-});
-
-// Directory Import Completions
-testCompletion('NotVisible {\n\t|\n}', {
- start: { line: 1, ch: 1 },
- end: { line: 1, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: []
-}, function (server) {
- server.addFile("subdir/NotVisible.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}");
-});
-
-testCompletion('import "./subdir/"\nButton {\n\t|\n}', {
- start: { line: 2, ch: 1 },
- end: { line: 2, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "onClicked", type: "Signal Handler", origin: "subdir/Button.qml" },
- { name: "Button", type: "Button", origin: "subdir/Button.qml" }
- ]
-}, function (server) {
- server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}");
-});
-
-testCompletion('import "./subdir/" as Controls\nControls.Button {\n\t|\n}', {
- start: { line: 2, ch: 1 },
- end: { line: 2, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "onClicked", type: "Signal Handler", origin: "subdir/Button.qml" },
- { name: "Controls", type: "Controls", origin: "main.qml" }
- ]
-}, function (server) {
- server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}");
-});
-
-testCompletion('import "./subdir/" as Controls\nControls.|', {
- start: { line: 1, ch: 9 },
- end: { line: 1, ch: 9 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "Button", type: "Button", origin: "subdir/Button.qml" }
- ]
-}, function (server) {
- server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}");
-});
-
-testCompletion('import "./subdir/" as Controls\nControls.|.', {
- start: { line: 1, ch: 9 },
- end: { line: 1, ch: 9 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "Button", type: "Button", origin: "subdir/Button.qml" }
- ]
-}, function (server) {
- server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}");
-});
-
-testCompletion('import "./subdir/" as Controls\nControls..|', {
- start: { line: 1, ch: 10 },
- end: { line: 1, ch: 10 },
- isProperty: false,
- isObjectKey: false,
- completions: []
-}, function (server) {
- server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}");
-});
-
-test("{Add File After Import}", function (server, callback, name) {
- var failed;
- assertCompletion(server, "", {
- start: { line: 0, ch: 0 },
- end: { line: 0, ch: 0 },
- isProperty: false,
- isObjectKey: false,
- completions: []
- }, 0, function (mis) {
- failed = mis;
- });
- if (failed) {
- return callback("fail", name, "- failed on initial file " + failed);
- }
- server.addFile("MyObject.qml", "QtObject {\n\tproperty var test\n}");
- assertCompletion(server, "", {
- start: { line: 0, ch: 0 },
- end: { line: 0, ch: 0 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "MyObject", type: "MyObject", origin: "MyObject.qml" }]
- }, 0, function (mis) {
- failed = mis;
- });
- if (failed) {
- return callback("fail", name, "- failed after adding file " + failed);
- }
- return callback("ok", name);
-});
-
-// Cyclic Dependency Completions
-testCompletion('Cyclic {\n\t|\n}', {
- start: { line: 1, ch: 1 },
- end: { line: 1, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "test", type: "?", origin: "Cyclic.qml" },
- { name: "Cyclic", type: "Cyclic", origin: "Cyclic.qml" }
- ]
-}, function (server) {
- server.addFile("Cyclic.qml", "Cyclic {\n\property var test\n}");
-});
-
-testCompletion('Cyclic2 {\n\t|\n}', {
- start: { line: 1, ch: 1 },
- end: { line: 1, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "test1", type: "?", origin: "Cyclic2.qml" },
- { name: "test2", type: "?", origin: "OtherCyclic.qml" },
- { name: "Cyclic2", type: "Cyclic2", origin: "Cyclic2.qml" },
- { name: "OtherCyclic", type: "OtherCyclic", origin: "OtherCyclic.qml" }
- ]
-}, function (server) {
- server.addFile("Cyclic2.qml", "OtherCyclic {\n\property var test1\n}");
- server.addFile("OtherCyclic.qml", "Cyclic2 {\n\property var test2\n}");
-});
-
-testCompletion('OtherCyclic {\n\t|\n}', {
- start: { line: 1, ch: 1 },
- end: { line: 1, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "test2", type: "?", origin: "OtherCyclic.qml" },
- { name: "Cyclic", type: "Cyclic", origin: "Cyclic.qml" },
- { name: "OtherCyclic", type: "OtherCyclic", origin: "OtherCyclic.qml" }
- ]
-}, function (server) {
- server.addFile("Cyclic.qml", "OtherCyclic {\n\property var test1\n}");
- server.addFile("OtherCyclic.qml", "Cyclic {\n\property var test2\n}");
-});
-
-// QML Object Property Completions
-testCompletion("Window {\n\tproperty int height\n\the|\n}", {
- start: { line: 2, ch: 1 },
- end: { line: 2, ch: 3 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "height", type: "number", origin: "main.qml" }]
-});
-
-testCompletion("Window {\n\tproperty int height\n\tproperty int width\n\tproperty string text\n\t|\n}", {
- start: { line: 4, ch: 1 },
- end: { line: 4, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "height", type: "number", origin: "main.qml" },
- { name: "text", type: "string", origin: "main.qml" },
- { name: "width", type: "number", origin: "main.qml" }
- ]
-});
-
-testCompletion("Window {\n\tproperty int height\n\tObject {\n\t\t|\n\t}\n}", {
- start: { line: 3, ch: 2 },
- end: { line: 3, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: []
-});
-
-testCompletion("Window {\n\tproperty var prop\n\tfunction test() {\n\t\t|\n\t}\n}", {
- start: { line: 3, ch: 2 },
- end: { line: 3, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "prop", type: "?", origin: "main.qml" },
- { name: "test", type: "fn()", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-// QML ID Property Completions
-testCompletion("Window {\n\tid: btn\n\t|\n}", {
- start: { line: 2, ch: 1 },
- end: { line: 2, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: []
-});
-
-testCompletion("Window {\n\tButton {\n\t\tid: btn\n\t\tproperty int height\n\t}\n\ttest: btn.|\n}", {
- start: { line: 5, ch: 11 },
- end: { line: 5, ch: 11 },
- isProperty: true,
- isObjectKey: false,
- completions: [{ name: "height", type: "number", origin: "main.qml" }]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tproperty var btn\n\tButton {\n\t\tid: btn\n\t\tproperty int height\n\t}\n\ttest: btn.|\n}", {
- start: { line: 6, ch: 11 },
- end: { line: 6, ch: 11 },
- isProperty: true,
- isObjectKey: false,
- completions: [{ name: "height", type: "number", origin: "main.qml" }]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tButton {\n\t\tproperty var id\n\t\tid: btn\n\t}\n\ts: bt|\n}", {
- start: { line: 5, ch: 4 },
- end: { line: 5, ch: 6 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "btn", type: "Button", origin: "main.qml" }]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tButton {\n\t\tproperty var id\n\t\tid: btn\n\t\ts: i|\n\t}\n}", {
- start: { line: 4, ch: 5 },
- end: { line: 4, ch: 6 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "id", type: "?", origin: "main.qml" }]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tButton {\n\t\tproperty var id: 34\n\t\tid: btn\n\t\ts: i|\n\t}\n}", {
- start: { line: 4, ch: 5 },
- end: { line: 4, ch: 6 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "id", type: "number", origin: "main.qml" }]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tButton {\n\t\tproperty string id\n\t\tid: btn\n\t\ts: i|\n\t}\n}", {
- start: { line: 4, ch: 5 },
- end: { line: 4, ch: 6 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "id", type: "string", origin: "main.qml" }]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tButton {\n\t\tproperty var id\n\t\ts: i|\n\t}\n}", {
- start: { line: 3, ch: 5 },
- end: { line: 3, ch: 6 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "id", type: "?", origin: "main.qml" }]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tButton {\n\t\tproperty var id: 34\n\t\ts: i|\n\t}\n}", {
- start: { line: 3, ch: 5 },
- end: { line: 3, ch: 6 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "id", type: "number", origin: "main.qml" }]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tButton {\n\t\tproperty string id\n\t\ts: i|\n\t}\n}", {
- start: { line: 3, ch: 5 },
- end: { line: 3, ch: 6 },
- isProperty: false,
- isObjectKey: false,
- completions: [{ name: "id", type: "string", origin: "main.qml" }]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tid: wind\n\tfunction test() {\n\t\t|\n\t}\n}", {
- start: { line: 3, ch: 2 },
- end: { line: 3, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "test", type: "fn()", origin: "main.qml" },
- { name: "wind", type: "Window", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-// JavaScript Completions
-testCompletion("Window {\n\tproperty var test: |\n}", {
- start: { line: 1, ch: 20 },
- end: { line: 1, ch: 20 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "decodeURI", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "decodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "encodeURI", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "encodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "eval", type: "fn(code: string)", origin: "ecma5" },
- { name: "isFinite", type: "fn(value: number) -> bool", origin: "ecma5" },
- { name: "isNaN", type: "fn(value: number) -> bool", origin: "ecma5" },
- { name: "parseFloat", type: "fn(string: string) -> number", origin: "ecma5" },
- { name: "parseInt", type: "fn(string: string, radix?: number) -> number", origin: "ecma5" },
- { name: "test", type: "?", origin: "main.qml" },
- { name: "undefined", type: "?", origin: "ecma5" },
- { name: "Array", type: "fn(size: number)", origin: "ecma5" },
- { name: "Boolean", type: "fn(value: ?) -> bool", origin: "ecma5" },
- { name: "Date", type: "fn(ms: number)", origin: "ecma5" },
- { name: "Error", type: "fn(message: string)", origin: "ecma5" },
- { name: "EvalError", type: "fn(message: string)", origin: "ecma5" },
- { name: "Function", type: "fn(body: string) -> fn()", origin: "ecma5" },
- { name: "Infinity", type: "number", origin: "ecma5" },
- { name: "JSON", type: "JSON", origin: "ecma5" },
- { name: "Math", type: "Math", origin: "ecma5" },
- { name: "NaN", type: "number", origin: "ecma5" },
- { name: "Number", type: "fn(value: ?) -> number", origin: "ecma5" },
- { name: "Object", type: "fn()", origin: "ecma5" },
- { name: "RangeError", type: "fn(message: string)", origin: "ecma5" },
- { name: "ReferenceError", type: "fn(message: string)", origin: "ecma5" },
- { name: "RegExp", type: "fn(source: string, flags?: string)", origin: "ecma5" },
- { name: "String", type: "fn(value: ?) -> string", origin: "ecma5" },
- { name: "SyntaxError", type: "fn(message: string)", origin: "ecma5" },
- { name: "TypeError", type: "fn(message: string)", origin: "ecma5" },
- { name: "URIError", type: "fn(message: string)", origin: "ecma5" }
- ]
-});
-
-testCompletion("Window {\n\ttest: |\n}", {
- start: { line: 1, ch: 7 },
- end: { line: 1, ch: 7 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "decodeURI", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "decodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "encodeURI", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "encodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "eval", type: "fn(code: string)", origin: "ecma5" },
- { name: "isFinite", type: "fn(value: number) -> bool", origin: "ecma5" },
- { name: "isNaN", type: "fn(value: number) -> bool", origin: "ecma5" },
- { name: "parseFloat", type: "fn(string: string) -> number", origin: "ecma5" },
- { name: "parseInt", type: "fn(string: string, radix?: number) -> number", origin: "ecma5" },
- { name: "undefined", type: "?", origin: "ecma5" },
- { name: "Array", type: "fn(size: number)", origin: "ecma5" },
- { name: "Boolean", type: "fn(value: ?) -> bool", origin: "ecma5" },
- { name: "Date", type: "fn(ms: number)", origin: "ecma5" },
- { name: "Error", type: "fn(message: string)", origin: "ecma5" },
- { name: "EvalError", type: "fn(message: string)", origin: "ecma5" },
- { name: "Function", type: "fn(body: string) -> fn()", origin: "ecma5" },
- { name: "Infinity", type: "number", origin: "ecma5" },
- { name: "JSON", type: "JSON", origin: "ecma5" },
- { name: "Math", type: "Math", origin: "ecma5" },
- { name: "NaN", type: "number", origin: "ecma5" },
- { name: "Number", type: "fn(value: ?) -> number", origin: "ecma5" },
- { name: "Object", type: "fn()", origin: "ecma5" },
- { name: "RangeError", type: "fn(message: string)", origin: "ecma5" },
- { name: "ReferenceError", type: "fn(message: string)", origin: "ecma5" },
- { name: "RegExp", type: "fn(source: string, flags?: string)", origin: "ecma5" },
- { name: "String", type: "fn(value: ?) -> string", origin: "ecma5" },
- { name: "SyntaxError", type: "fn(message: string)", origin: "ecma5" },
- { name: "TypeError", type: "fn(message: string)", origin: "ecma5" },
- { name: "URIError", type: "fn(message: string)", origin: "ecma5" }
- ]
-});
-
-testCompletion("Window {\n\ttest: {\n\t\t|\n\t}\n}", {
- start: { line: 2, ch: 2 },
- end: { line: 2, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "decodeURI", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "decodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "encodeURI", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "encodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "eval", type: "fn(code: string)", origin: "ecma5" },
- { name: "isFinite", type: "fn(value: number) -> bool", origin: "ecma5" },
- { name: "isNaN", type: "fn(value: number) -> bool", origin: "ecma5" },
- { name: "parseFloat", type: "fn(string: string) -> number", origin: "ecma5" },
- { name: "parseInt", type: "fn(string: string, radix?: number) -> number", origin: "ecma5" },
- { name: "undefined", type: "?", origin: "ecma5" },
- { name: "Array", type: "fn(size: number)", origin: "ecma5" },
- { name: "Boolean", type: "fn(value: ?) -> bool", origin: "ecma5" },
- { name: "Date", type: "fn(ms: number)", origin: "ecma5" },
- { name: "Error", type: "fn(message: string)", origin: "ecma5" },
- { name: "EvalError", type: "fn(message: string)", origin: "ecma5" },
- { name: "Function", type: "fn(body: string) -> fn()", origin: "ecma5" },
- { name: "Infinity", type: "number", origin: "ecma5" },
- { name: "JSON", type: "JSON", origin: "ecma5" },
- { name: "Math", type: "Math", origin: "ecma5" },
- { name: "NaN", type: "number", origin: "ecma5" },
- { name: "Number", type: "fn(value: ?) -> number", origin: "ecma5" },
- { name: "Object", type: "fn()", origin: "ecma5" },
- { name: "RangeError", type: "fn(message: string)", origin: "ecma5" },
- { name: "ReferenceError", type: "fn(message: string)", origin: "ecma5" },
- { name: "RegExp", type: "fn(source: string, flags?: string)", origin: "ecma5" },
- { name: "String", type: "fn(value: ?) -> string", origin: "ecma5" },
- { name: "SyntaxError", type: "fn(message: string)", origin: "ecma5" },
- { name: "TypeError", type: "fn(message: string)", origin: "ecma5" },
- { name: "URIError", type: "fn(message: string)", origin: "ecma5" }
- ]
-});
-
-testCompletion("Window {\n\tfunction test() {\n\t\t|\n\t}\n}", {
- start: { line: 2, ch: 2 },
- end: { line: 2, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "decodeURI", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "decodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "encodeURI", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "encodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" },
- { name: "eval", type: "fn(code: string)", origin: "ecma5" },
- { name: "isFinite", type: "fn(value: number) -> bool", origin: "ecma5" },
- { name: "isNaN", type: "fn(value: number) -> bool", origin: "ecma5" },
- { name: "parseFloat", type: "fn(string: string) -> number", origin: "ecma5" },
- { name: "parseInt", type: "fn(string: string, radix?: number) -> number", origin: "ecma5" },
- { name: "test", type: "fn()", origin: "main.qml" },
- { name: "undefined", type: "?", origin: "ecma5" },
- { name: "Array", type: "fn(size: number)", origin: "ecma5" },
- { name: "Boolean", type: "fn(value: ?) -> bool", origin: "ecma5" },
- { name: "Date", type: "fn(ms: number)", origin: "ecma5" },
- { name: "Error", type: "fn(message: string)", origin: "ecma5" },
- { name: "EvalError", type: "fn(message: string)", origin: "ecma5" },
- { name: "Function", type: "fn(body: string) -> fn()", origin: "ecma5" },
- { name: "Infinity", type: "number", origin: "ecma5" },
- { name: "JSON", type: "JSON", origin: "ecma5" },
- { name: "Math", type: "Math", origin: "ecma5" },
- { name: "NaN", type: "number", origin: "ecma5" },
- { name: "Number", type: "fn(value: ?) -> number", origin: "ecma5" },
- { name: "Object", type: "fn()", origin: "ecma5" },
- { name: "RangeError", type: "fn(message: string)", origin: "ecma5" },
- { name: "ReferenceError", type: "fn(message: string)", origin: "ecma5" },
- { name: "RegExp", type: "fn(source: string, flags?: string)", origin: "ecma5" },
- { name: "String", type: "fn(value: ?) -> string", origin: "ecma5" },
- { name: "SyntaxError", type: "fn(message: string)", origin: "ecma5" },
- { name: "TypeError", type: "fn(message: string)", origin: "ecma5" },
- { name: "URIError", type: "fn(message: string)", origin: "ecma5" }
- ]
-});
-
-// Signal and Signal Handler Completions
-testCompletion("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\t|\n}", {
- start: { line: 2, ch: 1 },
- end: { line: 2, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "onClicked", type: "Signal Handler", origin: "main.qml" }
- ]
-});
-
-testCompletion("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tButton {\n\t\t|\n\t}\n}", {
- start: { line: 3, ch: 2 },
- end: { line: 3, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: []
-});
-
-testCompletion("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\ts: |\n}", {
- start: { line: 2, ch: 4 },
- end: { line: 2, ch: 4 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "clicked", type: "fn(mouseX: number, mouseY: number)", origin: "main.qml" },
- { name: "onClicked", type: "Signal Handler", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tsignal error(string msg, boolean flag)\n\ts: |\n}", {
- start: { line: 2, ch: 4 },
- end: { line: 2, ch: 4 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" },
- { name: "onError", type: "Signal Handler", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tid: wind\n\tsignal error(string msg, boolean flag)\n\ts: wind.|\n}", {
- start: { line: 3, ch: 9 },
- end: { line: 3, ch: 9 },
- isProperty: true,
- isObjectKey: false,
- completions: [
- { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" },
- { name: "onError", type: "Signal Handler", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tsignal error(string msg, boolean flag)\n\tonError: |\n}", {
- start: { line: 2, ch: 10 },
- end: { line: 2, ch: 10 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" },
- { name: "flag", type: "bool", origin: "main.qml" },
- { name: "msg", type: "string", origin: "main.qml" },
- { name: "onError", type: "Signal Handler", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tsignal error(string msg, boolean flag)\n\tonError: {\n\t\t|\n\t}\n}", {
- start: { line: 3, ch: 2 },
- end: { line: 3, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" },
- { name: "flag", type: "bool", origin: "main.qml" },
- { name: "msg", type: "string", origin: "main.qml" },
- { name: "onError", type: "Signal Handler", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tproperty int msg\n\tsignal error(string msg, boolean flag)\n\tonError: {\n\t\t|\n\t}\n}", {
- start: { line: 4, ch: 2 },
- end: { line: 4, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" },
- { name: "flag", type: "bool", origin: "main.qml" },
- { name: "msg", type: "string", origin: "main.qml" },
- { name: "onError", type: "Signal Handler", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-// Function Declarations
-testCompletion("Window {\n\tfunction test() {}\n\t|\n}", {
- start: { line: 2, ch: 1 },
- end: { line: 2, ch: 1 },
- isProperty: false,
- isObjectKey: false,
- completions: []
-});
-
-testCompletion("Window {\n\tfunction test(a, b, c) {\n\t\t|\n\t}\n}", {
- start: { line: 2, ch: 2 },
- end: { line: 2, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "a", type: "?", origin: "main.qml" },
- { name: "b", type: "?", origin: "main.qml" },
- { name: "c", type: "?", origin: "main.qml" },
- { name: "test", type: "fn(a: ?, b: ?, c: ?)", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion("Window {\n\tfunction test(a) {\n\t\ta = 3\n\t\t|\n\t}\n}", {
- start: { line: 3, ch: 2 },
- end: { line: 3, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "a", type: "number", origin: "main.qml" },
- { name: "test", type: "fn(a: number)", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion('Window {\n\tfunction test(a) {\n\t\ttest("something")\n\t\t|\n\t}\n}', {
- start: { line: 3, ch: 2 },
- end: { line: 3, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "a", type: "string", origin: "main.qml" },
- { name: "test", type: "fn(a: string)", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-testCompletion('Window {\n\tfunction test(a) {\n\t\t|\n\t\treturn 7\n\t}\n}', {
- start: { line: 2, ch: 2 },
- end: { line: 2, ch: 2 },
- isProperty: false,
- isObjectKey: false,
- completions: [
- { name: "a", type: "?", origin: "main.qml" },
- { name: "test", type: "fn(a: ?) -> number", origin: "main.qml" }
- ]
-}, function (server) { server.jsDefs = []; });
-
-// TODO: Uncomment once this is fixed. The find defs version of this test does find the right definition
-// so it seems the problem is related to Tern and not the QML plugin.
-//testCompletion('Window {\n\tproperty int a\n\tfunction test(a) {\n\t\t|\n\t}\n}', {
-// start: { line: 3, ch: 2 },
-// end: { line: 3, ch: 2 },
-// isProperty: false,
-// isObjectKey: false,
-// completions: [
-// { name: "a", type: "?", origin: "main.qml" },
-// { name: "test", type: "fn()", origin: "main.qml" }
-// ]
-//}, function (server) { server.jsDefs = []; });
-
+/******************************************************************************* + * 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 + *******************************************************************************/ +"use strict"; + +var driver = require("./driver.js"); +var test = driver.test; +var testCompletion = driver.testCompletion; +var assertCompletion = driver.assertCompletion; +var groupStart = driver.groupStart; +var groupEnd = driver.groupEnd; + +var group = exports.group = "Code Completion"; +groupStart(group); + +// Local Directory Completions +testCompletion('My|', { + start: { line: 0, ch: 0 }, + end: { line: 0, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "MyObject", type: "MyObject", origin: "MyObject.qml" }] +}, function (server) { + server.addFile("MyObject.qml", "Button {}"); +}); + +testCompletion('import "./subdir/"\nSameDirTest {\n\t|\n}', { + start: { line: 2, ch: 1 }, + end: { line: 2, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "obj", type: "?", origin: "subdir/Button.qml" }, + { name: "Button", type: "Button", origin: "subdir/Button.qml" }, + { name: "SameDirTest", type: "SameDirTest", origin: "subdir/SameDirTest.qml" } + ] +}, function (server) { + server.addFile("subdir/SameDirTest.qml", "Button {}"); + server.addFile("subdir/Button.qml", "QtObject {property var obj}"); +}); + +testCompletion('MyObject {\n\t|\n}', { + start: { line: 1, ch: 1 }, + end: { line: 1, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "width", type: "number", origin: "MyObject.qml" }, + { name: "MyObject", type: "MyObject", origin: "MyObject.qml" } + ] +}, function (server) { + server.addFile("MyObject.qml", "Button {\n\tproperty int width\n}"); +}); + +testCompletion('MyObject {\n\tid: obj\n\ts: obj.|\n}', { + start: { line: 2, ch: 8 }, + end: { line: 2, ch: 8 }, + isProperty: true, + isObjectKey: false, + completions: [{ name: "width", type: "number", origin: "MyObject.qml" }] +}, function (server) { + server.addFile("MyObject.qml", "Button {\n\tproperty int width\n}"); +}); + +testCompletion('Button {\n\t|\n}', { + start: { line: 1, ch: 1 }, + end: { line: 1, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "onClicked", type: "Signal Handler", origin: "Button.qml" }, + { name: "Button", type: "Button", origin: "Button.qml" } + ] +}, function (server) { + server.addFile("Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}"); +}); + +testCompletion('CButton {\n\t|\n}', { + start: { line: 1, ch: 1 }, + end: { line: 1, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "height", type: "number", origin: "Button.qml" }, + { name: "numClicks", type: "number", origin: "CButton.qml" }, + { name: "text", type: "string", origin: "Button.qml" }, + { name: "width", type: "number", origin: "Button.qml" }, + { name: "Button", type: "Button", origin: "Button.qml" }, + { name: "CButton", type: "CButton", origin: "CButton.qml" } + ] +}, function (server) { + server.addFile("CButton.qml", "Button {\n\tproperty int numClicks\n}"); + server.addFile("Button.qml", "QtObject {\n\tproperty string text\n\tproperty int width\n\tproperty int height\n}"); +}); + +testCompletion('CButton {\n\tid:btn\n\ts: btn.|\n}', { + start: { line: 2, ch: 8 }, + end: { line: 2, ch: 8 }, + isProperty: true, + isObjectKey: false, + completions: [ + { name: "height", type: "number", origin: "Button.qml" }, + { name: "numClicks", type: "number", origin: "CButton.qml" }, + { name: "text", type: "string", origin: "Button.qml" }, + { name: "width", type: "number", origin: "Button.qml" } + ] +}, function (server) { + server.addFile("CButton.qml", "Button {\n\tproperty int numClicks\n}"); + server.addFile("Button.qml", "QtObject {\n\tproperty string text\n\tproperty int width\n\tproperty int height\n}"); +}); + +// Directory Import Completions +testCompletion('NotVisible {\n\t|\n}', { + start: { line: 1, ch: 1 }, + end: { line: 1, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [] +}, function (server) { + server.addFile("subdir/NotVisible.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}"); +}); + +testCompletion('import "./subdir/"\nButton {\n\t|\n}', { + start: { line: 2, ch: 1 }, + end: { line: 2, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "onClicked", type: "Signal Handler", origin: "subdir/Button.qml" }, + { name: "Button", type: "Button", origin: "subdir/Button.qml" } + ] +}, function (server) { + server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}"); +}); + +testCompletion('import "./subdir/" as Controls\nControls.Button {\n\t|\n}', { + start: { line: 2, ch: 1 }, + end: { line: 2, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "onClicked", type: "Signal Handler", origin: "subdir/Button.qml" }, + { name: "Controls", type: "Controls", origin: "main.qml" } + ] +}, function (server) { + server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}"); +}); + +testCompletion('import "./subdir/" as Controls\nControls.|', { + start: { line: 1, ch: 9 }, + end: { line: 1, ch: 9 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "Button", type: "Button", origin: "subdir/Button.qml" } + ] +}, function (server) { + server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}"); +}); + +testCompletion('import "./subdir/" as Controls\nControls.|.', { + start: { line: 1, ch: 9 }, + end: { line: 1, ch: 9 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "Button", type: "Button", origin: "subdir/Button.qml" } + ] +}, function (server) { + server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}"); +}); + +testCompletion('import "./subdir/" as Controls\nControls..|', { + start: { line: 1, ch: 10 }, + end: { line: 1, ch: 10 }, + isProperty: false, + isObjectKey: false, + completions: [] +}, function (server) { + server.addFile("subdir/Button.qml", "QtObject {\n\signal clicked(int mouseX, int mouseY)\n}"); +}); + +test("{Add File After Import}", function (server, callback, name) { + var failed; + assertCompletion(server, "", { + start: { line: 0, ch: 0 }, + end: { line: 0, ch: 0 }, + isProperty: false, + isObjectKey: false, + completions: [] + }, 0, function (mis) { + failed = mis; + }); + if (failed) { + return callback("fail", name, "- failed on initial file " + failed); + } + server.addFile("MyObject.qml", "QtObject {\n\tproperty var test\n}"); + assertCompletion(server, "", { + start: { line: 0, ch: 0 }, + end: { line: 0, ch: 0 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "MyObject", type: "MyObject", origin: "MyObject.qml" }] + }, 0, function (mis) { + failed = mis; + }); + if (failed) { + return callback("fail", name, "- failed after adding file " + failed); + } + return callback("ok", name); +}); + +// Cyclic Dependency Completions +testCompletion('Cyclic {\n\t|\n}', { + start: { line: 1, ch: 1 }, + end: { line: 1, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "test", type: "?", origin: "Cyclic.qml" }, + { name: "Cyclic", type: "Cyclic", origin: "Cyclic.qml" } + ] +}, function (server) { + server.addFile("Cyclic.qml", "Cyclic {\n\property var test\n}"); +}); + +testCompletion('Cyclic2 {\n\t|\n}', { + start: { line: 1, ch: 1 }, + end: { line: 1, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "test1", type: "?", origin: "Cyclic2.qml" }, + { name: "test2", type: "?", origin: "OtherCyclic.qml" }, + { name: "Cyclic2", type: "Cyclic2", origin: "Cyclic2.qml" }, + { name: "OtherCyclic", type: "OtherCyclic", origin: "OtherCyclic.qml" } + ] +}, function (server) { + server.addFile("Cyclic2.qml", "OtherCyclic {\n\property var test1\n}"); + server.addFile("OtherCyclic.qml", "Cyclic2 {\n\property var test2\n}"); +}); + +testCompletion('OtherCyclic {\n\t|\n}', { + start: { line: 1, ch: 1 }, + end: { line: 1, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "test2", type: "?", origin: "OtherCyclic.qml" }, + { name: "Cyclic", type: "Cyclic", origin: "Cyclic.qml" }, + { name: "OtherCyclic", type: "OtherCyclic", origin: "OtherCyclic.qml" } + ] +}, function (server) { + server.addFile("Cyclic.qml", "OtherCyclic {\n\property var test1\n}"); + server.addFile("OtherCyclic.qml", "Cyclic {\n\property var test2\n}"); +}); + +// QML Object Property Completions +testCompletion("Window {\n\tproperty int height\n\the|\n}", { + start: { line: 2, ch: 1 }, + end: { line: 2, ch: 3 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "height", type: "number", origin: "main.qml" }] +}); + +testCompletion("Window {\n\tproperty int height\n\tproperty int width\n\tproperty string text\n\t|\n}", { + start: { line: 4, ch: 1 }, + end: { line: 4, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "height", type: "number", origin: "main.qml" }, + { name: "text", type: "string", origin: "main.qml" }, + { name: "width", type: "number", origin: "main.qml" } + ] +}); + +testCompletion("Window {\n\tproperty int height\n\tObject {\n\t\t|\n\t}\n}", { + start: { line: 3, ch: 2 }, + end: { line: 3, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [] +}); + +testCompletion("Window {\n\tproperty var prop\n\tfunction test() {\n\t\t|\n\t}\n}", { + start: { line: 3, ch: 2 }, + end: { line: 3, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "prop", type: "?", origin: "main.qml" }, + { name: "test", type: "fn()", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +// QML ID Property Completions +testCompletion("Window {\n\tid: btn\n\t|\n}", { + start: { line: 2, ch: 1 }, + end: { line: 2, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [] +}); + +testCompletion("Window {\n\tButton {\n\t\tid: btn\n\t\tproperty int height\n\t}\n\ttest: btn.|\n}", { + start: { line: 5, ch: 11 }, + end: { line: 5, ch: 11 }, + isProperty: true, + isObjectKey: false, + completions: [{ name: "height", type: "number", origin: "main.qml" }] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tproperty var btn\n\tButton {\n\t\tid: btn\n\t\tproperty int height\n\t}\n\ttest: btn.|\n}", { + start: { line: 6, ch: 11 }, + end: { line: 6, ch: 11 }, + isProperty: true, + isObjectKey: false, + completions: [{ name: "height", type: "number", origin: "main.qml" }] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tButton {\n\t\tproperty var id\n\t\tid: btn\n\t}\n\ts: bt|\n}", { + start: { line: 5, ch: 4 }, + end: { line: 5, ch: 6 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "btn", type: "Button", origin: "main.qml" }] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tButton {\n\t\tproperty var id\n\t\tid: btn\n\t\ts: i|\n\t}\n}", { + start: { line: 4, ch: 5 }, + end: { line: 4, ch: 6 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "id", type: "?", origin: "main.qml" }] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tButton {\n\t\tproperty var id: 34\n\t\tid: btn\n\t\ts: i|\n\t}\n}", { + start: { line: 4, ch: 5 }, + end: { line: 4, ch: 6 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "id", type: "number", origin: "main.qml" }] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tButton {\n\t\tproperty string id\n\t\tid: btn\n\t\ts: i|\n\t}\n}", { + start: { line: 4, ch: 5 }, + end: { line: 4, ch: 6 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "id", type: "string", origin: "main.qml" }] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tButton {\n\t\tproperty var id\n\t\ts: i|\n\t}\n}", { + start: { line: 3, ch: 5 }, + end: { line: 3, ch: 6 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "id", type: "?", origin: "main.qml" }] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tButton {\n\t\tproperty var id: 34\n\t\ts: i|\n\t}\n}", { + start: { line: 3, ch: 5 }, + end: { line: 3, ch: 6 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "id", type: "number", origin: "main.qml" }] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tButton {\n\t\tproperty string id\n\t\ts: i|\n\t}\n}", { + start: { line: 3, ch: 5 }, + end: { line: 3, ch: 6 }, + isProperty: false, + isObjectKey: false, + completions: [{ name: "id", type: "string", origin: "main.qml" }] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tid: wind\n\tfunction test() {\n\t\t|\n\t}\n}", { + start: { line: 3, ch: 2 }, + end: { line: 3, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "test", type: "fn()", origin: "main.qml" }, + { name: "wind", type: "Window", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +// JavaScript Completions +testCompletion("Window {\n\tproperty var test: |\n}", { + start: { line: 1, ch: 20 }, + end: { line: 1, ch: 20 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "decodeURI", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "decodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "encodeURI", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "encodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "eval", type: "fn(code: string)", origin: "ecma5" }, + { name: "isFinite", type: "fn(value: number) -> bool", origin: "ecma5" }, + { name: "isNaN", type: "fn(value: number) -> bool", origin: "ecma5" }, + { name: "parseFloat", type: "fn(string: string) -> number", origin: "ecma5" }, + { name: "parseInt", type: "fn(string: string, radix?: number) -> number", origin: "ecma5" }, + { name: "test", type: "?", origin: "main.qml" }, + { name: "undefined", type: "?", origin: "ecma5" }, + { name: "Array", type: "fn(size: number)", origin: "ecma5" }, + { name: "Boolean", type: "fn(value: ?) -> bool", origin: "ecma5" }, + { name: "Date", type: "fn(ms: number)", origin: "ecma5" }, + { name: "Error", type: "fn(message: string)", origin: "ecma5" }, + { name: "EvalError", type: "fn(message: string)", origin: "ecma5" }, + { name: "Function", type: "fn(body: string) -> fn()", origin: "ecma5" }, + { name: "Infinity", type: "number", origin: "ecma5" }, + { name: "JSON", type: "JSON", origin: "ecma5" }, + { name: "Math", type: "Math", origin: "ecma5" }, + { name: "NaN", type: "number", origin: "ecma5" }, + { name: "Number", type: "fn(value: ?) -> number", origin: "ecma5" }, + { name: "Object", type: "fn()", origin: "ecma5" }, + { name: "RangeError", type: "fn(message: string)", origin: "ecma5" }, + { name: "ReferenceError", type: "fn(message: string)", origin: "ecma5" }, + { name: "RegExp", type: "fn(source: string, flags?: string)", origin: "ecma5" }, + { name: "String", type: "fn(value: ?) -> string", origin: "ecma5" }, + { name: "SyntaxError", type: "fn(message: string)", origin: "ecma5" }, + { name: "TypeError", type: "fn(message: string)", origin: "ecma5" }, + { name: "URIError", type: "fn(message: string)", origin: "ecma5" } + ] +}); + +testCompletion("Window {\n\ttest: |\n}", { + start: { line: 1, ch: 7 }, + end: { line: 1, ch: 7 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "decodeURI", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "decodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "encodeURI", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "encodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "eval", type: "fn(code: string)", origin: "ecma5" }, + { name: "isFinite", type: "fn(value: number) -> bool", origin: "ecma5" }, + { name: "isNaN", type: "fn(value: number) -> bool", origin: "ecma5" }, + { name: "parseFloat", type: "fn(string: string) -> number", origin: "ecma5" }, + { name: "parseInt", type: "fn(string: string, radix?: number) -> number", origin: "ecma5" }, + { name: "undefined", type: "?", origin: "ecma5" }, + { name: "Array", type: "fn(size: number)", origin: "ecma5" }, + { name: "Boolean", type: "fn(value: ?) -> bool", origin: "ecma5" }, + { name: "Date", type: "fn(ms: number)", origin: "ecma5" }, + { name: "Error", type: "fn(message: string)", origin: "ecma5" }, + { name: "EvalError", type: "fn(message: string)", origin: "ecma5" }, + { name: "Function", type: "fn(body: string) -> fn()", origin: "ecma5" }, + { name: "Infinity", type: "number", origin: "ecma5" }, + { name: "JSON", type: "JSON", origin: "ecma5" }, + { name: "Math", type: "Math", origin: "ecma5" }, + { name: "NaN", type: "number", origin: "ecma5" }, + { name: "Number", type: "fn(value: ?) -> number", origin: "ecma5" }, + { name: "Object", type: "fn()", origin: "ecma5" }, + { name: "RangeError", type: "fn(message: string)", origin: "ecma5" }, + { name: "ReferenceError", type: "fn(message: string)", origin: "ecma5" }, + { name: "RegExp", type: "fn(source: string, flags?: string)", origin: "ecma5" }, + { name: "String", type: "fn(value: ?) -> string", origin: "ecma5" }, + { name: "SyntaxError", type: "fn(message: string)", origin: "ecma5" }, + { name: "TypeError", type: "fn(message: string)", origin: "ecma5" }, + { name: "URIError", type: "fn(message: string)", origin: "ecma5" } + ] +}); + +testCompletion("Window {\n\ttest: {\n\t\t|\n\t}\n}", { + start: { line: 2, ch: 2 }, + end: { line: 2, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "decodeURI", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "decodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "encodeURI", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "encodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "eval", type: "fn(code: string)", origin: "ecma5" }, + { name: "isFinite", type: "fn(value: number) -> bool", origin: "ecma5" }, + { name: "isNaN", type: "fn(value: number) -> bool", origin: "ecma5" }, + { name: "parseFloat", type: "fn(string: string) -> number", origin: "ecma5" }, + { name: "parseInt", type: "fn(string: string, radix?: number) -> number", origin: "ecma5" }, + { name: "undefined", type: "?", origin: "ecma5" }, + { name: "Array", type: "fn(size: number)", origin: "ecma5" }, + { name: "Boolean", type: "fn(value: ?) -> bool", origin: "ecma5" }, + { name: "Date", type: "fn(ms: number)", origin: "ecma5" }, + { name: "Error", type: "fn(message: string)", origin: "ecma5" }, + { name: "EvalError", type: "fn(message: string)", origin: "ecma5" }, + { name: "Function", type: "fn(body: string) -> fn()", origin: "ecma5" }, + { name: "Infinity", type: "number", origin: "ecma5" }, + { name: "JSON", type: "JSON", origin: "ecma5" }, + { name: "Math", type: "Math", origin: "ecma5" }, + { name: "NaN", type: "number", origin: "ecma5" }, + { name: "Number", type: "fn(value: ?) -> number", origin: "ecma5" }, + { name: "Object", type: "fn()", origin: "ecma5" }, + { name: "RangeError", type: "fn(message: string)", origin: "ecma5" }, + { name: "ReferenceError", type: "fn(message: string)", origin: "ecma5" }, + { name: "RegExp", type: "fn(source: string, flags?: string)", origin: "ecma5" }, + { name: "String", type: "fn(value: ?) -> string", origin: "ecma5" }, + { name: "SyntaxError", type: "fn(message: string)", origin: "ecma5" }, + { name: "TypeError", type: "fn(message: string)", origin: "ecma5" }, + { name: "URIError", type: "fn(message: string)", origin: "ecma5" } + ] +}); + +testCompletion("Window {\n\tfunction test() {\n\t\t|\n\t}\n}", { + start: { line: 2, ch: 2 }, + end: { line: 2, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "decodeURI", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "decodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "encodeURI", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "encodeURIComponent", type: "fn(uri: string) -> string", origin: "ecma5" }, + { name: "eval", type: "fn(code: string)", origin: "ecma5" }, + { name: "isFinite", type: "fn(value: number) -> bool", origin: "ecma5" }, + { name: "isNaN", type: "fn(value: number) -> bool", origin: "ecma5" }, + { name: "parseFloat", type: "fn(string: string) -> number", origin: "ecma5" }, + { name: "parseInt", type: "fn(string: string, radix?: number) -> number", origin: "ecma5" }, + { name: "test", type: "fn()", origin: "main.qml" }, + { name: "undefined", type: "?", origin: "ecma5" }, + { name: "Array", type: "fn(size: number)", origin: "ecma5" }, + { name: "Boolean", type: "fn(value: ?) -> bool", origin: "ecma5" }, + { name: "Date", type: "fn(ms: number)", origin: "ecma5" }, + { name: "Error", type: "fn(message: string)", origin: "ecma5" }, + { name: "EvalError", type: "fn(message: string)", origin: "ecma5" }, + { name: "Function", type: "fn(body: string) -> fn()", origin: "ecma5" }, + { name: "Infinity", type: "number", origin: "ecma5" }, + { name: "JSON", type: "JSON", origin: "ecma5" }, + { name: "Math", type: "Math", origin: "ecma5" }, + { name: "NaN", type: "number", origin: "ecma5" }, + { name: "Number", type: "fn(value: ?) -> number", origin: "ecma5" }, + { name: "Object", type: "fn()", origin: "ecma5" }, + { name: "RangeError", type: "fn(message: string)", origin: "ecma5" }, + { name: "ReferenceError", type: "fn(message: string)", origin: "ecma5" }, + { name: "RegExp", type: "fn(source: string, flags?: string)", origin: "ecma5" }, + { name: "String", type: "fn(value: ?) -> string", origin: "ecma5" }, + { name: "SyntaxError", type: "fn(message: string)", origin: "ecma5" }, + { name: "TypeError", type: "fn(message: string)", origin: "ecma5" }, + { name: "URIError", type: "fn(message: string)", origin: "ecma5" } + ] +}); + +// Signal and Signal Handler Completions +testCompletion("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\t|\n}", { + start: { line: 2, ch: 1 }, + end: { line: 2, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "onClicked", type: "Signal Handler", origin: "main.qml" } + ] +}); + +testCompletion("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tButton {\n\t\t|\n\t}\n}", { + start: { line: 3, ch: 2 }, + end: { line: 3, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [] +}); + +testCompletion("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\ts: |\n}", { + start: { line: 2, ch: 4 }, + end: { line: 2, ch: 4 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "clicked", type: "fn(mouseX: number, mouseY: number)", origin: "main.qml" }, + { name: "onClicked", type: "Signal Handler", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tsignal error(string msg, boolean flag)\n\ts: |\n}", { + start: { line: 2, ch: 4 }, + end: { line: 2, ch: 4 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" }, + { name: "onError", type: "Signal Handler", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tid: wind\n\tsignal error(string msg, boolean flag)\n\ts: wind.|\n}", { + start: { line: 3, ch: 9 }, + end: { line: 3, ch: 9 }, + isProperty: true, + isObjectKey: false, + completions: [ + { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" }, + { name: "onError", type: "Signal Handler", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tsignal error(string msg, boolean flag)\n\tonError: |\n}", { + start: { line: 2, ch: 10 }, + end: { line: 2, ch: 10 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" }, + { name: "flag", type: "bool", origin: "main.qml" }, + { name: "msg", type: "string", origin: "main.qml" }, + { name: "onError", type: "Signal Handler", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tsignal error(string msg, boolean flag)\n\tonError: {\n\t\t|\n\t}\n}", { + start: { line: 3, ch: 2 }, + end: { line: 3, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" }, + { name: "flag", type: "bool", origin: "main.qml" }, + { name: "msg", type: "string", origin: "main.qml" }, + { name: "onError", type: "Signal Handler", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tproperty int msg\n\tsignal error(string msg, boolean flag)\n\tonError: {\n\t\t|\n\t}\n}", { + start: { line: 4, ch: 2 }, + end: { line: 4, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "error", type: "fn(msg: string, flag: bool)", origin: "main.qml" }, + { name: "flag", type: "bool", origin: "main.qml" }, + { name: "msg", type: "string", origin: "main.qml" }, + { name: "onError", type: "Signal Handler", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +// Function Declarations +testCompletion("Window {\n\tfunction test() {}\n\t|\n}", { + start: { line: 2, ch: 1 }, + end: { line: 2, ch: 1 }, + isProperty: false, + isObjectKey: false, + completions: [] +}); + +testCompletion("Window {\n\tfunction test(a, b, c) {\n\t\t|\n\t}\n}", { + start: { line: 2, ch: 2 }, + end: { line: 2, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "a", type: "?", origin: "main.qml" }, + { name: "b", type: "?", origin: "main.qml" }, + { name: "c", type: "?", origin: "main.qml" }, + { name: "test", type: "fn(a: ?, b: ?, c: ?)", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +testCompletion("Window {\n\tfunction test(a) {\n\t\ta = 3\n\t\t|\n\t}\n}", { + start: { line: 3, ch: 2 }, + end: { line: 3, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "a", type: "number", origin: "main.qml" }, + { name: "test", type: "fn(a: number)", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +testCompletion('Window {\n\tfunction test(a) {\n\t\ttest("something")\n\t\t|\n\t}\n}', { + start: { line: 3, ch: 2 }, + end: { line: 3, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "a", type: "string", origin: "main.qml" }, + { name: "test", type: "fn(a: string)", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +testCompletion('Window {\n\tfunction test(a) {\n\t\t|\n\t\treturn 7\n\t}\n}', { + start: { line: 2, ch: 2 }, + end: { line: 2, ch: 2 }, + isProperty: false, + isObjectKey: false, + completions: [ + { name: "a", type: "?", origin: "main.qml" }, + { name: "test", type: "fn(a: ?) -> number", origin: "main.qml" } + ] +}, function (server) { server.jsDefs = []; }); + +// TODO: Uncomment once this is fixed. The find defs version of this test does find the right definition +// so it seems the problem is related to Tern and not the QML plugin. +//testCompletion('Window {\n\tproperty int a\n\tfunction test(a) {\n\t\t|\n\t}\n}', { +// start: { line: 3, ch: 2 }, +// end: { line: 3, ch: 2 }, +// isProperty: false, +// isObjectKey: false, +// completions: [ +// { name: "a", type: "?", origin: "main.qml" }, +// { name: "test", type: "fn()", origin: "main.qml" } +// ] +//}, function (server) { server.jsDefs = []; }); + groupEnd();
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-finddef.js b/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-finddef.js index c6090d4f1b4..c5bb1d54275 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-finddef.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-finddef.js @@ -1,309 +1,309 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-var driver = require("./driver.js");
-var test = driver.test;
-var testDefinition = driver.testDefinition;
-var assertDefinition = driver.assertDefintion;
-var groupStart = driver.groupStart;
-var groupEnd = driver.groupEnd;
-
-var group = exports.group = "Find Definition";
-groupStart(group);
-
-// Directory Imports
-// TODO: Getting this test to pass breaks some of the type inferencing which is more important
-//testDefinition('My|Object {}', {
-// origin: "MyObject.qml",
-// start: { line: 0, ch: 0 },
-// end: { line: 0, ch: 6 },
-// file: "MyObject.qml",
-// contextOffset: 0
-//}, function (server) {
-// server.addFile("MyObject.qml", "Button {}");
-//});
-
-testDefinition("MyObject {\n\tte|stProp: ident\n}", {
- origin: "MyObject.qml",
- start: { line: 1, ch: 14 },
- end: { line: 1, ch: 22 },
- file: "MyObject.qml",
- contextOffset: 23
-}, function (server) {
- server.addFile("MyObject.qml", "Button {\n\tproperty var testProp\n}");
-});
-
-testDefinition("MyObject {\n\ts: te|stSig()\n}", {
- origin: "MyObject.qml",
- start: { line: 1, ch: 8 },
- end: { line: 1, ch: 15 },
- file: "MyObject.qml",
- contextOffset: 17
-}, function (server) {
- server.addFile("MyObject.qml", "Button {\n\tsignal testSig()\n}");
-});
-
-testDefinition("MyObject {\n\tonTe|stSig: ident\n}", {
- origin: "MyObject.qml",
- start: { line: 1, ch: 8 },
- end: { line: 1, ch: 15 },
- file: "MyObject.qml",
- contextOffset: 17
-}, function (server) {
- server.addFile("MyObject.qml", "Button {\n\tsignal testSig()\n}");
-});
-
-testDefinition("MyObject {\n\tonTestSig: ar|g0\n}", {
- origin: "MyObject.qml",
- start: { line: 1, ch: 20 },
- end: { line: 1, ch: 24 },
- file: "MyObject.qml",
- contextOffset: 29
-}, function (server) {
- server.addFile("MyObject.qml", "Button {\n\tsignal testSig(int arg0)\n}");
-});
-
-testDefinition("MyObject {\n\ts: te|stFn()\n}", {
- origin: "MyObject.qml",
- start: { line: 1, ch: 10 },
- end: { line: 1, ch: 16 },
- file: "MyObject.qml",
- contextOffset: 19
-}, function (server) {
- server.addFile("MyObject.qml", "Button {\n\tfunction testFn() {}\n}");
-});
-
-testDefinition("MyObject {\n\ts: btn|Id\n}", {
- origin: undefined,
- start: undefined,
- end: undefined,
- file: undefined,
- contextOffset: undefined
-}, function (server) {
- server.addFile("MyObject.qml", "Button {\n\tid: btnId\n}");
-});
-
-testDefinition("MyObject {\n\tot|her: ident\n}", {
- origin: undefined,
- start: undefined,
- end: undefined,
- file: undefined,
- contextOffset: undefined
-}, function (server) {
- server.addFile("MyObject.qml", "Button {\n\tSecondButton {\n\t\tjproperty var other\n\t}\n}");
-});
-
-// ID Property
-testDefinition("QtObject {\n\tid: obj\n\tproperty var prop: {\n\t\tob|j\n\t}\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 5 },
- end: { line: 1, ch: 8 },
- file: "main.qml",
- contextOffset: 16
-});
-
-testDefinition("Window {\n\tButton {\n\t\tid: btn\n\t\tproperty int height\n\t}\n\ttest: bt|n\n}", {
- origin: "main.qml",
- start: { line: 2, ch: 6 },
- end: { line: 2, ch: 9 },
- file: "main.qml",
- contextOffset: 25
-});
-
-testDefinition("Window {\n\tproperty var btn\n\tButton {\n\t\tid: btn\n\t\tproperty int height\n\t}\n\ttest: bt|n\n}", {
- origin: "main.qml",
- start: { line: 3, ch: 6 },
- end: { line: 3, ch: 9 },
- file: "main.qml",
- contextOffset: 43
-});
-
-testDefinition("Window {\n\tproperty var btn\n\tButton {\n\t\tid: bt|n\n\t\tproperty int height\n\t}\n}", {
- origin: "main.qml",
- start: { line: 3, ch: 6 },
- end: { line: 3, ch: 9 },
- file: "main.qml",
- contextOffset: 43
-});
-
-// Property Declarations
-testDefinition("QtObject {\n\tproperty var prop\n\tpr|op: 3\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 14 },
- end: { line: 1, ch: 18 },
- file: "main.qml",
- contextOffset: 25
-});
-
-testDefinition("Window {\n\tproperty var btn\n\tButton {\n\t\tprop: b|tn\n\t}\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 14 },
- end: { line: 1, ch: 17 },
- file: "main.qml",
- contextOffset: 23
-});
-
-testDefinition("Window {\n\tproperty var btn\n\tButton {\n\t\tButton {\n\t\t\tprop: b|tn\n\t\t}\n\t}\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 14 },
- end: { line: 1, ch: 17 },
- file: "main.qml",
- contextOffset: 23
-});
-
-testDefinition("Window {\n\tButton {\n\t\tproperty var btn\n\t\tbt|n: 3\n\t}\n}", {
- origin: "main.qml",
- start: { line: 2, ch: 15 },
- end: { line: 2, ch: 18 },
- file: "main.qml",
- contextOffset: 34
-});
-
-testDefinition("Window {\n\tButton {\n\t\tproperty var btn\n\t\tButton {\n\t\t\tprop: b|tn\n\t\t}\n\t}\n}", {
- origin: undefined,
- start: undefined,
- end: undefined,
- file: undefined,
- contextOffset: undefined
-});
-
-// Signals and Signal Handlers
-testDefinition("Window {\n\tsignal clic|ked(int mouseX, int mouseY)\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 8 },
- end: { line: 1, ch: 15 },
- file: "main.qml",
- contextOffset: 17
-});
-
-testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tonCli|cked: 3\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 8 },
- end: { line: 1, ch: 15 },
- file: "main.qml",
- contextOffset: 17
-});
-
-testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tonClicked: mou|seX\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 20 },
- end: { line: 1, ch: 26 },
- file: "main.qml",
- contextOffset: 29
-});
-
-testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tonClicked: cli|cked(3,4)\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 8 },
- end: { line: 1, ch: 15 },
- file: "main.qml",
- contextOffset: 17
-});
-
-testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tonClicked: onCli|cked\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 8 },
- end: { line: 1, ch: 15 },
- file: "main.qml",
- contextOffset: 17
-});
-
-testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tid: wind\n\tonClicked: wind.onCli|cked\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 8 },
- end: { line: 1, ch: 15 },
- file: "main.qml",
- contextOffset: 17
-});
-
-testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tid: wind\n\tonClicked: wind.cli|cked(3,4)\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 8 },
- end: { line: 1, ch: 15 },
- file: "main.qml",
- contextOffset: 17
-});
-
-testDefinition("Window {\n\tproperty int msg\n\tsignal error(string msg, boolean flag)\n\tonError: {\n\t\tms|g\n\t}\n}", {
- origin: "main.qml",
- start: { line: 2, ch: 21 },
- end: { line: 2, ch: 24 },
- file: "main.qml",
- contextOffset: 48
-}, function (server) { server.jsDefs = []; });
-
-// Function Declarations
-testDefinition("Window {\n\tfunction te|st(a) {}\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 10 },
- end: { line: 1, ch: 14 },
- file: "main.qml",
- contextOffset: 19
-});
-
-testDefinition("Window {\n\tfunction test(a) {\n\t\ta|\n\t}\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 15 },
- end: { line: 1, ch: 16 },
- file: "main.qml",
- contextOffset: 24
-});
-
-testDefinition("Window {\n\tfunction test(a) {\n\t\tte|st(3)\n\t}\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 10 },
- end: { line: 1, ch: 14 },
- file: "main.qml",
- contextOffset: 19
-});
-
-testDefinition("Window {\n\tfunction test(a) {}\n\ts: te|st(3)\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 10 },
- end: { line: 1, ch: 14 },
- file: "main.qml",
- contextOffset: 19
-});
-
-testDefinition("Window {\n\tfunction test(a) {}\n\ts: {\n\t\tte|st(3)\n\t}\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 10 },
- end: { line: 1, ch: 14 },
- file: "main.qml",
- contextOffset: 19
-});
-
-testDefinition("Window {\n\tfunction test(a) {}\n\tid: wind\n\ts: {\n\t\twind.te|st(3)\n\t}\n}", {
- origin: "main.qml",
- start: { line: 1, ch: 10 },
- end: { line: 1, ch: 14 },
- file: "main.qml",
- contextOffset: 19
-});
-
-testDefinition("Window {\n\tfunction test(a) {}\n\tte|st: 3;\n}", {
- origin: undefined,
- start: undefined,
- end: undefined,
- file: undefined,
- contextOffset: undefined
-});
-
-testDefinition('Window {\n\tfunction test(a) {\n\t\ta|\n\t}\n}\n\tproperty int a', {
- origin: "main.qml",
- start: { line: 1, ch: 15 },
- end: { line: 1, ch: 16 },
- file: "main.qml",
- contextOffset: 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 + *******************************************************************************/ +"use strict"; + +var driver = require("./driver.js"); +var test = driver.test; +var testDefinition = driver.testDefinition; +var assertDefinition = driver.assertDefintion; +var groupStart = driver.groupStart; +var groupEnd = driver.groupEnd; + +var group = exports.group = "Find Definition"; +groupStart(group); + +// Directory Imports +// TODO: Getting this test to pass breaks some of the type inferencing which is more important +//testDefinition('My|Object {}', { +// origin: "MyObject.qml", +// start: { line: 0, ch: 0 }, +// end: { line: 0, ch: 6 }, +// file: "MyObject.qml", +// contextOffset: 0 +//}, function (server) { +// server.addFile("MyObject.qml", "Button {}"); +//}); + +testDefinition("MyObject {\n\tte|stProp: ident\n}", { + origin: "MyObject.qml", + start: { line: 1, ch: 14 }, + end: { line: 1, ch: 22 }, + file: "MyObject.qml", + contextOffset: 23 +}, function (server) { + server.addFile("MyObject.qml", "Button {\n\tproperty var testProp\n}"); +}); + +testDefinition("MyObject {\n\ts: te|stSig()\n}", { + origin: "MyObject.qml", + start: { line: 1, ch: 8 }, + end: { line: 1, ch: 15 }, + file: "MyObject.qml", + contextOffset: 17 +}, function (server) { + server.addFile("MyObject.qml", "Button {\n\tsignal testSig()\n}"); +}); + +testDefinition("MyObject {\n\tonTe|stSig: ident\n}", { + origin: "MyObject.qml", + start: { line: 1, ch: 8 }, + end: { line: 1, ch: 15 }, + file: "MyObject.qml", + contextOffset: 17 +}, function (server) { + server.addFile("MyObject.qml", "Button {\n\tsignal testSig()\n}"); +}); + +testDefinition("MyObject {\n\tonTestSig: ar|g0\n}", { + origin: "MyObject.qml", + start: { line: 1, ch: 20 }, + end: { line: 1, ch: 24 }, + file: "MyObject.qml", + contextOffset: 29 +}, function (server) { + server.addFile("MyObject.qml", "Button {\n\tsignal testSig(int arg0)\n}"); +}); + +testDefinition("MyObject {\n\ts: te|stFn()\n}", { + origin: "MyObject.qml", + start: { line: 1, ch: 10 }, + end: { line: 1, ch: 16 }, + file: "MyObject.qml", + contextOffset: 19 +}, function (server) { + server.addFile("MyObject.qml", "Button {\n\tfunction testFn() {}\n}"); +}); + +testDefinition("MyObject {\n\ts: btn|Id\n}", { + origin: undefined, + start: undefined, + end: undefined, + file: undefined, + contextOffset: undefined +}, function (server) { + server.addFile("MyObject.qml", "Button {\n\tid: btnId\n}"); +}); + +testDefinition("MyObject {\n\tot|her: ident\n}", { + origin: undefined, + start: undefined, + end: undefined, + file: undefined, + contextOffset: undefined +}, function (server) { + server.addFile("MyObject.qml", "Button {\n\tSecondButton {\n\t\tjproperty var other\n\t}\n}"); +}); + +// ID Property +testDefinition("QtObject {\n\tid: obj\n\tproperty var prop: {\n\t\tob|j\n\t}\n}", { + origin: "main.qml", + start: { line: 1, ch: 5 }, + end: { line: 1, ch: 8 }, + file: "main.qml", + contextOffset: 16 +}); + +testDefinition("Window {\n\tButton {\n\t\tid: btn\n\t\tproperty int height\n\t}\n\ttest: bt|n\n}", { + origin: "main.qml", + start: { line: 2, ch: 6 }, + end: { line: 2, ch: 9 }, + file: "main.qml", + contextOffset: 25 +}); + +testDefinition("Window {\n\tproperty var btn\n\tButton {\n\t\tid: btn\n\t\tproperty int height\n\t}\n\ttest: bt|n\n}", { + origin: "main.qml", + start: { line: 3, ch: 6 }, + end: { line: 3, ch: 9 }, + file: "main.qml", + contextOffset: 43 +}); + +testDefinition("Window {\n\tproperty var btn\n\tButton {\n\t\tid: bt|n\n\t\tproperty int height\n\t}\n}", { + origin: "main.qml", + start: { line: 3, ch: 6 }, + end: { line: 3, ch: 9 }, + file: "main.qml", + contextOffset: 43 +}); + +// Property Declarations +testDefinition("QtObject {\n\tproperty var prop\n\tpr|op: 3\n}", { + origin: "main.qml", + start: { line: 1, ch: 14 }, + end: { line: 1, ch: 18 }, + file: "main.qml", + contextOffset: 25 +}); + +testDefinition("Window {\n\tproperty var btn\n\tButton {\n\t\tprop: b|tn\n\t}\n}", { + origin: "main.qml", + start: { line: 1, ch: 14 }, + end: { line: 1, ch: 17 }, + file: "main.qml", + contextOffset: 23 +}); + +testDefinition("Window {\n\tproperty var btn\n\tButton {\n\t\tButton {\n\t\t\tprop: b|tn\n\t\t}\n\t}\n}", { + origin: "main.qml", + start: { line: 1, ch: 14 }, + end: { line: 1, ch: 17 }, + file: "main.qml", + contextOffset: 23 +}); + +testDefinition("Window {\n\tButton {\n\t\tproperty var btn\n\t\tbt|n: 3\n\t}\n}", { + origin: "main.qml", + start: { line: 2, ch: 15 }, + end: { line: 2, ch: 18 }, + file: "main.qml", + contextOffset: 34 +}); + +testDefinition("Window {\n\tButton {\n\t\tproperty var btn\n\t\tButton {\n\t\t\tprop: b|tn\n\t\t}\n\t}\n}", { + origin: undefined, + start: undefined, + end: undefined, + file: undefined, + contextOffset: undefined +}); + +// Signals and Signal Handlers +testDefinition("Window {\n\tsignal clic|ked(int mouseX, int mouseY)\n}", { + origin: "main.qml", + start: { line: 1, ch: 8 }, + end: { line: 1, ch: 15 }, + file: "main.qml", + contextOffset: 17 +}); + +testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tonCli|cked: 3\n}", { + origin: "main.qml", + start: { line: 1, ch: 8 }, + end: { line: 1, ch: 15 }, + file: "main.qml", + contextOffset: 17 +}); + +testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tonClicked: mou|seX\n}", { + origin: "main.qml", + start: { line: 1, ch: 20 }, + end: { line: 1, ch: 26 }, + file: "main.qml", + contextOffset: 29 +}); + +testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tonClicked: cli|cked(3,4)\n}", { + origin: "main.qml", + start: { line: 1, ch: 8 }, + end: { line: 1, ch: 15 }, + file: "main.qml", + contextOffset: 17 +}); + +testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tonClicked: onCli|cked\n}", { + origin: "main.qml", + start: { line: 1, ch: 8 }, + end: { line: 1, ch: 15 }, + file: "main.qml", + contextOffset: 17 +}); + +testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tid: wind\n\tonClicked: wind.onCli|cked\n}", { + origin: "main.qml", + start: { line: 1, ch: 8 }, + end: { line: 1, ch: 15 }, + file: "main.qml", + contextOffset: 17 +}); + +testDefinition("Window {\n\tsignal clicked(int mouseX, int mouseY)\n\tid: wind\n\tonClicked: wind.cli|cked(3,4)\n}", { + origin: "main.qml", + start: { line: 1, ch: 8 }, + end: { line: 1, ch: 15 }, + file: "main.qml", + contextOffset: 17 +}); + +testDefinition("Window {\n\tproperty int msg\n\tsignal error(string msg, boolean flag)\n\tonError: {\n\t\tms|g\n\t}\n}", { + origin: "main.qml", + start: { line: 2, ch: 21 }, + end: { line: 2, ch: 24 }, + file: "main.qml", + contextOffset: 48 +}, function (server) { server.jsDefs = []; }); + +// Function Declarations +testDefinition("Window {\n\tfunction te|st(a) {}\n}", { + origin: "main.qml", + start: { line: 1, ch: 10 }, + end: { line: 1, ch: 14 }, + file: "main.qml", + contextOffset: 19 +}); + +testDefinition("Window {\n\tfunction test(a) {\n\t\ta|\n\t}\n}", { + origin: "main.qml", + start: { line: 1, ch: 15 }, + end: { line: 1, ch: 16 }, + file: "main.qml", + contextOffset: 24 +}); + +testDefinition("Window {\n\tfunction test(a) {\n\t\tte|st(3)\n\t}\n}", { + origin: "main.qml", + start: { line: 1, ch: 10 }, + end: { line: 1, ch: 14 }, + file: "main.qml", + contextOffset: 19 +}); + +testDefinition("Window {\n\tfunction test(a) {}\n\ts: te|st(3)\n}", { + origin: "main.qml", + start: { line: 1, ch: 10 }, + end: { line: 1, ch: 14 }, + file: "main.qml", + contextOffset: 19 +}); + +testDefinition("Window {\n\tfunction test(a) {}\n\ts: {\n\t\tte|st(3)\n\t}\n}", { + origin: "main.qml", + start: { line: 1, ch: 10 }, + end: { line: 1, ch: 14 }, + file: "main.qml", + contextOffset: 19 +}); + +testDefinition("Window {\n\tfunction test(a) {}\n\tid: wind\n\ts: {\n\t\twind.te|st(3)\n\t}\n}", { + origin: "main.qml", + start: { line: 1, ch: 10 }, + end: { line: 1, ch: 14 }, + file: "main.qml", + contextOffset: 19 +}); + +testDefinition("Window {\n\tfunction test(a) {}\n\tte|st: 3;\n}", { + origin: undefined, + start: undefined, + end: undefined, + file: undefined, + contextOffset: undefined +}); + +testDefinition('Window {\n\tfunction test(a) {\n\t\ta|\n\t}\n}\n\tproperty int a', { + origin: "main.qml", + start: { line: 1, ch: 15 }, + end: { line: 1, ch: 16 }, + file: "main.qml", + contextOffset: 24 +}); + groupEnd();
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-parse.js b/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-parse.js index 489808f6865..833d7fac516 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-parse.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-parse.js @@ -1,126 +1,126 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-var driver = require("./driver.js");
-var test = driver.test;
-var groupStart = driver.groupStart;
-var groupEnd = driver.groupEnd;
-
-var group = exports.group = "Parse Query";
-groupStart(group);
-
-test("{Parse existing file}", function (server, callback, name) {
- server.addFile("main.qml", "import QtQuick 2.0\nModule {\n\tComponent {\n\t}\n}");
- server.request({
- query: {
- type: "parseFile",
- file: "main.qml"
- }
- }, function (err, resp) {
- if (err) {
- throw err;
- }
- if (!resp.ast || resp.ast.type !== "QMLProgram") {
- return callback("fail", name, "AST could not be found in response");
- }
- return callback("ok", name);
- });
-});
-
-test("{Parse given file}", function (server, callback, name) {
- server.request({
- files: [
- {
- name: "main.qml",
- text: "import QtQuick 2.0\nModule {\n\tComponent {\n\t}\n}",
- type: "full"
- }
- ],
- query: {
- type: "parseFile",
- file: "main.qml"
- }
- }, function (err, resp) {
- if (err) {
- throw err;
- }
- if (!resp.ast || resp.ast.type !== "QMLProgram") {
- return callback("fail", name, "AST could not be found in response");
- }
- return callback("ok", name);
- });
-});
-
-test("{Parse empty text}", function (server, callback, name) {
- server.parseString("", null, function (err, resp) {
- if (err) {
- throw err;
- }
- if (!resp.ast) {
- return callback("fail", name, "AST could not be found in response");
- } else if (resp.ast.type !== "QMLProgram" || resp.ast.mode !== "qml") {
- return callback("fail", name, "AST was not a QMLProgram with mode 'qml'");
- }
- return callback("ok", name);
- });
-});
-
-test("{Parse text no mode}", function (server, callback, name) {
- server.parseString("import QtQuick 2.0\nModule {\n\tComponent {\n\t}\n}", null, function (err, resp) {
- if (err) {
- throw err;
- }
- if (!resp.ast) {
- return callback("fail", name, "AST could not be found in response");
- } else if (resp.ast.type !== "QMLProgram" || resp.ast.mode !== "qml") {
- return callback("fail", name, "AST was not a QMLProgram with mode 'qml'");
- }
- return callback("ok", name);
- });
-});
-
-test("{Parse text (mode: qmltypes)}", function (server, callback, name) {
- server.parseString("QtObject {\n\tobj: {\n\t\tprop1: 1,\n\t\tprop2: 2\n\t}\n}", {
- mode: "qmltypes"
- }, function (err, resp) {
- if (err) {
- throw err;
- }
- if (!resp.ast) {
- return callback("fail", name, "AST could not be found in response");
- } else if (resp.ast.type !== "QMLProgram" || resp.ast.mode !== "qmltypes") {
- return callback("fail", name, "AST was not a QMLProgram with mode 'qmltypes'");
- }
- return callback("ok", name);
- });
-});
-
-test("{Parse text with locations}", function (server, callback, name) {
- server.parseString("var w = 3", {
- mode: "js",
- locations: true
- }, function (err, resp) {
- if (err) {
- throw err;
- }
- if (!resp.ast) {
- return callback("fail", name, "AST could not be found in response");
- } else if (resp.ast.type !== "Program") {
- return callback("fail", name, "AST was not a JavaScript Program");
- } else if (!resp.ast.loc) {
- return callback("fail", name, "AST had no loc object");
- }
- return callback("ok", name);
- });
-});
-
+/******************************************************************************* + * 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 + *******************************************************************************/ +"use strict"; + +var driver = require("./driver.js"); +var test = driver.test; +var groupStart = driver.groupStart; +var groupEnd = driver.groupEnd; + +var group = exports.group = "Parse Query"; +groupStart(group); + +test("{Parse existing file}", function (server, callback, name) { + server.addFile("main.qml", "import QtQuick 2.0\nModule {\n\tComponent {\n\t}\n}"); + server.request({ + query: { + type: "parseFile", + file: "main.qml" + } + }, function (err, resp) { + if (err) { + throw err; + } + if (!resp.ast || resp.ast.type !== "QMLProgram") { + return callback("fail", name, "AST could not be found in response"); + } + return callback("ok", name); + }); +}); + +test("{Parse given file}", function (server, callback, name) { + server.request({ + files: [ + { + name: "main.qml", + text: "import QtQuick 2.0\nModule {\n\tComponent {\n\t}\n}", + type: "full" + } + ], + query: { + type: "parseFile", + file: "main.qml" + } + }, function (err, resp) { + if (err) { + throw err; + } + if (!resp.ast || resp.ast.type !== "QMLProgram") { + return callback("fail", name, "AST could not be found in response"); + } + return callback("ok", name); + }); +}); + +test("{Parse empty text}", function (server, callback, name) { + server.parseString("", null, function (err, resp) { + if (err) { + throw err; + } + if (!resp.ast) { + return callback("fail", name, "AST could not be found in response"); + } else if (resp.ast.type !== "QMLProgram" || resp.ast.mode !== "qml") { + return callback("fail", name, "AST was not a QMLProgram with mode 'qml'"); + } + return callback("ok", name); + }); +}); + +test("{Parse text no mode}", function (server, callback, name) { + server.parseString("import QtQuick 2.0\nModule {\n\tComponent {\n\t}\n}", null, function (err, resp) { + if (err) { + throw err; + } + if (!resp.ast) { + return callback("fail", name, "AST could not be found in response"); + } else if (resp.ast.type !== "QMLProgram" || resp.ast.mode !== "qml") { + return callback("fail", name, "AST was not a QMLProgram with mode 'qml'"); + } + return callback("ok", name); + }); +}); + +test("{Parse text (mode: qmltypes)}", function (server, callback, name) { + server.parseString("QtObject {\n\tobj: {\n\t\tprop1: 1,\n\t\tprop2: 2\n\t}\n}", { + mode: "qmltypes" + }, function (err, resp) { + if (err) { + throw err; + } + if (!resp.ast) { + return callback("fail", name, "AST could not be found in response"); + } else if (resp.ast.type !== "QMLProgram" || resp.ast.mode !== "qmltypes") { + return callback("fail", name, "AST was not a QMLProgram with mode 'qmltypes'"); + } + return callback("ok", name); + }); +}); + +test("{Parse text with locations}", function (server, callback, name) { + server.parseString("var w = 3", { + mode: "js", + locations: true + }, function (err, resp) { + if (err) { + throw err; + } + if (!resp.ast) { + return callback("fail", name, "AST could not be found in response"); + } else if (resp.ast.type !== "Program") { + return callback("fail", name, "AST was not a JavaScript Program"); + } else if (!resp.ast.loc) { + return callback("fail", name, "AST had no loc object"); + } + return callback("ok", name); + }); +}); + groupEnd();
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-scoping.js b/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-scoping.js index c44f8b4104c..a46e0f6dd54 100644 --- a/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-scoping.js +++ b/qt/org.eclipse.cdt.qt.core/tern-qml/test/test-scoping.js @@ -1,409 +1,409 @@ -/*******************************************************************************
- * 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
- *******************************************************************************/
-"use strict";
-
-var plugin = require("../qml.js");
-var infer = require("tern/lib/infer");
-var driver = require("./driver.js");
-var test = driver.test;
-var groupStart = driver.groupStart;
-var groupEnd = driver.groupEnd;
-
-var group = exports.group = "Custom Scoping";
-groupStart(group);
-
-test("QMLObjScope::defProp()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var obj = new infer.Obj(null, "MyObject");
- var scope = new plugin.QMLObjScope(fileScope, null, obj);
-
- // Define some properties
- scope.defProp("first", null);
- scope.defProp("second", null);
-
- // Make sure there are no properties in the scopes themselves
- if (fileScope.props && fileScope.props.length > 0) {
- return callback("fail", name, "- File scope contained properties (none expected)");
- }
- if (scope.props && scope.props.length > 0) {
- return callback("fail", name, "- QMLObjScope contained properties (none expected)");
- }
-
- // Check the Obj Type for the props we created
- if (!obj.props.first) {
- return callback("fail", name, "- Obj did not contain property 'first'");
- }
- if (!obj.props.second) {
- return callback("fail", name, "- Obj did not contain property 'second'");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLObjScope::hasProp()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var obj = new infer.Obj(null, "MyObject");
- var scope = new plugin.QMLObjScope(fileScope, null, obj);
-
- // Define a property on the Obj Type
- obj.defProp("first", null);
-
- // Query the scope for the prop we created and make sure it returns the right one
- var prop = scope.hasProp("first", true);
- if (!prop) {
- return callback("fail", name, "- hasProp('first') returned null");
- } else if (prop.propertyName !== "first") {
- return callback("fail", name, "- hasProp('first') returned invalid property");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLObjScope::removeProp()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var obj = new infer.Obj(null, "MyObject");
- var scope = new plugin.QMLObjScope(fileScope, null, obj);
-
- // Define some properties
- scope.defProp("first", null);
- scope.defProp("second", null);
-
- // Remove the properties we defined
- scope.removeProp("first");
- scope.removeProp("second");
-
- // Check the Obj Type for the props we created
- if (obj.props && obj.props.length > 0) {
- return callback("fail", name, "- Obj contained properties (none expected)");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLObjScope::gatherProperties()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var obj = new infer.Obj(null, "MyObject");
- var scope = new plugin.QMLObjScope(fileScope, null, obj);
-
- // Define some properties
- fileScope.defProp("third", null);
- scope.defProp("first", null);
- scope.defProp("second", null);
-
- // Gather the properties and store them in the order they were received
- var props = [];
- scope.gatherProperties(function (prop, obj, depth) {
- props.push(prop);
- });
-
- // Check the gathered properties for correctness (order matters)
- if (props.length !== 3) {
- return callback("fail", name, "- Invalid number of properties gathered (" + props.length + ")");
- }
- if (props[0] !== "first") {
- return callback("fail", name, "- props[0] was not property 'first'");
- }
- if (props[1] !== "second") {
- return callback("fail", name, "- props[1] was not property 'second'");
- }
- if (props[2] !== "third") {
- return callback("fail", name, "- props[2] was not property 'third'");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLMemScope::defProp()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var obj = new infer.Obj(null, "MyObject");
- var objScope = new plugin.QMLObjScope(fileScope, null, obj);
- var scope = new plugin.QMLMemScope(objScope, null, fileScope);
-
- // Define some properties
- scope.defProp("first", null);
- scope.defProp("second", null);
-
- // Make sure there are no properties in the scopes themselves
- if (fileScope.props && fileScope.props.length > 0) {
- return callback("fail", name, "- File scope contained properties (none expected)");
- }
- if (scope.props && scope.props.length > 0) {
- return callback("fail", name, "- QMLMemScope contained properties (none expected)");
- }
-
- // Check the Obj Type for the props we created
- if (!obj.props.first) {
- return callback("fail", name, "- Obj did not contain property 'first'");
- }
- if (!obj.props.second) {
- return callback("fail", name, "- Obj did not contain property 'second'");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLMemScope::hasProp()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var obj = new infer.Obj(null, "MyObject");
- var objScope = new plugin.QMLObjScope(fileScope, null, obj);
- var scope = new plugin.QMLMemScope(objScope, null, fileScope);
-
- // Define a property on the Obj Type and File Scope
- obj.defProp("first", null);
- fileScope.defProp("second", null);
-
- // Query the scope for the prop we created and make sure it returns the right one
- var prop = scope.hasProp("first", true);
- if (!prop) {
- return callback("fail", name, "- hasProp('first') returned null");
- } else if (prop.propertyName !== "first") {
- return callback("fail", name, "- hasProp('first') returned invalid property");
- }
- prop = scope.hasProp("second", true);
- if (!prop) {
- return callback("fail", name, "- hasProp('second') returned null");
- } else if (prop.propertyName !== "second") {
- return callback("fail", name, "- hasProp('second') returned invalid property");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLMemScope::hasProp() [Multiple Parent Scopes]", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var rootObj = new infer.Obj(null, "Root");
- var rootObjScope = new plugin.QMLObjScope(fileScope, null, rootObj);
- var obj = new infer.Obj(null, "MyObject");
- var objScope = new plugin.QMLObjScope(rootObjScope, null, obj);
- var scope = new plugin.QMLMemScope(objScope, null, fileScope);
-
- // Define a property on the Root Obj Type and Obj Type
- rootObj.defProp("notVisible", null);
- obj.defProp("visible", null);
-
- // Query the scope for the prop we created and make sure it returns the right one
- var prop = scope.hasProp("notVisible", true);
- if (prop) {
- return callback("fail", name, "- found property 'notVisible'");
- }
- prop = scope.hasProp("visible", true);
- if (!prop) {
- return callback("fail", name, "- hasProp('visible') returned null");
- } else if (prop.propertyName !== "visible") {
- return callback("fail", name, "- hasProp('visible') returned invalid property");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLMemScope::removeProp()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var obj = new infer.Obj(null, "MyObject");
- var objScope = new plugin.QMLObjScope(fileScope, null, obj);
- var scope = new plugin.QMLMemScope(objScope, null, fileScope);
-
- // Define some properties
- scope.defProp("first", null);
- scope.defProp("second", null);
-
- // Remove the properties we defined
- scope.removeProp("first");
- scope.removeProp("second");
-
- // Check the Obj Type for the props we created
- if (obj.props && obj.props.length > 0) {
- return callback("fail", name, "- Obj contained properties (none expected)");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLMemScope::gatherProperties()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var obj = new infer.Obj(null, "MyObject");
- var objScope = new plugin.QMLObjScope(fileScope, null, obj);
- var scope = new plugin.QMLMemScope(objScope, null, fileScope);
-
- // Define some properties
- fileScope.defProp("third", null);
- scope.defProp("first", null);
- scope.defProp("second", null);
-
- // Gather the properties and store them in the order they were received
- var props = [];
- scope.gatherProperties(function (prop, obj, depth) {
- props.push(prop);
- });
-
- // Check the gathered properties for correctness (order matters)
- if (props.length !== 3) {
- return callback("fail", name, "- Invalid number of properties gathered (" + props.length + ")");
- }
- if (props[0] !== "first") {
- return callback("fail", name, "- props[0] was not property 'first'");
- }
- if (props[1] !== "second") {
- return callback("fail", name, "- props[1] was not property 'second'");
- }
- if (props[2] !== "third") {
- return callback("fail", name, "- props[2] was not property 'third'");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLMemScope::gatherProperties() [Multiple Parent Scopes]", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var rootObj = new infer.Obj(null, "Root");
- var rootObjScope = new plugin.QMLObjScope(fileScope, null, rootObj);
- var obj = new infer.Obj(null, "MyObject");
- var objScope = new plugin.QMLObjScope(rootObjScope, null, obj);
- var scope = new plugin.QMLMemScope(objScope, null, fileScope);
-
- // Define a property on the Root Obj Type and Obj Type
- rootObj.defProp("notVisible", null);
- obj.defProp("visible", null);
-
- // Gather the properties and store them in the order they were received
- var props = [];
- scope.gatherProperties(function (prop, obj, depth) {
- props.push(prop);
- });
-
- // Check the gathered properties for correctness (order matters)
- if (props.length !== 1) {
- return callback("fail", name, "- Invalid number of properties gathered (" + props.length + ")");
- }
- if (props[0] !== "visible") {
- return callback("fail", name, "- props[0] was not property 'visible'");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLJSScope::hasProp()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var idScope = new infer.Scope(null, "<qml-id>");
- var jsScope = new infer.Scope(null, "<qml-js>");
- var fnScope = new infer.Scope(null, "<qml-fn>");
- var scope = new plugin.QMLJSScope(fileScope, null, idScope, jsScope, fnScope);
-
- // Define properties in each scope
- fileScope.defProp("first", null);
- idScope.defProp("second", null);
- jsScope.defProp("third", null);
- fnScope.defProp("fourth", null);
- scope.defProp("fifth", null);
-
- // Query the scope for the prop we created and make sure it returns the right one
- var prop = scope.hasProp("first", true);
- if (!prop) {
- return callback("fail", name, "- hasProp('first') returned null");
- } else if (prop.propertyName !== "first") {
- return callback("fail", name, "- hasProp('first') returned invalid property");
- }
- prop = scope.hasProp("second", true);
- if (!prop) {
- return callback("fail", name, "- hasProp('second') returned null");
- } else if (prop.propertyName !== "second") {
- return callback("fail", name, "- hasProp('second') returned invalid property");
- }
- prop = scope.hasProp("third", true);
- if (!prop) {
- return callback("fail", name, "- hasProp('third') returned null");
- } else if (prop.propertyName !== "third") {
- return callback("fail", name, "- hasProp('third') returned invalid property");
- }
- prop = scope.hasProp("fourth", true);
- if (!prop) {
- return callback("fail", name, "- hasProp('fourth') returned null");
- } else if (prop.propertyName !== "fourth") {
- return callback("fail", name, "- hasProp('fourth') returned invalid property");
- }
- prop = scope.hasProp("fifth", true);
- if (!prop) {
- return callback("fail", name, "- hasProp('fifth') returned null");
- } else if (prop.propertyName !== "fifth") {
- return callback("fail", name, "- hasProp('fifth') returned invalid property");
- }
- return callback("ok", name);
- });
-});
-
-test("QMLJSScope::gatherProperties()", function (server, callback, name) {
- infer.withContext(new infer.Context([], server), function () {
- // Create the scope and objects to test
- // Create the scope and objects to test
- var fileScope = new infer.Scope();
- var idScope = new infer.Scope(null, "<qml-id>");
- var jsScope = new infer.Scope(null, "<qml-js>");
- var fnScope = new infer.Scope(null, "<qml-fn>");
- var scope = new plugin.QMLJSScope(fileScope, null, idScope, jsScope, fnScope);
-
- // Define properties in each scope
- fileScope.defProp("fifth", null);
- idScope.defProp("first", null);
- jsScope.defProp("fourth", null);
- fnScope.defProp("third", null);
- scope.defProp("second", null);
-
- // Gather the properties and store them in the order they were received
- var props = [];
- scope.gatherProperties(function (prop, obj, depth) {
- props.push(prop);
- });
-
- // Check the gathered properties for correctness (order matters)
- if (props.length !== 5) {
- return callback("fail", name, "- Invalid number of properties gathered (" + props.length + ")");
- }
- if (props[0] !== "first") {
- return callback("fail", name, "- props[0] was not property 'first'");
- }
- if (props[1] !== "second") {
- return callback("fail", name, "- props[1] was not property 'second'");
- }
- if (props[2] !== "third") {
- return callback("fail", name, "- props[2] was not property 'third'");
- }
- if (props[3] !== "fourth") {
- return callback("fail", name, "- props[3] was not property 'fourth'");
- }
- if (props[4] !== "fifth") {
- return callback("fail", name, "- props[4] was not property 'fifth'");
- }
- return callback("ok", name);
- });
-});
-
+/******************************************************************************* + * 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 + *******************************************************************************/ +"use strict"; + +var plugin = require("../qml.js"); +var infer = require("tern/lib/infer"); +var driver = require("./driver.js"); +var test = driver.test; +var groupStart = driver.groupStart; +var groupEnd = driver.groupEnd; + +var group = exports.group = "Custom Scoping"; +groupStart(group); + +test("QMLObjScope::defProp()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var obj = new infer.Obj(null, "MyObject"); + var scope = new plugin.QMLObjScope(fileScope, null, obj); + + // Define some properties + scope.defProp("first", null); + scope.defProp("second", null); + + // Make sure there are no properties in the scopes themselves + if (fileScope.props && fileScope.props.length > 0) { + return callback("fail", name, "- File scope contained properties (none expected)"); + } + if (scope.props && scope.props.length > 0) { + return callback("fail", name, "- QMLObjScope contained properties (none expected)"); + } + + // Check the Obj Type for the props we created + if (!obj.props.first) { + return callback("fail", name, "- Obj did not contain property 'first'"); + } + if (!obj.props.second) { + return callback("fail", name, "- Obj did not contain property 'second'"); + } + return callback("ok", name); + }); +}); + +test("QMLObjScope::hasProp()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var obj = new infer.Obj(null, "MyObject"); + var scope = new plugin.QMLObjScope(fileScope, null, obj); + + // Define a property on the Obj Type + obj.defProp("first", null); + + // Query the scope for the prop we created and make sure it returns the right one + var prop = scope.hasProp("first", true); + if (!prop) { + return callback("fail", name, "- hasProp('first') returned null"); + } else if (prop.propertyName !== "first") { + return callback("fail", name, "- hasProp('first') returned invalid property"); + } + return callback("ok", name); + }); +}); + +test("QMLObjScope::removeProp()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var obj = new infer.Obj(null, "MyObject"); + var scope = new plugin.QMLObjScope(fileScope, null, obj); + + // Define some properties + scope.defProp("first", null); + scope.defProp("second", null); + + // Remove the properties we defined + scope.removeProp("first"); + scope.removeProp("second"); + + // Check the Obj Type for the props we created + if (obj.props && obj.props.length > 0) { + return callback("fail", name, "- Obj contained properties (none expected)"); + } + return callback("ok", name); + }); +}); + +test("QMLObjScope::gatherProperties()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var obj = new infer.Obj(null, "MyObject"); + var scope = new plugin.QMLObjScope(fileScope, null, obj); + + // Define some properties + fileScope.defProp("third", null); + scope.defProp("first", null); + scope.defProp("second", null); + + // Gather the properties and store them in the order they were received + var props = []; + scope.gatherProperties(function (prop, obj, depth) { + props.push(prop); + }); + + // Check the gathered properties for correctness (order matters) + if (props.length !== 3) { + return callback("fail", name, "- Invalid number of properties gathered (" + props.length + ")"); + } + if (props[0] !== "first") { + return callback("fail", name, "- props[0] was not property 'first'"); + } + if (props[1] !== "second") { + return callback("fail", name, "- props[1] was not property 'second'"); + } + if (props[2] !== "third") { + return callback("fail", name, "- props[2] was not property 'third'"); + } + return callback("ok", name); + }); +}); + +test("QMLMemScope::defProp()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var obj = new infer.Obj(null, "MyObject"); + var objScope = new plugin.QMLObjScope(fileScope, null, obj); + var scope = new plugin.QMLMemScope(objScope, null, fileScope); + + // Define some properties + scope.defProp("first", null); + scope.defProp("second", null); + + // Make sure there are no properties in the scopes themselves + if (fileScope.props && fileScope.props.length > 0) { + return callback("fail", name, "- File scope contained properties (none expected)"); + } + if (scope.props && scope.props.length > 0) { + return callback("fail", name, "- QMLMemScope contained properties (none expected)"); + } + + // Check the Obj Type for the props we created + if (!obj.props.first) { + return callback("fail", name, "- Obj did not contain property 'first'"); + } + if (!obj.props.second) { + return callback("fail", name, "- Obj did not contain property 'second'"); + } + return callback("ok", name); + }); +}); + +test("QMLMemScope::hasProp()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var obj = new infer.Obj(null, "MyObject"); + var objScope = new plugin.QMLObjScope(fileScope, null, obj); + var scope = new plugin.QMLMemScope(objScope, null, fileScope); + + // Define a property on the Obj Type and File Scope + obj.defProp("first", null); + fileScope.defProp("second", null); + + // Query the scope for the prop we created and make sure it returns the right one + var prop = scope.hasProp("first", true); + if (!prop) { + return callback("fail", name, "- hasProp('first') returned null"); + } else if (prop.propertyName !== "first") { + return callback("fail", name, "- hasProp('first') returned invalid property"); + } + prop = scope.hasProp("second", true); + if (!prop) { + return callback("fail", name, "- hasProp('second') returned null"); + } else if (prop.propertyName !== "second") { + return callback("fail", name, "- hasProp('second') returned invalid property"); + } + return callback("ok", name); + }); +}); + +test("QMLMemScope::hasProp() [Multiple Parent Scopes]", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var rootObj = new infer.Obj(null, "Root"); + var rootObjScope = new plugin.QMLObjScope(fileScope, null, rootObj); + var obj = new infer.Obj(null, "MyObject"); + var objScope = new plugin.QMLObjScope(rootObjScope, null, obj); + var scope = new plugin.QMLMemScope(objScope, null, fileScope); + + // Define a property on the Root Obj Type and Obj Type + rootObj.defProp("notVisible", null); + obj.defProp("visible", null); + + // Query the scope for the prop we created and make sure it returns the right one + var prop = scope.hasProp("notVisible", true); + if (prop) { + return callback("fail", name, "- found property 'notVisible'"); + } + prop = scope.hasProp("visible", true); + if (!prop) { + return callback("fail", name, "- hasProp('visible') returned null"); + } else if (prop.propertyName !== "visible") { + return callback("fail", name, "- hasProp('visible') returned invalid property"); + } + return callback("ok", name); + }); +}); + +test("QMLMemScope::removeProp()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var obj = new infer.Obj(null, "MyObject"); + var objScope = new plugin.QMLObjScope(fileScope, null, obj); + var scope = new plugin.QMLMemScope(objScope, null, fileScope); + + // Define some properties + scope.defProp("first", null); + scope.defProp("second", null); + + // Remove the properties we defined + scope.removeProp("first"); + scope.removeProp("second"); + + // Check the Obj Type for the props we created + if (obj.props && obj.props.length > 0) { + return callback("fail", name, "- Obj contained properties (none expected)"); + } + return callback("ok", name); + }); +}); + +test("QMLMemScope::gatherProperties()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var obj = new infer.Obj(null, "MyObject"); + var objScope = new plugin.QMLObjScope(fileScope, null, obj); + var scope = new plugin.QMLMemScope(objScope, null, fileScope); + + // Define some properties + fileScope.defProp("third", null); + scope.defProp("first", null); + scope.defProp("second", null); + + // Gather the properties and store them in the order they were received + var props = []; + scope.gatherProperties(function (prop, obj, depth) { + props.push(prop); + }); + + // Check the gathered properties for correctness (order matters) + if (props.length !== 3) { + return callback("fail", name, "- Invalid number of properties gathered (" + props.length + ")"); + } + if (props[0] !== "first") { + return callback("fail", name, "- props[0] was not property 'first'"); + } + if (props[1] !== "second") { + return callback("fail", name, "- props[1] was not property 'second'"); + } + if (props[2] !== "third") { + return callback("fail", name, "- props[2] was not property 'third'"); + } + return callback("ok", name); + }); +}); + +test("QMLMemScope::gatherProperties() [Multiple Parent Scopes]", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var rootObj = new infer.Obj(null, "Root"); + var rootObjScope = new plugin.QMLObjScope(fileScope, null, rootObj); + var obj = new infer.Obj(null, "MyObject"); + var objScope = new plugin.QMLObjScope(rootObjScope, null, obj); + var scope = new plugin.QMLMemScope(objScope, null, fileScope); + + // Define a property on the Root Obj Type and Obj Type + rootObj.defProp("notVisible", null); + obj.defProp("visible", null); + + // Gather the properties and store them in the order they were received + var props = []; + scope.gatherProperties(function (prop, obj, depth) { + props.push(prop); + }); + + // Check the gathered properties for correctness (order matters) + if (props.length !== 1) { + return callback("fail", name, "- Invalid number of properties gathered (" + props.length + ")"); + } + if (props[0] !== "visible") { + return callback("fail", name, "- props[0] was not property 'visible'"); + } + return callback("ok", name); + }); +}); + +test("QMLJSScope::hasProp()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var idScope = new infer.Scope(null, "<qml-id>"); + var jsScope = new infer.Scope(null, "<qml-js>"); + var fnScope = new infer.Scope(null, "<qml-fn>"); + var scope = new plugin.QMLJSScope(fileScope, null, idScope, jsScope, fnScope); + + // Define properties in each scope + fileScope.defProp("first", null); + idScope.defProp("second", null); + jsScope.defProp("third", null); + fnScope.defProp("fourth", null); + scope.defProp("fifth", null); + + // Query the scope for the prop we created and make sure it returns the right one + var prop = scope.hasProp("first", true); + if (!prop) { + return callback("fail", name, "- hasProp('first') returned null"); + } else if (prop.propertyName !== "first") { + return callback("fail", name, "- hasProp('first') returned invalid property"); + } + prop = scope.hasProp("second", true); + if (!prop) { + return callback("fail", name, "- hasProp('second') returned null"); + } else if (prop.propertyName !== "second") { + return callback("fail", name, "- hasProp('second') returned invalid property"); + } + prop = scope.hasProp("third", true); + if (!prop) { + return callback("fail", name, "- hasProp('third') returned null"); + } else if (prop.propertyName !== "third") { + return callback("fail", name, "- hasProp('third') returned invalid property"); + } + prop = scope.hasProp("fourth", true); + if (!prop) { + return callback("fail", name, "- hasProp('fourth') returned null"); + } else if (prop.propertyName !== "fourth") { + return callback("fail", name, "- hasProp('fourth') returned invalid property"); + } + prop = scope.hasProp("fifth", true); + if (!prop) { + return callback("fail", name, "- hasProp('fifth') returned null"); + } else if (prop.propertyName !== "fifth") { + return callback("fail", name, "- hasProp('fifth') returned invalid property"); + } + return callback("ok", name); + }); +}); + +test("QMLJSScope::gatherProperties()", function (server, callback, name) { + infer.withContext(new infer.Context([], server), function () { + // Create the scope and objects to test + // Create the scope and objects to test + var fileScope = new infer.Scope(); + var idScope = new infer.Scope(null, "<qml-id>"); + var jsScope = new infer.Scope(null, "<qml-js>"); + var fnScope = new infer.Scope(null, "<qml-fn>"); + var scope = new plugin.QMLJSScope(fileScope, null, idScope, jsScope, fnScope); + + // Define properties in each scope + fileScope.defProp("fifth", null); + idScope.defProp("first", null); + jsScope.defProp("fourth", null); + fnScope.defProp("third", null); + scope.defProp("second", null); + + // Gather the properties and store them in the order they were received + var props = []; + scope.gatherProperties(function (prop, obj, depth) { + props.push(prop); + }); + + // Check the gathered properties for correctness (order matters) + if (props.length !== 5) { + return callback("fail", name, "- Invalid number of properties gathered (" + props.length + ")"); + } + if (props[0] !== "first") { + return callback("fail", name, "- props[0] was not property 'first'"); + } + if (props[1] !== "second") { + return callback("fail", name, "- props[1] was not property 'second'"); + } + if (props[2] !== "third") { + return callback("fail", name, "- props[2] was not property 'third'"); + } + if (props[3] !== "fourth") { + return callback("fail", name, "- props[3] was not property 'fourth'"); + } + if (props[4] !== "fifth") { + return callback("fail", name, "- props[4] was not property 'fifth'"); + } + return callback("ok", name); + }); +}); + groupEnd();
\ No newline at end of file |