forked from qt-creator/qt-creator
Renamed classes and files to use the QmlJS prefix.
This commit is contained in:
@@ -47,13 +47,13 @@
|
|||||||
# define QT_QML_BEGIN_NAMESPACE
|
# define QT_QML_BEGIN_NAMESPACE
|
||||||
# define QT_QML_END_NAMESPACE
|
# define QT_QML_END_NAMESPACE
|
||||||
|
|
||||||
# ifdef QML_BUILD_LIB
|
# ifdef QMLJS_BUILD_DIR
|
||||||
# define QML_PARSER_EXPORT Q_DECL_EXPORT
|
# define QML_PARSER_EXPORT Q_DECL_EXPORT
|
||||||
# elif QML_BUILD_STATIC_LIB
|
# elif QML_BUILD_STATIC_LIB
|
||||||
# define QML_PARSER_EXPORT
|
# define QML_PARSER_EXPORT
|
||||||
# else
|
# else
|
||||||
# define QML_PARSER_EXPORT Q_DECL_IMPORT
|
# define QML_PARSER_EXPORT Q_DECL_IMPORT
|
||||||
# endif // QML_BUILD_LIB
|
# endif // QMLJS_BUILD_DIR
|
||||||
|
|
||||||
#else // !QT_CREATOR
|
#else // !QT_CREATOR
|
||||||
# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
|
# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
contains(CONFIG, dll) {
|
contains(CONFIG, dll) {
|
||||||
DEFINES += QML_BUILD_LIB
|
DEFINES += QMLJS_BUILD_DIR
|
||||||
} else {
|
} else {
|
||||||
DEFINES += QML_BUILD_STATIC_LIB
|
DEFINES += QML_BUILD_STATIC_LIB
|
||||||
}
|
}
|
||||||
@@ -12,23 +12,27 @@ DEPENDPATH += $$PWD
|
|||||||
INCLUDEPATH += $$PWD/..
|
INCLUDEPATH += $$PWD/..
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/qml_global.h \
|
$$PWD/qmljs_global.h \
|
||||||
$$PWD/qmlidcollector.h \
|
$$PWD/qmljsbind.h \
|
||||||
$$PWD/qmldocument.h \
|
$$PWD/qmljscheck.h \
|
||||||
$$PWD/qmlpackageinfo.h \
|
$$PWD/qmljsdocument.h \
|
||||||
$$PWD/qmlsymbol.h \
|
$$PWD/qmljsidcollector.h \
|
||||||
$$PWD/qmlmetatypebackend.h \
|
$$PWD/qmljsmetatypebackend.h \
|
||||||
$$PWD/qmltypesystem.h \
|
$$PWD/qmljspackageinfo.h \
|
||||||
$$PWD/qscriptincrementalscanner.h
|
$$PWD/qmljsscanner.h \
|
||||||
|
$$PWD/qmljssymbol.h \
|
||||||
|
$$PWD/qmljstypesystem.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/qmlidcollector.cpp \
|
$$PWD/qmljsbind.cpp \
|
||||||
$$PWD/qmldocument.cpp \
|
$$PWD/qmljscheck.cpp \
|
||||||
$$PWD/qmlsymbol.cpp \
|
$$PWD/qmljsdocument.cpp \
|
||||||
$$PWD/qmlpackageinfo.cpp \
|
$$PWD/qmljsidcollector.cpp \
|
||||||
$$PWD/qmlmetatypebackend.cpp \
|
$$PWD/qmljsmetatypebackend.cpp \
|
||||||
$$PWD/qmltypesystem.cpp \
|
$$PWD/qmljspackageinfo.cpp \
|
||||||
$$PWD/qscriptincrementalscanner.cpp
|
$$PWD/qmljsscanner.cpp \
|
||||||
|
$$PWD/qmljssymbol.cpp \
|
||||||
|
$$PWD/qmljstypesystem.cpp
|
||||||
|
|
||||||
contains(QT_CONFIG, declarative) {
|
contains(QT_CONFIG, declarative) {
|
||||||
QT += declarative
|
QT += declarative
|
||||||
@@ -43,6 +47,6 @@ contains(QT_CONFIG, declarative) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
contains(QT, gui) {
|
contains(QT, gui) {
|
||||||
SOURCES += $$PWD/qscripthighlighter.cpp $$PWD/qscriptindenter.cpp
|
SOURCES += $$PWD/qmljshighlighter.cpp $$PWD/qmljsindenter.cpp
|
||||||
HEADERS += $$PWD/qscripthighlighter.h $$PWD/qscriptindenter.h
|
HEADERS += $$PWD/qmljshighlighter.h $$PWD/qmljsindenter.h
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += dll
|
CONFIG += dll
|
||||||
TARGET = QmlJS
|
TARGET = QmlJS
|
||||||
DEFINES += QML_BUILD_LIB QT_CREATOR
|
DEFINES += QMLJS_BUILD_DIR QT_CREATOR
|
||||||
|
|
||||||
unix:QMAKE_CXXFLAGS_DEBUG += -O3
|
unix:QMAKE_CXXFLAGS_DEBUG += -O3
|
||||||
|
|
||||||
|
@@ -27,17 +27,17 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef QML_GLOBAL_H
|
#ifndef QMLJS_GLOBAL_H
|
||||||
#define QML_GLOBAL_H
|
#define QMLJS_GLOBAL_H
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
#if defined(QML_BUILD_LIB)
|
#if defined(QMLJS_BUILD_DIR)
|
||||||
# define QML_EXPORT Q_DECL_EXPORT
|
# define QMLJS_EXPORT Q_DECL_EXPORT
|
||||||
#elif defined(QML_BUILD_STATIC_LIB)
|
#elif defined(QML_BUILD_STATIC_LIB)
|
||||||
# define QML_EXPORT
|
# define QMLJS_EXPORT
|
||||||
#else
|
#else
|
||||||
# define QML_EXPORT Q_DECL_IMPORT
|
# define QMLJS_EXPORT Q_DECL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // QML_GLOBAL_H
|
#endif // QMLJS_GLOBAL_H
|
501
src/libs/qmljs/qmljsbind.cpp
Normal file
501
src/libs/qmljs/qmljsbind.cpp
Normal file
@@ -0,0 +1,501 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "qmljsbind.h"
|
||||||
|
#include "parser/qmljsast_p.h"
|
||||||
|
|
||||||
|
using namespace QmlJS;
|
||||||
|
|
||||||
|
Bind::Bind()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Bind::~Bind()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bind::operator()(Document::Ptr doc)
|
||||||
|
{
|
||||||
|
_doc = doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bind::accept(AST::Node *node)
|
||||||
|
{
|
||||||
|
AST::Node::accept(node, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiProgram *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiImportList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiImport *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiPublicMember *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiSourceElement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiObjectDefinition *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiObjectInitializer *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiObjectBinding *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiScriptBinding *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiArrayBinding *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiObjectMemberList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiArrayMemberList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiQualifiedId *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiSignature *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiFormalList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UiFormal *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ThisExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::IdentifierExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::NullExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::TrueLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::FalseLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::StringLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::NumericLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::RegExpLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ArrayLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ObjectLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ElementList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::Elision *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::PropertyNameAndValueList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::NestedExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::IdentifierPropertyName *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::StringLiteralPropertyName *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::NumericLiteralPropertyName *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ArrayMemberExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::FieldMemberExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::NewMemberExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::NewExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::CallExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ArgumentList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::PostIncrementExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::PostDecrementExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::DeleteExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::VoidExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::TypeOfExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::PreIncrementExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::PreDecrementExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UnaryPlusExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::UnaryMinusExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::TildeExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::NotExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::BinaryExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ConditionalExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::Expression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::Block *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::StatementList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::VariableStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::VariableDeclarationList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::VariableDeclaration *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::EmptyStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ExpressionStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::IfStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::DoWhileStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::WhileStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ForStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::LocalForStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ForEachStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::LocalForEachStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ContinueStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::BreakStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ReturnStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::WithStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::SwitchStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::CaseBlock *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::CaseClauses *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::CaseClause *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::DefaultClause *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::LabelledStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::ThrowStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::TryStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::Catch *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::Finally *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::FunctionDeclaration *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::FunctionExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::FormalParameterList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::FunctionBody *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::Program *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::SourceElements *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::FunctionSourceElement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::StatementSourceElement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(AST::DebuggerStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
149
src/libs/qmljs/qmljsbind.h
Normal file
149
src/libs/qmljs/qmljsbind.h
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QMLBIND_H
|
||||||
|
#define QMLBIND_H
|
||||||
|
|
||||||
|
#include "parser/qmljsastvisitor_p.h"
|
||||||
|
#include "qmljsdocument.h"
|
||||||
|
|
||||||
|
namespace QmlJS {
|
||||||
|
|
||||||
|
class QMLJS_EXPORT Bind: protected AST::Visitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Bind();
|
||||||
|
virtual ~Bind();
|
||||||
|
|
||||||
|
void operator()(QmlJS::Document::Ptr doc);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void accept(AST::Node *node);
|
||||||
|
|
||||||
|
// Ui
|
||||||
|
virtual bool visit(AST::UiProgram *ast);
|
||||||
|
virtual bool visit(AST::UiImportList *ast);
|
||||||
|
virtual bool visit(AST::UiImport *ast);
|
||||||
|
virtual bool visit(AST::UiPublicMember *ast);
|
||||||
|
virtual bool visit(AST::UiSourceElement *ast);
|
||||||
|
virtual bool visit(AST::UiObjectDefinition *ast);
|
||||||
|
virtual bool visit(AST::UiObjectInitializer *ast);
|
||||||
|
virtual bool visit(AST::UiObjectBinding *ast);
|
||||||
|
virtual bool visit(AST::UiScriptBinding *ast);
|
||||||
|
virtual bool visit(AST::UiArrayBinding *ast);
|
||||||
|
virtual bool visit(AST::UiObjectMemberList *ast);
|
||||||
|
virtual bool visit(AST::UiArrayMemberList *ast);
|
||||||
|
virtual bool visit(AST::UiQualifiedId *ast);
|
||||||
|
virtual bool visit(AST::UiSignature *ast);
|
||||||
|
virtual bool visit(AST::UiFormalList *ast);
|
||||||
|
virtual bool visit(AST::UiFormal *ast);
|
||||||
|
|
||||||
|
// QmlJS
|
||||||
|
virtual bool visit(AST::ThisExpression *ast);
|
||||||
|
virtual bool visit(AST::IdentifierExpression *ast);
|
||||||
|
virtual bool visit(AST::NullExpression *ast);
|
||||||
|
virtual bool visit(AST::TrueLiteral *ast);
|
||||||
|
virtual bool visit(AST::FalseLiteral *ast);
|
||||||
|
virtual bool visit(AST::StringLiteral *ast);
|
||||||
|
virtual bool visit(AST::NumericLiteral *ast);
|
||||||
|
virtual bool visit(AST::RegExpLiteral *ast);
|
||||||
|
virtual bool visit(AST::ArrayLiteral *ast);
|
||||||
|
virtual bool visit(AST::ObjectLiteral *ast);
|
||||||
|
virtual bool visit(AST::ElementList *ast);
|
||||||
|
virtual bool visit(AST::Elision *ast);
|
||||||
|
virtual bool visit(AST::PropertyNameAndValueList *ast);
|
||||||
|
virtual bool visit(AST::NestedExpression *ast);
|
||||||
|
virtual bool visit(AST::IdentifierPropertyName *ast);
|
||||||
|
virtual bool visit(AST::StringLiteralPropertyName *ast);
|
||||||
|
virtual bool visit(AST::NumericLiteralPropertyName *ast);
|
||||||
|
virtual bool visit(AST::ArrayMemberExpression *ast);
|
||||||
|
virtual bool visit(AST::FieldMemberExpression *ast);
|
||||||
|
virtual bool visit(AST::NewMemberExpression *ast);
|
||||||
|
virtual bool visit(AST::NewExpression *ast);
|
||||||
|
virtual bool visit(AST::CallExpression *ast);
|
||||||
|
virtual bool visit(AST::ArgumentList *ast);
|
||||||
|
virtual bool visit(AST::PostIncrementExpression *ast);
|
||||||
|
virtual bool visit(AST::PostDecrementExpression *ast);
|
||||||
|
virtual bool visit(AST::DeleteExpression *ast);
|
||||||
|
virtual bool visit(AST::VoidExpression *ast);
|
||||||
|
virtual bool visit(AST::TypeOfExpression *ast);
|
||||||
|
virtual bool visit(AST::PreIncrementExpression *ast);
|
||||||
|
virtual bool visit(AST::PreDecrementExpression *ast);
|
||||||
|
virtual bool visit(AST::UnaryPlusExpression *ast);
|
||||||
|
virtual bool visit(AST::UnaryMinusExpression *ast);
|
||||||
|
virtual bool visit(AST::TildeExpression *ast);
|
||||||
|
virtual bool visit(AST::NotExpression *ast);
|
||||||
|
virtual bool visit(AST::BinaryExpression *ast);
|
||||||
|
virtual bool visit(AST::ConditionalExpression *ast);
|
||||||
|
virtual bool visit(AST::Expression *ast);
|
||||||
|
virtual bool visit(AST::Block *ast);
|
||||||
|
virtual bool visit(AST::StatementList *ast);
|
||||||
|
virtual bool visit(AST::VariableStatement *ast);
|
||||||
|
virtual bool visit(AST::VariableDeclarationList *ast);
|
||||||
|
virtual bool visit(AST::VariableDeclaration *ast);
|
||||||
|
virtual bool visit(AST::EmptyStatement *ast);
|
||||||
|
virtual bool visit(AST::ExpressionStatement *ast);
|
||||||
|
virtual bool visit(AST::IfStatement *ast);
|
||||||
|
virtual bool visit(AST::DoWhileStatement *ast);
|
||||||
|
virtual bool visit(AST::WhileStatement *ast);
|
||||||
|
virtual bool visit(AST::ForStatement *ast);
|
||||||
|
virtual bool visit(AST::LocalForStatement *ast);
|
||||||
|
virtual bool visit(AST::ForEachStatement *ast);
|
||||||
|
virtual bool visit(AST::LocalForEachStatement *ast);
|
||||||
|
virtual bool visit(AST::ContinueStatement *ast);
|
||||||
|
virtual bool visit(AST::BreakStatement *ast);
|
||||||
|
virtual bool visit(AST::ReturnStatement *ast);
|
||||||
|
virtual bool visit(AST::WithStatement *ast);
|
||||||
|
virtual bool visit(AST::SwitchStatement *ast);
|
||||||
|
virtual bool visit(AST::CaseBlock *ast);
|
||||||
|
virtual bool visit(AST::CaseClauses *ast);
|
||||||
|
virtual bool visit(AST::CaseClause *ast);
|
||||||
|
virtual bool visit(AST::DefaultClause *ast);
|
||||||
|
virtual bool visit(AST::LabelledStatement *ast);
|
||||||
|
virtual bool visit(AST::ThrowStatement *ast);
|
||||||
|
virtual bool visit(AST::TryStatement *ast);
|
||||||
|
virtual bool visit(AST::Catch *ast);
|
||||||
|
virtual bool visit(AST::Finally *ast);
|
||||||
|
virtual bool visit(AST::FunctionDeclaration *ast);
|
||||||
|
virtual bool visit(AST::FunctionExpression *ast);
|
||||||
|
virtual bool visit(AST::FormalParameterList *ast);
|
||||||
|
virtual bool visit(AST::FunctionBody *ast);
|
||||||
|
virtual bool visit(AST::Program *ast);
|
||||||
|
virtual bool visit(AST::SourceElements *ast);
|
||||||
|
virtual bool visit(AST::FunctionSourceElement *ast);
|
||||||
|
virtual bool visit(AST::StatementSourceElement *ast);
|
||||||
|
virtual bool visit(AST::DebuggerStatement *ast);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QmlJS::Document::Ptr _doc;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end of namespace Qml
|
||||||
|
|
||||||
|
#endif // QMLBIND_H
|
501
src/libs/qmljs/qmljscheck.cpp
Normal file
501
src/libs/qmljs/qmljscheck.cpp
Normal file
@@ -0,0 +1,501 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "qmljscheck.h"
|
||||||
|
#include "parser/qmljsast_p.h"
|
||||||
|
|
||||||
|
using namespace QmlJS;
|
||||||
|
|
||||||
|
Check::Check()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Check::~Check()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Check::operator()(Document::Ptr doc)
|
||||||
|
{
|
||||||
|
_doc = doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Check::accept(AST::Node *node)
|
||||||
|
{
|
||||||
|
AST::Node::accept(node, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiProgram *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiImportList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiImport *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiPublicMember *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiSourceElement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiObjectDefinition *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiObjectInitializer *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiObjectBinding *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiScriptBinding *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiArrayBinding *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiObjectMemberList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiArrayMemberList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiQualifiedId *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiSignature *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiFormalList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UiFormal *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ThisExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::IdentifierExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::NullExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::TrueLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::FalseLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::StringLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::NumericLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::RegExpLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ArrayLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ObjectLiteral *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ElementList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::Elision *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::PropertyNameAndValueList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::NestedExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::IdentifierPropertyName *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::StringLiteralPropertyName *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::NumericLiteralPropertyName *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ArrayMemberExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::FieldMemberExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::NewMemberExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::NewExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::CallExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ArgumentList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::PostIncrementExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::PostDecrementExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::DeleteExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::VoidExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::TypeOfExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::PreIncrementExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::PreDecrementExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UnaryPlusExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::UnaryMinusExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::TildeExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::NotExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::BinaryExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ConditionalExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::Expression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::Block *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::StatementList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::VariableStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::VariableDeclarationList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::VariableDeclaration *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::EmptyStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ExpressionStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::IfStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::DoWhileStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::WhileStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ForStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::LocalForStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ForEachStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::LocalForEachStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ContinueStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::BreakStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ReturnStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::WithStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::SwitchStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::CaseBlock *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::CaseClauses *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::CaseClause *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::DefaultClause *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::LabelledStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::ThrowStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::TryStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::Catch *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::Finally *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::FunctionDeclaration *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::FunctionExpression *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::FormalParameterList *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::FunctionBody *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::Program *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::SourceElements *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::FunctionSourceElement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::StatementSourceElement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Check::visit(AST::DebuggerStatement *)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
149
src/libs/qmljs/qmljscheck.h
Normal file
149
src/libs/qmljs/qmljscheck.h
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QMLCHECK_H
|
||||||
|
#define QMLCHECK_H
|
||||||
|
|
||||||
|
#include "parser/qmljsastvisitor_p.h"
|
||||||
|
#include "qmljsdocument.h"
|
||||||
|
|
||||||
|
namespace QmlJS {
|
||||||
|
|
||||||
|
class QMLJS_EXPORT Check: protected AST::Visitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Check();
|
||||||
|
virtual ~Check();
|
||||||
|
|
||||||
|
void operator()(QmlJS::Document::Ptr doc);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void accept(AST::Node *node);
|
||||||
|
|
||||||
|
// Ui
|
||||||
|
virtual bool visit(AST::UiProgram *ast);
|
||||||
|
virtual bool visit(AST::UiImportList *ast);
|
||||||
|
virtual bool visit(AST::UiImport *ast);
|
||||||
|
virtual bool visit(AST::UiPublicMember *ast);
|
||||||
|
virtual bool visit(AST::UiSourceElement *ast);
|
||||||
|
virtual bool visit(AST::UiObjectDefinition *ast);
|
||||||
|
virtual bool visit(AST::UiObjectInitializer *ast);
|
||||||
|
virtual bool visit(AST::UiObjectBinding *ast);
|
||||||
|
virtual bool visit(AST::UiScriptBinding *ast);
|
||||||
|
virtual bool visit(AST::UiArrayBinding *ast);
|
||||||
|
virtual bool visit(AST::UiObjectMemberList *ast);
|
||||||
|
virtual bool visit(AST::UiArrayMemberList *ast);
|
||||||
|
virtual bool visit(AST::UiQualifiedId *ast);
|
||||||
|
virtual bool visit(AST::UiSignature *ast);
|
||||||
|
virtual bool visit(AST::UiFormalList *ast);
|
||||||
|
virtual bool visit(AST::UiFormal *ast);
|
||||||
|
|
||||||
|
// QmlJS
|
||||||
|
virtual bool visit(AST::ThisExpression *ast);
|
||||||
|
virtual bool visit(AST::IdentifierExpression *ast);
|
||||||
|
virtual bool visit(AST::NullExpression *ast);
|
||||||
|
virtual bool visit(AST::TrueLiteral *ast);
|
||||||
|
virtual bool visit(AST::FalseLiteral *ast);
|
||||||
|
virtual bool visit(AST::StringLiteral *ast);
|
||||||
|
virtual bool visit(AST::NumericLiteral *ast);
|
||||||
|
virtual bool visit(AST::RegExpLiteral *ast);
|
||||||
|
virtual bool visit(AST::ArrayLiteral *ast);
|
||||||
|
virtual bool visit(AST::ObjectLiteral *ast);
|
||||||
|
virtual bool visit(AST::ElementList *ast);
|
||||||
|
virtual bool visit(AST::Elision *ast);
|
||||||
|
virtual bool visit(AST::PropertyNameAndValueList *ast);
|
||||||
|
virtual bool visit(AST::NestedExpression *ast);
|
||||||
|
virtual bool visit(AST::IdentifierPropertyName *ast);
|
||||||
|
virtual bool visit(AST::StringLiteralPropertyName *ast);
|
||||||
|
virtual bool visit(AST::NumericLiteralPropertyName *ast);
|
||||||
|
virtual bool visit(AST::ArrayMemberExpression *ast);
|
||||||
|
virtual bool visit(AST::FieldMemberExpression *ast);
|
||||||
|
virtual bool visit(AST::NewMemberExpression *ast);
|
||||||
|
virtual bool visit(AST::NewExpression *ast);
|
||||||
|
virtual bool visit(AST::CallExpression *ast);
|
||||||
|
virtual bool visit(AST::ArgumentList *ast);
|
||||||
|
virtual bool visit(AST::PostIncrementExpression *ast);
|
||||||
|
virtual bool visit(AST::PostDecrementExpression *ast);
|
||||||
|
virtual bool visit(AST::DeleteExpression *ast);
|
||||||
|
virtual bool visit(AST::VoidExpression *ast);
|
||||||
|
virtual bool visit(AST::TypeOfExpression *ast);
|
||||||
|
virtual bool visit(AST::PreIncrementExpression *ast);
|
||||||
|
virtual bool visit(AST::PreDecrementExpression *ast);
|
||||||
|
virtual bool visit(AST::UnaryPlusExpression *ast);
|
||||||
|
virtual bool visit(AST::UnaryMinusExpression *ast);
|
||||||
|
virtual bool visit(AST::TildeExpression *ast);
|
||||||
|
virtual bool visit(AST::NotExpression *ast);
|
||||||
|
virtual bool visit(AST::BinaryExpression *ast);
|
||||||
|
virtual bool visit(AST::ConditionalExpression *ast);
|
||||||
|
virtual bool visit(AST::Expression *ast);
|
||||||
|
virtual bool visit(AST::Block *ast);
|
||||||
|
virtual bool visit(AST::StatementList *ast);
|
||||||
|
virtual bool visit(AST::VariableStatement *ast);
|
||||||
|
virtual bool visit(AST::VariableDeclarationList *ast);
|
||||||
|
virtual bool visit(AST::VariableDeclaration *ast);
|
||||||
|
virtual bool visit(AST::EmptyStatement *ast);
|
||||||
|
virtual bool visit(AST::ExpressionStatement *ast);
|
||||||
|
virtual bool visit(AST::IfStatement *ast);
|
||||||
|
virtual bool visit(AST::DoWhileStatement *ast);
|
||||||
|
virtual bool visit(AST::WhileStatement *ast);
|
||||||
|
virtual bool visit(AST::ForStatement *ast);
|
||||||
|
virtual bool visit(AST::LocalForStatement *ast);
|
||||||
|
virtual bool visit(AST::ForEachStatement *ast);
|
||||||
|
virtual bool visit(AST::LocalForEachStatement *ast);
|
||||||
|
virtual bool visit(AST::ContinueStatement *ast);
|
||||||
|
virtual bool visit(AST::BreakStatement *ast);
|
||||||
|
virtual bool visit(AST::ReturnStatement *ast);
|
||||||
|
virtual bool visit(AST::WithStatement *ast);
|
||||||
|
virtual bool visit(AST::SwitchStatement *ast);
|
||||||
|
virtual bool visit(AST::CaseBlock *ast);
|
||||||
|
virtual bool visit(AST::CaseClauses *ast);
|
||||||
|
virtual bool visit(AST::CaseClause *ast);
|
||||||
|
virtual bool visit(AST::DefaultClause *ast);
|
||||||
|
virtual bool visit(AST::LabelledStatement *ast);
|
||||||
|
virtual bool visit(AST::ThrowStatement *ast);
|
||||||
|
virtual bool visit(AST::TryStatement *ast);
|
||||||
|
virtual bool visit(AST::Catch *ast);
|
||||||
|
virtual bool visit(AST::Finally *ast);
|
||||||
|
virtual bool visit(AST::FunctionDeclaration *ast);
|
||||||
|
virtual bool visit(AST::FunctionExpression *ast);
|
||||||
|
virtual bool visit(AST::FormalParameterList *ast);
|
||||||
|
virtual bool visit(AST::FunctionBody *ast);
|
||||||
|
virtual bool visit(AST::Program *ast);
|
||||||
|
virtual bool visit(AST::SourceElements *ast);
|
||||||
|
virtual bool visit(AST::FunctionSourceElement *ast);
|
||||||
|
virtual bool visit(AST::StatementSourceElement *ast);
|
||||||
|
virtual bool visit(AST::DebuggerStatement *ast);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QmlJS::Document::Ptr _doc;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end of namespace Qml
|
||||||
|
|
||||||
|
#endif // QMLCheck_H
|
@@ -27,19 +27,19 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "qmlidcollector.h"
|
#include "qmljsidcollector.h"
|
||||||
#include "qmldocument.h"
|
#include "qmljsdocument.h"
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
#include <qmljs/parser/qmljslexer_p.h>
|
#include <qmljs/parser/qmljslexer_p.h>
|
||||||
#include <qmljs/parser/qmljsparser_p.h>
|
#include <qmljs/parser/qmljsparser_p.h>
|
||||||
#include <qmljs/parser/qmljsnodepool_p.h>
|
#include <qmljs/parser/qmljsnodepool_p.h>
|
||||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace QmlJS;
|
using namespace QmlJS;
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
|
|
||||||
QmlDocument::QmlDocument(const QString &fileName)
|
Document::Document(const QString &fileName)
|
||||||
: _engine(0)
|
: _engine(0)
|
||||||
, _pool(0)
|
, _pool(0)
|
||||||
, _uiProgram(0)
|
, _uiProgram(0)
|
||||||
@@ -55,7 +55,7 @@ QmlDocument::QmlDocument(const QString &fileName)
|
|||||||
_componentName = fileName.mid(slashIdx + 1, fileName.size() - (slashIdx + 1) - 4);
|
_componentName = fileName.mid(slashIdx + 1, fileName.size() - (slashIdx + 1) - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlDocument::~QmlDocument()
|
Document::~Document()
|
||||||
{
|
{
|
||||||
if (_engine)
|
if (_engine)
|
||||||
delete _engine;
|
delete _engine;
|
||||||
@@ -66,38 +66,38 @@ QmlDocument::~QmlDocument()
|
|||||||
qDeleteAll(_symbols);
|
qDeleteAll(_symbols);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlDocument::Ptr QmlDocument::create(const QString &fileName)
|
Document::Ptr Document::create(const QString &fileName)
|
||||||
{
|
{
|
||||||
QmlDocument::Ptr doc(new QmlDocument(fileName));
|
Document::Ptr doc(new Document(fileName));
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST::UiProgram *QmlDocument::qmlProgram() const
|
AST::UiProgram *Document::qmlProgram() const
|
||||||
{
|
{
|
||||||
return _uiProgram;
|
return _uiProgram;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST::Program *QmlDocument::jsProgram() const
|
AST::Program *Document::jsProgram() const
|
||||||
{
|
{
|
||||||
return _jsProgram;
|
return _jsProgram;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<DiagnosticMessage> QmlDocument::diagnosticMessages() const
|
QList<DiagnosticMessage> Document::diagnosticMessages() const
|
||||||
{
|
{
|
||||||
return _diagnosticMessages;
|
return _diagnosticMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlDocument::source() const
|
QString Document::source() const
|
||||||
{
|
{
|
||||||
return _source;
|
return _source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDocument::setSource(const QString &source)
|
void Document::setSource(const QString &source)
|
||||||
{
|
{
|
||||||
_source = source;
|
_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlDocument::parseQml()
|
bool Document::parseQml()
|
||||||
{
|
{
|
||||||
Q_ASSERT(! _engine);
|
Q_ASSERT(! _engine);
|
||||||
Q_ASSERT(! _pool);
|
Q_ASSERT(! _pool);
|
||||||
@@ -120,9 +120,9 @@ bool QmlDocument::parseQml()
|
|||||||
if (_uiProgram) {
|
if (_uiProgram) {
|
||||||
for (QmlJS::AST::UiObjectMemberList *iter = _uiProgram->members; iter; iter = iter->next)
|
for (QmlJS::AST::UiObjectMemberList *iter = _uiProgram->members; iter; iter = iter->next)
|
||||||
if (iter->member)
|
if (iter->member)
|
||||||
_symbols.append(new QmlSymbolFromFile(_fileName, iter->member));
|
_symbols.append(new SymbolFromFile(_fileName, iter->member));
|
||||||
|
|
||||||
Internal::QmlIdCollector collect;
|
Internal::IdCollector collect;
|
||||||
_ids = collect(*this);
|
_ids = collect(*this);
|
||||||
if (_diagnosticMessages.isEmpty())
|
if (_diagnosticMessages.isEmpty())
|
||||||
_diagnosticMessages = collect.diagnosticMessages();
|
_diagnosticMessages = collect.diagnosticMessages();
|
||||||
@@ -131,7 +131,7 @@ bool QmlDocument::parseQml()
|
|||||||
return _parsedCorrectly;
|
return _parsedCorrectly;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlDocument::parseJavaScript()
|
bool Document::parseJavaScript()
|
||||||
{
|
{
|
||||||
Q_ASSERT(! _engine);
|
Q_ASSERT(! _engine);
|
||||||
Q_ASSERT(! _pool);
|
Q_ASSERT(! _pool);
|
||||||
@@ -154,9 +154,9 @@ bool QmlDocument::parseJavaScript()
|
|||||||
return _parsedCorrectly;
|
return _parsedCorrectly;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbolFromFile *QmlDocument::findSymbol(QmlJS::AST::Node *node) const
|
SymbolFromFile *Document::findSymbol(QmlJS::AST::Node *node) const
|
||||||
{
|
{
|
||||||
foreach (QmlSymbol *symbol, _symbols)
|
foreach (Symbol *symbol, _symbols)
|
||||||
if (symbol->isSymbolFromFile())
|
if (symbol->isSymbolFromFile())
|
||||||
if (symbol->asSymbolFromFile()->node() == node)
|
if (symbol->asSymbolFromFile()->node() == node)
|
||||||
return symbol->asSymbolFromFile();
|
return symbol->asSymbolFromFile();
|
||||||
@@ -172,19 +172,19 @@ Snapshot::~Snapshot()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Snapshot::insert(const QmlDocument::Ptr &document)
|
void Snapshot::insert(const Document::Ptr &document)
|
||||||
{
|
{
|
||||||
if (document && (document->qmlProgram() || document->jsProgram()))
|
if (document && (document->qmlProgram() || document->jsProgram()))
|
||||||
QMap<QString, QmlDocument::Ptr>::insert(document->fileName(), document);
|
QMap<QString, Document::Ptr>::insert(document->fileName(), document);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlDocument::PtrList Snapshot::importedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const
|
Document::PtrList Snapshot::importedDocuments(const Document::Ptr &doc, const QString &importPath) const
|
||||||
{
|
{
|
||||||
QmlDocument::PtrList result;
|
Document::PtrList result;
|
||||||
|
|
||||||
const QString docPath = doc->path() + '/' + importPath;
|
const QString docPath = doc->path() + '/' + importPath;
|
||||||
|
|
||||||
foreach (QmlDocument::Ptr candidate, *this) {
|
foreach (Document::Ptr candidate, *this) {
|
||||||
if (candidate == doc)
|
if (candidate == doc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -195,13 +195,13 @@ QmlDocument::PtrList Snapshot::importedDocuments(const QmlDocument::Ptr &doc, co
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QmlDocument::Ptr> Snapshot::componentsDefinedByImportedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const
|
QMap<QString, Document::Ptr> Snapshot::componentsDefinedByImportedDocuments(const Document::Ptr &doc, const QString &importPath) const
|
||||||
{
|
{
|
||||||
QMap<QString, QmlDocument::Ptr> result;
|
QMap<QString, Document::Ptr> result;
|
||||||
|
|
||||||
const QString docPath = doc->path() + '/' + importPath;
|
const QString docPath = doc->path() + '/' + importPath;
|
||||||
|
|
||||||
foreach (QmlDocument::Ptr candidate, *this) {
|
foreach (Document::Ptr candidate, *this) {
|
||||||
if (candidate == doc)
|
if (candidate == doc)
|
||||||
continue;
|
continue;
|
||||||
|
|
@@ -36,25 +36,25 @@
|
|||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
#include "parser/qmljsengine_p.h"
|
#include "parser/qmljsengine_p.h"
|
||||||
#include "qml_global.h"
|
#include "qmljs_global.h"
|
||||||
#include "qmlsymbol.h"
|
#include "qmljssymbol.h"
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
|
|
||||||
class QML_EXPORT QmlDocument
|
class QMLJS_EXPORT Document
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QSharedPointer<QmlDocument> Ptr;
|
typedef QSharedPointer<Document> Ptr;
|
||||||
typedef QList<QmlDocument::Ptr> PtrList;
|
typedef QList<Document::Ptr> PtrList;
|
||||||
typedef QMap<QString, Qml::QmlIdSymbol*> IdTable;
|
typedef QMap<QString, IdSymbol*> IdTable;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QmlDocument(const QString &fileName);
|
Document(const QString &fileName);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~QmlDocument();
|
~Document();
|
||||||
|
|
||||||
static QmlDocument::Ptr create(const QString &fileName);
|
static Document::Ptr create(const QString &fileName);
|
||||||
|
|
||||||
QmlJS::AST::UiProgram *qmlProgram() const;
|
QmlJS::AST::UiProgram *qmlProgram() const;
|
||||||
QmlJS::AST::Program *jsProgram() const;
|
QmlJS::AST::Program *jsProgram() const;
|
||||||
@@ -75,8 +75,8 @@ public:
|
|||||||
QString path() const { return _path; }
|
QString path() const { return _path; }
|
||||||
QString componentName() const { return _componentName; }
|
QString componentName() const { return _componentName; }
|
||||||
|
|
||||||
Qml::QmlSymbolFromFile *findSymbol(QmlJS::AST::Node *node) const;
|
QmlJS::SymbolFromFile *findSymbol(QmlJS::AST::Node *node) const;
|
||||||
Qml::QmlSymbol::List symbols() const
|
QmlJS::Symbol::List symbols() const
|
||||||
{ return _symbols; }
|
{ return _symbols; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -91,22 +91,22 @@ private:
|
|||||||
QString _source;
|
QString _source;
|
||||||
bool _parsedCorrectly;
|
bool _parsedCorrectly;
|
||||||
IdTable _ids;
|
IdTable _ids;
|
||||||
Qml::QmlSymbol::List _symbols;
|
QmlJS::Symbol::List _symbols;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_EXPORT Snapshot: public QMap<QString, QmlDocument::Ptr>
|
class QMLJS_EXPORT Snapshot: public QMap<QString, Document::Ptr>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Snapshot();
|
Snapshot();
|
||||||
~Snapshot();
|
~Snapshot();
|
||||||
|
|
||||||
void insert(const QmlDocument::Ptr &document);
|
void insert(const Document::Ptr &document);
|
||||||
|
|
||||||
QmlDocument::Ptr document(const QString &fileName) const
|
Document::Ptr document(const QString &fileName) const
|
||||||
{ return value(fileName); }
|
{ return value(fileName); }
|
||||||
|
|
||||||
QmlDocument::PtrList importedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const;
|
Document::PtrList importedDocuments(const Document::Ptr &doc, const QString &importPath) const;
|
||||||
QMap<QString, QmlDocument::Ptr> componentsDefinedByImportedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const;
|
QMap<QString, Document::Ptr> componentsDefinedByImportedDocuments(const Document::Ptr &doc, const QString &importPath) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace Qml
|
} // end of namespace Qml
|
@@ -27,7 +27,7 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include <qmljs/qscripthighlighter.h>
|
#include <qmljs/qmljshighlighter.h>
|
||||||
|
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
#include <QtCore/QtAlgorithms>
|
#include <QtCore/QtAlgorithms>
|
||||||
@@ -62,60 +62,60 @@ void QScriptHighlighter::highlightBlock(const QString &text)
|
|||||||
|
|
||||||
QTextCharFormat emptyFormat;
|
QTextCharFormat emptyFormat;
|
||||||
int lastEnd = 0;
|
int lastEnd = 0;
|
||||||
const QList<QScriptIncrementalScanner::Token> tokens = m_scanner.tokens();
|
const QList<QmlJSScanner::Token> tokens = m_scanner.tokens();
|
||||||
for (int i = 0; i < tokens.size(); ++i) {
|
for (int i = 0; i < tokens.size(); ++i) {
|
||||||
const QScriptIncrementalScanner::Token token = tokens.at(i);
|
const QmlJSScanner::Token token = tokens.at(i);
|
||||||
|
|
||||||
if (token.offset != lastEnd)
|
if (token.offset != lastEnd)
|
||||||
setFormat(lastEnd, token.offset - lastEnd, m_formats[VisualWhitespace]);
|
setFormat(lastEnd, token.offset - lastEnd, m_formats[VisualWhitespace]);
|
||||||
|
|
||||||
switch (token.kind) {
|
switch (token.kind) {
|
||||||
case QScriptIncrementalScanner::Token::Keyword:
|
case QmlJSScanner::Token::Keyword:
|
||||||
setFormat(token.offset, token.length, m_formats[KeywordFormat]);
|
setFormat(token.offset, token.length, m_formats[KeywordFormat]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::String:
|
case QmlJSScanner::Token::String:
|
||||||
highlightWhitespace(token, text, StringFormat);
|
highlightWhitespace(token, text, StringFormat);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::Comment:
|
case QmlJSScanner::Token::Comment:
|
||||||
highlightWhitespace(token, text, CommentFormat);
|
highlightWhitespace(token, text, CommentFormat);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::Number:
|
case QmlJSScanner::Token::Number:
|
||||||
highlightWhitespace(token, text, NumberFormat);
|
highlightWhitespace(token, text, NumberFormat);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::LeftParenthesis:
|
case QmlJSScanner::Token::LeftParenthesis:
|
||||||
onOpeningParenthesis('(', token.offset);
|
onOpeningParenthesis('(', token.offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::RightParenthesis:
|
case QmlJSScanner::Token::RightParenthesis:
|
||||||
onClosingParenthesis(')', token.offset);
|
onClosingParenthesis(')', token.offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::LeftBrace:
|
case QmlJSScanner::Token::LeftBrace:
|
||||||
onOpeningParenthesis('{', token.offset);
|
onOpeningParenthesis('{', token.offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::RightBrace:
|
case QmlJSScanner::Token::RightBrace:
|
||||||
onClosingParenthesis('}', token.offset);
|
onClosingParenthesis('}', token.offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::LeftBracket:
|
case QmlJSScanner::Token::LeftBracket:
|
||||||
onOpeningParenthesis('[', token.offset);
|
onOpeningParenthesis('[', token.offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::RightBracket:
|
case QmlJSScanner::Token::RightBracket:
|
||||||
onClosingParenthesis(']', token.offset);
|
onClosingParenthesis(']', token.offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::Identifier:
|
case QmlJSScanner::Token::Identifier:
|
||||||
if (m_duiEnabled && (i + 1 != tokens.size()) && tokens.at(i + 1).kind == QScriptIncrementalScanner::Token::Colon) {
|
if (m_duiEnabled && (i + 1 != tokens.size()) && tokens.at(i + 1).kind == QmlJSScanner::Token::Colon) {
|
||||||
int j = i;
|
int j = i;
|
||||||
for (; j != -1; --j) {
|
for (; j != -1; --j) {
|
||||||
const QScriptIncrementalScanner::Token &tok = tokens.at(j);
|
const QmlJSScanner::Token &tok = tokens.at(j);
|
||||||
if (tok.is(QScriptIncrementalScanner::Token::Dot) || tok.is(QScriptIncrementalScanner::Token::Identifier)) {
|
if (tok.is(QmlJSScanner::Token::Dot) || tok.is(QmlJSScanner::Token::Identifier)) {
|
||||||
setFormat(tok.offset, tok.length, m_formats[LabelFormat]);
|
setFormat(tok.offset, tok.length, m_formats[LabelFormat]);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@@ -131,15 +131,15 @@ void QScriptHighlighter::highlightBlock(const QString &text)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::Colon:
|
case QmlJSScanner::Token::Colon:
|
||||||
if (m_duiEnabled && i > 0 && tokens.at(i - 1).kind == QScriptIncrementalScanner::Token::Identifier)
|
if (m_duiEnabled && i > 0 && tokens.at(i - 1).kind == QmlJSScanner::Token::Identifier)
|
||||||
setFormat(token.offset, token.length, m_formats[LabelFormat]);
|
setFormat(token.offset, token.length, m_formats[LabelFormat]);
|
||||||
else
|
else
|
||||||
setFormat(token.offset, token.length, emptyFormat);
|
setFormat(token.offset, token.length, emptyFormat);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::Operator:
|
case QmlJSScanner::Token::Operator:
|
||||||
case QScriptIncrementalScanner::Token::Dot:
|
case QmlJSScanner::Token::Dot:
|
||||||
setFormat(token.offset, token.length, emptyFormat);
|
setFormat(token.offset, token.length, emptyFormat);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ void QScriptHighlighter::onOpeningParenthesis(QChar, int) {}
|
|||||||
void QScriptHighlighter::onClosingParenthesis(QChar, int) {}
|
void QScriptHighlighter::onClosingParenthesis(QChar, int) {}
|
||||||
void QScriptHighlighter::onBlockEnd(int state, int) { return setCurrentBlockState(state); }
|
void QScriptHighlighter::onBlockEnd(int state, int) { return setCurrentBlockState(state); }
|
||||||
|
|
||||||
void QScriptHighlighter::highlightWhitespace(const QScriptIncrementalScanner::Token &token, const QString &text, int nonWhitespaceFormat)
|
void QScriptHighlighter::highlightWhitespace(const QmlJSScanner::Token &token, const QString &text, int nonWhitespaceFormat)
|
||||||
{
|
{
|
||||||
const QTextCharFormat normalFormat = m_formats[nonWhitespaceFormat];
|
const QTextCharFormat normalFormat = m_formats[nonWhitespaceFormat];
|
||||||
const QTextCharFormat visualSpaceFormat = m_formats[VisualWhitespace];
|
const QTextCharFormat visualSpaceFormat = m_formats[VisualWhitespace];
|
@@ -30,7 +30,7 @@
|
|||||||
#ifndef QSCRIPTSYNTAXHIGHLIGHTER_H
|
#ifndef QSCRIPTSYNTAXHIGHLIGHTER_H
|
||||||
#define QSCRIPTSYNTAXHIGHLIGHTER_H
|
#define QSCRIPTSYNTAXHIGHLIGHTER_H
|
||||||
|
|
||||||
#include <qmljs/qscriptincrementalscanner.h>
|
#include <qmljs/qmljsscanner.h>
|
||||||
|
|
||||||
#include <QtCore/QVector>
|
#include <QtCore/QVector>
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
namespace QmlJS {
|
namespace QmlJS {
|
||||||
|
|
||||||
class QML_EXPORT QScriptHighlighter : public QSyntaxHighlighter
|
class QMLJS_EXPORT QScriptHighlighter : public QSyntaxHighlighter
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -69,10 +69,10 @@ protected:
|
|||||||
// sets the enriched user state, or simply calls setCurrentBlockState(state);
|
// sets the enriched user state, or simply calls setCurrentBlockState(state);
|
||||||
virtual void onBlockEnd(int state, int firstNonSpace);
|
virtual void onBlockEnd(int state, int firstNonSpace);
|
||||||
|
|
||||||
virtual void highlightWhitespace(const QScriptIncrementalScanner::Token &token, const QString &text, int nonWhitespaceFormat);
|
virtual void highlightWhitespace(const QmlJSScanner::Token &token, const QString &text, int nonWhitespaceFormat);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QScriptIncrementalScanner m_scanner;
|
QmlJSScanner m_scanner;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_duiEnabled;
|
bool m_duiEnabled;
|
@@ -31,14 +31,14 @@
|
|||||||
|
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
|
|
||||||
#include "qmlidcollector.h"
|
#include "qmljsidcollector.h"
|
||||||
|
|
||||||
using namespace QmlJS;
|
using namespace QmlJS;
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace Qml::Internal;
|
using namespace QmlJS::Internal;
|
||||||
|
|
||||||
QMap<QString, QmlIdSymbol*> QmlIdCollector::operator()(Qml::QmlDocument &doc)
|
QMap<QString, IdSymbol*> IdCollector::operator()(QmlJS::Document &doc)
|
||||||
{
|
{
|
||||||
_doc = &doc;
|
_doc = &doc;
|
||||||
_ids.clear();
|
_ids.clear();
|
||||||
@@ -49,31 +49,31 @@ QMap<QString, QmlIdSymbol*> QmlIdCollector::operator()(Qml::QmlDocument &doc)
|
|||||||
return _ids;
|
return _ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlIdCollector::visit(UiArrayBinding *ast)
|
bool IdCollector::visit(UiArrayBinding *ast)
|
||||||
{
|
{
|
||||||
QmlSymbolFromFile *oldSymbol = switchSymbol(ast);
|
SymbolFromFile *oldSymbol = switchSymbol(ast);
|
||||||
Node::accept(ast->members, this);
|
Node::accept(ast->members, this);
|
||||||
_currentSymbol = oldSymbol;
|
_currentSymbol = oldSymbol;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlIdCollector::visit(QmlJS::AST::UiObjectBinding *ast)
|
bool IdCollector::visit(QmlJS::AST::UiObjectBinding *ast)
|
||||||
{
|
{
|
||||||
QmlSymbolFromFile *oldSymbol = switchSymbol(ast);
|
SymbolFromFile *oldSymbol = switchSymbol(ast);
|
||||||
Node::accept(ast->initializer, this);
|
Node::accept(ast->initializer, this);
|
||||||
_currentSymbol = oldSymbol;
|
_currentSymbol = oldSymbol;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlIdCollector::visit(QmlJS::AST::UiObjectDefinition *ast)
|
bool IdCollector::visit(QmlJS::AST::UiObjectDefinition *ast)
|
||||||
{
|
{
|
||||||
QmlSymbolFromFile *oldSymbol = switchSymbol(ast);
|
SymbolFromFile *oldSymbol = switchSymbol(ast);
|
||||||
Node::accept(ast->initializer, this);
|
Node::accept(ast->initializer, this);
|
||||||
_currentSymbol = oldSymbol;
|
_currentSymbol = oldSymbol;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlIdCollector::visit(QmlJS::AST::UiScriptBinding *ast)
|
bool IdCollector::visit(QmlJS::AST::UiScriptBinding *ast)
|
||||||
{
|
{
|
||||||
if (!(ast->qualifiedId->next) && ast->qualifiedId->name->asString() == "id")
|
if (!(ast->qualifiedId->next) && ast->qualifiedId->name->asString() == "id")
|
||||||
if (ExpressionStatement *e = cast<ExpressionStatement*>(ast->statement))
|
if (ExpressionStatement *e = cast<ExpressionStatement*>(ast->statement))
|
||||||
@@ -84,9 +84,9 @@ bool QmlIdCollector::visit(QmlJS::AST::UiScriptBinding *ast)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbolFromFile *QmlIdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node)
|
SymbolFromFile *IdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node)
|
||||||
{
|
{
|
||||||
QmlSymbolFromFile *newSymbol = 0;
|
SymbolFromFile *newSymbol = 0;
|
||||||
|
|
||||||
if (_currentSymbol == 0) {
|
if (_currentSymbol == 0) {
|
||||||
newSymbol = _doc->findSymbol(node);
|
newSymbol = _doc->findSymbol(node);
|
||||||
@@ -94,7 +94,7 @@ QmlSymbolFromFile *QmlIdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node
|
|||||||
newSymbol = _currentSymbol->findMember(node);
|
newSymbol = _currentSymbol->findMember(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbolFromFile *oldSymbol = _currentSymbol;
|
SymbolFromFile *oldSymbol = _currentSymbol;
|
||||||
|
|
||||||
if (newSymbol) {
|
if (newSymbol) {
|
||||||
_currentSymbol = newSymbol;
|
_currentSymbol = newSymbol;
|
||||||
@@ -106,7 +106,7 @@ QmlSymbolFromFile *QmlIdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node
|
|||||||
return oldSymbol;
|
return oldSymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlIdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
|
void IdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
|
||||||
{
|
{
|
||||||
if (!_currentSymbol)
|
if (!_currentSymbol)
|
||||||
return;
|
return;
|
||||||
@@ -114,8 +114,8 @@ void QmlIdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
|
|||||||
if (_ids.contains(id)) {
|
if (_ids.contains(id)) {
|
||||||
_diagnosticMessages.append(DiagnosticMessage(DiagnosticMessage::Warning, ast->statement->firstSourceLocation(), "Duplicate ID"));
|
_diagnosticMessages.append(DiagnosticMessage(DiagnosticMessage::Warning, ast->statement->firstSourceLocation(), "Duplicate ID"));
|
||||||
} else {
|
} else {
|
||||||
if (QmlSymbolFromFile *symbol = _currentSymbol->findMember(ast))
|
if (SymbolFromFile *symbol = _currentSymbol->findMember(ast))
|
||||||
if (QmlIdSymbol *idSymbol = symbol->asIdSymbol())
|
if (IdSymbol *idSymbol = symbol->asIdSymbol())
|
||||||
_ids[id] = idSymbol;
|
_ids[id] = idSymbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -32,40 +32,40 @@
|
|||||||
|
|
||||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||||
#include <qmljs/parser/qmljsengine_p.h>
|
#include <qmljs/parser/qmljsengine_p.h>
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <qmljs/qmlsymbol.h>
|
#include <qmljs/qmljssymbol.h>
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class QML_EXPORT QmlIdCollector: protected QmlJS::AST::Visitor
|
class QMLJS_EXPORT IdCollector: protected AST::Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QMap<QString, Qml::QmlIdSymbol*> operator()(Qml::QmlDocument &doc);
|
QMap<QString, IdSymbol*> operator()(Document &doc);
|
||||||
|
|
||||||
QList<QmlJS::DiagnosticMessage> diagnosticMessages()
|
QList<DiagnosticMessage> diagnosticMessages()
|
||||||
{ return _diagnosticMessages; }
|
{ return _diagnosticMessages; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool visit(QmlJS::AST::UiArrayBinding *ast);
|
virtual bool visit(AST::UiArrayBinding *ast);
|
||||||
virtual bool visit(QmlJS::AST::UiObjectBinding *ast);
|
virtual bool visit(AST::UiObjectBinding *ast);
|
||||||
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
|
virtual bool visit(AST::UiObjectDefinition *ast);
|
||||||
virtual bool visit(QmlJS::AST::UiScriptBinding *ast);
|
virtual bool visit(AST::UiScriptBinding *ast);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qml::QmlSymbolFromFile *switchSymbol(QmlJS::AST::UiObjectMember *node);
|
SymbolFromFile *switchSymbol(AST::UiObjectMember *node);
|
||||||
void addId(const QString &id, QmlJS::AST::UiScriptBinding *ast);
|
void addId(const QString &id, AST::UiScriptBinding *ast);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qml::QmlDocument *_doc;
|
Document *_doc;
|
||||||
QMap<QString, Qml::QmlIdSymbol*> _ids;
|
QMap<QString, IdSymbol*> _ids;
|
||||||
Qml::QmlSymbolFromFile *_currentSymbol;
|
SymbolFromFile *_currentSymbol;
|
||||||
QList<QmlJS::DiagnosticMessage> _diagnosticMessages;
|
QList<DiagnosticMessage> _diagnosticMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
@@ -65,8 +65,8 @@
|
|||||||
as comments and string literals are removed beforehand.
|
as comments and string literals are removed beforehand.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <qmljs/qscriptindenter.h>
|
#include <qmljs/qmljsindenter.h>
|
||||||
#include <qmljs/qscriptincrementalscanner.h>
|
#include <qmljs/qmljsscanner.h>
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
@@ -80,10 +80,10 @@ using namespace QmlJS;
|
|||||||
For example, the indenter never considers more than BigRoof lines
|
For example, the indenter never considers more than BigRoof lines
|
||||||
backwards when looking for the start of a C-style comment.
|
backwards when looking for the start of a C-style comment.
|
||||||
*/
|
*/
|
||||||
const int QScriptIndenter::SmallRoof = 40;
|
const int QmlJSIndenter::SmallRoof = 40;
|
||||||
const int QScriptIndenter::BigRoof = 400;
|
const int QmlJSIndenter::BigRoof = 400;
|
||||||
|
|
||||||
QScriptIndenter::QScriptIndenter()
|
QmlJSIndenter::QmlJSIndenter()
|
||||||
: label(QRegExp(QLatin1String("^\\s*((?:case\\b([^:])+|[a-zA-Z_0-9.]+)(?:\\s+)?:)(?!:)"))),
|
: label(QRegExp(QLatin1String("^\\s*((?:case\\b([^:])+|[a-zA-Z_0-9.]+)(?:\\s+)?:)(?!:)"))),
|
||||||
braceX(QRegExp(QLatin1String("^\\s*\\}\\s*(?:else|catch)\\b"))),
|
braceX(QRegExp(QLatin1String("^\\s*\\}\\s*(?:else|catch)\\b"))),
|
||||||
iflikeKeyword(QRegExp(QLatin1String("\\b(?:catch|do|for|if|while|with)\\b")))
|
iflikeKeyword(QRegExp(QLatin1String("\\b(?:catch|do|for|if|while|with)\\b")))
|
||||||
@@ -121,16 +121,16 @@ QScriptIndenter::QScriptIndenter()
|
|||||||
yyLeftBraceFollows = 0;
|
yyLeftBraceFollows = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptIndenter::~QScriptIndenter()
|
QmlJSIndenter::~QmlJSIndenter()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScriptIndenter::setTabSize(int size)
|
void QmlJSIndenter::setTabSize(int size)
|
||||||
{
|
{
|
||||||
ppHardwareTabSize = size;
|
ppHardwareTabSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScriptIndenter::setIndentSize(int size)
|
void QmlJSIndenter::setIndentSize(int size)
|
||||||
{
|
{
|
||||||
ppIndentSize = size;
|
ppIndentSize = size;
|
||||||
ppContinuationIndentSize = 2 * size;
|
ppContinuationIndentSize = 2 * size;
|
||||||
@@ -140,7 +140,7 @@ void QScriptIndenter::setIndentSize(int size)
|
|||||||
Returns the first non-space character in the string t, or
|
Returns the first non-space character in the string t, or
|
||||||
QChar() if the string is made only of white space.
|
QChar() if the string is made only of white space.
|
||||||
*/
|
*/
|
||||||
QChar QScriptIndenter::firstNonWhiteSpace(const QString &t) const
|
QChar QmlJSIndenter::firstNonWhiteSpace(const QString &t) const
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < t.length()) {
|
while (i < t.length()) {
|
||||||
@@ -155,7 +155,7 @@ QChar QScriptIndenter::firstNonWhiteSpace(const QString &t) const
|
|||||||
Returns true if string t is made only of white space; otherwise
|
Returns true if string t is made only of white space; otherwise
|
||||||
returns false.
|
returns false.
|
||||||
*/
|
*/
|
||||||
bool QScriptIndenter::isOnlyWhiteSpace(const QString &t) const
|
bool QmlJSIndenter::isOnlyWhiteSpace(const QString &t) const
|
||||||
{
|
{
|
||||||
return firstNonWhiteSpace(t).isNull();
|
return firstNonWhiteSpace(t).isNull();
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ bool QScriptIndenter::isOnlyWhiteSpace(const QString &t) const
|
|||||||
index. Column numbers and index are identical for strings that don't
|
index. Column numbers and index are identical for strings that don't
|
||||||
contain '\t's.
|
contain '\t's.
|
||||||
*/
|
*/
|
||||||
int QScriptIndenter::columnForIndex(const QString &t, int index) const
|
int QmlJSIndenter::columnForIndex(const QString &t, int index) const
|
||||||
{
|
{
|
||||||
int col = 0;
|
int col = 0;
|
||||||
if (index > t.length())
|
if (index > t.length())
|
||||||
@@ -184,7 +184,7 @@ int QScriptIndenter::columnForIndex(const QString &t, int index) const
|
|||||||
/*
|
/*
|
||||||
Returns the indentation size of string t.
|
Returns the indentation size of string t.
|
||||||
*/
|
*/
|
||||||
int QScriptIndenter::indentOfLine(const QString &t) const
|
int QmlJSIndenter::indentOfLine(const QString &t) const
|
||||||
{
|
{
|
||||||
return columnForIndex(t, t.indexOf(firstNonWhiteSpace(t)));
|
return columnForIndex(t, t.indexOf(firstNonWhiteSpace(t)));
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ int QScriptIndenter::indentOfLine(const QString &t) const
|
|||||||
provisions are taken against '\n' or '\r', which shouldn't occur in
|
provisions are taken against '\n' or '\r', which shouldn't occur in
|
||||||
t anyway.
|
t anyway.
|
||||||
*/
|
*/
|
||||||
void QScriptIndenter::eraseChar(QString &t, int k, QChar ch) const
|
void QmlJSIndenter::eraseChar(QString &t, int k, QChar ch) const
|
||||||
{
|
{
|
||||||
if (t.at(k) != QLatin1Char('\t'))
|
if (t.at(k) != QLatin1Char('\t'))
|
||||||
t[k] = ch;
|
t[k] = ch;
|
||||||
@@ -205,9 +205,9 @@ void QScriptIndenter::eraseChar(QString &t, int k, QChar ch) const
|
|||||||
Removes some nefast constructs from a code line and returns the
|
Removes some nefast constructs from a code line and returns the
|
||||||
resulting line.
|
resulting line.
|
||||||
*/
|
*/
|
||||||
QString QScriptIndenter::trimmedCodeLine(const QString &t)
|
QString QmlJSIndenter::trimmedCodeLine(const QString &t)
|
||||||
{
|
{
|
||||||
QScriptIncrementalScanner scanner;
|
QmlJSScanner scanner;
|
||||||
|
|
||||||
QTextBlock currentLine = yyLinizerState.iter;
|
QTextBlock currentLine = yyLinizerState.iter;
|
||||||
int startState = qMax(0, currentLine.previous().userState()) & 0xff;
|
int startState = qMax(0, currentLine.previous().userState()) & 0xff;
|
||||||
@@ -215,14 +215,14 @@ QString QScriptIndenter::trimmedCodeLine(const QString &t)
|
|||||||
yyLinizerState.tokens = scanner(t, startState);
|
yyLinizerState.tokens = scanner(t, startState);
|
||||||
QString trimmed;
|
QString trimmed;
|
||||||
int previousTokenEnd = 0;
|
int previousTokenEnd = 0;
|
||||||
foreach (const QScriptIncrementalScanner::Token &token, yyLinizerState.tokens) {
|
foreach (const QmlJSScanner::Token &token, yyLinizerState.tokens) {
|
||||||
trimmed.append(t.midRef(previousTokenEnd, token.begin() - previousTokenEnd));
|
trimmed.append(t.midRef(previousTokenEnd, token.begin() - previousTokenEnd));
|
||||||
|
|
||||||
if (token.is(QScriptIncrementalScanner::Token::String)) {
|
if (token.is(QmlJSScanner::Token::String)) {
|
||||||
for (int i = 0; i < token.length; ++i)
|
for (int i = 0; i < token.length; ++i)
|
||||||
trimmed.append(QLatin1Char('X'));
|
trimmed.append(QLatin1Char('X'));
|
||||||
|
|
||||||
} else if (token.is(QScriptIncrementalScanner::Token::Comment)) {
|
} else if (token.is(QmlJSScanner::Token::Comment)) {
|
||||||
for (int i = 0; i < token.length; ++i)
|
for (int i = 0; i < token.length; ++i)
|
||||||
trimmed.append(QLatin1Char(' '));
|
trimmed.append(QLatin1Char(' '));
|
||||||
|
|
||||||
@@ -235,43 +235,43 @@ QString QScriptIndenter::trimmedCodeLine(const QString &t)
|
|||||||
|
|
||||||
int index = yyLinizerState.tokens.size() - 1;
|
int index = yyLinizerState.tokens.size() - 1;
|
||||||
for (; index != -1; --index) {
|
for (; index != -1; --index) {
|
||||||
const QScriptIncrementalScanner::Token &token = yyLinizerState.tokens.at(index);
|
const QmlJSScanner::Token &token = yyLinizerState.tokens.at(index);
|
||||||
if (token.isNot(QScriptIncrementalScanner::Token::Comment))
|
if (token.isNot(QmlJSScanner::Token::Comment))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isBinding = false;
|
bool isBinding = false;
|
||||||
foreach (const QScriptIncrementalScanner::Token &token, yyLinizerState.tokens) {
|
foreach (const QmlJSScanner::Token &token, yyLinizerState.tokens) {
|
||||||
if (token.is(QScriptIncrementalScanner::Token::Colon)) {
|
if (token.is(QmlJSScanner::Token::Colon)) {
|
||||||
isBinding = true;
|
isBinding = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
const QScriptIncrementalScanner::Token &last = yyLinizerState.tokens.at(index);
|
const QmlJSScanner::Token &last = yyLinizerState.tokens.at(index);
|
||||||
|
|
||||||
switch (last.kind) {
|
switch (last.kind) {
|
||||||
case QScriptIncrementalScanner::Token::LeftParenthesis:
|
case QmlJSScanner::Token::LeftParenthesis:
|
||||||
case QScriptIncrementalScanner::Token::LeftBrace:
|
case QmlJSScanner::Token::LeftBrace:
|
||||||
case QScriptIncrementalScanner::Token::Semicolon:
|
case QmlJSScanner::Token::Semicolon:
|
||||||
case QScriptIncrementalScanner::Token::Operator:
|
case QmlJSScanner::Token::Operator:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::RightParenthesis:
|
case QmlJSScanner::Token::RightParenthesis:
|
||||||
case QScriptIncrementalScanner::Token::RightBrace:
|
case QmlJSScanner::Token::RightBrace:
|
||||||
if (isBinding)
|
if (isBinding)
|
||||||
trimmed.append(QLatin1Char(';'));
|
trimmed.append(QLatin1Char(';'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::Colon:
|
case QmlJSScanner::Token::Colon:
|
||||||
case QScriptIncrementalScanner::Token::LeftBracket:
|
case QmlJSScanner::Token::LeftBracket:
|
||||||
case QScriptIncrementalScanner::Token::RightBracket:
|
case QmlJSScanner::Token::RightBracket:
|
||||||
trimmed.append(QLatin1Char(';'));
|
trimmed.append(QLatin1Char(';'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::Identifier:
|
case QmlJSScanner::Token::Identifier:
|
||||||
case QScriptIncrementalScanner::Token::Keyword:
|
case QmlJSScanner::Token::Keyword:
|
||||||
if (t.midRef(last.offset, last.length) != QLatin1String("else"))
|
if (t.midRef(last.offset, last.length) != QLatin1String("else"))
|
||||||
trimmed.append(QLatin1Char(';'));
|
trimmed.append(QLatin1Char(';'));
|
||||||
break;
|
break;
|
||||||
@@ -289,7 +289,7 @@ QString QScriptIndenter::trimmedCodeLine(const QString &t)
|
|||||||
Returns '(' if the last parenthesis is opening, ')' if it is
|
Returns '(' if the last parenthesis is opening, ')' if it is
|
||||||
closing, and QChar() if there are no parentheses in t.
|
closing, and QChar() if there are no parentheses in t.
|
||||||
*/
|
*/
|
||||||
QChar QScriptIndenter::lastParen(const QString &t) const
|
QChar QmlJSIndenter::lastParen(const QString &t) const
|
||||||
{
|
{
|
||||||
int i = t.length();
|
int i = t.length();
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
@@ -304,7 +304,7 @@ QChar QScriptIndenter::lastParen(const QString &t) const
|
|||||||
Returns true if typedIn the same as okayCh or is null; otherwise
|
Returns true if typedIn the same as okayCh or is null; otherwise
|
||||||
returns false.
|
returns false.
|
||||||
*/
|
*/
|
||||||
bool QScriptIndenter::okay(QChar typedIn, QChar okayCh) const
|
bool QmlJSIndenter::okay(QChar typedIn, QChar okayCh) const
|
||||||
{
|
{
|
||||||
return typedIn == QChar() || typedIn == okayCh;
|
return typedIn == QChar() || typedIn == okayCh;
|
||||||
}
|
}
|
||||||
@@ -321,7 +321,7 @@ bool QScriptIndenter::okay(QChar typedIn, QChar okayCh) const
|
|||||||
accordingly. yyLine is cleaned from comments and other damageable
|
accordingly. yyLine is cleaned from comments and other damageable
|
||||||
constructs. Empty lines are skipped.
|
constructs. Empty lines are skipped.
|
||||||
*/
|
*/
|
||||||
bool QScriptIndenter::readLine()
|
bool QmlJSIndenter::readLine()
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
@@ -395,7 +395,7 @@ bool QScriptIndenter::readLine()
|
|||||||
Resets the linizer to its initial state, with yyLine containing the
|
Resets the linizer to its initial state, with yyLine containing the
|
||||||
line above the bottom line of the program.
|
line above the bottom line of the program.
|
||||||
*/
|
*/
|
||||||
void QScriptIndenter::startLinizer()
|
void QmlJSIndenter::startLinizer()
|
||||||
{
|
{
|
||||||
yyLinizerState.braceDepth = 0;
|
yyLinizerState.braceDepth = 0;
|
||||||
yyLinizerState.pendingRightBrace = false;
|
yyLinizerState.pendingRightBrace = false;
|
||||||
@@ -415,7 +415,7 @@ void QScriptIndenter::startLinizer()
|
|||||||
potentially the whole line) is part of a C-style comment;
|
potentially the whole line) is part of a C-style comment;
|
||||||
otherwise returns false.
|
otherwise returns false.
|
||||||
*/
|
*/
|
||||||
bool QScriptIndenter::bottomLineStartsInMultilineComment()
|
bool QmlJSIndenter::bottomLineStartsInMultilineComment()
|
||||||
{
|
{
|
||||||
QTextBlock currentLine = yyProgram.lastBlock().previous();
|
QTextBlock currentLine = yyProgram.lastBlock().previous();
|
||||||
QTextBlock previousLine = currentLine.previous();
|
QTextBlock previousLine = currentLine.previous();
|
||||||
@@ -435,7 +435,7 @@ bool QScriptIndenter::bottomLineStartsInMultilineComment()
|
|||||||
Essentially, we're trying to align against some text on the
|
Essentially, we're trying to align against some text on the
|
||||||
previous line.
|
previous line.
|
||||||
*/
|
*/
|
||||||
int QScriptIndenter::indentWhenBottomLineStartsInMultiLineComment()
|
int QmlJSIndenter::indentWhenBottomLineStartsInMultiLineComment()
|
||||||
{
|
{
|
||||||
QTextBlock block = yyProgram.lastBlock().previous();
|
QTextBlock block = yyProgram.lastBlock().previous();
|
||||||
QString blockText;
|
QString blockText;
|
||||||
@@ -468,7 +468,7 @@ int QScriptIndenter::indentWhenBottomLineStartsInMultiLineComment()
|
|||||||
if (x)
|
if (x)
|
||||||
y;
|
y;
|
||||||
*/
|
*/
|
||||||
bool QScriptIndenter::matchBracelessControlStatement()
|
bool QmlJSIndenter::matchBracelessControlStatement()
|
||||||
{
|
{
|
||||||
int delimDepth = 0;
|
int delimDepth = 0;
|
||||||
|
|
||||||
@@ -553,7 +553,7 @@ bool QScriptIndenter::matchBracelessControlStatement()
|
|||||||
f + // unfinished continuation line
|
f + // unfinished continuation line
|
||||||
g; // continuation line
|
g; // continuation line
|
||||||
*/
|
*/
|
||||||
bool QScriptIndenter::isUnfinishedLine()
|
bool QmlJSIndenter::isUnfinishedLine()
|
||||||
{
|
{
|
||||||
bool unf = false;
|
bool unf = false;
|
||||||
|
|
||||||
@@ -600,7 +600,7 @@ bool QScriptIndenter::isUnfinishedLine()
|
|||||||
Returns true if yyLine is a continuation line; otherwise returns
|
Returns true if yyLine is a continuation line; otherwise returns
|
||||||
false.
|
false.
|
||||||
*/
|
*/
|
||||||
bool QScriptIndenter::isContinuationLine()
|
bool QmlJSIndenter::isContinuationLine()
|
||||||
{
|
{
|
||||||
bool cont = false;
|
bool cont = false;
|
||||||
|
|
||||||
@@ -619,7 +619,7 @@ bool QScriptIndenter::isContinuationLine()
|
|||||||
or other bracked left opened on a previous line, or some interesting
|
or other bracked left opened on a previous line, or some interesting
|
||||||
operator such as '='.
|
operator such as '='.
|
||||||
*/
|
*/
|
||||||
int QScriptIndenter::indentForContinuationLine()
|
int QmlJSIndenter::indentForContinuationLine()
|
||||||
{
|
{
|
||||||
int braceDepth = 0;
|
int braceDepth = 0;
|
||||||
int delimDepth = 0;
|
int delimDepth = 0;
|
||||||
@@ -863,7 +863,7 @@ int QScriptIndenter::indentForContinuationLine()
|
|||||||
accommodate people with irregular indentation schemes. A hook line
|
accommodate people with irregular indentation schemes. A hook line
|
||||||
near at hand is much more reliable than a remote one.
|
near at hand is much more reliable than a remote one.
|
||||||
*/
|
*/
|
||||||
int QScriptIndenter::indentForStandaloneLine()
|
int QmlJSIndenter::indentForStandaloneLine()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < SmallRoof; i++) {
|
for (int i = 0; i < SmallRoof; i++) {
|
||||||
if (!*yyLeftBraceFollows) {
|
if (!*yyLeftBraceFollows) {
|
||||||
@@ -948,7 +948,7 @@ int QScriptIndenter::indentForStandaloneLine()
|
|||||||
slighly more liberal if typedIn is always null. The user might be
|
slighly more liberal if typedIn is always null. The user might be
|
||||||
annoyed by the liberal behavior.
|
annoyed by the liberal behavior.
|
||||||
*/
|
*/
|
||||||
int QScriptIndenter::indentForBottomLine(QTextBlock begin, QTextBlock end, QChar typedIn)
|
int QmlJSIndenter::indentForBottomLine(QTextBlock begin, QTextBlock end, QChar typedIn)
|
||||||
{
|
{
|
||||||
if (begin == end)
|
if (begin == end)
|
||||||
return 0;
|
return 0;
|
@@ -27,11 +27,11 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef QTSCRIPTINDENTER_H
|
#ifndef QMLJSINDENTER_H
|
||||||
#define QTSCRIPTINDENTER_H
|
#define QMLJSINDENTER_H
|
||||||
|
|
||||||
#include <qmljs/qml_global.h>
|
#include <qmljs/qmljs_global.h>
|
||||||
#include <qmljs/qscriptincrementalscanner.h>
|
#include <qmljs/qmljsscanner.h>
|
||||||
|
|
||||||
#include <QtCore/QRegExp>
|
#include <QtCore/QRegExp>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
@@ -39,13 +39,13 @@
|
|||||||
|
|
||||||
namespace QmlJS {
|
namespace QmlJS {
|
||||||
|
|
||||||
class QML_EXPORT QScriptIndenter
|
class QMLJS_EXPORT QmlJSIndenter
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY(QScriptIndenter)
|
Q_DISABLE_COPY(QmlJSIndenter)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QScriptIndenter();
|
QmlJSIndenter();
|
||||||
~QScriptIndenter();
|
~QmlJSIndenter();
|
||||||
|
|
||||||
void setTabSize(int size);
|
void setTabSize(int size);
|
||||||
void setIndentSize(int size);
|
void setIndentSize(int size);
|
||||||
@@ -103,7 +103,7 @@ private:
|
|||||||
bool leftBraceFollows;
|
bool leftBraceFollows;
|
||||||
bool pendingRightBrace;
|
bool pendingRightBrace;
|
||||||
QString line;
|
QString line;
|
||||||
QList<QScriptIncrementalScanner::Token> tokens;
|
QList<QmlJSScanner::Token> tokens;
|
||||||
QTextBlock iter;
|
QTextBlock iter;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,5 +136,5 @@ private:
|
|||||||
|
|
||||||
} // namespace QmlJS
|
} // namespace QmlJS
|
||||||
|
|
||||||
#endif // QTSCRIPTINDENTER_H
|
#endif // QMLJSINDENTER_H
|
||||||
|
|
@@ -27,17 +27,17 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "qmlmetatypebackend.h"
|
#include "qmljsmetatypebackend.h"
|
||||||
#include "qmltypesystem.h"
|
#include "qmljstypesystem.h"
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
|
|
||||||
QmlMetaTypeBackend::QmlMetaTypeBackend(QmlTypeSystem *typeSystem):
|
MetaTypeBackend::MetaTypeBackend(TypeSystem *typeSystem):
|
||||||
m_typeSystem(typeSystem)
|
m_typeSystem(typeSystem)
|
||||||
{
|
{
|
||||||
Q_ASSERT(typeSystem);
|
Q_ASSERT(typeSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlMetaTypeBackend::~QmlMetaTypeBackend()
|
MetaTypeBackend::~MetaTypeBackend()
|
||||||
{
|
{
|
||||||
}
|
}
|
@@ -30,29 +30,29 @@
|
|||||||
#ifndef QMLMETATYPEBACKEND_H
|
#ifndef QMLMETATYPEBACKEND_H
|
||||||
#define QMLMETATYPEBACKEND_H
|
#define QMLMETATYPEBACKEND_H
|
||||||
|
|
||||||
#include <qmljs/qml_global.h>
|
#include <qmljs/qmljs_global.h>
|
||||||
#include <qmljs/qmlpackageinfo.h>
|
#include <qmljs/qmljspackageinfo.h>
|
||||||
#include <qmljs/qmlsymbol.h>
|
#include <qmljs/qmljssymbol.h>
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
|
|
||||||
class QmlTypeSystem;
|
class TypeSystem;
|
||||||
|
|
||||||
class QML_EXPORT QmlMetaTypeBackend
|
class QMLJS_EXPORT MetaTypeBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlMetaTypeBackend(QmlTypeSystem *typeSystem);
|
MetaTypeBackend(TypeSystem *typeSystem);
|
||||||
virtual ~QmlMetaTypeBackend() = 0;
|
virtual ~MetaTypeBackend() = 0;
|
||||||
|
|
||||||
virtual QList<QmlSymbol *> availableTypes(const QString &package, int majorVersion, int minorVersion) = 0;
|
virtual QList<Symbol *> availableTypes(const QString &package, int majorVersion, int minorVersion) = 0;
|
||||||
virtual QmlSymbol *resolve(const QString &typeName, const QList<PackageInfo> &packages) = 0;
|
virtual Symbol *resolve(const QString &typeName, const QList<PackageInfo> &packages) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QmlTypeSystem *typeSystem() const
|
TypeSystem *typeSystem() const
|
||||||
{ return m_typeSystem; }
|
{ return m_typeSystem; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlTypeSystem *m_typeSystem;
|
TypeSystem *m_typeSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Qml
|
} // namespace Qml
|
@@ -27,9 +27,9 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "qmlpackageinfo.h"
|
#include "qmljspackageinfo.h"
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
|
|
||||||
PackageInfo::PackageInfo(const QString &name, int majorVersion, int minorVersion):
|
PackageInfo::PackageInfo(const QString &name, int majorVersion, int minorVersion):
|
||||||
m_name(name),
|
m_name(name),
|
@@ -30,13 +30,13 @@
|
|||||||
#ifndef PACKAGEINFO_H
|
#ifndef PACKAGEINFO_H
|
||||||
#define PACKAGEINFO_H
|
#define PACKAGEINFO_H
|
||||||
|
|
||||||
#include <qmljs/qml_global.h>
|
#include <qmljs/qmljs_global.h>
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
|
|
||||||
class QML_EXPORT PackageInfo
|
class QMLJS_EXPORT PackageInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PackageInfo(const QString &name, int majorVersion, int minorVersion);
|
PackageInfo(const QString &name, int majorVersion, int minorVersion);
|
@@ -27,28 +27,28 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include <qmljs/qscriptincrementalscanner.h>
|
#include <qmljs/qmljsscanner.h>
|
||||||
|
|
||||||
#include <QTextCharFormat>
|
#include <QTextCharFormat>
|
||||||
|
|
||||||
using namespace QmlJS;
|
using namespace QmlJS;
|
||||||
|
|
||||||
QScriptIncrementalScanner::QScriptIncrementalScanner()
|
QmlJSScanner::QmlJSScanner()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptIncrementalScanner::~QScriptIncrementalScanner()
|
QmlJSScanner::~QmlJSScanner()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void QScriptIncrementalScanner::reset()
|
void QmlJSScanner::reset()
|
||||||
{
|
{
|
||||||
m_endState = -1;
|
m_endState = -1;
|
||||||
m_firstNonSpace = -1;
|
m_firstNonSpace = -1;
|
||||||
m_tokens.clear();
|
m_tokens.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QScriptIncrementalScanner::Token> QScriptIncrementalScanner::operator()(const QString &text, int startState)
|
QList<QmlJSScanner::Token> QmlJSScanner::operator()(const QString &text, int startState)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ QList<QScriptIncrementalScanner::Token> QScriptIncrementalScanner::operator()(co
|
|||||||
return m_tokens;
|
return m_tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScriptIncrementalScanner::insertToken(int start, int length, Token::Kind kind, bool forceNewToken)
|
void QmlJSScanner::insertToken(int start, int length, Token::Kind kind, bool forceNewToken)
|
||||||
{
|
{
|
||||||
if (m_tokens.isEmpty() || forceNewToken) {
|
if (m_tokens.isEmpty() || forceNewToken) {
|
||||||
m_tokens.append(Token(start, length, kind));
|
m_tokens.append(Token(start, length, kind));
|
||||||
@@ -316,7 +316,7 @@ void QScriptIncrementalScanner::insertToken(int start, int length, Token::Kind k
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScriptIncrementalScanner::insertCharToken(int start, const char c)
|
void QmlJSScanner::insertCharToken(int start, const char c)
|
||||||
{
|
{
|
||||||
Token::Kind kind;
|
Token::Kind kind;
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ void QScriptIncrementalScanner::insertCharToken(int start, const char c)
|
|||||||
insertToken(start, 1, kind, true);
|
insertToken(start, 1, kind, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScriptIncrementalScanner::scanForKeywords(const QString &text)
|
void QmlJSScanner::scanForKeywords(const QString &text)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_tokens.length(); ++i) {
|
for (int i = 0; i < m_tokens.length(); ++i) {
|
||||||
Token &t(m_tokens[i]);
|
Token &t(m_tokens[i]);
|
@@ -27,10 +27,10 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef QSCRIPTINCREMENTALSCANNER_H
|
#ifndef QMLJSSCANNER_H
|
||||||
#define QSCRIPTINCREMENTALSCANNER_H
|
#define QMLJSSCANNER_H
|
||||||
|
|
||||||
#include <qmljs/qml_global.h>
|
#include <qmljs/qmljs_global.h>
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
namespace QmlJS {
|
namespace QmlJS {
|
||||||
|
|
||||||
class QML_EXPORT QScriptIncrementalScanner
|
class QMLJS_EXPORT QmlJSScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -72,15 +72,15 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QScriptIncrementalScanner();
|
QmlJSScanner();
|
||||||
virtual ~QScriptIncrementalScanner();
|
virtual ~QmlJSScanner();
|
||||||
|
|
||||||
void setKeywords(const QSet<QString> keywords)
|
void setKeywords(const QSet<QString> keywords)
|
||||||
{ m_keywords = keywords;; }
|
{ m_keywords = keywords;; }
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
QList<QScriptIncrementalScanner::Token> operator()(const QString &text, int startState = 0);
|
QList<QmlJSScanner::Token> operator()(const QString &text, int startState = 0);
|
||||||
|
|
||||||
int endState() const
|
int endState() const
|
||||||
{ return m_endState; }
|
{ return m_endState; }
|
||||||
@@ -88,7 +88,7 @@ public:
|
|||||||
int firstNonSpace() const
|
int firstNonSpace() const
|
||||||
{ return m_firstNonSpace; }
|
{ return m_firstNonSpace; }
|
||||||
|
|
||||||
QList<QScriptIncrementalScanner::Token> tokens() const
|
QList<QmlJSScanner::Token> tokens() const
|
||||||
{ return m_tokens; }
|
{ return m_tokens; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -110,9 +110,9 @@ private:
|
|||||||
QSet<QString> m_keywords;
|
QSet<QString> m_keywords;
|
||||||
int m_endState;
|
int m_endState;
|
||||||
int m_firstNonSpace;
|
int m_firstNonSpace;
|
||||||
QList<QScriptIncrementalScanner::Token> m_tokens;
|
QList<QmlJSScanner::Token> m_tokens;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlJS
|
} // namespace QmlJS
|
||||||
|
|
||||||
#endif // QSCRIPTINCREMENTALSCANNER_H
|
#endif // QMLJSSCANNER_H
|
@@ -27,56 +27,56 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "qmlsymbol.h"
|
#include "qmljssymbol.h"
|
||||||
|
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
#include <qmljs/parser/qmljsengine_p.h>
|
#include <qmljs/parser/qmljsengine_p.h>
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace QmlJS;
|
using namespace QmlJS;
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
|
|
||||||
QmlSymbol::~QmlSymbol()
|
Symbol::~Symbol()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlSymbol::isBuildInSymbol()
|
bool Symbol::isBuildInSymbol()
|
||||||
{ return asBuildInSymbol() != 0; }
|
{ return asPrimitiveSymbol() != 0; }
|
||||||
|
|
||||||
bool QmlSymbol::isSymbolFromFile()
|
bool Symbol::isSymbolFromFile()
|
||||||
{ return asSymbolFromFile() != 0; }
|
{ return asSymbolFromFile() != 0; }
|
||||||
|
|
||||||
bool QmlSymbol::isIdSymbol()
|
bool Symbol::isIdSymbol()
|
||||||
{ return asIdSymbol() != 0; }
|
{ return asIdSymbol() != 0; }
|
||||||
|
|
||||||
bool QmlSymbol::isPropertyDefinitionSymbol()
|
bool Symbol::isPropertyDefinitionSymbol()
|
||||||
{ return asPropertyDefinitionSymbol() != 0; }
|
{ return asPropertyDefinitionSymbol() != 0; }
|
||||||
|
|
||||||
QmlBuildInSymbol *QmlSymbol::asBuildInSymbol()
|
PrimitiveSymbol *Symbol::asPrimitiveSymbol()
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
QmlSymbolFromFile *QmlSymbol::asSymbolFromFile()
|
SymbolFromFile *Symbol::asSymbolFromFile()
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
QmlIdSymbol *QmlSymbol::asIdSymbol()
|
IdSymbol *Symbol::asIdSymbol()
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
QmlPropertyDefinitionSymbol *QmlSymbol::asPropertyDefinitionSymbol()
|
PropertyDefinitionSymbol *Symbol::asPropertyDefinitionSymbol()
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
QmlBuildInSymbol::~QmlBuildInSymbol()
|
PrimitiveSymbol::~PrimitiveSymbol()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QmlBuildInSymbol *QmlBuildInSymbol::asBuildInSymbol()
|
PrimitiveSymbol *PrimitiveSymbol::asPrimitiveSymbol()
|
||||||
{ return this; }
|
{ return this; }
|
||||||
|
|
||||||
QmlSymbolWithMembers::~QmlSymbolWithMembers()
|
SymbolWithMembers::~SymbolWithMembers()
|
||||||
{ qDeleteAll(_members); }
|
{ qDeleteAll(_members); }
|
||||||
|
|
||||||
const QmlSymbol::List QmlSymbolWithMembers::members()
|
const Symbol::List SymbolWithMembers::members()
|
||||||
{ return _members; }
|
{ return _members; }
|
||||||
|
|
||||||
QmlSymbolFromFile::QmlSymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node):
|
SymbolFromFile::SymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node):
|
||||||
_fileName(fileName),
|
_fileName(fileName),
|
||||||
_node(node)
|
_node(node)
|
||||||
{
|
{
|
||||||
@@ -97,16 +97,16 @@ QmlSymbolFromFile::QmlSymbolFromFile(const QString &fileName, QmlJS::AST::UiObje
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbolFromFile::~QmlSymbolFromFile()
|
SymbolFromFile::~SymbolFromFile()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QmlSymbolFromFile *QmlSymbolFromFile::asSymbolFromFile()
|
SymbolFromFile *SymbolFromFile::asSymbolFromFile()
|
||||||
{ return this; }
|
{ return this; }
|
||||||
|
|
||||||
int QmlSymbolFromFile::line() const
|
int SymbolFromFile::line() const
|
||||||
{ return _node->firstSourceLocation().startLine; }
|
{ return _node->firstSourceLocation().startLine; }
|
||||||
|
|
||||||
int QmlSymbolFromFile::column() const
|
int SymbolFromFile::column() const
|
||||||
{ return _node->firstSourceLocation().startColumn; }
|
{ return _node->firstSourceLocation().startColumn; }
|
||||||
|
|
||||||
static inline QString toString(UiQualifiedId *qId)
|
static inline QString toString(UiQualifiedId *qId)
|
||||||
@@ -126,7 +126,7 @@ static inline QString toString(UiQualifiedId *qId)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString QmlSymbolFromFile::name() const
|
const QString SymbolFromFile::name() const
|
||||||
{
|
{
|
||||||
if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(_node))
|
if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(_node))
|
||||||
return toString(objectBinding->qualifiedId);
|
return toString(objectBinding->qualifiedId);
|
||||||
@@ -140,23 +140,23 @@ const QString QmlSymbolFromFile::name() const
|
|||||||
return QString::null;
|
return QString::null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QmlSymbol::List QmlSymbolFromFile::members()
|
const Symbol::List SymbolFromFile::members()
|
||||||
{
|
{
|
||||||
if (!todo.isEmpty()) {
|
if (!todo.isEmpty()) {
|
||||||
foreach (Node *todoNode, todo) {
|
foreach (Node *todoNode, todo) {
|
||||||
if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(todoNode))
|
if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(todoNode))
|
||||||
_members.append(new QmlSymbolFromFile(fileName(), objectBinding));
|
_members.append(new SymbolFromFile(fileName(), objectBinding));
|
||||||
else if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(todoNode))
|
else if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(todoNode))
|
||||||
_members.append(new QmlSymbolFromFile(fileName(), objectDefinition));
|
_members.append(new SymbolFromFile(fileName(), objectDefinition));
|
||||||
else if (UiArrayBinding *arrayBinding = cast<UiArrayBinding*>(todoNode))
|
else if (UiArrayBinding *arrayBinding = cast<UiArrayBinding*>(todoNode))
|
||||||
_members.append(new QmlSymbolFromFile(fileName(), arrayBinding));
|
_members.append(new SymbolFromFile(fileName(), arrayBinding));
|
||||||
else if (UiPublicMember *publicMember = cast<UiPublicMember*>(todoNode))
|
else if (UiPublicMember *publicMember = cast<UiPublicMember*>(todoNode))
|
||||||
_members.append(new QmlPropertyDefinitionSymbol(fileName(), publicMember));
|
_members.append(new PropertyDefinitionSymbol(fileName(), publicMember));
|
||||||
else if (UiScriptBinding *scriptBinding = cast<UiScriptBinding*>(todoNode)) {
|
else if (UiScriptBinding *scriptBinding = cast<UiScriptBinding*>(todoNode)) {
|
||||||
if (scriptBinding->qualifiedId && scriptBinding->qualifiedId->name && scriptBinding->qualifiedId->name->asString() == QLatin1String("id") && !scriptBinding->qualifiedId->next)
|
if (scriptBinding->qualifiedId && scriptBinding->qualifiedId->name && scriptBinding->qualifiedId->name->asString() == QLatin1String("id") && !scriptBinding->qualifiedId->next)
|
||||||
_members.append(new QmlIdSymbol(fileName(), scriptBinding, this));
|
_members.append(new IdSymbol(fileName(), scriptBinding, this));
|
||||||
else
|
else
|
||||||
_members.append(new QmlSymbolFromFile(fileName(), scriptBinding));
|
_members.append(new SymbolFromFile(fileName(), scriptBinding));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,14 +166,14 @@ const QmlSymbol::List QmlSymbolFromFile::members()
|
|||||||
return _members;
|
return _members;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlSymbolFromFile::isProperty() const
|
bool SymbolFromFile::isProperty() const
|
||||||
{ return cast<UiObjectDefinition*>(_node) == 0; }
|
{ return cast<UiObjectDefinition*>(_node) == 0; }
|
||||||
|
|
||||||
QmlSymbolFromFile *QmlSymbolFromFile::findMember(QmlJS::AST::Node *memberNode)
|
SymbolFromFile *SymbolFromFile::findMember(QmlJS::AST::Node *memberNode)
|
||||||
{
|
{
|
||||||
List symbols = members();
|
List symbols = members();
|
||||||
|
|
||||||
foreach (QmlSymbol *symbol, symbols)
|
foreach (Symbol *symbol, symbols)
|
||||||
if (symbol->isSymbolFromFile())
|
if (symbol->isSymbolFromFile())
|
||||||
if (memberNode == symbol->asSymbolFromFile()->node())
|
if (memberNode == symbol->asSymbolFromFile()->node())
|
||||||
return symbol->asSymbolFromFile();
|
return symbol->asSymbolFromFile();
|
||||||
@@ -181,24 +181,24 @@ QmlSymbolFromFile *QmlSymbolFromFile::findMember(QmlJS::AST::Node *memberNode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlIdSymbol::QmlIdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, QmlSymbolFromFile *parentNode):
|
IdSymbol::IdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, SymbolFromFile *parentNode):
|
||||||
QmlSymbolFromFile(fileName, idNode),
|
SymbolFromFile(fileName, idNode),
|
||||||
_parentNode(parentNode)
|
_parentNode(parentNode)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QmlIdSymbol::~QmlIdSymbol()
|
IdSymbol::~IdSymbol()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QmlIdSymbol *QmlIdSymbol::asIdSymbol()
|
IdSymbol *IdSymbol::asIdSymbol()
|
||||||
{ return this; }
|
{ return this; }
|
||||||
|
|
||||||
int QmlIdSymbol::line() const
|
int IdSymbol::line() const
|
||||||
{ return idNode()->statement->firstSourceLocation().startLine; }
|
{ return idNode()->statement->firstSourceLocation().startLine; }
|
||||||
|
|
||||||
int QmlIdSymbol::column() const
|
int IdSymbol::column() const
|
||||||
{ return idNode()->statement->firstSourceLocation().startColumn; }
|
{ return idNode()->statement->firstSourceLocation().startColumn; }
|
||||||
|
|
||||||
const QString QmlIdSymbol::id() const
|
const QString IdSymbol::id() const
|
||||||
{
|
{
|
||||||
if (ExpressionStatement *e = cast<ExpressionStatement*>(idNode()->statement))
|
if (ExpressionStatement *e = cast<ExpressionStatement*>(idNode()->statement))
|
||||||
if (IdentifierExpression *i = cast<IdentifierExpression*>(e->expression))
|
if (IdentifierExpression *i = cast<IdentifierExpression*>(e->expression))
|
||||||
@@ -208,27 +208,27 @@ const QString QmlIdSymbol::id() const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJS::AST::UiScriptBinding *QmlIdSymbol::idNode() const
|
QmlJS::AST::UiScriptBinding *IdSymbol::idNode() const
|
||||||
{ return cast<UiScriptBinding*>(node()); }
|
{ return cast<UiScriptBinding*>(node()); }
|
||||||
|
|
||||||
QmlPropertyDefinitionSymbol::QmlPropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode):
|
PropertyDefinitionSymbol::PropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode):
|
||||||
QmlSymbolFromFile(fileName, propertyNode)
|
SymbolFromFile(fileName, propertyNode)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QmlPropertyDefinitionSymbol::~QmlPropertyDefinitionSymbol()
|
PropertyDefinitionSymbol::~PropertyDefinitionSymbol()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QmlPropertyDefinitionSymbol *QmlPropertyDefinitionSymbol::asPropertyDefinitionSymbol()
|
PropertyDefinitionSymbol *PropertyDefinitionSymbol::asPropertyDefinitionSymbol()
|
||||||
{ return this; }
|
{ return this; }
|
||||||
|
|
||||||
int QmlPropertyDefinitionSymbol::line() const
|
int PropertyDefinitionSymbol::line() const
|
||||||
{ return propertyNode()->identifierToken.startLine; }
|
{ return propertyNode()->identifierToken.startLine; }
|
||||||
|
|
||||||
int QmlPropertyDefinitionSymbol::column() const
|
int PropertyDefinitionSymbol::column() const
|
||||||
{ return propertyNode()->identifierToken.startColumn; }
|
{ return propertyNode()->identifierToken.startColumn; }
|
||||||
|
|
||||||
QmlJS::AST::UiPublicMember *QmlPropertyDefinitionSymbol::propertyNode() const
|
QmlJS::AST::UiPublicMember *PropertyDefinitionSymbol::propertyNode() const
|
||||||
{ return cast<UiPublicMember*>(node()); }
|
{ return cast<UiPublicMember*>(node()); }
|
||||||
|
|
||||||
const QString QmlPropertyDefinitionSymbol::name() const
|
const QString PropertyDefinitionSymbol::name() const
|
||||||
{ return propertyNode()->name->asString(); }
|
{ return propertyNode()->name->asString(); }
|
@@ -31,20 +31,20 @@
|
|||||||
#define QMLSYMBOL_H
|
#define QMLSYMBOL_H
|
||||||
|
|
||||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||||
#include <qmljs/qml_global.h>
|
#include <qmljs/qmljs_global.h>
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
|
|
||||||
class QML_EXPORT QmlSymbol
|
class QMLJS_EXPORT Symbol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QList<QmlSymbol *> List;
|
typedef QList<Symbol *> List;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~QmlSymbol() = 0;
|
virtual ~Symbol() = 0;
|
||||||
|
|
||||||
virtual const QString name() const = 0;
|
virtual const QString name() const = 0;
|
||||||
virtual const List members() = 0;
|
virtual const List members() = 0;
|
||||||
@@ -55,28 +55,28 @@ public:
|
|||||||
bool isIdSymbol();
|
bool isIdSymbol();
|
||||||
bool isPropertyDefinitionSymbol();
|
bool isPropertyDefinitionSymbol();
|
||||||
|
|
||||||
virtual class QmlBuildInSymbol *asBuildInSymbol();
|
virtual class PrimitiveSymbol *asPrimitiveSymbol();
|
||||||
virtual class QmlSymbolFromFile *asSymbolFromFile();
|
virtual class SymbolFromFile *asSymbolFromFile();
|
||||||
virtual class QmlIdSymbol *asIdSymbol();
|
virtual class IdSymbol *asIdSymbol();
|
||||||
virtual class QmlPropertyDefinitionSymbol *asPropertyDefinitionSymbol();
|
virtual class PropertyDefinitionSymbol *asPropertyDefinitionSymbol();
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_EXPORT QmlBuildInSymbol: public QmlSymbol
|
class QMLJS_EXPORT PrimitiveSymbol: public Symbol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QmlBuildInSymbol() = 0;
|
virtual ~PrimitiveSymbol() = 0;
|
||||||
|
|
||||||
virtual QmlBuildInSymbol *asBuildInSymbol();
|
virtual PrimitiveSymbol *asPrimitiveSymbol();
|
||||||
|
|
||||||
virtual QmlBuildInSymbol *type() const = 0;
|
virtual PrimitiveSymbol *type() const = 0;
|
||||||
using QmlSymbol::members;
|
using Symbol::members;
|
||||||
virtual List members(bool includeBaseClassMembers) = 0;
|
virtual List members(bool includeBaseClassMembers) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_EXPORT QmlSymbolWithMembers: public QmlSymbol
|
class QMLJS_EXPORT SymbolWithMembers: public Symbol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QmlSymbolWithMembers() = 0;
|
virtual ~SymbolWithMembers() = 0;
|
||||||
|
|
||||||
virtual const List members();
|
virtual const List members();
|
||||||
|
|
||||||
@@ -84,13 +84,13 @@ protected:
|
|||||||
List _members;
|
List _members;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_EXPORT QmlSymbolFromFile: public QmlSymbolWithMembers
|
class QMLJS_EXPORT SymbolFromFile: public SymbolWithMembers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlSymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node);
|
SymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node);
|
||||||
virtual ~QmlSymbolFromFile();
|
virtual ~SymbolFromFile();
|
||||||
|
|
||||||
virtual QmlSymbolFromFile *asSymbolFromFile();
|
virtual SymbolFromFile *asSymbolFromFile();
|
||||||
|
|
||||||
QString fileName() const
|
QString fileName() const
|
||||||
{ return _fileName; }
|
{ return _fileName; }
|
||||||
@@ -104,7 +104,7 @@ public:
|
|||||||
virtual const QString name() const;
|
virtual const QString name() const;
|
||||||
virtual const List members();
|
virtual const List members();
|
||||||
virtual bool isProperty() const;
|
virtual bool isProperty() const;
|
||||||
virtual QmlSymbolFromFile *findMember(QmlJS::AST::Node *memberNode);
|
virtual SymbolFromFile *findMember(QmlJS::AST::Node *memberNode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fillTodo(QmlJS::AST::UiObjectMemberList *members);
|
void fillTodo(QmlJS::AST::UiObjectMemberList *members);
|
||||||
@@ -115,18 +115,18 @@ private:
|
|||||||
QList<QmlJS::AST::Node*> todo;
|
QList<QmlJS::AST::Node*> todo;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_EXPORT QmlIdSymbol: public QmlSymbolFromFile
|
class QMLJS_EXPORT IdSymbol: public SymbolFromFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlIdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, QmlSymbolFromFile *parentNode);
|
IdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, SymbolFromFile *parentNode);
|
||||||
virtual ~QmlIdSymbol();
|
virtual ~IdSymbol();
|
||||||
|
|
||||||
QmlIdSymbol *asIdSymbol();
|
IdSymbol *asIdSymbol();
|
||||||
|
|
||||||
virtual int line() const;
|
virtual int line() const;
|
||||||
virtual int column() const;
|
virtual int column() const;
|
||||||
|
|
||||||
QmlSymbolFromFile *parentNode() const
|
SymbolFromFile *parentNode() const
|
||||||
{ return _parentNode; }
|
{ return _parentNode; }
|
||||||
|
|
||||||
virtual const QString name() const
|
virtual const QString name() const
|
||||||
@@ -138,16 +138,16 @@ private:
|
|||||||
QmlJS::AST::UiScriptBinding *idNode() const;
|
QmlJS::AST::UiScriptBinding *idNode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlSymbolFromFile *_parentNode;
|
SymbolFromFile *_parentNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_EXPORT QmlPropertyDefinitionSymbol: public QmlSymbolFromFile
|
class QMLJS_EXPORT PropertyDefinitionSymbol: public SymbolFromFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlPropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode);
|
PropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode);
|
||||||
virtual ~QmlPropertyDefinitionSymbol();
|
virtual ~PropertyDefinitionSymbol();
|
||||||
|
|
||||||
QmlPropertyDefinitionSymbol *asPropertyDefinitionSymbol();
|
PropertyDefinitionSymbol *asPropertyDefinitionSymbol();
|
||||||
|
|
||||||
virtual int line() const;
|
virtual int line() const;
|
||||||
virtual int column() const;
|
virtual int column() const;
|
@@ -27,8 +27,8 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "qmlmetatypebackend.h"
|
#include "qmljsmetatypebackend.h"
|
||||||
#include "qmltypesystem.h"
|
#include "qmljstypesystem.h"
|
||||||
|
|
||||||
#ifdef BUILD_DECLARATIVE_BACKEND
|
#ifdef BUILD_DECLARATIVE_BACKEND
|
||||||
# include "qtdeclarativemetatypebackend.h"
|
# include "qtdeclarativemetatypebackend.h"
|
||||||
@@ -36,34 +36,34 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
|
|
||||||
QmlTypeSystem::QmlTypeSystem()
|
TypeSystem::TypeSystem()
|
||||||
{
|
{
|
||||||
#ifdef BUILD_DECLARATIVE_BACKEND
|
#ifdef BUILD_DECLARATIVE_BACKEND
|
||||||
backends.append(new Internal::QtDeclarativeMetaTypeBackend(this));
|
backends.append(new Internal::QtDeclarativeMetaTypeBackend(this));
|
||||||
#endif // BUILD_DECLARATIVE_BACKEND
|
#endif // BUILD_DECLARATIVE_BACKEND
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlTypeSystem::~QmlTypeSystem()
|
TypeSystem::~TypeSystem()
|
||||||
{
|
{
|
||||||
qDeleteAll(backends);
|
qDeleteAll(backends);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QmlSymbol *> QmlTypeSystem::availableTypes(const QString &package, int majorVersion, int minorVersion)
|
QList<Symbol *> TypeSystem::availableTypes(const QString &package, int majorVersion, int minorVersion)
|
||||||
{
|
{
|
||||||
QList<QmlSymbol *> results;
|
QList<Symbol *> results;
|
||||||
|
|
||||||
foreach (QmlMetaTypeBackend *backend, backends)
|
foreach (MetaTypeBackend *backend, backends)
|
||||||
results.append(backend->availableTypes(package, majorVersion, minorVersion));
|
results.append(backend->availableTypes(package, majorVersion, minorVersion));
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbol *QmlTypeSystem::resolve(const QString &typeName, const QList<PackageInfo> &packages)
|
Symbol *TypeSystem::resolve(const QString &typeName, const QList<PackageInfo> &packages)
|
||||||
{
|
{
|
||||||
foreach (QmlMetaTypeBackend *backend, backends)
|
foreach (MetaTypeBackend *backend, backends)
|
||||||
if (QmlSymbol *symbol = backend->resolve(typeName, packages))
|
if (Symbol *symbol = backend->resolve(typeName, packages))
|
||||||
return symbol;
|
return symbol;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
@@ -30,30 +30,30 @@
|
|||||||
#ifndef QMLTYPESYSTEM_H
|
#ifndef QMLTYPESYSTEM_H
|
||||||
#define QMLTYPESYSTEM_H
|
#define QMLTYPESYSTEM_H
|
||||||
|
|
||||||
#include <qmljs/qml_global.h>
|
#include <qmljs/qmljs_global.h>
|
||||||
#include <qmljs/qmlpackageinfo.h>
|
#include <qmljs/qmljspackageinfo.h>
|
||||||
#include <qmljs/qmlsymbol.h>
|
#include <qmljs/qmljssymbol.h>
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
|
|
||||||
class QmlMetaTypeBackend;
|
class MetaTypeBackend;
|
||||||
|
|
||||||
class QML_EXPORT QmlTypeSystem: public QObject
|
class QMLJS_EXPORT TypeSystem: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlTypeSystem();
|
TypeSystem();
|
||||||
virtual ~QmlTypeSystem();
|
virtual ~TypeSystem();
|
||||||
|
|
||||||
QList<QmlSymbol *> availableTypes(const QString &package, int majorVersion, int minorVersion);
|
QList<Symbol *> availableTypes(const QString &package, int majorVersion, int minorVersion);
|
||||||
QmlSymbol *resolve(const QString &typeName, const QList<PackageInfo> &packages);
|
Symbol *resolve(const QString &typeName, const QList<PackageInfo> &packages);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QmlMetaTypeBackend *> backends;
|
QList<MetaTypeBackend *> backends;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Qml
|
} // namespace Qml
|
@@ -31,17 +31,17 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class QmlDeclarativeSymbol: public QmlBuildInSymbol
|
class DeclarativeSymbol: public PrimitiveSymbol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QmlDeclarativeSymbol()
|
virtual ~DeclarativeSymbol()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QmlDeclarativeSymbol(QtDeclarativeMetaTypeBackend* backend):
|
DeclarativeSymbol(QtDeclarativeMetaTypeBackend* backend):
|
||||||
m_backend(backend)
|
m_backend(backend)
|
||||||
{ Q_ASSERT(backend); }
|
{ Q_ASSERT(backend); }
|
||||||
|
|
||||||
@@ -52,24 +52,24 @@ private:
|
|||||||
QtDeclarativeMetaTypeBackend* m_backend;
|
QtDeclarativeMetaTypeBackend* m_backend;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QmlDeclarativeObjectSymbol: public QmlDeclarativeSymbol
|
class DeclarativeObjectSymbol: public DeclarativeSymbol
|
||||||
{
|
{
|
||||||
QmlDeclarativeObjectSymbol(const QmlDeclarativeObjectSymbol &);
|
DeclarativeObjectSymbol(const DeclarativeObjectSymbol &);
|
||||||
QmlDeclarativeObjectSymbol &operator=(const QmlDeclarativeObjectSymbol &);
|
DeclarativeObjectSymbol &operator=(const DeclarativeObjectSymbol &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlDeclarativeObjectSymbol(QtDeclarativeMetaTypeBackend* backend):
|
DeclarativeObjectSymbol(QtDeclarativeMetaTypeBackend* backend):
|
||||||
QmlDeclarativeSymbol(backend)
|
DeclarativeSymbol(backend)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~QmlDeclarativeObjectSymbol()
|
virtual ~DeclarativeObjectSymbol()
|
||||||
{ qDeleteAll(m_members); }
|
{ qDeleteAll(m_members); }
|
||||||
|
|
||||||
virtual const QString name() const
|
virtual const QString name() const
|
||||||
{ return m_name; }
|
{ return m_name; }
|
||||||
|
|
||||||
virtual QmlBuildInSymbol *type() const
|
virtual PrimitiveSymbol *type() const
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
virtual const List members()
|
virtual const List members()
|
||||||
@@ -114,24 +114,24 @@ private:
|
|||||||
List m_members;
|
List m_members;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QmlDeclarativePropertySymbol: public QmlDeclarativeSymbol
|
class DeclarativePropertySymbol: public DeclarativeSymbol
|
||||||
{
|
{
|
||||||
QmlDeclarativePropertySymbol(const QmlDeclarativePropertySymbol &);
|
DeclarativePropertySymbol(const DeclarativePropertySymbol &);
|
||||||
QmlDeclarativePropertySymbol &operator=(const QmlDeclarativePropertySymbol &);
|
DeclarativePropertySymbol &operator=(const DeclarativePropertySymbol &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlDeclarativePropertySymbol(QtDeclarativeMetaTypeBackend* backend):
|
DeclarativePropertySymbol(QtDeclarativeMetaTypeBackend* backend):
|
||||||
QmlDeclarativeSymbol(backend)
|
DeclarativeSymbol(backend)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~QmlDeclarativePropertySymbol()
|
virtual ~DeclarativePropertySymbol()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual const QString name() const
|
virtual const QString name() const
|
||||||
{ return QString(); }
|
{ return QString(); }
|
||||||
|
|
||||||
virtual QmlBuildInSymbol *type() const
|
virtual PrimitiveSymbol *type() const
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
virtual const List members()
|
virtual const List members()
|
||||||
@@ -153,11 +153,11 @@ private:
|
|||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Qml
|
} // namespace Qml
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace Qml::Internal;
|
using namespace QmlJS::Internal;
|
||||||
|
|
||||||
QtDeclarativeMetaTypeBackend::QtDeclarativeMetaTypeBackend(QmlTypeSystem *typeSystem):
|
QtDeclarativeMetaTypeBackend::QtDeclarativeMetaTypeBackend(TypeSystem *typeSystem):
|
||||||
QmlMetaTypeBackend(typeSystem)
|
MetaTypeBackend(typeSystem)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,16 +165,16 @@ QtDeclarativeMetaTypeBackend::~QtDeclarativeMetaTypeBackend()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QmlSymbol *> QtDeclarativeMetaTypeBackend::availableTypes(const QString &package, int majorVersion, int minorVersion)
|
QList<Symbol *> QtDeclarativeMetaTypeBackend::availableTypes(const QString &package, int majorVersion, int minorVersion)
|
||||||
{
|
{
|
||||||
QList<QmlSymbol *> result;
|
QList<Symbol *> result;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbol *QtDeclarativeMetaTypeBackend::resolve(const QString &typeName, const QList<PackageInfo> &packages)
|
Symbol *QtDeclarativeMetaTypeBackend::resolve(const QString &typeName, const QList<PackageInfo> &packages)
|
||||||
{
|
{
|
||||||
QList<QmlSymbol *> result;
|
QList<Symbol *> result;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -30,37 +30,37 @@
|
|||||||
#ifndef QTDECLARATIVEMETATYPEBACKEND_H
|
#ifndef QTDECLARATIVEMETATYPEBACKEND_H
|
||||||
#define QTDECLARATIVEMETATYPEBACKEND_H
|
#define QTDECLARATIVEMETATYPEBACKEND_H
|
||||||
|
|
||||||
#include <qmljs/qmlmetatypebackend.h>
|
#include <qmljs/qmljsmetatypebackend.h>
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class QmlDeclarativeSymbol;
|
class DeclarativeSymbol;
|
||||||
class QmlDeclarativeObjectSymbol;
|
class DeclarativeObjectSymbol;
|
||||||
class QmlDeclarativePropertySymbol;
|
class DeclarativePropertySymbol;
|
||||||
|
|
||||||
class QtDeclarativeMetaTypeBackend: public QmlMetaTypeBackend
|
class QtDeclarativeMetaTypeBackend: public MetaTypeBackend
|
||||||
{
|
{
|
||||||
friend class QmlDeclarativeSymbol;
|
friend class DeclarativeSymbol;
|
||||||
friend class QmlDeclarativeObjectSymbol;
|
friend class DeclarativeObjectSymbol;
|
||||||
friend class QmlDeclarativePropertySymbol;
|
friend class DeclarativePropertySymbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtDeclarativeMetaTypeBackend(QmlTypeSystem *typeSystem);
|
QtDeclarativeMetaTypeBackend(TypeSystem *typeSystem);
|
||||||
~QtDeclarativeMetaTypeBackend();
|
~QtDeclarativeMetaTypeBackend();
|
||||||
|
|
||||||
virtual QList<QmlSymbol *> availableTypes(const QString &package, int majorVersion, int minorVersion);
|
virtual QList<Symbol *> availableTypes(const QString &package, int majorVersion, int minorVersion);
|
||||||
virtual QmlSymbol *resolve(const QString &typeName, const QList<PackageInfo> &packages);
|
virtual Symbol *resolve(const QString &typeName, const QList<PackageInfo> &packages);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QList<QmlSymbol *> members(const Qml::NodeMetaInfo &metaInfo);
|
// QList<QmlSymbol *> members(const QmlJS::NodeMetaInfo &metaInfo);
|
||||||
// QList<QmlSymbol *> inheritedMembers(const Qml::NodeMetaInfo &metaInfo);
|
// QList<QmlSymbol *> inheritedMembers(const QmlJS::NodeMetaInfo &metaInfo);
|
||||||
// QmlDeclarativeSymbol *typeOf(const Qml::PropertyMetaInfo &metaInfo);
|
// QmlDeclarativeSymbol *typeOf(const QmlJS::PropertyMetaInfo &metaInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// QmlDeclarativeSymbol *getSymbol(const Qml::NodeMetaInfo &metaInfo);
|
// QmlDeclarativeSymbol *getSymbol(const QmlJS::NodeMetaInfo &metaInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// QMap<QString, QmlDeclarativeSymbol*> m_symbols;
|
// QMap<QString, QmlDeclarativeSymbol*> m_symbols;
|
||||||
|
@@ -31,12 +31,12 @@
|
|||||||
|
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace QmlDesigner;
|
using namespace QmlDesigner;
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
|
|
||||||
ASTObjectTextExtractor::ASTObjectTextExtractor(const QString &text):
|
ASTObjectTextExtractor::ASTObjectTextExtractor(const QString &text):
|
||||||
m_document(QmlDocument::create("<ASTObjectTextExtractor>"))
|
m_document(Document::create("<ASTObjectTextExtractor>"))
|
||||||
{
|
{
|
||||||
m_document->setSource(text);
|
m_document->setSource(text);
|
||||||
m_document->parseQml();
|
m_document->parseQml();
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#define ASTOBJECTTEXTEXTRACTOR_H
|
#define ASTOBJECTTEXTEXTRACTOR_H
|
||||||
|
|
||||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ protected:
|
|||||||
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
|
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qml::QmlDocument::Ptr m_document;
|
QmlJS::Document::Ptr m_document;
|
||||||
quint32 m_location;
|
quint32 m_location;
|
||||||
QString m_text;
|
QString m_text;
|
||||||
};
|
};
|
||||||
|
@@ -31,12 +31,12 @@
|
|||||||
|
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace QmlDesigner;
|
using namespace QmlDesigner;
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
|
|
||||||
FirstDefinitionFinder::FirstDefinitionFinder(const QString &text):
|
FirstDefinitionFinder::FirstDefinitionFinder(const QString &text):
|
||||||
m_doc(QmlDocument::create("<internal>"))
|
m_doc(Document::create("<internal>"))
|
||||||
{
|
{
|
||||||
m_doc->setSource(text);
|
m_doc->setSource(text);
|
||||||
bool ok = m_doc->parseQml();
|
bool ok = m_doc->parseQml();
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#define FIRSTDEFINITIONFINDER_H
|
#define FIRSTDEFINITIONFINDER_H
|
||||||
|
|
||||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ protected:
|
|||||||
void extractFirstObjectDefinition(QmlJS::AST::UiObjectInitializer* ast);
|
void extractFirstObjectDefinition(QmlJS::AST::UiObjectInitializer* ast);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qml::QmlDocument::Ptr m_doc;
|
QmlJS::Document::Ptr m_doc;
|
||||||
quint32 m_offset;
|
quint32 m_offset;
|
||||||
QmlJS::AST::UiObjectDefinition *m_firstObjectDefinition;
|
QmlJS::AST::UiObjectDefinition *m_firstObjectDefinition;
|
||||||
|
|
||||||
|
@@ -31,12 +31,12 @@
|
|||||||
|
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace QmlDesigner;
|
using namespace QmlDesigner;
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
|
|
||||||
ObjectLengthCalculator::ObjectLengthCalculator(const QString &text):
|
ObjectLengthCalculator::ObjectLengthCalculator(const QString &text):
|
||||||
m_doc(QmlDocument::create("<internal>"))
|
m_doc(Document::create("<internal>"))
|
||||||
{
|
{
|
||||||
m_doc->setSource(text);
|
m_doc->setSource(text);
|
||||||
bool ok = m_doc->parseQml();
|
bool ok = m_doc->parseQml();
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#define OBJECTLENGTHCALCULATOR_H
|
#define OBJECTLENGTHCALCULATOR_H
|
||||||
|
|
||||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ protected:
|
|||||||
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
|
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qml::QmlDocument::Ptr m_doc;
|
QmlJS::Document::Ptr m_doc;
|
||||||
quint32 m_offset;
|
quint32 m_offset;
|
||||||
quint32 m_length;
|
quint32 m_length;
|
||||||
};
|
};
|
||||||
|
@@ -40,11 +40,11 @@
|
|||||||
#include "removepropertyvisitor.h"
|
#include "removepropertyvisitor.h"
|
||||||
#include "removeuiobjectmembervisitor.h"
|
#include "removeuiobjectmembervisitor.h"
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace QmlDesigner;
|
using namespace QmlDesigner;
|
||||||
using namespace QmlDesigner::Internal;
|
using namespace QmlDesigner::Internal;
|
||||||
|
|
||||||
QmlRefactoring::QmlRefactoring(const QmlDocument::Ptr &doc, TextModifier &modifier, const QStringList &propertyOrder):
|
QmlRefactoring::QmlRefactoring(const Document::Ptr &doc, TextModifier &modifier, const QStringList &propertyOrder):
|
||||||
qmlDocument(doc),
|
qmlDocument(doc),
|
||||||
textModifier(&modifier),
|
textModifier(&modifier),
|
||||||
m_propertyOrder(propertyOrder)
|
m_propertyOrder(propertyOrder)
|
||||||
@@ -57,7 +57,7 @@ bool QmlRefactoring::reparseDocument()
|
|||||||
|
|
||||||
// qDebug() << "QmlRefactoring::reparseDocument() new QML source:" << newSource;
|
// qDebug() << "QmlRefactoring::reparseDocument() new QML source:" << newSource;
|
||||||
|
|
||||||
QmlDocument::Ptr tmpDocument(QmlDocument::create("<ModelToTextMerger>"));
|
Document::Ptr tmpDocument(Document::create("<ModelToTextMerger>"));
|
||||||
tmpDocument->setSource(newSource);
|
tmpDocument->setSource(newSource);
|
||||||
|
|
||||||
if (tmpDocument->parseQml()) {
|
if (tmpDocument->parseQml()) {
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include <import.h>
|
#include <import.h>
|
||||||
#include <textmodifier.h>
|
#include <textmodifier.h>
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlRefactoring(const Qml::QmlDocument::Ptr &doc, QmlDesigner::TextModifier &modifier, const QStringList &propertyOrder);
|
QmlRefactoring(const QmlJS::Document::Ptr &doc, QmlDesigner::TextModifier &modifier, const QStringList &propertyOrder);
|
||||||
|
|
||||||
bool reparseDocument();
|
bool reparseDocument();
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
bool removeProperty(int parentLocation, const QString &name);
|
bool removeProperty(int parentLocation, const QString &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qml::QmlDocument::Ptr qmlDocument;
|
QmlJS::Document::Ptr qmlDocument;
|
||||||
TextModifier *textModifier;
|
TextModifier *textModifier;
|
||||||
QStringList m_propertyOrder;
|
QStringList m_propertyOrder;
|
||||||
};
|
};
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
#include "rewriteactioncompressor.h"
|
#include "rewriteactioncompressor.h"
|
||||||
#include "rewriterview.h"
|
#include "rewriterview.h"
|
||||||
|
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <variantproperty.h>
|
#include <variantproperty.h>
|
||||||
#include <nodelistproperty.h>
|
#include <nodelistproperty.h>
|
||||||
#include <nodeproperty.h>
|
#include <nodeproperty.h>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
#define INDENT_DEPTH 4
|
#define INDENT_DEPTH 4
|
||||||
#undef DUMP_REWRITE_ACTIONS
|
#undef DUMP_REWRITE_ACTIONS
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace QmlDesigner;
|
using namespace QmlDesigner;
|
||||||
using namespace QmlDesigner::Internal;
|
using namespace QmlDesigner::Internal;
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ void ModelToTextMerger::applyChanges()
|
|||||||
if (m_rewriteActions.isEmpty())
|
if (m_rewriteActions.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QmlDocument::Ptr tmpDocument(QmlDocument::create(QLatin1String("<ModelToTextMerger>")));
|
Document::Ptr tmpDocument(Document::create(QLatin1String("<ModelToTextMerger>")));
|
||||||
tmpDocument->setSource(m_rewriterView->textModifier()->text());
|
tmpDocument->setSource(m_rewriterView->textModifier()->text());
|
||||||
if (!tmpDocument->parseQml()) {
|
if (!tmpDocument->parseQml()) {
|
||||||
qDebug() << "*** Possible problem: QML file wasn't parsed correctly.";
|
qDebug() << "*** Possible problem: QML file wasn't parsed correctly.";
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
#include "qmllookupcontext.h"
|
#include "qmllookupcontext.h"
|
||||||
#include "qmlresolveexpression.h"
|
#include "qmlresolveexpression.h"
|
||||||
|
|
||||||
#include <qmljs/qmlsymbol.h>
|
#include <qmljs/qmljssymbol.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
using namespace QmlJSEditor;
|
using namespace QmlJSEditor;
|
||||||
using namespace QmlJSEditor::Internal;
|
using namespace QmlJSEditor::Internal;
|
||||||
|
|
||||||
QmlCodeCompletion::QmlCodeCompletion(QmlModelManagerInterface *modelManager, Qml::QmlTypeSystem *typeSystem, QObject *parent)
|
QmlCodeCompletion::QmlCodeCompletion(QmlModelManagerInterface *modelManager, QmlJS::TypeSystem *typeSystem, QObject *parent)
|
||||||
: TextEditor::ICompletionCollector(parent),
|
: TextEditor::ICompletionCollector(parent),
|
||||||
m_modelManager(modelManager),
|
m_modelManager(modelManager),
|
||||||
m_editor(0),
|
m_editor(0),
|
||||||
@@ -90,7 +90,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
|||||||
m_startPosition = pos;
|
m_startPosition = pos;
|
||||||
m_completions.clear();
|
m_completions.clear();
|
||||||
|
|
||||||
Qml::QmlDocument::Ptr qmlDocument = edit->qmlDocument();
|
QmlJS::Document::Ptr qmlDocument = edit->qmlDocument();
|
||||||
// qDebug() << "*** document:" << qmlDocument;
|
// qDebug() << "*** document:" << qmlDocument;
|
||||||
if (qmlDocument.isNull())
|
if (qmlDocument.isNull())
|
||||||
return pos;
|
return pos;
|
||||||
@@ -112,10 +112,10 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
|||||||
QmlLookupContext context(expressionUnderCursor.expressionScopes(), qmlDocument, m_modelManager->snapshot(), m_typeSystem);
|
QmlLookupContext context(expressionUnderCursor.expressionScopes(), qmlDocument, m_modelManager->snapshot(), m_typeSystem);
|
||||||
QmlResolveExpression resolver(context);
|
QmlResolveExpression resolver(context);
|
||||||
// qDebug()<<"*** expression under cursor:"<<expressionUnderCursor.expressionNode();
|
// qDebug()<<"*** expression under cursor:"<<expressionUnderCursor.expressionNode();
|
||||||
QList<Qml::QmlSymbol*> symbols = resolver.visibleSymbols(expressionUnderCursor.expressionNode());
|
QList<QmlJS::Symbol*> symbols = resolver.visibleSymbols(expressionUnderCursor.expressionNode());
|
||||||
// qDebug()<<"***"<<symbols.size()<<"visible symbols";
|
// qDebug()<<"***"<<symbols.size()<<"visible symbols";
|
||||||
|
|
||||||
foreach (Qml::QmlSymbol *symbol, symbols) {
|
foreach (QmlJS::Symbol *symbol, symbols) {
|
||||||
QString word;
|
QString word;
|
||||||
|
|
||||||
if (symbol->isIdSymbol()) {
|
if (symbol->isIdSymbol()) {
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#ifndef QMLCODECOMPLETION_H
|
#ifndef QMLCODECOMPLETION_H
|
||||||
#define QMLCODECOMPLETION_H
|
#define QMLCODECOMPLETION_H
|
||||||
|
|
||||||
#include <qmljs/qmltypesystem.h>
|
#include <qmljs/qmljstypesystem.h>
|
||||||
#include <texteditor/icompletioncollector.h>
|
#include <texteditor/icompletioncollector.h>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
@@ -48,7 +48,7 @@ class QmlCodeCompletion: public TextEditor::ICompletionCollector
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlCodeCompletion(QmlModelManagerInterface *modelManager, Qml::QmlTypeSystem *typeSystem, QObject *parent = 0);
|
QmlCodeCompletion(QmlModelManagerInterface *modelManager, QmlJS::TypeSystem *typeSystem, QObject *parent = 0);
|
||||||
virtual ~QmlCodeCompletion();
|
virtual ~QmlCodeCompletion();
|
||||||
|
|
||||||
Qt::CaseSensitivity caseSensitivity() const;
|
Qt::CaseSensitivity caseSensitivity() const;
|
||||||
@@ -68,7 +68,7 @@ private:
|
|||||||
int m_startPosition;
|
int m_startPosition;
|
||||||
QList<TextEditor::CompletionItem> m_completions;
|
QList<TextEditor::CompletionItem> m_completions;
|
||||||
Qt::CaseSensitivity m_caseSensitivity;
|
Qt::CaseSensitivity m_caseSensitivity;
|
||||||
Qml::QmlTypeSystem *m_typeSystem;
|
QmlJS::TypeSystem *m_typeSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
using namespace Qml;
|
|
||||||
using namespace QmlJS;
|
using namespace QmlJS;
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
|
|
||||||
@@ -124,7 +123,7 @@ namespace QmlJSEditor {
|
|||||||
class ScopeCalculator: protected Visitor
|
class ScopeCalculator: protected Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QStack<QmlSymbol*> operator()(const QmlDocument::Ptr &doc, int pos)
|
QStack<Symbol*> operator()(const Document::Ptr &doc, int pos)
|
||||||
{
|
{
|
||||||
_doc = doc;
|
_doc = doc;
|
||||||
_pos = pos;
|
_pos = pos;
|
||||||
@@ -179,7 +178,7 @@ namespace QmlJSEditor {
|
|||||||
private:
|
private:
|
||||||
void push(Node *node)
|
void push(Node *node)
|
||||||
{
|
{
|
||||||
QmlSymbolFromFile* symbol;
|
SymbolFromFile* symbol;
|
||||||
|
|
||||||
if (_currentSymbol) {
|
if (_currentSymbol) {
|
||||||
symbol = _currentSymbol->findMember(node);
|
symbol = _currentSymbol->findMember(node);
|
||||||
@@ -196,10 +195,10 @@ namespace QmlJSEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlDocument::Ptr _doc;
|
Document::Ptr _doc;
|
||||||
quint32 _pos;
|
quint32 _pos;
|
||||||
QStack<QmlSymbol*> _scopes;
|
QStack<Symbol*> _scopes;
|
||||||
QmlSymbolFromFile* _currentSymbol;
|
SymbolFromFile* _currentSymbol;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,7 +219,7 @@ QmlExpressionUnderCursor::~QmlExpressionUnderCursor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QmlExpressionUnderCursor::operator()(const QTextCursor &cursor,
|
void QmlExpressionUnderCursor::operator()(const QTextCursor &cursor,
|
||||||
const QmlDocument::Ptr &doc)
|
const Document::Ptr &doc)
|
||||||
{
|
{
|
||||||
if (_engine) { delete _engine; _engine = 0; }
|
if (_engine) { delete _engine; _engine = 0; }
|
||||||
if (_nodePool) { delete _nodePool; _nodePool = 0; }
|
if (_nodePool) { delete _nodePool; _nodePool = 0; }
|
||||||
|
@@ -31,8 +31,8 @@
|
|||||||
#define QMLEXPRESSIONUNDERCURSOR_H
|
#define QMLEXPRESSIONUNDERCURSOR_H
|
||||||
|
|
||||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <qmljs/qmlsymbol.h>
|
#include <qmljs/qmljssymbol.h>
|
||||||
|
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
@@ -52,9 +52,9 @@ public:
|
|||||||
QmlExpressionUnderCursor();
|
QmlExpressionUnderCursor();
|
||||||
virtual ~QmlExpressionUnderCursor();
|
virtual ~QmlExpressionUnderCursor();
|
||||||
|
|
||||||
void operator()(const QTextCursor &cursor, const Qml::QmlDocument::Ptr &doc);
|
void operator()(const QTextCursor &cursor, const QmlJS::Document::Ptr &doc);
|
||||||
|
|
||||||
QStack<Qml::QmlSymbol *> expressionScopes() const
|
QStack<QmlJS::Symbol *> expressionScopes() const
|
||||||
{ return _expressionScopes; }
|
{ return _expressionScopes; }
|
||||||
|
|
||||||
QmlJS::AST::Node *expressionNode() const
|
QmlJS::AST::Node *expressionNode() const
|
||||||
@@ -73,7 +73,7 @@ private:
|
|||||||
QmlJS::AST::UiObjectMember *tryBinding(const QString &text);
|
QmlJS::AST::UiObjectMember *tryBinding(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStack<Qml::QmlSymbol *> _expressionScopes;
|
QStack<QmlJS::Symbol *> _expressionScopes;
|
||||||
QmlJS::AST::Node *_expressionNode;
|
QmlJS::AST::Node *_expressionNode;
|
||||||
int _expressionOffset;
|
int _expressionOffset;
|
||||||
int _expressionLength;
|
int _expressionLength;
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#ifndef QMLSYNTAXHIGHLIGHTER_H
|
#ifndef QMLSYNTAXHIGHLIGHTER_H
|
||||||
#define QMLSYNTAXHIGHLIGHTER_H
|
#define QMLSYNTAXHIGHLIGHTER_H
|
||||||
|
|
||||||
#include <qmljs/qscripthighlighter.h>
|
#include <qmljs/qmljshighlighter.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <debugger/debuggerconstants.h>
|
#include <debugger/debuggerconstants.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <qmljs/qmlsymbol.h>
|
#include <qmljs/qmljssymbol.h>
|
||||||
#include <texteditor/itexteditor.h>
|
#include <texteditor/itexteditor.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
#include <QtHelp/QHelpEngineCore>
|
#include <QtHelp/QHelpEngineCore>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace QmlJSEditor;
|
using namespace QmlJSEditor;
|
||||||
using namespace QmlJSEditor::Internal;
|
using namespace QmlJSEditor::Internal;
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ void QmlHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int p
|
|||||||
updateHelpIdAndTooltip(editor, pos);
|
updateHelpIdAndTooltip(editor, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString buildHelpId(QmlSymbol *symbol)
|
static QString buildHelpId(Symbol *symbol)
|
||||||
{
|
{
|
||||||
if (!symbol)
|
if (!symbol)
|
||||||
return QString();
|
return QString();
|
||||||
@@ -152,7 +152,7 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
|
|||||||
|
|
||||||
const Snapshot documents = m_modelManager->snapshot();
|
const Snapshot documents = m_modelManager->snapshot();
|
||||||
const QString fileName = editor->file()->fileName();
|
const QString fileName = editor->file()->fileName();
|
||||||
QmlDocument::Ptr doc = documents.value(fileName);
|
Document::Ptr doc = documents.value(fileName);
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
|
|
||||||
@@ -188,18 +188,18 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
|
|||||||
QmlExpressionUnderCursor expressionUnderCursor;
|
QmlExpressionUnderCursor expressionUnderCursor;
|
||||||
expressionUnderCursor(tc, doc);
|
expressionUnderCursor(tc, doc);
|
||||||
|
|
||||||
Qml::QmlTypeSystem *typeSystem = ExtensionSystem::PluginManager::instance()->getObject<Qml::QmlTypeSystem>();
|
QmlJS::TypeSystem *typeSystem = ExtensionSystem::PluginManager::instance()->getObject<QmlJS::TypeSystem>();
|
||||||
|
|
||||||
QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, m_modelManager->snapshot(), typeSystem);
|
QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, m_modelManager->snapshot(), typeSystem);
|
||||||
QmlResolveExpression resolver(context);
|
QmlResolveExpression resolver(context);
|
||||||
QmlSymbol *resolvedSymbol = resolver.typeOf(expressionUnderCursor.expressionNode());
|
Symbol *resolvedSymbol = resolver.typeOf(expressionUnderCursor.expressionNode());
|
||||||
|
|
||||||
if (resolvedSymbol) {
|
if (resolvedSymbol) {
|
||||||
symbolName = resolvedSymbol->name();
|
symbolName = resolvedSymbol->name();
|
||||||
|
|
||||||
if (resolvedSymbol->isBuildInSymbol())
|
if (resolvedSymbol->isBuildInSymbol())
|
||||||
m_helpId = buildHelpId(resolvedSymbol);
|
m_helpId = buildHelpId(resolvedSymbol);
|
||||||
else if (QmlSymbolFromFile *symbolFromFile = resolvedSymbol->asSymbolFromFile())
|
else if (SymbolFromFile *symbolFromFile = resolvedSymbol->asSymbolFromFile())
|
||||||
m_toolTip = symbolFromFile->fileName();
|
m_toolTip = symbolFromFile->fileName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,14 +37,14 @@
|
|||||||
#include "qmllookupcontext.h"
|
#include "qmllookupcontext.h"
|
||||||
#include "qmlresolveexpression.h"
|
#include "qmlresolveexpression.h"
|
||||||
|
|
||||||
#include <qmljs/qscriptindenter.h>
|
#include <qmljs/qmljsindenter.h>
|
||||||
|
|
||||||
#include <qmljs/qmltypesystem.h>
|
#include <qmljs/qmljstypesystem.h>
|
||||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
#include <qmljs/parser/qmljsengine_p.h>
|
#include <qmljs/parser/qmljsengine_p.h>
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <qmljs/qmlidcollector.h>
|
#include <qmljs/qmljsidcollector.h>
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -74,7 +74,6 @@ enum {
|
|||||||
UPDATE_USES_DEFAULT_INTERVAL = 150
|
UPDATE_USES_DEFAULT_INTERVAL = 150
|
||||||
};
|
};
|
||||||
|
|
||||||
using namespace Qml;
|
|
||||||
using namespace QmlJS;
|
using namespace QmlJS;
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
|
|
||||||
@@ -359,11 +358,11 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
|
|||||||
baseTextDocument()->setSyntaxHighlighter(new QmlHighlighter);
|
baseTextDocument()->setSyntaxHighlighter(new QmlHighlighter);
|
||||||
|
|
||||||
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<QmlModelManagerInterface>();
|
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<QmlModelManagerInterface>();
|
||||||
m_typeSystem = ExtensionSystem::PluginManager::instance()->getObject<Qml::QmlTypeSystem>();
|
m_typeSystem = ExtensionSystem::PluginManager::instance()->getObject<QmlJS::TypeSystem>();
|
||||||
|
|
||||||
if (m_modelManager) {
|
if (m_modelManager) {
|
||||||
connect(m_modelManager, SIGNAL(documentUpdated(Qml::QmlDocument::Ptr)),
|
connect(m_modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
||||||
this, SLOT(onDocumentUpdated(Qml::QmlDocument::Ptr)));
|
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,7 +414,7 @@ void QmlJSTextEditor::updateDocumentNow()
|
|||||||
m_modelManager->updateSourceFiles(QStringList() << fileName);
|
m_modelManager->updateSourceFiles(QStringList() << fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSTextEditor::onDocumentUpdated(Qml::QmlDocument::Ptr doc)
|
void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
|
||||||
{
|
{
|
||||||
if (file()->fileName() != doc->fileName())
|
if (file()->fileName() != doc->fileName())
|
||||||
return;
|
return;
|
||||||
@@ -617,13 +616,13 @@ bool QmlJSTextEditor::isElectricCharacter(const QChar &ch) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlJSTextEditor::isClosingBrace(const QList<QScriptIncrementalScanner::Token> &tokens) const
|
bool QmlJSTextEditor::isClosingBrace(const QList<QmlJSScanner::Token> &tokens) const
|
||||||
{
|
{
|
||||||
|
|
||||||
if (tokens.size() == 1) {
|
if (tokens.size() == 1) {
|
||||||
const QScriptIncrementalScanner::Token firstToken = tokens.first();
|
const QmlJSScanner::Token firstToken = tokens.first();
|
||||||
|
|
||||||
return firstToken.is(QScriptIncrementalScanner::Token::RightBrace) || firstToken.is(QScriptIncrementalScanner::Token::RightBracket);
|
return firstToken.is(QmlJSScanner::Token::RightBrace) || firstToken.is(QmlJSScanner::Token::RightBracket);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -632,7 +631,7 @@ bool QmlJSTextEditor::isClosingBrace(const QList<QScriptIncrementalScanner::Toke
|
|||||||
void QmlJSTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
|
void QmlJSTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
|
||||||
{
|
{
|
||||||
TextEditor::TabSettings ts = tabSettings();
|
TextEditor::TabSettings ts = tabSettings();
|
||||||
QScriptIndenter indenter;
|
QmlJSIndenter indenter;
|
||||||
indenter.setTabSize(ts.m_tabSize);
|
indenter.setTabSize(ts.m_tabSize);
|
||||||
indenter.setIndentSize(ts.m_indentSize);
|
indenter.setIndentSize(ts.m_indentSize);
|
||||||
|
|
||||||
@@ -678,7 +677,7 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
|
|||||||
return link;
|
return link;
|
||||||
|
|
||||||
const Snapshot snapshot = m_modelManager->snapshot();
|
const Snapshot snapshot = m_modelManager->snapshot();
|
||||||
QmlDocument::Ptr doc = snapshot.document(file()->fileName());
|
Document::Ptr doc = snapshot.document(file()->fileName());
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return link;
|
return link;
|
||||||
|
|
||||||
@@ -702,12 +701,12 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
|
|||||||
|
|
||||||
QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, snapshot, m_typeSystem);
|
QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, snapshot, m_typeSystem);
|
||||||
QmlResolveExpression resolver(context);
|
QmlResolveExpression resolver(context);
|
||||||
QmlSymbol *symbol = resolver.typeOf(expressionUnderCursor.expressionNode());
|
Symbol *symbol = resolver.typeOf(expressionUnderCursor.expressionNode());
|
||||||
|
|
||||||
if (!symbol)
|
if (!symbol)
|
||||||
return link;
|
return link;
|
||||||
|
|
||||||
if (const QmlSymbolFromFile *target = symbol->asSymbolFromFile()) {
|
if (const SymbolFromFile *target = symbol->asSymbolFromFile()) {
|
||||||
link.pos = expressionUnderCursor.expressionOffset();
|
link.pos = expressionUnderCursor.expressionOffset();
|
||||||
link.length = expressionUnderCursor.expressionLength();
|
link.length = expressionUnderCursor.expressionLength();
|
||||||
link.fileName = target->fileName();
|
link.fileName = target->fileName();
|
||||||
@@ -794,32 +793,32 @@ bool QmlJSTextEditor::contextAllowsAutoParentheses(const QTextCursor &cursor, co
|
|||||||
const QString blockText = cursor.block().text();
|
const QString blockText = cursor.block().text();
|
||||||
const int blockState = blockStartState(cursor.block());
|
const int blockState = blockStartState(cursor.block());
|
||||||
|
|
||||||
QScriptIncrementalScanner tokenize;
|
QmlJSScanner tokenize;
|
||||||
const QList<QScriptIncrementalScanner::Token> tokens = tokenize(blockText, blockState);
|
const QList<QmlJSScanner::Token> tokens = tokenize(blockText, blockState);
|
||||||
const int pos = cursor.columnNumber();
|
const int pos = cursor.columnNumber();
|
||||||
|
|
||||||
int tokenIndex = 0;
|
int tokenIndex = 0;
|
||||||
for (; tokenIndex < tokens.size(); ++tokenIndex) {
|
for (; tokenIndex < tokens.size(); ++tokenIndex) {
|
||||||
const QScriptIncrementalScanner::Token &token = tokens.at(tokenIndex);
|
const QmlJSScanner::Token &token = tokens.at(tokenIndex);
|
||||||
|
|
||||||
if (pos >= token.begin()) {
|
if (pos >= token.begin()) {
|
||||||
if (pos < token.end())
|
if (pos < token.end())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
else if (pos == token.end() && (token.is(QScriptIncrementalScanner::Token::Comment) ||
|
else if (pos == token.end() && (token.is(QmlJSScanner::Token::Comment) ||
|
||||||
token.is(QScriptIncrementalScanner::Token::String)))
|
token.is(QmlJSScanner::Token::String)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenIndex != tokens.size()) {
|
if (tokenIndex != tokens.size()) {
|
||||||
const QScriptIncrementalScanner::Token &token = tokens.at(tokenIndex);
|
const QmlJSScanner::Token &token = tokens.at(tokenIndex);
|
||||||
|
|
||||||
switch (token.kind) {
|
switch (token.kind) {
|
||||||
case QScriptIncrementalScanner::Token::Comment:
|
case QmlJSScanner::Token::Comment:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case QScriptIncrementalScanner::Token::String: {
|
case QmlJSScanner::Token::String: {
|
||||||
const QStringRef tokenText = blockText.midRef(token.offset, token.length);
|
const QStringRef tokenText = blockText.midRef(token.offset, token.length);
|
||||||
const QChar quote = tokenText.at(0);
|
const QChar quote = tokenText.at(0);
|
||||||
|
|
||||||
|
@@ -30,8 +30,8 @@
|
|||||||
#ifndef QMLJSEDITOR_H
|
#ifndef QMLJSEDITOR_H
|
||||||
#define QMLJSEDITOR_H
|
#define QMLJSEDITOR_H
|
||||||
|
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <qmljs/qscriptincrementalscanner.h>
|
#include <qmljs/qmljsscanner.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -43,8 +43,8 @@ namespace Core {
|
|||||||
class ICore;
|
class ICore;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
class QmlTypeSystem;
|
class TypeSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
@@ -109,13 +109,13 @@ public:
|
|||||||
|
|
||||||
virtual void unCommentSelection();
|
virtual void unCommentSelection();
|
||||||
|
|
||||||
Qml::QmlDocument::Ptr qmlDocument() const { return m_document; }
|
QmlJS::Document::Ptr qmlDocument() const { return m_document; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setFontSettings(const TextEditor::FontSettings &);
|
virtual void setFontSettings(const TextEditor::FontSettings &);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDocumentUpdated(Qml::QmlDocument::Ptr doc);
|
void onDocumentUpdated(QmlJS::Document::Ptr doc);
|
||||||
|
|
||||||
void updateDocument();
|
void updateDocument();
|
||||||
void updateDocumentNow();
|
void updateDocumentNow();
|
||||||
@@ -145,7 +145,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
virtual bool isElectricCharacter(const QChar &ch) const;
|
virtual bool isElectricCharacter(const QChar &ch) const;
|
||||||
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
||||||
bool isClosingBrace(const QList<QmlJS::QScriptIncrementalScanner::Token> &tokens) const;
|
bool isClosingBrace(const QList<QmlJS::QmlJSScanner::Token> &tokens) const;
|
||||||
|
|
||||||
QString wordUnderCursor() const;
|
QString wordUnderCursor() const;
|
||||||
|
|
||||||
@@ -158,9 +158,9 @@ private:
|
|||||||
QMap<QString, QList<QmlJS::AST::SourceLocation> > m_ids; // ### use QMultiMap
|
QMap<QString, QList<QmlJS::AST::SourceLocation> > m_ids; // ### use QMultiMap
|
||||||
int m_idsRevision;
|
int m_idsRevision;
|
||||||
QList<QmlJS::DiagnosticMessage> m_diagnosticMessages;
|
QList<QmlJS::DiagnosticMessage> m_diagnosticMessages;
|
||||||
Qml::QmlDocument::Ptr m_document;
|
QmlJS::Document::Ptr m_document;
|
||||||
QmlModelManagerInterface *m_modelManager;
|
QmlModelManagerInterface *m_modelManager;
|
||||||
Qml::QmlTypeSystem *m_typeSystem;
|
QmlJS::TypeSystem *m_typeSystem;
|
||||||
QTextCharFormat m_occurrencesFormat;
|
QTextCharFormat m_occurrencesFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -92,7 +92,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
|
|||||||
|
|
||||||
m_modelManager = new QmlModelManager(this);
|
m_modelManager = new QmlModelManager(this);
|
||||||
addAutoReleasedObject(m_modelManager);
|
addAutoReleasedObject(m_modelManager);
|
||||||
Qml::QmlTypeSystem *typeSystem = new Qml::QmlTypeSystem;
|
QmlJS::TypeSystem *typeSystem = new QmlJS::TypeSystem;
|
||||||
addAutoReleasedObject(typeSystem);
|
addAutoReleasedObject(typeSystem);
|
||||||
|
|
||||||
QList<int> context;
|
QList<int> context;
|
||||||
|
@@ -33,20 +33,19 @@
|
|||||||
|
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
#include <qmljs/parser/qmljsengine_p.h>
|
#include <qmljs/parser/qmljsengine_p.h>
|
||||||
#include <qmljs/qmltypesystem.h>
|
#include <qmljs/qmljstypesystem.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
using namespace Qml;
|
using namespace QmlJS;
|
||||||
using namespace QmlJSEditor;
|
using namespace QmlJSEditor;
|
||||||
using namespace QmlJSEditor::Internal;
|
using namespace QmlJSEditor::Internal;
|
||||||
using namespace QmlJS;
|
|
||||||
using namespace QmlJS::AST;
|
using namespace QmlJS::AST;
|
||||||
|
|
||||||
QmlLookupContext::QmlLookupContext(const QStack<QmlSymbol *> &scopes,
|
QmlLookupContext::QmlLookupContext(const QStack<Symbol *> &scopes,
|
||||||
const QmlDocument::Ptr &doc,
|
const Document::Ptr &doc,
|
||||||
const Snapshot &snapshot,
|
const Snapshot &snapshot,
|
||||||
QmlTypeSystem *typeSystem):
|
TypeSystem *typeSystem):
|
||||||
_scopes(scopes),
|
_scopes(scopes),
|
||||||
_doc(doc),
|
_doc(doc),
|
||||||
_snapshot(snapshot),
|
_snapshot(snapshot),
|
||||||
@@ -55,13 +54,13 @@ QmlLookupContext::QmlLookupContext(const QStack<QmlSymbol *> &scopes,
|
|||||||
Q_ASSERT(typeSystem != 0);
|
Q_ASSERT(typeSystem != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int findFirstQmlObjectScope(const QStack<QmlSymbol*> &scopes, int startIdx)
|
static inline int findFirstQmlObjectScope(const QStack<Symbol*> &scopes, int startIdx)
|
||||||
{
|
{
|
||||||
if (startIdx < 0 || startIdx >= scopes.size())
|
if (startIdx < 0 || startIdx >= scopes.size())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (int i = startIdx; i >= 0; --i) {
|
for (int i = startIdx; i >= 0; --i) {
|
||||||
QmlSymbol *current = scopes.at(i);
|
Symbol *current = scopes.at(i);
|
||||||
|
|
||||||
if (current->isSymbolFromFile()) {
|
if (current->isSymbolFromFile()) {
|
||||||
Node *node = current->asSymbolFromFile()->node();
|
Node *node = current->asSymbolFromFile()->node();
|
||||||
@@ -75,7 +74,7 @@ static inline int findFirstQmlObjectScope(const QStack<QmlSymbol*> &scopes, int
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QmlSymbol *resolveParent(const QStack<QmlSymbol*> &scopes)
|
static inline Symbol *resolveParent(const QStack<Symbol*> &scopes)
|
||||||
{
|
{
|
||||||
int idx = findFirstQmlObjectScope(scopes, scopes.size() - 1);
|
int idx = findFirstQmlObjectScope(scopes, scopes.size() - 1);
|
||||||
if (idx < 1)
|
if (idx < 1)
|
||||||
@@ -89,14 +88,14 @@ static inline QmlSymbol *resolveParent(const QStack<QmlSymbol*> &scopes)
|
|||||||
return scopes.at(idx);
|
return scopes.at(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbol *QmlLookupContext::resolve(const QString &name)
|
Symbol *QmlLookupContext::resolve(const QString &name)
|
||||||
{
|
{
|
||||||
// find element type names
|
// find element type names
|
||||||
if (QmlSymbol *type = resolveType(name))
|
if (Symbol *type = resolveType(name))
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
// find ids
|
// find ids
|
||||||
const QmlDocument::IdTable ids = _doc->ids();
|
const Document::IdTable ids = _doc->ids();
|
||||||
if (ids.contains(name))
|
if (ids.contains(name))
|
||||||
return ids[name];
|
return ids[name];
|
||||||
|
|
||||||
@@ -110,12 +109,12 @@ QmlSymbol *QmlLookupContext::resolve(const QString &name)
|
|||||||
// find properties of the scope object
|
// find properties of the scope object
|
||||||
int scopeObjectIndex = findFirstQmlObjectScope(_scopes, _scopes.size() - 1);
|
int scopeObjectIndex = findFirstQmlObjectScope(_scopes, _scopes.size() - 1);
|
||||||
if (scopeObjectIndex != -1)
|
if (scopeObjectIndex != -1)
|
||||||
if (QmlSymbol *propertySymbol = resolveProperty(name, _scopes.at(scopeObjectIndex), _doc->fileName()))
|
if (Symbol *propertySymbol = resolveProperty(name, _scopes.at(scopeObjectIndex), _doc->fileName()))
|
||||||
return propertySymbol;
|
return propertySymbol;
|
||||||
|
|
||||||
// find properties of the component's root object
|
// find properties of the component's root object
|
||||||
if (!_doc->symbols().isEmpty())
|
if (!_doc->symbols().isEmpty())
|
||||||
if (QmlSymbol *propertySymbol = resolveProperty(name, _doc->symbols()[0], _doc->fileName()))
|
if (Symbol *propertySymbol = resolveProperty(name, _doc->symbols()[0], _doc->fileName()))
|
||||||
return propertySymbol;
|
return propertySymbol;
|
||||||
|
|
||||||
// component chain
|
// component chain
|
||||||
@@ -130,10 +129,10 @@ QmlSymbol *QmlLookupContext::resolve(const QString &name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fileName)
|
Symbol *QmlLookupContext::resolveType(const QString &name, const QString &fileName)
|
||||||
{
|
{
|
||||||
// TODO: handle import-as.
|
// TODO: handle import-as.
|
||||||
QmlDocument::Ptr document = _snapshot[fileName];
|
Document::Ptr document = _snapshot[fileName];
|
||||||
if (document.isNull())
|
if (document.isNull())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -157,9 +156,9 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
|
|||||||
|
|
||||||
const QString path = import->fileName->asString();
|
const QString path = import->fileName->asString();
|
||||||
|
|
||||||
const QMap<QString, QmlDocument::Ptr> importedTypes = _snapshot.componentsDefinedByImportedDocuments(document, path);
|
const QMap<QString, Document::Ptr> importedTypes = _snapshot.componentsDefinedByImportedDocuments(document, path);
|
||||||
if (importedTypes.contains(name)) {
|
if (importedTypes.contains(name)) {
|
||||||
QmlDocument::Ptr importedDoc = importedTypes.value(name);
|
Document::Ptr importedDoc = importedTypes.value(name);
|
||||||
|
|
||||||
return importedDoc->symbols().at(0);
|
return importedDoc->symbols().at(0);
|
||||||
}
|
}
|
||||||
@@ -169,17 +168,17 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
|
|||||||
return resolveBuildinType(name);
|
return resolveBuildinType(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbol *QmlLookupContext::resolveBuildinType(const QString &name)
|
Symbol *QmlLookupContext::resolveBuildinType(const QString &name)
|
||||||
{
|
{
|
||||||
QList<Qml::PackageInfo> packages;
|
QList<QmlJS::PackageInfo> packages;
|
||||||
// FIXME:
|
// FIXME:
|
||||||
packages.append(PackageInfo("Qt", 4, 6));
|
packages.append(PackageInfo("Qt", 4, 6));
|
||||||
return m_typeSystem->resolve(name, packages);
|
return m_typeSystem->resolve(name, packages);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbol *QmlLookupContext::resolveProperty(const QString &name, QmlSymbol *scope, const QString &fileName)
|
Symbol *QmlLookupContext::resolveProperty(const QString &name, Symbol *scope, const QString &fileName)
|
||||||
{
|
{
|
||||||
foreach (QmlSymbol *symbol, scope->members())
|
foreach (Symbol *symbol, scope->members())
|
||||||
if (symbol->isProperty() && symbol->name() == name)
|
if (symbol->isProperty() && symbol->name() == name)
|
||||||
return symbol;
|
return symbol;
|
||||||
|
|
||||||
@@ -198,14 +197,14 @@ QmlSymbol *QmlLookupContext::resolveProperty(const QString &name, QmlSymbol *sco
|
|||||||
if (typeName == 0)
|
if (typeName == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QmlSymbol *typeSymbol = resolveType(toString(typeName), fileName);
|
Symbol *typeSymbol = resolveType(toString(typeName), fileName);
|
||||||
if (!typeSymbol)
|
if (!typeSymbol)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (typeSymbol->isSymbolFromFile()) {
|
if (typeSymbol->isSymbolFromFile()) {
|
||||||
return resolveProperty(name, typeSymbol->asSymbolFromFile(), typeSymbol->asSymbolFromFile()->fileName());
|
return resolveProperty(name, typeSymbol->asSymbolFromFile(), typeSymbol->asSymbolFromFile()->fileName());
|
||||||
} else if (QmlBuildInSymbol *builtinSymbol = typeSymbol->asBuildInSymbol()) {
|
} else if (PrimitiveSymbol *builtinSymbol = typeSymbol->asPrimitiveSymbol()) {
|
||||||
foreach (QmlSymbol *member, builtinSymbol->members(true)) {
|
foreach (Symbol *member, builtinSymbol->members(true)) {
|
||||||
if (member->isProperty() && member->name() == name)
|
if (member->isProperty() && member->name() == name)
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
@@ -231,12 +230,12 @@ QString QmlLookupContext::toString(UiQualifiedId *id)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QmlSymbol*> QmlLookupContext::visibleSymbolsInScope()
|
QList<Symbol*> QmlLookupContext::visibleSymbolsInScope()
|
||||||
{
|
{
|
||||||
QList<QmlSymbol*> result;
|
QList<Symbol*> result;
|
||||||
|
|
||||||
if (!_scopes.isEmpty()) {
|
if (!_scopes.isEmpty()) {
|
||||||
QmlSymbol *scope = _scopes.top();
|
Symbol *scope = _scopes.top();
|
||||||
|
|
||||||
// add members defined in this symbol:
|
// add members defined in this symbol:
|
||||||
result.append(scope->members());
|
result.append(scope->members());
|
||||||
@@ -248,9 +247,9 @@ QList<QmlSymbol*> QmlLookupContext::visibleSymbolsInScope()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QmlSymbol*> QmlLookupContext::visibleTypes()
|
QList<Symbol*> QmlLookupContext::visibleTypes()
|
||||||
{
|
{
|
||||||
QList<QmlSymbol*> result;
|
QList<Symbol*> result;
|
||||||
|
|
||||||
UiProgram *program = _doc->qmlProgram();
|
UiProgram *program = _doc->qmlProgram();
|
||||||
if (!program)
|
if (!program)
|
||||||
@@ -267,8 +266,8 @@ QList<QmlSymbol*> QmlLookupContext::visibleTypes()
|
|||||||
|
|
||||||
// TODO: handle "import as".
|
// TODO: handle "import as".
|
||||||
|
|
||||||
const QMap<QString, QmlDocument::Ptr> types = _snapshot.componentsDefinedByImportedDocuments(_doc, path);
|
const QMap<QString, Document::Ptr> types = _snapshot.componentsDefinedByImportedDocuments(_doc, path);
|
||||||
foreach (const QmlDocument::Ptr typeDoc, types) {
|
foreach (const Document::Ptr typeDoc, types) {
|
||||||
result.append(typeDoc->symbols().at(0));
|
result.append(typeDoc->symbols().at(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,22 +277,22 @@ QList<QmlSymbol*> QmlLookupContext::visibleTypes()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QmlSymbol*> QmlLookupContext::expandType(Qml::QmlSymbol *symbol)
|
QList<Symbol*> QmlLookupContext::expandType(QmlJS::Symbol *symbol)
|
||||||
{
|
{
|
||||||
if (symbol == 0) {
|
if (symbol == 0) {
|
||||||
return QList<QmlSymbol*>();
|
return QList<Symbol*>();
|
||||||
} else if (QmlBuildInSymbol *buildInSymbol = symbol->asBuildInSymbol()) {
|
} else if (PrimitiveSymbol *buildInSymbol = symbol->asPrimitiveSymbol()) {
|
||||||
return buildInSymbol->members(true);
|
return buildInSymbol->members(true);
|
||||||
} else if (QmlSymbolFromFile *symbolFromFile = symbol->asSymbolFromFile()){
|
} else if (SymbolFromFile *symbolFromFile = symbol->asSymbolFromFile()){
|
||||||
QList<QmlSymbol*> result;
|
QList<Symbol*> result;
|
||||||
|
|
||||||
if (QmlSymbol *superTypeSymbol = resolveType(symbolFromFile->name(), symbolFromFile->fileName())) {
|
if (Symbol *superTypeSymbol = resolveType(symbolFromFile->name(), symbolFromFile->fileName())) {
|
||||||
result.append(superTypeSymbol->members());
|
result.append(superTypeSymbol->members());
|
||||||
result.append(expandType(superTypeSymbol));
|
result.append(expandType(superTypeSymbol));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
return QList<QmlSymbol*>();
|
return QList<Symbol*>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,10 +30,10 @@
|
|||||||
#ifndef QMLLOOKUPCONTEXT_H
|
#ifndef QMLLOOKUPCONTEXT_H
|
||||||
#define QMLLOOKUPCONTEXT_H
|
#define QMLLOOKUPCONTEXT_H
|
||||||
|
|
||||||
#include <qmljs/qmltypesystem.h>
|
#include <qmljs/qmljstypesystem.h>
|
||||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <qmljs/qmlsymbol.h>
|
#include <qmljs/qmljssymbol.h>
|
||||||
|
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
|
|
||||||
@@ -43,37 +43,37 @@ namespace Internal {
|
|||||||
class QmlLookupContext
|
class QmlLookupContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlLookupContext(const QStack<Qml::QmlSymbol *> &scopes,
|
QmlLookupContext(const QStack<QmlJS::Symbol *> &scopes,
|
||||||
const Qml::QmlDocument::Ptr &doc,
|
const QmlJS::Document::Ptr &doc,
|
||||||
const Qml::Snapshot &snapshot,
|
const QmlJS::Snapshot &snapshot,
|
||||||
Qml::QmlTypeSystem *typeSystem);
|
QmlJS::TypeSystem *typeSystem);
|
||||||
|
|
||||||
Qml::QmlSymbol *resolve(const QString &name);
|
QmlJS::Symbol *resolve(const QString &name);
|
||||||
Qml::QmlSymbol *resolveType(const QString &name)
|
QmlJS::Symbol *resolveType(const QString &name)
|
||||||
{ return resolveType(name, _doc->fileName()); }
|
{ return resolveType(name, _doc->fileName()); }
|
||||||
Qml::QmlSymbol *resolveType(QmlJS::AST::UiQualifiedId *name)
|
QmlJS::Symbol *resolveType(QmlJS::AST::UiQualifiedId *name)
|
||||||
{ return resolveType(toString(name), _doc->fileName()); }
|
{ return resolveType(toString(name), _doc->fileName()); }
|
||||||
|
|
||||||
Qml::QmlDocument::Ptr document() const
|
QmlJS::Document::Ptr document() const
|
||||||
{ return _doc; }
|
{ return _doc; }
|
||||||
|
|
||||||
QList<Qml::QmlSymbol*> visibleSymbolsInScope();
|
QList<QmlJS::Symbol*> visibleSymbolsInScope();
|
||||||
QList<Qml::QmlSymbol*> visibleTypes();
|
QList<QmlJS::Symbol*> visibleTypes();
|
||||||
|
|
||||||
QList<Qml::QmlSymbol*> expandType(Qml::QmlSymbol *symbol);
|
QList<QmlJS::Symbol*> expandType(QmlJS::Symbol *symbol);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qml::QmlSymbol *resolveType(const QString &name, const QString &fileName);
|
QmlJS::Symbol *resolveType(const QString &name, const QString &fileName);
|
||||||
Qml::QmlSymbol *resolveProperty(const QString &name, Qml::QmlSymbol *scope, const QString &fileName);
|
QmlJS::Symbol *resolveProperty(const QString &name, QmlJS::Symbol *scope, const QString &fileName);
|
||||||
Qml::QmlSymbol *resolveBuildinType(const QString &name);
|
QmlJS::Symbol *resolveBuildinType(const QString &name);
|
||||||
|
|
||||||
static QString toString(QmlJS::AST::UiQualifiedId *id);
|
static QString toString(QmlJS::AST::UiQualifiedId *id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStack<Qml::QmlSymbol *> _scopes;
|
QStack<QmlJS::Symbol *> _scopes;
|
||||||
Qml::QmlDocument::Ptr _doc;
|
QmlJS::Document::Ptr _doc;
|
||||||
Qml::Snapshot _snapshot;
|
QmlJS::Snapshot _snapshot;
|
||||||
Qml::QmlTypeSystem *m_typeSystem;
|
QmlJS::TypeSystem *m_typeSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -51,13 +51,13 @@ QmlModelManager::QmlModelManager(QObject *parent):
|
|||||||
{
|
{
|
||||||
m_synchronizer.setCancelOnWait(true);
|
m_synchronizer.setCancelOnWait(true);
|
||||||
|
|
||||||
qRegisterMetaType<Qml::QmlDocument::Ptr>("Qml::QmlDocument::Ptr");
|
qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
|
||||||
|
|
||||||
connect(this, SIGNAL(documentUpdated(Qml::QmlDocument::Ptr)),
|
connect(this, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
||||||
this, SLOT(onDocumentUpdated(Qml::QmlDocument::Ptr)));
|
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Qml::Snapshot QmlModelManager::snapshot() const
|
QmlJS::Snapshot QmlModelManager::snapshot() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
@@ -118,10 +118,10 @@ QMap<QString, QString> QmlModelManager::buildWorkingCopyList()
|
|||||||
return workingCopy;
|
return workingCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlModelManager::emitDocumentUpdated(Qml::QmlDocument::Ptr doc)
|
void QmlModelManager::emitDocumentUpdated(QmlJS::Document::Ptr doc)
|
||||||
{ emit documentUpdated(doc); }
|
{ emit documentUpdated(doc); }
|
||||||
|
|
||||||
void QmlModelManager::onDocumentUpdated(Qml::QmlDocument::Ptr doc)
|
void QmlModelManager::onDocumentUpdated(QmlJS::Document::Ptr doc)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ void QmlModelManager::parse(QFutureInterface<void> &future,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Qml::QmlDocument::Ptr doc = Qml::QmlDocument::create(fileName);
|
QmlJS::Document::Ptr doc = QmlJS::Document::create(fileName);
|
||||||
doc->setSource(contents);
|
doc->setSource(contents);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "qmlmodelmanagerinterface.h"
|
#include "qmlmodelmanagerinterface.h"
|
||||||
|
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QFutureSynchronizer>
|
#include <QFutureSynchronizer>
|
||||||
@@ -52,10 +52,10 @@ class QmlModelManager: public QmlModelManagerInterface
|
|||||||
public:
|
public:
|
||||||
QmlModelManager(QObject *parent = 0);
|
QmlModelManager(QObject *parent = 0);
|
||||||
|
|
||||||
virtual Qml::Snapshot snapshot() const;
|
virtual QmlJS::Snapshot snapshot() const;
|
||||||
virtual void updateSourceFiles(const QStringList &files);
|
virtual void updateSourceFiles(const QStringList &files);
|
||||||
|
|
||||||
void emitDocumentUpdated(Qml::QmlDocument::Ptr doc);
|
void emitDocumentUpdated(QmlJS::Document::Ptr doc);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void projectPathChanged(const QString &projectPath);
|
void projectPathChanged(const QString &projectPath);
|
||||||
@@ -63,7 +63,7 @@ Q_SIGNALS:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
// this should be executed in the GUI thread.
|
// this should be executed in the GUI thread.
|
||||||
void onDocumentUpdated(Qml::QmlDocument::Ptr doc);
|
void onDocumentUpdated(QmlJS::Document::Ptr doc);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
|
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
|
||||||
@@ -77,7 +77,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
mutable QMutex m_mutex;
|
mutable QMutex m_mutex;
|
||||||
Core::ICore *m_core;
|
Core::ICore *m_core;
|
||||||
Qml::Snapshot _snapshot;
|
QmlJS::Snapshot _snapshot;
|
||||||
|
|
||||||
QFutureSynchronizer<void> m_synchronizer;
|
QFutureSynchronizer<void> m_synchronizer;
|
||||||
};
|
};
|
||||||
|
@@ -32,14 +32,14 @@
|
|||||||
|
|
||||||
#include "qmljseditor_global.h"
|
#include "qmljseditor_global.h"
|
||||||
|
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <qmljs/qmltypesystem.h>
|
#include <qmljs/qmljstypesystem.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
|
||||||
namespace Qml {
|
namespace QmlJS {
|
||||||
class Snapshot;
|
class Snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,11 +53,11 @@ public:
|
|||||||
QmlModelManagerInterface(QObject *parent = 0);
|
QmlModelManagerInterface(QObject *parent = 0);
|
||||||
virtual ~QmlModelManagerInterface();
|
virtual ~QmlModelManagerInterface();
|
||||||
|
|
||||||
virtual Qml::Snapshot snapshot() const = 0;
|
virtual QmlJS::Snapshot snapshot() const = 0;
|
||||||
virtual void updateSourceFiles(const QStringList &files) = 0;
|
virtual void updateSourceFiles(const QStringList &files) = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void documentUpdated(Qml::QmlDocument::Ptr doc);
|
void documentUpdated(QmlJS::Document::Ptr doc);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlJSEditor
|
} // namespace QmlJSEditor
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
#include <qmljs/parser/qmljsengine_p.h>
|
#include <qmljs/parser/qmljsengine_p.h>
|
||||||
|
|
||||||
using namespace Qml;
|
|
||||||
using namespace QmlJSEditor;
|
using namespace QmlJSEditor;
|
||||||
using namespace QmlJSEditor::Internal;
|
using namespace QmlJSEditor::Internal;
|
||||||
using namespace QmlJS;
|
using namespace QmlJS;
|
||||||
@@ -43,18 +42,18 @@ QmlResolveExpression::QmlResolveExpression(const QmlLookupContext &context)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbol *QmlResolveExpression::typeOf(Node *node)
|
Symbol *QmlResolveExpression::typeOf(Node *node)
|
||||||
{
|
{
|
||||||
QmlSymbol *previousValue = switchValue(0);
|
Symbol *previousValue = switchValue(0);
|
||||||
Node::accept(node, this);
|
Node::accept(node, this);
|
||||||
return switchValue(previousValue);
|
return switchValue(previousValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QmlSymbol*> QmlResolveExpression::visibleSymbols(Node *node)
|
QList<Symbol*> QmlResolveExpression::visibleSymbols(Node *node)
|
||||||
{
|
{
|
||||||
QList<QmlSymbol*> result;
|
QList<Symbol*> result;
|
||||||
|
|
||||||
QmlSymbol *symbol = typeOf(node);
|
Symbol *symbol = typeOf(node);
|
||||||
if (symbol) {
|
if (symbol) {
|
||||||
if (symbol->isIdSymbol())
|
if (symbol->isIdSymbol())
|
||||||
symbol = symbol->asIdSymbol()->parentNode();
|
symbol = symbol->asIdSymbol()->parentNode();
|
||||||
@@ -66,7 +65,7 @@ QList<QmlSymbol*> QmlResolveExpression::visibleSymbols(Node *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
foreach (QmlIdSymbol *idSymbol, _context.document()->ids().values())
|
foreach (IdSymbol *idSymbol, _context.document()->ids().values())
|
||||||
result.append(idSymbol);
|
result.append(idSymbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,9 +74,9 @@ QList<QmlSymbol*> QmlResolveExpression::visibleSymbols(Node *node)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSymbol *QmlResolveExpression::switchValue(QmlSymbol *value)
|
Symbol *QmlResolveExpression::switchValue(Symbol *value)
|
||||||
{
|
{
|
||||||
QmlSymbol *previousValue = _value;
|
Symbol *previousValue = _value;
|
||||||
_value = value;
|
_value = value;
|
||||||
return previousValue;
|
return previousValue;
|
||||||
}
|
}
|
||||||
@@ -107,7 +106,7 @@ bool QmlResolveExpression::visit(FieldMemberExpression *ast)
|
|||||||
{
|
{
|
||||||
const QString memberName = ast->name->asString();
|
const QString memberName = ast->name->asString();
|
||||||
|
|
||||||
QmlSymbol *base = typeOf(ast->base);
|
Symbol *base = typeOf(ast->base);
|
||||||
if (!base)
|
if (!base)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -117,7 +116,7 @@ bool QmlResolveExpression::visit(FieldMemberExpression *ast)
|
|||||||
if (!base)
|
if (!base)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
foreach (QmlSymbol *memberSymbol, base->members())
|
foreach (Symbol *memberSymbol, base->members())
|
||||||
if (memberSymbol->name() == memberName)
|
if (memberSymbol->name() == memberName)
|
||||||
_value = memberSymbol;
|
_value = memberSymbol;
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
#include "qmllookupcontext.h"
|
#include "qmllookupcontext.h"
|
||||||
|
|
||||||
#include <qmljs/parser/qmljsastvisitor_p.h>
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
||||||
#include <qmljs/qmlsymbol.h>
|
#include <qmljs/qmljssymbol.h>
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -43,13 +43,13 @@ class QmlResolveExpression: protected QmlJS::AST::Visitor
|
|||||||
public:
|
public:
|
||||||
QmlResolveExpression(const QmlLookupContext &context);
|
QmlResolveExpression(const QmlLookupContext &context);
|
||||||
|
|
||||||
Qml::QmlSymbol *typeOf(QmlJS::AST::Node *node);
|
QmlJS::Symbol *typeOf(QmlJS::AST::Node *node);
|
||||||
QList<Qml::QmlSymbol*> visibleSymbols(QmlJS::AST::Node *node);
|
QList<QmlJS::Symbol*> visibleSymbols(QmlJS::AST::Node *node);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using QmlJS::AST::Visitor::visit;
|
using QmlJS::AST::Visitor::visit;
|
||||||
|
|
||||||
Qml::QmlSymbol *switchValue(Qml::QmlSymbol *symbol);
|
QmlJS::Symbol *switchValue(QmlJS::Symbol *symbol);
|
||||||
|
|
||||||
virtual bool visit(QmlJS::AST::FieldMemberExpression *ast);
|
virtual bool visit(QmlJS::AST::FieldMemberExpression *ast);
|
||||||
virtual bool visit(QmlJS::AST::IdentifierExpression *ast);
|
virtual bool visit(QmlJS::AST::IdentifierExpression *ast);
|
||||||
@@ -57,7 +57,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QmlLookupContext _context;
|
QmlLookupContext _context;
|
||||||
Qml::QmlSymbol *_value;
|
QmlJS::Symbol *_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -100,8 +100,8 @@ void QmlProjectPlugin::extensionsInitialized()
|
|||||||
|
|
||||||
QmlJSEditor::QmlModelManagerInterface *modelManager = pluginManager->getObject<QmlJSEditor::QmlModelManagerInterface>();
|
QmlJSEditor::QmlModelManagerInterface *modelManager = pluginManager->getObject<QmlJSEditor::QmlModelManagerInterface>();
|
||||||
Q_ASSERT(modelManager);
|
Q_ASSERT(modelManager);
|
||||||
connect(modelManager, SIGNAL(documentUpdated(Qml::QmlDocument::Ptr)),
|
connect(modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
||||||
m_qmlTaskManager, SLOT(documentUpdated(Qml::QmlDocument::Ptr)));
|
m_qmlTaskManager, SLOT(documentUpdated(QmlJS::Document::Ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(QmlProjectPlugin)
|
Q_EXPORT_PLUGIN(QmlProjectPlugin)
|
||||||
|
@@ -48,7 +48,7 @@ void QmlTaskManager::setTaskWindow(ProjectExplorer::TaskWindow *taskWindow)
|
|||||||
m_taskWindow->addCategory(Constants::TASK_CATEGORY_QML, "Qml");
|
m_taskWindow->addCategory(Constants::TASK_CATEGORY_QML, "Qml");
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlTaskManager::documentUpdated(Qml::QmlDocument::Ptr doc)
|
void QmlTaskManager::documentUpdated(QmlJS::Document::Ptr doc)
|
||||||
{
|
{
|
||||||
#if 0 // This will give way too many flickering errors in the build-results pane *when you're typing*
|
#if 0 // This will give way too many flickering errors in the build-results pane *when you're typing*
|
||||||
m_taskWindow->clearTasks(Constants::TASK_CATEGORY_QML);
|
m_taskWindow->clearTasks(Constants::TASK_CATEGORY_QML);
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#define QMLTASKMANAGER_H
|
#define QMLTASKMANAGER_H
|
||||||
|
|
||||||
#include <projectexplorer/taskwindow.h>
|
#include <projectexplorer/taskwindow.h>
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
void setTaskWindow(ProjectExplorer::TaskWindow *taskWindow);
|
void setTaskWindow(ProjectExplorer::TaskWindow *taskWindow);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void documentUpdated(Qml::QmlDocument::Ptr doc);
|
void documentUpdated(QmlJS::Document::Ptr doc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectExplorer::TaskWindow *m_taskWindow;
|
ProjectExplorer::TaskWindow *m_taskWindow;
|
||||||
|
@@ -3,14 +3,13 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
|
|
||||||
#include <qmllookupcontext.h>
|
#include <qmllookupcontext.h>
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
using namespace Qml;
|
|
||||||
using namespace QmlJSEditor;
|
using namespace QmlJSEditor;
|
||||||
using namespace QmlJSEditor::Internal;
|
using namespace QmlJSEditor::Internal;
|
||||||
using namespace QmlJS;
|
using namespace QmlJS;
|
||||||
@@ -35,10 +34,10 @@ private Q_SLOTS:
|
|||||||
void localRootLookup();
|
void localRootLookup();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QmlDocument::Ptr basicSymbolTest(const QString &input) const
|
Document::Ptr basicSymbolTest(const QString &input) const
|
||||||
{
|
{
|
||||||
const QLatin1String filename("<lookup test>");
|
const QLatin1String filename("<lookup test>");
|
||||||
QmlDocument::Ptr doc = QmlDocument::create(filename);
|
Document::Ptr doc = Document::create(filename);
|
||||||
doc->setSource(input);
|
doc->setSource(input);
|
||||||
doc->parseQml();
|
doc->parseQml();
|
||||||
|
|
||||||
@@ -56,21 +55,21 @@ protected:
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Snapshot snapshot(const QmlDocument::Ptr &doc) const
|
Snapshot snapshot(const Document::Ptr &doc) const
|
||||||
{
|
{
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
snapshot.insert(doc);
|
snapshot.insert(doc);
|
||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlTypeSystem *typeSystem() {
|
TypeSystem *typeSystem() {
|
||||||
if (!_typeSystem)
|
if (!_typeSystem)
|
||||||
_typeSystem = new QmlTypeSystem;
|
_typeSystem = new TypeSystem;
|
||||||
return _typeSystem;
|
return _typeSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlTypeSystem *_typeSystem;
|
TypeSystem *_typeSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_Lookup::basicSymbolTest()
|
void tst_Lookup::basicSymbolTest()
|
||||||
@@ -86,7 +85,7 @@ void tst_Lookup::basicSymbolTest()
|
|||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
QmlDocument::Ptr doc = basicSymbolTest(input);
|
Document::Ptr doc = basicSymbolTest(input);
|
||||||
QVERIFY(doc->isParsedCorrectly());
|
QVERIFY(doc->isParsedCorrectly());
|
||||||
|
|
||||||
UiProgram *program = doc->qmlProgram();
|
UiProgram *program = doc->qmlProgram();
|
||||||
@@ -108,16 +107,16 @@ void tst_Lookup::basicSymbolTest()
|
|||||||
QVERIFY(xBinding->qualifiedId->name);
|
QVERIFY(xBinding->qualifiedId->name);
|
||||||
QCOMPARE(xBinding->qualifiedId->name->asString(), QLatin1String("x"));
|
QCOMPARE(xBinding->qualifiedId->name->asString(), QLatin1String("x"));
|
||||||
|
|
||||||
QmlSymbol::List docSymbols = doc->symbols();
|
Symbol::List docSymbols = doc->symbols();
|
||||||
QCOMPARE(docSymbols.size(), 1);
|
QCOMPARE(docSymbols.size(), 1);
|
||||||
|
|
||||||
QmlSymbol *rectSymbol = docSymbols.at(0);
|
Symbol *rectSymbol = docSymbols.at(0);
|
||||||
QCOMPARE(rectSymbol->name(), QLatin1String("Rectangle"));
|
QCOMPARE(rectSymbol->name(), QLatin1String("Rectangle"));
|
||||||
QCOMPARE(rectSymbol->members().size(), 4);
|
QCOMPARE(rectSymbol->members().size(), 4);
|
||||||
|
|
||||||
QmlSymbolFromFile *rectFromFile = rectSymbol->asSymbolFromFile();
|
SymbolFromFile *rectFromFile = rectSymbol->asSymbolFromFile();
|
||||||
QVERIFY(rectFromFile);
|
QVERIFY(rectFromFile);
|
||||||
QmlSymbolFromFile *xSymbol = rectFromFile->findMember(xBinding);
|
SymbolFromFile *xSymbol = rectFromFile->findMember(xBinding);
|
||||||
QVERIFY(xSymbol);
|
QVERIFY(xSymbol);
|
||||||
QCOMPARE(xSymbol->name(), QLatin1String("x"));
|
QCOMPARE(xSymbol->name(), QLatin1String("x"));
|
||||||
}
|
}
|
||||||
@@ -129,26 +128,26 @@ void tst_Lookup::basicLookupTest()
|
|||||||
"Item{}\n"
|
"Item{}\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
QmlDocument::Ptr doc = basicSymbolTest(input);
|
Document::Ptr doc = basicSymbolTest(input);
|
||||||
QVERIFY(doc->isParsedCorrectly());
|
QVERIFY(doc->isParsedCorrectly());
|
||||||
|
|
||||||
UiProgram *program = doc->qmlProgram();
|
UiProgram *program = doc->qmlProgram();
|
||||||
QVERIFY(program);
|
QVERIFY(program);
|
||||||
|
|
||||||
QStack<QmlSymbol *> emptyScope;
|
QStack<Symbol *> emptyScope;
|
||||||
QmlLookupContext context(emptyScope, doc, snapshot(doc), typeSystem());
|
QmlLookupContext context(emptyScope, doc, snapshot(doc), typeSystem());
|
||||||
QmlSymbol *rectSymbol = context.resolveType(QLatin1String("Text"));
|
Symbol *rectSymbol = context.resolveType(QLatin1String("Text"));
|
||||||
QVERIFY(rectSymbol);
|
QVERIFY(rectSymbol);
|
||||||
|
|
||||||
QmlBuildInSymbol *buildInRect = rectSymbol->asBuildInSymbol();
|
PrimitiveSymbol *buildInRect = rectSymbol->asPrimitiveSymbol();
|
||||||
QVERIFY(buildInRect);
|
QVERIFY(buildInRect);
|
||||||
QCOMPARE(buildInRect->name(), QLatin1String("Text"));
|
QCOMPARE(buildInRect->name(), QLatin1String("Text"));
|
||||||
|
|
||||||
QmlSymbol::List allBuildInRectMembers = buildInRect->members(true);
|
Symbol::List allBuildInRectMembers = buildInRect->members(true);
|
||||||
QVERIFY(!allBuildInRectMembers.isEmpty());
|
QVERIFY(!allBuildInRectMembers.isEmpty());
|
||||||
bool xPropFound = false;
|
bool xPropFound = false;
|
||||||
bool fontPropFound = false;
|
bool fontPropFound = false;
|
||||||
foreach (QmlSymbol *symbol, allBuildInRectMembers) {
|
foreach (Symbol *symbol, allBuildInRectMembers) {
|
||||||
if (symbol->name() == QLatin1String("x"))
|
if (symbol->name() == QLatin1String("x"))
|
||||||
xPropFound = true;
|
xPropFound = true;
|
||||||
else if (symbol->name() == QLatin1String("font"))
|
else if (symbol->name() == QLatin1String("font"))
|
||||||
@@ -157,12 +156,12 @@ void tst_Lookup::basicLookupTest()
|
|||||||
QVERIFY(xPropFound);
|
QVERIFY(xPropFound);
|
||||||
QVERIFY(fontPropFound);
|
QVERIFY(fontPropFound);
|
||||||
|
|
||||||
QmlSymbol::List buildInRectMembers = buildInRect->members(false);
|
Symbol::List buildInRectMembers = buildInRect->members(false);
|
||||||
QVERIFY(!buildInRectMembers.isEmpty());
|
QVERIFY(!buildInRectMembers.isEmpty());
|
||||||
|
|
||||||
QSKIP("Getting properties _without_ the inerited properties doesn't work.", SkipSingle);
|
QSKIP("Getting properties _without_ the inerited properties doesn't work.", SkipSingle);
|
||||||
fontPropFound = false;
|
fontPropFound = false;
|
||||||
foreach (QmlSymbol *symbol, buildInRectMembers) {
|
foreach (Symbol *symbol, buildInRectMembers) {
|
||||||
if (symbol->name() == QLatin1String("x"))
|
if (symbol->name() == QLatin1String("x"))
|
||||||
QFAIL("Text has x property");
|
QFAIL("Text has x property");
|
||||||
else if (symbol->name() == QLatin1String("font"))
|
else if (symbol->name() == QLatin1String("font"))
|
||||||
@@ -176,7 +175,7 @@ void tst_Lookup::localIdLookup()
|
|||||||
QFile input(":/data/localIdLookup.qml");
|
QFile input(":/data/localIdLookup.qml");
|
||||||
QVERIFY(input.open(QIODevice::ReadOnly));
|
QVERIFY(input.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
QmlDocument::Ptr doc = basicSymbolTest(input.readAll());
|
Document::Ptr doc = basicSymbolTest(input.readAll());
|
||||||
QVERIFY(doc->isParsedCorrectly());
|
QVERIFY(doc->isParsedCorrectly());
|
||||||
|
|
||||||
QStringList symbolNames;
|
QStringList symbolNames;
|
||||||
@@ -192,17 +191,17 @@ void tst_Lookup::localIdLookup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try lookup
|
// try lookup
|
||||||
QStack<QmlSymbol *> scopes;
|
QStack<Symbol *> scopes;
|
||||||
foreach (const QString &contextSymbolName, symbolNames) {
|
foreach (const QString &contextSymbolName, symbolNames) {
|
||||||
scopes.push_back(doc->ids()[contextSymbolName]->parentNode());
|
scopes.push_back(doc->ids()[contextSymbolName]->parentNode());
|
||||||
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
|
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
|
||||||
|
|
||||||
foreach (const QString &lookupSymbolName, symbolNames) {
|
foreach (const QString &lookupSymbolName, symbolNames) {
|
||||||
QmlSymbol *resolvedSymbol = context.resolve(lookupSymbolName);
|
Symbol *resolvedSymbol = context.resolve(lookupSymbolName);
|
||||||
QmlIdSymbol *targetSymbol = doc->ids()[lookupSymbolName];
|
IdSymbol *targetSymbol = doc->ids()[lookupSymbolName];
|
||||||
QCOMPARE(resolvedSymbol, targetSymbol);
|
QCOMPARE(resolvedSymbol, targetSymbol);
|
||||||
|
|
||||||
QmlIdSymbol *resolvedId = resolvedSymbol->asIdSymbol();
|
IdSymbol *resolvedId = resolvedSymbol->asIdSymbol();
|
||||||
QVERIFY(resolvedId);
|
QVERIFY(resolvedId);
|
||||||
QCOMPARE(resolvedId->parentNode(), targetSymbol->parentNode());
|
QCOMPARE(resolvedId->parentNode(), targetSymbol->parentNode());
|
||||||
}
|
}
|
||||||
@@ -214,7 +213,7 @@ void tst_Lookup::localScriptMethodLookup()
|
|||||||
QFile input(":/data/localScriptMethodLookup.qml");
|
QFile input(":/data/localScriptMethodLookup.qml");
|
||||||
QVERIFY(input.open(QIODevice::ReadOnly));
|
QVERIFY(input.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
QmlDocument::Ptr doc = basicSymbolTest(input.readAll());
|
Document::Ptr doc = basicSymbolTest(input.readAll());
|
||||||
QVERIFY(doc->isParsedCorrectly());
|
QVERIFY(doc->isParsedCorrectly());
|
||||||
|
|
||||||
QStringList symbolNames;
|
QStringList symbolNames;
|
||||||
@@ -233,13 +232,13 @@ void tst_Lookup::localScriptMethodLookup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try lookup
|
// try lookup
|
||||||
QStack<QmlSymbol *> scopes;
|
QStack<Symbol *> scopes;
|
||||||
foreach (const QString &contextSymbolName, symbolNames) {
|
foreach (const QString &contextSymbolName, symbolNames) {
|
||||||
scopes.push_back(doc->ids()[contextSymbolName]->parentNode());
|
scopes.push_back(doc->ids()[contextSymbolName]->parentNode());
|
||||||
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
|
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
|
||||||
|
|
||||||
foreach (const QString &functionName, functionNames) {
|
foreach (const QString &functionName, functionNames) {
|
||||||
QmlSymbol *symbol = context.resolve(functionName);
|
Symbol *symbol = context.resolve(functionName);
|
||||||
QVERIFY(symbol);
|
QVERIFY(symbol);
|
||||||
QVERIFY(!symbol->isProperty());
|
QVERIFY(!symbol->isProperty());
|
||||||
// verify that it's a function
|
// verify that it's a function
|
||||||
@@ -252,7 +251,7 @@ void tst_Lookup::localScopeLookup()
|
|||||||
QFile input(":/data/localScopeLookup.qml");
|
QFile input(":/data/localScopeLookup.qml");
|
||||||
QVERIFY(input.open(QIODevice::ReadOnly));
|
QVERIFY(input.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
QmlDocument::Ptr doc = basicSymbolTest(input.readAll());
|
Document::Ptr doc = basicSymbolTest(input.readAll());
|
||||||
QVERIFY(doc->isParsedCorrectly());
|
QVERIFY(doc->isParsedCorrectly());
|
||||||
|
|
||||||
QStringList symbolNames;
|
QStringList symbolNames;
|
||||||
@@ -266,13 +265,13 @@ void tst_Lookup::localScopeLookup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try lookup
|
// try lookup
|
||||||
QStack<QmlSymbol *> scopes;
|
QStack<Symbol *> scopes;
|
||||||
foreach (const QString &contextSymbolName, symbolNames) {
|
foreach (const QString &contextSymbolName, symbolNames) {
|
||||||
QmlSymbol *parent = doc->ids()[contextSymbolName]->parentNode();
|
Symbol *parent = doc->ids()[contextSymbolName]->parentNode();
|
||||||
scopes.push_back(parent);
|
scopes.push_back(parent);
|
||||||
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
|
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
|
||||||
|
|
||||||
QmlSymbol *symbol;
|
Symbol *symbol;
|
||||||
symbol = context.resolve("prop");
|
symbol = context.resolve("prop");
|
||||||
QVERIFY(symbol);
|
QVERIFY(symbol);
|
||||||
QVERIFY(symbol->isPropertyDefinitionSymbol());
|
QVERIFY(symbol->isPropertyDefinitionSymbol());
|
||||||
@@ -290,7 +289,7 @@ void tst_Lookup::localRootLookup()
|
|||||||
QFile input(":/data/localRootLookup.qml");
|
QFile input(":/data/localRootLookup.qml");
|
||||||
QVERIFY(input.open(QIODevice::ReadOnly));
|
QVERIFY(input.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
QmlDocument::Ptr doc = basicSymbolTest(input.readAll());
|
Document::Ptr doc = basicSymbolTest(input.readAll());
|
||||||
QVERIFY(doc->isParsedCorrectly());
|
QVERIFY(doc->isParsedCorrectly());
|
||||||
|
|
||||||
QStringList symbolNames;
|
QStringList symbolNames;
|
||||||
@@ -299,18 +298,18 @@ void tst_Lookup::localRootLookup()
|
|||||||
symbolNames.append("theChild");
|
symbolNames.append("theChild");
|
||||||
|
|
||||||
// check symbol existence and build scopes
|
// check symbol existence and build scopes
|
||||||
QStack<QmlSymbol *> scopes;
|
QStack<Symbol *> scopes;
|
||||||
foreach (const QString &symbolName, symbolNames) {
|
foreach (const QString &symbolName, symbolNames) {
|
||||||
QmlIdSymbol *id = doc->ids()[symbolName];
|
IdSymbol *id = doc->ids()[symbolName];
|
||||||
QVERIFY(id);
|
QVERIFY(id);
|
||||||
scopes.push_back(id->parentNode());
|
scopes.push_back(id->parentNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
// try lookup
|
// try lookup
|
||||||
QmlSymbol *parent = scopes.front();
|
Symbol *parent = scopes.front();
|
||||||
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
|
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
|
||||||
|
|
||||||
QmlSymbol *symbol;
|
Symbol *symbol;
|
||||||
symbol = context.resolve("prop");
|
symbol = context.resolve("prop");
|
||||||
QVERIFY(symbol);
|
QVERIFY(symbol);
|
||||||
QVERIFY(symbol->isPropertyDefinitionSymbol());
|
QVERIFY(symbol->isPropertyDefinitionSymbol());
|
||||||
|
Reference in New Issue
Block a user