Skip to main content
summaryrefslogtreecommitdiffstats
path: root/qt
diff options
context:
space:
mode:
authorJonah Graham2018-11-20 16:20:39 -0500
committerJonah Graham2018-11-20 16:20:39 -0500
commit48d2271a58a68743e428d3096d2bca054d04e310 (patch)
tree235ba23e71c393ad22d1d57fc8fdfec14754c4ee /qt
parent3cf0297769e5cfb91823e93ce570120a75fe01ce (diff)
downloadorg.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.gz
org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.xz
org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.zip
Bug 540373: Normalize newlines with .gitattributes
There is also a new script to verify completeness of .gitattributes: releng/scripts/verify_gitattributes.sh Change-Id: I2ce270852ab54b66b6c474a6ec94203fe5bba78b
Diffstat (limited to 'qt')
-rw-r--r--qt/org.eclipse.cdt.qt.core.tests/scripts/ecma5-defs.js1936
-rw-r--r--qt/org.eclipse.cdt.qt.core.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryLexerTests.java574
-rw-r--r--qt/org.eclipse.cdt.qt.core.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryParserTests.java616
-rw-r--r--qt/org.eclipse.cdt.qt.core/acorn-qml/index.js40
-rw-r--r--qt/org.eclipse.cdt.qt.core/acorn-qml/inject.js1298
-rw-r--r--qt/org.eclipse.cdt.qt.core/acorn-qml/loose/index.js40
-rw-r--r--qt/org.eclipse.cdt.qt.core/acorn-qml/loose/inject.js1354
-rw-r--r--qt/org.eclipse.cdt.qt.core/acorn-qml/package.json22
-rw-r--r--qt/org.eclipse.cdt.qt.core/acorn-qml/test/driver.js224
-rw-r--r--qt/org.eclipse.cdt.qt.core/acorn-qml/test/run.js226
-rw-r--r--qt/org.eclipse.cdt.qt.core/acorn-qml/test/tests-qml.js8042
-rw-r--r--qt/org.eclipse.cdt.qt.core/acorn-qml/walk/index.js168
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QMLModuleResolver.java198
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QmlASTNodeHandler.java504
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/Position.java76
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/location/SourceLocation.java116
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirAST.java72
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirASTNode.java110
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirClassnameCommand.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirCommentCommand.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDependsCommand.java76
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirDesignerSupportedCommand.java32
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirInternalCommand.java76
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirModuleCommand.java54
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirPluginCommand.java76
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirResourceCommand.java94
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSingletonCommand.java96
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirSyntaxError.java80
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirTypeInfoCommand.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirVersion.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmldir/QDirWord.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLComponentInfo.java278
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLEnumInfo.java192
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLExportInfo.java74
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLMethodInfo.java138
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModelBuilder.java382
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLModuleInfo.java80
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLParameterInfo.java104
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLPropertyInfo.java176
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/qmltypes/QMLSignalInfo.java138
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQMLAnalyzer.java90
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java76
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/IPosition.java60
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/location/ISourceLocation.java76
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirAST.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirASTNode.java82
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirClassnameCommand.java50
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommand.java38
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirCommentCommand.java50
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDependsCommand.java64
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirDesignerSupportedCommand.java38
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirInternalCommand.java64
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirModuleCommand.java50
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirPluginCommand.java64
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirResourceCommand.java78
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSingletonCommand.java78
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirSyntaxError.java86
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirTypeInfoCommand.java50
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirVersion.java46
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/IQDirWord.java54
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryInfo.java360
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryLexer.java504
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmldir/QMLDirectoryParser.java846
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSArrayExpression.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSAssignmentExpression.java136
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBinaryExpression.java152
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBlockStatement.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSBreakStatement.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCallExpression.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSCatchClause.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSConditionalExpression.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSContinueStatement.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDebuggerStatement.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDeclaration.java36
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSDoWhileStatement.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSEmptyStatement.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpression.java36
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSExpressionStatement.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForInStatement.java62
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSForStatement.java66
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunction.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionDeclaration.java50
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSFunctionExpression.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIdentifier.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSIfStatement.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLabeledStatement.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLiteral.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSLogicalExpression.java116
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSMemberExpression.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSNewExpression.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSObjectExpression.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSPattern.java34
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProgram.java50
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSProperty.java62
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSRegExpLiteral.java80
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSReturnStatement.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSequenceExpression.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSStatement.java36
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchCase.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSSwitchStatement.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThisExpression.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSThrowStatement.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSTryStatement.java56
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUnaryExpression.java126
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSUpdateExpression.java116
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclaration.java60
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSVariableDeclarator.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWhileStatement.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IJSWithStatement.java52
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlASTNode.java160
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlArrayBinding.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlBinding.java28
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItem.java28
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlHeaderItemList.java34
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlImport.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlModule.java34
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectBinding.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectDefinition.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectInitializer.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlObjectMember.java28
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlParameter.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPragma.java40
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlProgram.java76
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyBinding.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyDeclaration.java60
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlPropertyType.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifiedID.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlQualifier.java40
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlRootObject.java28
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlScriptBinding.java50
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlSignalDefinition.java48
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlStatementBlock.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/IQmlVersionLiteral.java44
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/qmljs/QMLExpressionEvaluator.java240
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/tern/ITernScope.java30
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/.npmignore8
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/demo/defs/ecma5.json.js1930
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/demo/qml-demo.html506
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/ecma5-defs.js1950
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/package.json38
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/qml.js2064
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/test/driver.js418
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/test/ecma5-defs.js1958
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/test/run.js162
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/test/test-completions.js1420
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/test/test-finddef.js616
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/test/test-parse.js250
-rw-r--r--qt/org.eclipse.cdt.qt.core/tern-qml/test/test-scoping.js816
-rw-r--r--qt/org.eclipse.cdt.qt.ui.tests/src/org/eclipse/cdt/qt/pro/parser/tests/QtProjectFileModifierTest.java680
-rw-r--r--qt/org.eclipse.cdt.qt.ui.tests/src/org/eclipse/cdt/qt/pro/parser/tests/QtProjectFileParserTest.java362
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/IQMLPartitions.java54
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/QMLDocumentSetupParticipant.java64
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/QMLEditor.java326
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/QMLKeywords.java238
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/QMLPartitionScanner.java90
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/QMLSourceViewerConfiguration.java472
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/QtProjectFileContentAssistProcessor.java210
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/QtProjectFileEditor.java90
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/QtProjectFileKeyword.java658
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/editor/QtProjectFileSourceViewerConfiguration.java204
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/pro/parser/QtProjectFileModifier.java572
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/pro/parser/QtProjectFileParser.java232
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/pro/parser/QtProjectVariable.java776
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/resources/QMLTernFileUpdateJob.java152
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/resources/QtProjectFileUpdateJob.java314
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/resources/QtResourceChangeListener.java256
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/resources/QtWorkspaceSaveParticipant.java78
167 files changed, 21558 insertions, 21558 deletions
diff --git a/qt/org.eclipse.cdt.qt.core.tests/scripts/ecma5-defs.js b/qt/org.eclipse.cdt.qt.core.tests/scripts/ecma5-defs.js
index 9255014c28..4535e2d73e 100644
--- a/qt/org.eclipse.cdt.qt.core.tests/scripts/ecma5-defs.js
+++ b/qt/org.eclipse.cdt.qt.core.tests/scripts/ecma5-defs.js
@@ -1,968 +1,968 @@
-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."
- }
-};
+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.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryLexerTests.java b/qt/org.eclipse.cdt.qt.core.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryLexerTests.java
index 316430fa4d..1944c6feec 100644
--- a/qt/org.eclipse.cdt.qt.core.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryLexerTests.java
+++ b/qt/org.eclipse.cdt.qt.core.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryLexerTests.java
@@ -1,287 +1,287 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.qt.core.tests;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.eclipse.cdt.internal.qt.core.location.Position;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.Token;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.TokenType;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public class QMLDirectoryLexerTests {
- private void assertToken(TokenType type, String text, int start, int end, Position locStart, Position locEnd, Token actual) {
- // Check token type and text
- assertEquals("Unexpected token type", type, actual.getType());
- assertEquals("Unexpected token text", text, actual.getText());
-
- // Check position offsets
- assertEquals("Unexpected start position", start, actual.getStart());
- assertEquals("Unexpected end position", end, actual.getEnd());
-
- // Check SourceLocation start
- assertEquals("Unexpected location start line", locStart.getLine(), actual.getLocation().getStart().getLine());
- assertEquals("Unexpected location start column", locStart.getColumn(), actual.getLocation().getStart().getColumn());
-
- // Check SourceLocation end
- assertEquals("Unexpected location end line", locEnd.getLine(), actual.getLocation().getEnd().getLine());
- assertEquals("Unexpected location end column", locEnd.getColumn(), actual.getLocation().getEnd().getColumn());
- }
-
- private InputStream createInputStream(String s) {
- return new ByteArrayInputStream(s.getBytes());
- }
-
- @Test
- public void testCommentToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(new ByteArrayInputStream("# This is a comment".getBytes()));
- assertToken(TokenType.COMMENT,
- "# This is a comment",
- 0, 19,
- new Position(1, 0), new Position(1, 19),
- lexer.nextToken(false));
- }
-
- @Test
- public void testMultipleCommentTokens() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("# This is a comment\n# This is another comment\n"));
- assertToken(TokenType.COMMENT,
- "# This is a comment",
- 0, 19,
- new Position(1, 0), new Position(1, 19),
- lexer.nextToken(false));
- assertEquals(TokenType.COMMAND_END, lexer.nextToken(false).getType());
- assertToken(TokenType.COMMENT,
- "# This is another comment",
- 20, 45,
- new Position(2, 0), new Position(2, 25),
- lexer.nextToken(false));
- assertEquals(TokenType.COMMAND_END, lexer.nextToken(false).getType());
- assertEquals(TokenType.EOF, lexer.nextToken(false).getType());
- }
-
- @Test
- public void testModuleToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("module"));
- assertToken(TokenType.MODULE,
- "module",
- 0, 6,
- new Position(1, 0), new Position(1, 6),
- lexer.nextToken());
- }
-
- @Test
- public void testTypeInfoToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("typeinfo"));
- assertToken(TokenType.TYPEINFO,
- "typeinfo",
- 0, 8,
- new Position(1, 0), new Position(1, 8),
- lexer.nextToken());
- }
-
- @Test
- public void testSingletonToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("singleton"));
- assertToken(TokenType.SINGLETON,
- "singleton",
- 0, 9,
- new Position(1, 0), new Position(1, 9),
- lexer.nextToken());
- }
-
- @Test
- public void testInternalToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("internal"));
- assertToken(TokenType.INTERNAL,
- "internal",
- 0, 8,
- new Position(1, 0), new Position(1, 8),
- lexer.nextToken());
- }
-
- @Test
- public void testPluginToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("plugin"));
- assertToken(TokenType.PLUGIN,
- "plugin",
- 0, 6,
- new Position(1, 0), new Position(1, 6),
- lexer.nextToken());
- }
-
- @Test
- public void testClassnameToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("classname"));
- assertToken(TokenType.CLASSNAME,
- "classname",
- 0, 9,
- new Position(1, 0), new Position(1, 9),
- lexer.nextToken());
- }
-
- @Test
- public void testDependsToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("depends"));
- assertToken(TokenType.DEPENDS,
- "depends",
- 0, 7,
- new Position(1, 0), new Position(1, 7),
- lexer.nextToken());
- }
-
- @Test
- public void testDesignerSupportedToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("designersupported"));
- assertToken(TokenType.DESIGNERSUPPORTED,
- "designersupported",
- 0, 17,
- new Position(1, 0), new Position(1, 17),
- lexer.nextToken());
- }
-
- @Test
- public void testWordToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("QtQuick.Control"));
- assertToken(TokenType.WORD,
- "QtQuick.Control",
- 0, 15,
- new Position(1, 0), new Position(1, 15),
- lexer.nextToken());
- }
-
- @Test
- public void testWordTokenContainsKeyword() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("plugins.test"));
- assertToken(TokenType.WORD,
- "plugins.test",
- 0, 12,
- new Position(1, 0), new Position(1, 12),
- lexer.nextToken());
- }
-
- @Test
- public void testWordTokenAsRelativePath() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("./test/something/"));
- assertToken(TokenType.WORD,
- "./test/something/",
- 0, 17,
- new Position(1, 0), new Position(1, 17),
- lexer.nextToken());
- }
-
- @Test
- public void testWordTokenAsAbsoluteWindowsPath() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("C:\\Users\\someone\\test\\something\\"));
- assertToken(TokenType.WORD,
- "C:\\Users\\someone\\test\\something\\",
- 0, 32,
- new Position(1, 0), new Position(1, 32),
- lexer.nextToken());
- }
-
- @Test
- public void testWordTokenAsAbsoluteUnixPath() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("/usr/local/test/something/"));
- assertToken(TokenType.WORD,
- "/usr/local/test/something/",
- 0, 26,
- new Position(1, 0), new Position(1, 26),
- lexer.nextToken());
- }
-
- @Test
- public void testDecimalToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("2.3"));
- assertToken(TokenType.DECIMAL,
- "2.3",
- 0, 3,
- new Position(1, 0), new Position(1, 3),
- lexer.nextToken());
- }
-
- @Test
- public void testIntegerToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("3"));
- assertToken(TokenType.INTEGER,
- "3",
- 0, 1,
- new Position(1, 0), new Position(1, 1),
- lexer.nextToken());
- }
-
- @Test
- public void testWhitespaceToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream(" \t\n"));
- assertToken(TokenType.WHITESPACE,
- " \t",
- 0, 2,
- new Position(1, 0), new Position(1, 2),
- lexer.nextToken(false));
- }
-
- @Test
- public void testCommandEndToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("\n"));
- assertToken(TokenType.COMMAND_END,
- "\\n",
- 0, 1,
- new Position(1, 0), new Position(1, 1),
- lexer.nextToken());
- }
-
- @Test
- public void testEOFToken() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream(""));
- assertToken(TokenType.EOF,
- "",
- 0, 0,
- new Position(1, 0), new Position(1, 0),
- lexer.nextToken());
- }
-
- @Test
- public void testEOFTokenAfterCommand() {
- QMLDirectoryLexer lexer = new QMLDirectoryLexer();
- lexer.setInput(createInputStream("\n"));
- lexer.nextToken();
- assertToken(TokenType.EOF,
- "",
- 1, 1,
- new Position(2, 0), new Position(2, 0),
- lexer.nextToken());
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.qt.core.tests;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.cdt.internal.qt.core.location.Position;
+import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer;
+import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.Token;
+import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryLexer.TokenType;
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class QMLDirectoryLexerTests {
+ private void assertToken(TokenType type, String text, int start, int end, Position locStart, Position locEnd, Token actual) {
+ // Check token type and text
+ assertEquals("Unexpected token type", type, actual.getType());
+ assertEquals("Unexpected token text", text, actual.getText());
+
+ // Check position offsets
+ assertEquals("Unexpected start position", start, actual.getStart());
+ assertEquals("Unexpected end position", end, actual.getEnd());
+
+ // Check SourceLocation start
+ assertEquals("Unexpected location start line", locStart.getLine(), actual.getLocation().getStart().getLine());
+ assertEquals("Unexpected location start column", locStart.getColumn(), actual.getLocation().getStart().getColumn());
+
+ // Check SourceLocation end
+ assertEquals("Unexpected location end line", locEnd.getLine(), actual.getLocation().getEnd().getLine());
+ assertEquals("Unexpected location end column", locEnd.getColumn(), actual.getLocation().getEnd().getColumn());
+ }
+
+ private InputStream createInputStream(String s) {
+ return new ByteArrayInputStream(s.getBytes());
+ }
+
+ @Test
+ public void testCommentToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(new ByteArrayInputStream("# This is a comment".getBytes()));
+ assertToken(TokenType.COMMENT,
+ "# This is a comment",
+ 0, 19,
+ new Position(1, 0), new Position(1, 19),
+ lexer.nextToken(false));
+ }
+
+ @Test
+ public void testMultipleCommentTokens() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("# This is a comment\n# This is another comment\n"));
+ assertToken(TokenType.COMMENT,
+ "# This is a comment",
+ 0, 19,
+ new Position(1, 0), new Position(1, 19),
+ lexer.nextToken(false));
+ assertEquals(TokenType.COMMAND_END, lexer.nextToken(false).getType());
+ assertToken(TokenType.COMMENT,
+ "# This is another comment",
+ 20, 45,
+ new Position(2, 0), new Position(2, 25),
+ lexer.nextToken(false));
+ assertEquals(TokenType.COMMAND_END, lexer.nextToken(false).getType());
+ assertEquals(TokenType.EOF, lexer.nextToken(false).getType());
+ }
+
+ @Test
+ public void testModuleToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("module"));
+ assertToken(TokenType.MODULE,
+ "module",
+ 0, 6,
+ new Position(1, 0), new Position(1, 6),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testTypeInfoToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("typeinfo"));
+ assertToken(TokenType.TYPEINFO,
+ "typeinfo",
+ 0, 8,
+ new Position(1, 0), new Position(1, 8),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testSingletonToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("singleton"));
+ assertToken(TokenType.SINGLETON,
+ "singleton",
+ 0, 9,
+ new Position(1, 0), new Position(1, 9),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testInternalToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("internal"));
+ assertToken(TokenType.INTERNAL,
+ "internal",
+ 0, 8,
+ new Position(1, 0), new Position(1, 8),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testPluginToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("plugin"));
+ assertToken(TokenType.PLUGIN,
+ "plugin",
+ 0, 6,
+ new Position(1, 0), new Position(1, 6),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testClassnameToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("classname"));
+ assertToken(TokenType.CLASSNAME,
+ "classname",
+ 0, 9,
+ new Position(1, 0), new Position(1, 9),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testDependsToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("depends"));
+ assertToken(TokenType.DEPENDS,
+ "depends",
+ 0, 7,
+ new Position(1, 0), new Position(1, 7),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testDesignerSupportedToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("designersupported"));
+ assertToken(TokenType.DESIGNERSUPPORTED,
+ "designersupported",
+ 0, 17,
+ new Position(1, 0), new Position(1, 17),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testWordToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("QtQuick.Control"));
+ assertToken(TokenType.WORD,
+ "QtQuick.Control",
+ 0, 15,
+ new Position(1, 0), new Position(1, 15),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testWordTokenContainsKeyword() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("plugins.test"));
+ assertToken(TokenType.WORD,
+ "plugins.test",
+ 0, 12,
+ new Position(1, 0), new Position(1, 12),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testWordTokenAsRelativePath() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("./test/something/"));
+ assertToken(TokenType.WORD,
+ "./test/something/",
+ 0, 17,
+ new Position(1, 0), new Position(1, 17),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testWordTokenAsAbsoluteWindowsPath() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("C:\\Users\\someone\\test\\something\\"));
+ assertToken(TokenType.WORD,
+ "C:\\Users\\someone\\test\\something\\",
+ 0, 32,
+ new Position(1, 0), new Position(1, 32),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testWordTokenAsAbsoluteUnixPath() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("/usr/local/test/something/"));
+ assertToken(TokenType.WORD,
+ "/usr/local/test/something/",
+ 0, 26,
+ new Position(1, 0), new Position(1, 26),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testDecimalToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("2.3"));
+ assertToken(TokenType.DECIMAL,
+ "2.3",
+ 0, 3,
+ new Position(1, 0), new Position(1, 3),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testIntegerToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("3"));
+ assertToken(TokenType.INTEGER,
+ "3",
+ 0, 1,
+ new Position(1, 0), new Position(1, 1),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testWhitespaceToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream(" \t\n"));
+ assertToken(TokenType.WHITESPACE,
+ " \t",
+ 0, 2,
+ new Position(1, 0), new Position(1, 2),
+ lexer.nextToken(false));
+ }
+
+ @Test
+ public void testCommandEndToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("\n"));
+ assertToken(TokenType.COMMAND_END,
+ "\\n",
+ 0, 1,
+ new Position(1, 0), new Position(1, 1),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testEOFToken() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream(""));
+ assertToken(TokenType.EOF,
+ "",
+ 0, 0,
+ new Position(1, 0), new Position(1, 0),
+ lexer.nextToken());
+ }
+
+ @Test
+ public void testEOFTokenAfterCommand() {
+ QMLDirectoryLexer lexer = new QMLDirectoryLexer();
+ lexer.setInput(createInputStream("\n"));
+ lexer.nextToken();
+ assertToken(TokenType.EOF,
+ "",
+ 1, 1,
+ new Position(2, 0), new Position(2, 0),
+ lexer.nextToken());
+ }
+}
diff --git a/qt/org.eclipse.cdt.qt.core.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryParserTests.java b/qt/org.eclipse.cdt.qt.core.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryParserTests.java
index 74333f01e2..2ef27911ed 100644
--- a/qt/org.eclipse.cdt.qt.core.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryParserTests.java
+++ b/qt/org.eclipse.cdt.qt.core.tests/src/org/eclipse/cdt/qt/core/tests/QMLDirectoryParserTests.java
@@ -1,308 +1,308 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.qt.core.tests;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.eclipse.cdt.internal.qt.core.location.Position;
-import org.eclipse.cdt.qt.core.location.IPosition;
-import org.eclipse.cdt.qt.core.qmldir.IQDirAST;
-import org.eclipse.cdt.qt.core.qmldir.IQDirASTNode;
-import org.eclipse.cdt.qt.core.qmldir.IQDirClassnameCommand;
-import org.eclipse.cdt.qt.core.qmldir.IQDirCommentCommand;
-import org.eclipse.cdt.qt.core.qmldir.IQDirDependsCommand;
-import org.eclipse.cdt.qt.core.qmldir.IQDirDesignerSupportedCommand;
-import org.eclipse.cdt.qt.core.qmldir.IQDirInternalCommand;
-import org.eclipse.cdt.qt.core.qmldir.IQDirModuleCommand;
-import org.eclipse.cdt.qt.core.qmldir.IQDirPluginCommand;
-import org.eclipse.cdt.qt.core.qmldir.IQDirResourceCommand;
-import org.eclipse.cdt.qt.core.qmldir.IQDirSingletonCommand;
-import org.eclipse.cdt.qt.core.qmldir.IQDirSyntaxError;
-import org.eclipse.cdt.qt.core.qmldir.IQDirTypeInfoCommand;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryParser;
-import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryParser.SyntaxError;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public class QMLDirectoryParserTests {
-
- public void assertLocation(int start, int end, IPosition locStart, IPosition locEnd, IQDirASTNode node) {
- // Check position offsets
- assertEquals("Unexpected start position", start, node.getStart());
- assertEquals("Unexpected end position", end, node.getEnd());
-
- // Check SourceLocation start
- assertEquals("Unexpected location start line", locStart.getLine(), node.getLocation().getStart().getLine());
- assertEquals("Unexpected location start column", locStart.getColumn(), node.getLocation().getStart().getColumn());
- }
-
- private InputStream createInputStream(String s) {
- return new ByteArrayInputStream(s.getBytes());
- }
-
- @Test
- public void testModuleCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("module QtQuick.Controls\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
- IQDirModuleCommand mod = (IQDirModuleCommand) ast.getCommands().get(0);
- assertEquals("Unexpected qualified ID", "QtQuick.Controls", mod.getModuleIdentifier().getText());
- assertLocation(0, 24, new Position(1, 0), new Position(1, 24), mod);
- }
-
- @Test
- public void testModuleNoIdentifier() {
- try {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- parser.parse(createInputStream("module\n"), false);
- fail("Parser did not throw SyntaxError");
- } catch (SyntaxError e) {
- assertEquals("Unexpected token '\\n' (1:6)", e.getMessage());
- }
- }
-
- @Test
- public void testSingletonCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("singleton Singleton 2.3 Singleton.qml\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirSingletonCommand.class));
- IQDirSingletonCommand singleton = (IQDirSingletonCommand) ast.getCommands().get(0);
- assertEquals("Unexpected type name", "Singleton", singleton.getTypeName().getText());
- assertEquals("Unexpected initial version", "2.3", singleton.getInitialVersion().getVersionString());
- assertEquals("Unexpected file name", "Singleton.qml", singleton.getFile().getText());
- assertLocation(0, 38, new Position(1, 0), new Position(1, 38), singleton);
- }
-
- @Test
- public void testInvalidVersionNumber() {
- try {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- parser.parse(createInputStream("singleton Singleton 2 Singleton.qml\n"), false);
- fail("Parser did not throw SyntaxError");
- } catch (SyntaxError e) {
- assertEquals("Unexpected token '2' (1:20)", e.getMessage());
- }
- }
-
- @Test
- public void testInternalCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("internal MyPrivateType MyPrivateType.qml\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirInternalCommand.class));
- IQDirInternalCommand internal = (IQDirInternalCommand) ast.getCommands().get(0);
- assertEquals("Unexpected type name", "MyPrivateType", internal.getTypeName().getText());
- assertEquals("Unexpected file name", "MyPrivateType.qml", internal.getFile().getText());
- assertLocation(0, 41, new Position(1, 0), new Position(1, 41), internal);
- }
-
- @Test
- public void testResourceCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("MyScript 1.0 MyScript.qml\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirResourceCommand.class));
- IQDirResourceCommand resource = (IQDirResourceCommand) ast.getCommands().get(0);
- assertEquals("Unexpected type name", "MyScript", resource.getResourceIdentifier().getText());
- assertEquals("Unexpected initial version", "1.0", resource.getInitialVersion().getVersionString());
- assertEquals("Unexpected file name", "MyScript.qml", resource.getFile().getText());
- assertLocation(0, 26, new Position(1, 0), new Position(1, 26), resource);
- }
-
- @Test
- public void testPluginCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("plugin MyPluginLibrary\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirPluginCommand.class));
- IQDirPluginCommand plugin = (IQDirPluginCommand) ast.getCommands().get(0);
- assertEquals("Unexpected identifier", "MyPluginLibrary", plugin.getName().getText());
- assertEquals("Unexpected path", null, plugin.getPath());
- assertLocation(0, 23, new Position(1, 0), new Position(1, 23), plugin);
- }
-
- @Test
- public void testPluginCommandWithPath() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("plugin MyPluginLibrary ./lib/\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirPluginCommand.class));
- IQDirPluginCommand plugin = (IQDirPluginCommand) ast.getCommands().get(0);
- assertEquals("Unexpected identifier", "MyPluginLibrary", plugin.getName().getText());
- assertEquals("Unexpected path", "./lib/", plugin.getPath().getText());
- assertLocation(0, 30, new Position(1, 0), new Position(1, 30), plugin);
- }
-
- @Test
- public void testClassnameCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("classname MyClass\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirClassnameCommand.class));
- IQDirClassnameCommand classname = (IQDirClassnameCommand) ast.getCommands().get(0);
- assertEquals("Unexpected class name", "MyClass", classname.getIdentifier().getText());
- assertLocation(0, 18, new Position(1, 0), new Position(1, 18), classname);
- }
-
- @Test
- public void testTypeInfoCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("typeinfo mymodule.qmltypes\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirTypeInfoCommand.class));
- IQDirTypeInfoCommand typeinfo = (IQDirTypeInfoCommand) ast.getCommands().get(0);
- assertEquals("Unexpected file name", "mymodule.qmltypes", typeinfo.getFile().getText());
- assertLocation(0, 27, new Position(1, 0), new Position(1, 27), typeinfo);
- }
-
- @Test
- public void testDependsCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("depends MyOtherModule 1.0\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirDependsCommand.class));
- IQDirDependsCommand depends = (IQDirDependsCommand) ast.getCommands().get(0);
- assertEquals("Unexpected module identifier", "MyOtherModule", depends.getModuleIdentifier().getText());
- assertEquals("Unexpected initial version", "1.0", depends.getInitialVersion().getVersionString());
- assertLocation(0, 26, new Position(1, 0), new Position(1, 26), depends);
- }
-
- @Test
- public void testDesignerSupportedCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("designersupported\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirDesignerSupportedCommand.class));
- assertLocation(0, 18, new Position(1, 0), new Position(1, 18), ast.getCommands().get(0));
- }
-
- @Test
- public void testCommentCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("# This is a comment command\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirCommentCommand.class));
- IQDirCommentCommand comment = (IQDirCommentCommand) ast.getCommands().get(0);
- assertEquals("Unexpected text", "# This is a comment command", comment.getText());
- }
-
- @Test
- public void testSyntaxErrorCommand() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("classname"));
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirSyntaxError.class));
- IQDirSyntaxError err = (IQDirSyntaxError) ast.getCommands().get(0);
- assertEquals("Unexpected message", "Unexpected token 'EOF' (1:9)", err.getSyntaxError().getMessage());
- assertLocation(0, 9, new Position(1, 0), new Position(1, 9), err);
- }
-
- @Test
- public void testSyntaxErrorCommandIncludesWholeLine() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("classname class extra\n"));
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirSyntaxError.class));
- IQDirSyntaxError err = (IQDirSyntaxError) ast.getCommands().get(0);
- assertEquals("Unexpected message", "Expected token '\\n' or 'EOF', but saw 'extra' (1:16)",
- err.getSyntaxError().getMessage());
- assertLocation(0, 22, new Position(1, 0), new Position(1, 22), err);
- }
-
- @Test
- public void testExampleQMLDirFile() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("module QtQuick\n" +
- "plugin qtquick2plugin\n" +
- "classname QtQuick2Plugin\n" +
- "typeinfo plugins.qmltypes\n" +
- "designersupported\n"));
-
- assertEquals("Unexpected command list size", 5, ast.getCommands().size());
- // Module Command (index 0)
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
- IQDirModuleCommand mod = (IQDirModuleCommand) ast.getCommands().get(0);
- assertEquals("Unexpected module qualified ID", "QtQuick", mod.getModuleIdentifier().getText());
- // Plugin Command (index 1)
- assertThat("Unexpected command", ast.getCommands().get(1), instanceOf(IQDirPluginCommand.class));
- IQDirPluginCommand plugin = (IQDirPluginCommand) ast.getCommands().get(1);
- assertEquals("Unexpected plugin identifier", "qtquick2plugin", plugin.getName().getText());
- assertEquals("Unexpected plugin path", null, plugin.getPath());
- // Classname Command (index 2)
- assertThat("Unexpected command", ast.getCommands().get(2), instanceOf(IQDirClassnameCommand.class));
- IQDirClassnameCommand classname = (IQDirClassnameCommand) ast.getCommands().get(2);
- assertEquals("Unexpected class name", "QtQuick2Plugin", classname.getIdentifier().getText());
- // Type Info Command (index 3)
- assertThat("Unexpected command", ast.getCommands().get(3), instanceOf(IQDirTypeInfoCommand.class));
- IQDirTypeInfoCommand typeinfo = (IQDirTypeInfoCommand) ast.getCommands().get(3);
- assertEquals("Unexpected type info file name", "plugins.qmltypes", typeinfo.getFile().getText());
- // Designer Supported Command (index 4)
- assertThat("Unexpected command", ast.getCommands().get(4), instanceOf(IQDirDesignerSupportedCommand.class));
- }
-
- @Test
- public void testExampleQMLDirFileWithError() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
- IQDirAST ast = parser.parse(createInputStream("module QtQuick\n" +
- "plugin qtquick2plugin\n" +
- "classnames QtQuick2Plugin\n" +
- "typeinfo plugins.qmltypes\n" +
- "designersupported\n"));
-
- assertEquals("Unexpected command list size", 5, ast.getCommands().size());
- // Module Command (index 0)
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
- IQDirModuleCommand mod = (IQDirModuleCommand) ast.getCommands().get(0);
- assertEquals("Unexpected module qualified ID", "QtQuick", mod.getModuleIdentifier().getText());
- // Plugin Command (index 1)
- assertThat("Unexpected command", ast.getCommands().get(1), instanceOf(IQDirPluginCommand.class));
- IQDirPluginCommand plugin = (IQDirPluginCommand) ast.getCommands().get(1);
- assertEquals("Unexpected plugin identifier", "qtquick2plugin", plugin.getName().getText());
- assertEquals("Unexpected plugin path", null, plugin.getPath());
- // Syntax Error Command (index 2)
- assertThat("Unexpected command", ast.getCommands().get(2), instanceOf(IQDirSyntaxError.class));
- IQDirSyntaxError err = (IQDirSyntaxError) ast.getCommands().get(2);
- assertEquals("Unexpected error message", "Unexpected token 'QtQuick2Plugin' (3:11)", err.getSyntaxError().getMessage());
- // Type Info Command (index 3)
- assertThat("Unexpected command", ast.getCommands().get(3), instanceOf(IQDirTypeInfoCommand.class));
- IQDirTypeInfoCommand typeinfo = (IQDirTypeInfoCommand) ast.getCommands().get(3);
- assertEquals("Unexpected type info file name", "plugins.qmltypes", typeinfo.getFile().getText());
- // Designer Supported Command (index 4)
- assertThat("Unexpected command", ast.getCommands().get(4), instanceOf(IQDirDesignerSupportedCommand.class));
- }
-
- @Test
- public void testParseTwoDifferentStreams() {
- QMLDirectoryParser parser = new QMLDirectoryParser();
-
- // Parse module QtQuick.Controls
- IQDirAST ast = parser.parse(createInputStream("module QtQuick.Controls\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
- IQDirModuleCommand mod = (IQDirModuleCommand) ast.getCommands().get(0);
- assertEquals("Unexpected qualified ID", "QtQuick.Controls", mod.getModuleIdentifier().getText());
- assertLocation(0, 24, new Position(1, 0), new Position(1, 24), mod);
-
- // Parse a second module MyModule
- ast = parser.parse(createInputStream("module MyModule\n"), false);
- assertEquals("Unexpected command list size", 1, ast.getCommands().size());
- assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
- mod = (IQDirModuleCommand) ast.getCommands().get(0);
- assertEquals("Unexpected qualified ID", "MyModule", mod.getModuleIdentifier().getText());
- assertLocation(0, 16, new Position(1, 0), new Position(1, 16), mod);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.qt.core.tests;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.cdt.internal.qt.core.location.Position;
+import org.eclipse.cdt.qt.core.location.IPosition;
+import org.eclipse.cdt.qt.core.qmldir.IQDirAST;
+import org.eclipse.cdt.qt.core.qmldir.IQDirASTNode;
+import org.eclipse.cdt.qt.core.qmldir.IQDirClassnameCommand;
+import org.eclipse.cdt.qt.core.qmldir.IQDirCommentCommand;
+import org.eclipse.cdt.qt.core.qmldir.IQDirDependsCommand;
+import org.eclipse.cdt.qt.core.qmldir.IQDirDesignerSupportedCommand;
+import org.eclipse.cdt.qt.core.qmldir.IQDirInternalCommand;
+import org.eclipse.cdt.qt.core.qmldir.IQDirModuleCommand;
+import org.eclipse.cdt.qt.core.qmldir.IQDirPluginCommand;
+import org.eclipse.cdt.qt.core.qmldir.IQDirResourceCommand;
+import org.eclipse.cdt.qt.core.qmldir.IQDirSingletonCommand;
+import org.eclipse.cdt.qt.core.qmldir.IQDirSyntaxError;
+import org.eclipse.cdt.qt.core.qmldir.IQDirTypeInfoCommand;
+import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryParser;
+import org.eclipse.cdt.qt.core.qmldir.QMLDirectoryParser.SyntaxError;
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class QMLDirectoryParserTests {
+
+ public void assertLocation(int start, int end, IPosition locStart, IPosition locEnd, IQDirASTNode node) {
+ // Check position offsets
+ assertEquals("Unexpected start position", start, node.getStart());
+ assertEquals("Unexpected end position", end, node.getEnd());
+
+ // Check SourceLocation start
+ assertEquals("Unexpected location start line", locStart.getLine(), node.getLocation().getStart().getLine());
+ assertEquals("Unexpected location start column", locStart.getColumn(), node.getLocation().getStart().getColumn());
+ }
+
+ private InputStream createInputStream(String s) {
+ return new ByteArrayInputStream(s.getBytes());
+ }
+
+ @Test
+ public void testModuleCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("module QtQuick.Controls\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
+ IQDirModuleCommand mod = (IQDirModuleCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected qualified ID", "QtQuick.Controls", mod.getModuleIdentifier().getText());
+ assertLocation(0, 24, new Position(1, 0), new Position(1, 24), mod);
+ }
+
+ @Test
+ public void testModuleNoIdentifier() {
+ try {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ parser.parse(createInputStream("module\n"), false);
+ fail("Parser did not throw SyntaxError");
+ } catch (SyntaxError e) {
+ assertEquals("Unexpected token '\\n' (1:6)", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testSingletonCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("singleton Singleton 2.3 Singleton.qml\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirSingletonCommand.class));
+ IQDirSingletonCommand singleton = (IQDirSingletonCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected type name", "Singleton", singleton.getTypeName().getText());
+ assertEquals("Unexpected initial version", "2.3", singleton.getInitialVersion().getVersionString());
+ assertEquals("Unexpected file name", "Singleton.qml", singleton.getFile().getText());
+ assertLocation(0, 38, new Position(1, 0), new Position(1, 38), singleton);
+ }
+
+ @Test
+ public void testInvalidVersionNumber() {
+ try {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ parser.parse(createInputStream("singleton Singleton 2 Singleton.qml\n"), false);
+ fail("Parser did not throw SyntaxError");
+ } catch (SyntaxError e) {
+ assertEquals("Unexpected token '2' (1:20)", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testInternalCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("internal MyPrivateType MyPrivateType.qml\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirInternalCommand.class));
+ IQDirInternalCommand internal = (IQDirInternalCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected type name", "MyPrivateType", internal.getTypeName().getText());
+ assertEquals("Unexpected file name", "MyPrivateType.qml", internal.getFile().getText());
+ assertLocation(0, 41, new Position(1, 0), new Position(1, 41), internal);
+ }
+
+ @Test
+ public void testResourceCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("MyScript 1.0 MyScript.qml\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirResourceCommand.class));
+ IQDirResourceCommand resource = (IQDirResourceCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected type name", "MyScript", resource.getResourceIdentifier().getText());
+ assertEquals("Unexpected initial version", "1.0", resource.getInitialVersion().getVersionString());
+ assertEquals("Unexpected file name", "MyScript.qml", resource.getFile().getText());
+ assertLocation(0, 26, new Position(1, 0), new Position(1, 26), resource);
+ }
+
+ @Test
+ public void testPluginCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("plugin MyPluginLibrary\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirPluginCommand.class));
+ IQDirPluginCommand plugin = (IQDirPluginCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected identifier", "MyPluginLibrary", plugin.getName().getText());
+ assertEquals("Unexpected path", null, plugin.getPath());
+ assertLocation(0, 23, new Position(1, 0), new Position(1, 23), plugin);
+ }
+
+ @Test
+ public void testPluginCommandWithPath() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("plugin MyPluginLibrary ./lib/\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirPluginCommand.class));
+ IQDirPluginCommand plugin = (IQDirPluginCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected identifier", "MyPluginLibrary", plugin.getName().getText());
+ assertEquals("Unexpected path", "./lib/", plugin.getPath().getText());
+ assertLocation(0, 30, new Position(1, 0), new Position(1, 30), plugin);
+ }
+
+ @Test
+ public void testClassnameCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("classname MyClass\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirClassnameCommand.class));
+ IQDirClassnameCommand classname = (IQDirClassnameCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected class name", "MyClass", classname.getIdentifier().getText());
+ assertLocation(0, 18, new Position(1, 0), new Position(1, 18), classname);
+ }
+
+ @Test
+ public void testTypeInfoCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("typeinfo mymodule.qmltypes\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirTypeInfoCommand.class));
+ IQDirTypeInfoCommand typeinfo = (IQDirTypeInfoCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected file name", "mymodule.qmltypes", typeinfo.getFile().getText());
+ assertLocation(0, 27, new Position(1, 0), new Position(1, 27), typeinfo);
+ }
+
+ @Test
+ public void testDependsCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("depends MyOtherModule 1.0\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirDependsCommand.class));
+ IQDirDependsCommand depends = (IQDirDependsCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected module identifier", "MyOtherModule", depends.getModuleIdentifier().getText());
+ assertEquals("Unexpected initial version", "1.0", depends.getInitialVersion().getVersionString());
+ assertLocation(0, 26, new Position(1, 0), new Position(1, 26), depends);
+ }
+
+ @Test
+ public void testDesignerSupportedCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("designersupported\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirDesignerSupportedCommand.class));
+ assertLocation(0, 18, new Position(1, 0), new Position(1, 18), ast.getCommands().get(0));
+ }
+
+ @Test
+ public void testCommentCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("# This is a comment command\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirCommentCommand.class));
+ IQDirCommentCommand comment = (IQDirCommentCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected text", "# This is a comment command", comment.getText());
+ }
+
+ @Test
+ public void testSyntaxErrorCommand() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("classname"));
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirSyntaxError.class));
+ IQDirSyntaxError err = (IQDirSyntaxError) ast.getCommands().get(0);
+ assertEquals("Unexpected message", "Unexpected token 'EOF' (1:9)", err.getSyntaxError().getMessage());
+ assertLocation(0, 9, new Position(1, 0), new Position(1, 9), err);
+ }
+
+ @Test
+ public void testSyntaxErrorCommandIncludesWholeLine() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("classname class extra\n"));
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirSyntaxError.class));
+ IQDirSyntaxError err = (IQDirSyntaxError) ast.getCommands().get(0);
+ assertEquals("Unexpected message", "Expected token '\\n' or 'EOF', but saw 'extra' (1:16)",
+ err.getSyntaxError().getMessage());
+ assertLocation(0, 22, new Position(1, 0), new Position(1, 22), err);
+ }
+
+ @Test
+ public void testExampleQMLDirFile() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("module QtQuick\n" +
+ "plugin qtquick2plugin\n" +
+ "classname QtQuick2Plugin\n" +
+ "typeinfo plugins.qmltypes\n" +
+ "designersupported\n"));
+
+ assertEquals("Unexpected command list size", 5, ast.getCommands().size());
+ // Module Command (index 0)
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
+ IQDirModuleCommand mod = (IQDirModuleCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected module qualified ID", "QtQuick", mod.getModuleIdentifier().getText());
+ // Plugin Command (index 1)
+ assertThat("Unexpected command", ast.getCommands().get(1), instanceOf(IQDirPluginCommand.class));
+ IQDirPluginCommand plugin = (IQDirPluginCommand) ast.getCommands().get(1);
+ assertEquals("Unexpected plugin identifier", "qtquick2plugin", plugin.getName().getText());
+ assertEquals("Unexpected plugin path", null, plugin.getPath());
+ // Classname Command (index 2)
+ assertThat("Unexpected command", ast.getCommands().get(2), instanceOf(IQDirClassnameCommand.class));
+ IQDirClassnameCommand classname = (IQDirClassnameCommand) ast.getCommands().get(2);
+ assertEquals("Unexpected class name", "QtQuick2Plugin", classname.getIdentifier().getText());
+ // Type Info Command (index 3)
+ assertThat("Unexpected command", ast.getCommands().get(3), instanceOf(IQDirTypeInfoCommand.class));
+ IQDirTypeInfoCommand typeinfo = (IQDirTypeInfoCommand) ast.getCommands().get(3);
+ assertEquals("Unexpected type info file name", "plugins.qmltypes", typeinfo.getFile().getText());
+ // Designer Supported Command (index 4)
+ assertThat("Unexpected command", ast.getCommands().get(4), instanceOf(IQDirDesignerSupportedCommand.class));
+ }
+
+ @Test
+ public void testExampleQMLDirFileWithError() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+ IQDirAST ast = parser.parse(createInputStream("module QtQuick\n" +
+ "plugin qtquick2plugin\n" +
+ "classnames QtQuick2Plugin\n" +
+ "typeinfo plugins.qmltypes\n" +
+ "designersupported\n"));
+
+ assertEquals("Unexpected command list size", 5, ast.getCommands().size());
+ // Module Command (index 0)
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
+ IQDirModuleCommand mod = (IQDirModuleCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected module qualified ID", "QtQuick", mod.getModuleIdentifier().getText());
+ // Plugin Command (index 1)
+ assertThat("Unexpected command", ast.getCommands().get(1), instanceOf(IQDirPluginCommand.class));
+ IQDirPluginCommand plugin = (IQDirPluginCommand) ast.getCommands().get(1);
+ assertEquals("Unexpected plugin identifier", "qtquick2plugin", plugin.getName().getText());
+ assertEquals("Unexpected plugin path", null, plugin.getPath());
+ // Syntax Error Command (index 2)
+ assertThat("Unexpected command", ast.getCommands().get(2), instanceOf(IQDirSyntaxError.class));
+ IQDirSyntaxError err = (IQDirSyntaxError) ast.getCommands().get(2);
+ assertEquals("Unexpected error message", "Unexpected token 'QtQuick2Plugin' (3:11)", err.getSyntaxError().getMessage());
+ // Type Info Command (index 3)
+ assertThat("Unexpected command", ast.getCommands().get(3), instanceOf(IQDirTypeInfoCommand.class));
+ IQDirTypeInfoCommand typeinfo = (IQDirTypeInfoCommand) ast.getCommands().get(3);
+ assertEquals("Unexpected type info file name", "plugins.qmltypes", typeinfo.getFile().getText());
+ // Designer Supported Command (index 4)
+ assertThat("Unexpected command", ast.getCommands().get(4), instanceOf(IQDirDesignerSupportedCommand.class));
+ }
+
+ @Test
+ public void testParseTwoDifferentStreams() {
+ QMLDirectoryParser parser = new QMLDirectoryParser();
+
+ // Parse module QtQuick.Controls
+ IQDirAST ast = parser.parse(createInputStream("module QtQuick.Controls\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
+ IQDirModuleCommand mod = (IQDirModuleCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected qualified ID", "QtQuick.Controls", mod.getModuleIdentifier().getText());
+ assertLocation(0, 24, new Position(1, 0), new Position(1, 24), mod);
+
+ // Parse a second module MyModule
+ ast = parser.parse(createInputStream("module MyModule\n"), false);
+ assertEquals("Unexpected command list size", 1, ast.getCommands().size());
+ assertThat("Unexpected command", ast.getCommands().get(0), instanceOf(IQDirModuleCommand.class));
+ mod = (IQDirModuleCommand) ast.getCommands().get(0);
+ assertEquals("Unexpected qualified ID", "MyModule", mod.getModuleIdentifier().getText());
+ assertLocation(0, 16, new Position(1, 0), new Position(1, 16), mod);
+ }
+}
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 7f4ad9d558..6bc36dd58e 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 3dc09cb40e..6e27ab94a8 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 524c15db17..7b0bdc97a3 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 0c2e042583..64959ecb5e 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 1a452cba41..12ed66314d 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 8c5fdcc9ff..bee02325c5 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 07816ecda7..dab4c8d4da 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 4610eb2336..4d2362db13 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 a1883ac501..09063fc703 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 602533ee12..40d91caec7 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 46e9866393..1e2d4e8fce 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 1ec2df36bb..b8cdfc6fa0 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 d1a702a772..12e42a241d 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 78f0f3e62e..5a61854684 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 a3fd932275..1a9e3ef4fd 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 6963f34541..a1ea7ab75a 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 40505866bb..b44d34be56 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 45639004a4..15ffaa4090 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 9b7583a437..b73274eefa 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 b437e8dc70..9262ffec54 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 cea1f44b25..08b29a0577 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 61fbb2fbdb..e2ff96311d 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 7c9b8541a8..7c3a2e5c28 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 03208f0afd..933ccaaefd 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 a66b968ddb..d186887cc7 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 9b2f00e1a9..0332e141ee 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 4a3c3dabe3..161ffdf672 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 89aac96b73..76ea26a8bf 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 b33d24a18a..5a30528aaf 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 3d1c19dc0b..99676d4d85 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 2a4707ed62..7fd83edf73 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 a09b6fd8f1..01a4c71ec6 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 401d941e4b..f7dd6da11d 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[] getIntege