Renamed classes and files to use the QmlJS prefix.

This commit is contained in:
Roberto Raggi
2010-01-18 16:15:23 +01:00
parent 7024c1e1a8
commit c943d8e4f1
57 changed files with 1888 additions and 589 deletions

View File

@@ -47,13 +47,13 @@
# define QT_QML_BEGIN_NAMESPACE
# define QT_QML_END_NAMESPACE
# ifdef QML_BUILD_LIB
# ifdef QMLJS_BUILD_DIR
# define QML_PARSER_EXPORT Q_DECL_EXPORT
# elif QML_BUILD_STATIC_LIB
# define QML_PARSER_EXPORT
# else
# define QML_PARSER_EXPORT Q_DECL_IMPORT
# endif // QML_BUILD_LIB
# endif // QMLJS_BUILD_DIR
#else // !QT_CREATOR
# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@@ -1,5 +1,5 @@
contains(CONFIG, dll) {
DEFINES += QML_BUILD_LIB
DEFINES += QMLJS_BUILD_DIR
} else {
DEFINES += QML_BUILD_STATIC_LIB
}
@@ -12,23 +12,27 @@ DEPENDPATH += $$PWD
INCLUDEPATH += $$PWD/..
HEADERS += \
$$PWD/qml_global.h \
$$PWD/qmlidcollector.h \
$$PWD/qmldocument.h \
$$PWD/qmlpackageinfo.h \
$$PWD/qmlsymbol.h \
$$PWD/qmlmetatypebackend.h \
$$PWD/qmltypesystem.h \
$$PWD/qscriptincrementalscanner.h
$$PWD/qmljs_global.h \
$$PWD/qmljsbind.h \
$$PWD/qmljscheck.h \
$$PWD/qmljsdocument.h \
$$PWD/qmljsidcollector.h \
$$PWD/qmljsmetatypebackend.h \
$$PWD/qmljspackageinfo.h \
$$PWD/qmljsscanner.h \
$$PWD/qmljssymbol.h \
$$PWD/qmljstypesystem.h
SOURCES += \
$$PWD/qmlidcollector.cpp \
$$PWD/qmldocument.cpp \
$$PWD/qmlsymbol.cpp \
$$PWD/qmlpackageinfo.cpp \
$$PWD/qmlmetatypebackend.cpp \
$$PWD/qmltypesystem.cpp \
$$PWD/qscriptincrementalscanner.cpp
$$PWD/qmljsbind.cpp \
$$PWD/qmljscheck.cpp \
$$PWD/qmljsdocument.cpp \
$$PWD/qmljsidcollector.cpp \
$$PWD/qmljsmetatypebackend.cpp \
$$PWD/qmljspackageinfo.cpp \
$$PWD/qmljsscanner.cpp \
$$PWD/qmljssymbol.cpp \
$$PWD/qmljstypesystem.cpp
contains(QT_CONFIG, declarative) {
QT += declarative
@@ -43,6 +47,6 @@ contains(QT_CONFIG, declarative) {
}
contains(QT, gui) {
SOURCES += $$PWD/qscripthighlighter.cpp $$PWD/qscriptindenter.cpp
HEADERS += $$PWD/qscripthighlighter.h $$PWD/qscriptindenter.h
SOURCES += $$PWD/qmljshighlighter.cpp $$PWD/qmljsindenter.cpp
HEADERS += $$PWD/qmljshighlighter.h $$PWD/qmljsindenter.h
}

View File

@@ -1,7 +1,7 @@
TEMPLATE = lib
CONFIG += dll
TARGET = QmlJS
DEFINES += QML_BUILD_LIB QT_CREATOR
DEFINES += QMLJS_BUILD_DIR QT_CREATOR
unix:QMAKE_CXXFLAGS_DEBUG += -O3

View File

@@ -27,17 +27,17 @@
**
**************************************************************************/
#ifndef QML_GLOBAL_H
#define QML_GLOBAL_H
#ifndef QMLJS_GLOBAL_H
#define QMLJS_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(QML_BUILD_LIB)
# define QML_EXPORT Q_DECL_EXPORT
#if defined(QMLJS_BUILD_DIR)
# define QMLJS_EXPORT Q_DECL_EXPORT
#elif defined(QML_BUILD_STATIC_LIB)
# define QML_EXPORT
# define QMLJS_EXPORT
#else
# define QML_EXPORT Q_DECL_IMPORT
# define QMLJS_EXPORT Q_DECL_IMPORT
#endif
#endif // QML_GLOBAL_H
#endif // QMLJS_GLOBAL_H

View 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
View 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

View 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
View 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

View File

@@ -27,19 +27,19 @@
**
**************************************************************************/
#include "qmlidcollector.h"
#include "qmldocument.h"
#include "qmljsidcollector.h"
#include "qmljsdocument.h"
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljslexer_p.h>
#include <qmljs/parser/qmljsparser_p.h>
#include <qmljs/parser/qmljsnodepool_p.h>
#include <qmljs/parser/qmljsastfwd_p.h>
using namespace Qml;
using namespace QmlJS;
using namespace QmlJS;
using namespace QmlJS::AST;
QmlDocument::QmlDocument(const QString &fileName)
Document::Document(const QString &fileName)
: _engine(0)
, _pool(0)
, _uiProgram(0)
@@ -55,7 +55,7 @@ QmlDocument::QmlDocument(const QString &fileName)
_componentName = fileName.mid(slashIdx + 1, fileName.size() - (slashIdx + 1) - 4);
}
QmlDocument::~QmlDocument()
Document::~Document()
{
if (_engine)
delete _engine;
@@ -66,38 +66,38 @@ QmlDocument::~QmlDocument()
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;
}
AST::UiProgram *QmlDocument::qmlProgram() const
AST::UiProgram *Document::qmlProgram() const
{
return _uiProgram;
}
AST::Program *QmlDocument::jsProgram() const
AST::Program *Document::jsProgram() const
{
return _jsProgram;
}
QList<DiagnosticMessage> QmlDocument::diagnosticMessages() const
QList<DiagnosticMessage> Document::diagnosticMessages() const
{
return _diagnosticMessages;
}
QString QmlDocument::source() const
QString Document::source() const
{
return _source;
}
void QmlDocument::setSource(const QString &source)
void Document::setSource(const QString &source)
{
_source = source;
}
bool QmlDocument::parseQml()
bool Document::parseQml()
{
Q_ASSERT(! _engine);
Q_ASSERT(! _pool);
@@ -120,9 +120,9 @@ bool QmlDocument::parseQml()
if (_uiProgram) {
for (QmlJS::AST::UiObjectMemberList *iter = _uiProgram->members; iter; iter = iter->next)
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);
if (_diagnosticMessages.isEmpty())
_diagnosticMessages = collect.diagnosticMessages();
@@ -131,7 +131,7 @@ bool QmlDocument::parseQml()
return _parsedCorrectly;
}
bool QmlDocument::parseJavaScript()
bool Document::parseJavaScript()
{
Q_ASSERT(! _engine);
Q_ASSERT(! _pool);
@@ -154,9 +154,9 @@ bool QmlDocument::parseJavaScript()
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->asSymbolFromFile()->node() == node)
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()))
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;
foreach (QmlDocument::Ptr candidate, *this) {
foreach (Document::Ptr candidate, *this) {
if (candidate == doc)
continue;
@@ -195,13 +195,13 @@ QmlDocument::PtrList Snapshot::importedDocuments(const QmlDocument::Ptr &doc, co
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;
foreach (QmlDocument::Ptr candidate, *this) {
foreach (Document::Ptr candidate, *this) {
if (candidate == doc)
continue;

View File

@@ -36,25 +36,25 @@
#include <QtCore/QString>
#include "parser/qmljsengine_p.h"
#include "qml_global.h"
#include "qmlsymbol.h"
#include "qmljs_global.h"
#include "qmljssymbol.h"
namespace Qml {
namespace QmlJS {
class QML_EXPORT QmlDocument
class QMLJS_EXPORT Document
{
public:
typedef QSharedPointer<QmlDocument> Ptr;
typedef QList<QmlDocument::Ptr> PtrList;
typedef QMap<QString, Qml::QmlIdSymbol*> IdTable;
typedef QSharedPointer<Document> Ptr;
typedef QList<Document::Ptr> PtrList;
typedef QMap<QString, IdSymbol*> IdTable;
protected:
QmlDocument(const QString &fileName);
Document(const QString &fileName);
public:
~QmlDocument();
~Document();
static QmlDocument::Ptr create(const QString &fileName);
static Document::Ptr create(const QString &fileName);
QmlJS::AST::UiProgram *qmlProgram() const;
QmlJS::AST::Program *jsProgram() const;
@@ -75,8 +75,8 @@ public:
QString path() const { return _path; }
QString componentName() const { return _componentName; }
Qml::QmlSymbolFromFile *findSymbol(QmlJS::AST::Node *node) const;
Qml::QmlSymbol::List symbols() const
QmlJS::SymbolFromFile *findSymbol(QmlJS::AST::Node *node) const;
QmlJS::Symbol::List symbols() const
{ return _symbols; }
private:
@@ -91,22 +91,22 @@ private:
QString _source;
bool _parsedCorrectly;
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:
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); }
QmlDocument::PtrList importedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const;
QMap<QString, QmlDocument::Ptr> componentsDefinedByImportedDocuments(const QmlDocument::Ptr &doc, const QString &importPath) const;
Document::PtrList importedDocuments(const Document::Ptr &doc, const QString &importPath) const;
QMap<QString, Document::Ptr> componentsDefinedByImportedDocuments(const Document::Ptr &doc, const QString &importPath) const;
};
} // end of namespace Qml

View File

@@ -27,7 +27,7 @@
**
**************************************************************************/
#include <qmljs/qscripthighlighter.h>
#include <qmljs/qmljshighlighter.h>
#include <QtCore/QSet>
#include <QtCore/QtAlgorithms>
@@ -62,60 +62,60 @@ void QScriptHighlighter::highlightBlock(const QString &text)
QTextCharFormat emptyFormat;
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) {
const QScriptIncrementalScanner::Token token = tokens.at(i);
const QmlJSScanner::Token token = tokens.at(i);
if (token.offset != lastEnd)
setFormat(lastEnd, token.offset - lastEnd, m_formats[VisualWhitespace]);
switch (token.kind) {
case QScriptIncrementalScanner::Token::Keyword:
case QmlJSScanner::Token::Keyword:
setFormat(token.offset, token.length, m_formats[KeywordFormat]);
break;
case QScriptIncrementalScanner::Token::String:
case QmlJSScanner::Token::String:
highlightWhitespace(token, text, StringFormat);
break;
case QScriptIncrementalScanner::Token::Comment:
case QmlJSScanner::Token::Comment:
highlightWhitespace(token, text, CommentFormat);
break;
case QScriptIncrementalScanner::Token::Number:
case QmlJSScanner::Token::Number:
highlightWhitespace(token, text, NumberFormat);
break;
case QScriptIncrementalScanner::Token::LeftParenthesis:
case QmlJSScanner::Token::LeftParenthesis:
onOpeningParenthesis('(', token.offset);
break;
case QScriptIncrementalScanner::Token::RightParenthesis:
case QmlJSScanner::Token::RightParenthesis:
onClosingParenthesis(')', token.offset);
break;
case QScriptIncrementalScanner::Token::LeftBrace:
case QmlJSScanner::Token::LeftBrace:
onOpeningParenthesis('{', token.offset);
break;
case QScriptIncrementalScanner::Token::RightBrace:
case QmlJSScanner::Token::RightBrace:
onClosingParenthesis('}', token.offset);
break;
case QScriptIncrementalScanner::Token::LeftBracket:
case QmlJSScanner::Token::LeftBracket:
onOpeningParenthesis('[', token.offset);
break;
case QScriptIncrementalScanner::Token::RightBracket:
case QmlJSScanner::Token::RightBracket:
onClosingParenthesis(']', token.offset);
break;
case QScriptIncrementalScanner::Token::Identifier:
if (m_duiEnabled && (i + 1 != tokens.size()) && tokens.at(i + 1).kind == QScriptIncrementalScanner::Token::Colon) {
case QmlJSScanner::Token::Identifier:
if (m_duiEnabled && (i + 1 != tokens.size()) && tokens.at(i + 1).kind == QmlJSScanner::Token::Colon) {
int j = i;
for (; j != -1; --j) {
const QScriptIncrementalScanner::Token &tok = tokens.at(j);
if (tok.is(QScriptIncrementalScanner::Token::Dot) || tok.is(QScriptIncrementalScanner::Token::Identifier)) {
const QmlJSScanner::Token &tok = tokens.at(j);
if (tok.is(QmlJSScanner::Token::Dot) || tok.is(QmlJSScanner::Token::Identifier)) {
setFormat(tok.offset, tok.length, m_formats[LabelFormat]);
} else {
break;
@@ -131,15 +131,15 @@ void QScriptHighlighter::highlightBlock(const QString &text)
}
break;
case QScriptIncrementalScanner::Token::Colon:
if (m_duiEnabled && i > 0 && tokens.at(i - 1).kind == QScriptIncrementalScanner::Token::Identifier)
case QmlJSScanner::Token::Colon:
if (m_duiEnabled && i > 0 && tokens.at(i - 1).kind == QmlJSScanner::Token::Identifier)
setFormat(token.offset, token.length, m_formats[LabelFormat]);
else
setFormat(token.offset, token.length, emptyFormat);
break;
case QScriptIncrementalScanner::Token::Operator:
case QScriptIncrementalScanner::Token::Dot:
case QmlJSScanner::Token::Operator:
case QmlJSScanner::Token::Dot:
setFormat(token.offset, token.length, emptyFormat);
break;
@@ -247,7 +247,7 @@ void QScriptHighlighter::onOpeningParenthesis(QChar, int) {}
void QScriptHighlighter::onClosingParenthesis(QChar, int) {}
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 visualSpaceFormat = m_formats[VisualWhitespace];

View File

@@ -30,7 +30,7 @@
#ifndef QSCRIPTSYNTAXHIGHLIGHTER_H
#define QSCRIPTSYNTAXHIGHLIGHTER_H
#include <qmljs/qscriptincrementalscanner.h>
#include <qmljs/qmljsscanner.h>
#include <QtCore/QVector>
#include <QtCore/QSet>
@@ -38,7 +38,7 @@
namespace QmlJS {
class QML_EXPORT QScriptHighlighter : public QSyntaxHighlighter
class QMLJS_EXPORT QScriptHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
@@ -69,10 +69,10 @@ protected:
// sets the enriched user state, or simply calls setCurrentBlockState(state);
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:
QScriptIncrementalScanner m_scanner;
QmlJSScanner m_scanner;
private:
bool m_duiEnabled;

View File

@@ -31,14 +31,14 @@
#include <qmljs/parser/qmljsast_p.h>
#include "qmlidcollector.h"
#include "qmljsidcollector.h"
using namespace QmlJS;
using namespace QmlJS::AST;
using namespace Qml;
using namespace Qml::Internal;
using namespace QmlJS;
using namespace QmlJS::Internal;
QMap<QString, QmlIdSymbol*> QmlIdCollector::operator()(Qml::QmlDocument &doc)
QMap<QString, IdSymbol*> IdCollector::operator()(QmlJS::Document &doc)
{
_doc = &doc;
_ids.clear();
@@ -49,31 +49,31 @@ QMap<QString, QmlIdSymbol*> QmlIdCollector::operator()(Qml::QmlDocument &doc)
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);
_currentSymbol = oldSymbol;
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);
_currentSymbol = oldSymbol;
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);
_currentSymbol = oldSymbol;
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 (ExpressionStatement *e = cast<ExpressionStatement*>(ast->statement))
@@ -84,9 +84,9 @@ bool QmlIdCollector::visit(QmlJS::AST::UiScriptBinding *ast)
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) {
newSymbol = _doc->findSymbol(node);
@@ -94,7 +94,7 @@ QmlSymbolFromFile *QmlIdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node
newSymbol = _currentSymbol->findMember(node);
}
QmlSymbolFromFile *oldSymbol = _currentSymbol;
SymbolFromFile *oldSymbol = _currentSymbol;
if (newSymbol) {
_currentSymbol = newSymbol;
@@ -106,7 +106,7 @@ QmlSymbolFromFile *QmlIdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node
return oldSymbol;
}
void QmlIdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
void IdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
{
if (!_currentSymbol)
return;
@@ -114,8 +114,8 @@ void QmlIdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
if (_ids.contains(id)) {
_diagnosticMessages.append(DiagnosticMessage(DiagnosticMessage::Warning, ast->statement->firstSourceLocation(), "Duplicate ID"));
} else {
if (QmlSymbolFromFile *symbol = _currentSymbol->findMember(ast))
if (QmlIdSymbol *idSymbol = symbol->asIdSymbol())
if (SymbolFromFile *symbol = _currentSymbol->findMember(ast))
if (IdSymbol *idSymbol = symbol->asIdSymbol())
_ids[id] = idSymbol;
}
}

View File

@@ -32,40 +32,40 @@
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/parser/qmljsengine_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljssymbol.h>
#include <QMap>
#include <QPair>
#include <QStack>
#include <QString>
namespace Qml {
namespace QmlJS {
namespace Internal {
class QML_EXPORT QmlIdCollector: protected QmlJS::AST::Visitor
class QMLJS_EXPORT IdCollector: protected AST::Visitor
{
public:
QMap<QString, Qml::QmlIdSymbol*> operator()(Qml::QmlDocument &doc);
QMap<QString, IdSymbol*> operator()(Document &doc);
QList<QmlJS::DiagnosticMessage> diagnosticMessages()
QList<DiagnosticMessage> diagnosticMessages()
{ return _diagnosticMessages; }
protected:
virtual bool visit(QmlJS::AST::UiArrayBinding *ast);
virtual bool visit(QmlJS::AST::UiObjectBinding *ast);
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
virtual bool visit(QmlJS::AST::UiScriptBinding *ast);
virtual bool visit(AST::UiArrayBinding *ast);
virtual bool visit(AST::UiObjectBinding *ast);
virtual bool visit(AST::UiObjectDefinition *ast);
virtual bool visit(AST::UiScriptBinding *ast);
private:
Qml::QmlSymbolFromFile *switchSymbol(QmlJS::AST::UiObjectMember *node);
void addId(const QString &id, QmlJS::AST::UiScriptBinding *ast);
SymbolFromFile *switchSymbol(AST::UiObjectMember *node);
void addId(const QString &id, AST::UiScriptBinding *ast);
private:
Qml::QmlDocument *_doc;
QMap<QString, Qml::QmlIdSymbol*> _ids;
Qml::QmlSymbolFromFile *_currentSymbol;
QList<QmlJS::DiagnosticMessage> _diagnosticMessages;
Document *_doc;
QMap<QString, IdSymbol*> _ids;
SymbolFromFile *_currentSymbol;
QList<DiagnosticMessage> _diagnosticMessages;
};
} // namespace Internal

View File

@@ -65,8 +65,8 @@
as comments and string literals are removed beforehand.
*/
#include <qmljs/qscriptindenter.h>
#include <qmljs/qscriptincrementalscanner.h>
#include <qmljs/qmljsindenter.h>
#include <qmljs/qmljsscanner.h>
#include <QtDebug>
@@ -80,10 +80,10 @@ using namespace QmlJS;
For example, the indenter never considers more than BigRoof lines
backwards when looking for the start of a C-style comment.
*/
const int QScriptIndenter::SmallRoof = 40;
const int QScriptIndenter::BigRoof = 400;
const int QmlJSIndenter::SmallRoof = 40;
const int QmlJSIndenter::BigRoof = 400;
QScriptIndenter::QScriptIndenter()
QmlJSIndenter::QmlJSIndenter()
: label(QRegExp(QLatin1String("^\\s*((?:case\\b([^:])+|[a-zA-Z_0-9.]+)(?:\\s+)?:)(?!:)"))),
braceX(QRegExp(QLatin1String("^\\s*\\}\\s*(?:else|catch)\\b"))),
iflikeKeyword(QRegExp(QLatin1String("\\b(?:catch|do|for|if|while|with)\\b")))
@@ -121,16 +121,16 @@ QScriptIndenter::QScriptIndenter()
yyLeftBraceFollows = 0;
}
QScriptIndenter::~QScriptIndenter()
QmlJSIndenter::~QmlJSIndenter()
{
}
void QScriptIndenter::setTabSize(int size)
void QmlJSIndenter::setTabSize(int size)
{
ppHardwareTabSize = size;
}
void QScriptIndenter::setIndentSize(int size)
void QmlJSIndenter::setIndentSize(int size)
{
ppIndentSize = size;
ppContinuationIndentSize = 2 * size;
@@ -140,7 +140,7 @@ void QScriptIndenter::setIndentSize(int size)
Returns the first non-space character in the string t, or
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;
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 false.
*/
bool QScriptIndenter::isOnlyWhiteSpace(const QString &t) const
bool QmlJSIndenter::isOnlyWhiteSpace(const QString &t) const
{
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
contain '\t's.
*/
int QScriptIndenter::columnForIndex(const QString &t, int index) const
int QmlJSIndenter::columnForIndex(const QString &t, int index) const
{
int col = 0;
if (index > t.length())
@@ -184,7 +184,7 @@ int QScriptIndenter::columnForIndex(const QString &t, int index) const
/*
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)));
}
@@ -195,7 +195,7 @@ int QScriptIndenter::indentOfLine(const QString &t) const
provisions are taken against '\n' or '\r', which shouldn't occur in
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'))
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
resulting line.
*/
QString QScriptIndenter::trimmedCodeLine(const QString &t)
QString QmlJSIndenter::trimmedCodeLine(const QString &t)
{
QScriptIncrementalScanner scanner;
QmlJSScanner scanner;
QTextBlock currentLine = yyLinizerState.iter;
int startState = qMax(0, currentLine.previous().userState()) & 0xff;
@@ -215,14 +215,14 @@ QString QScriptIndenter::trimmedCodeLine(const QString &t)
yyLinizerState.tokens = scanner(t, startState);
QString trimmed;
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));
if (token.is(QScriptIncrementalScanner::Token::String)) {
if (token.is(QmlJSScanner::Token::String)) {
for (int i = 0; i < token.length; ++i)
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)
trimmed.append(QLatin1Char(' '));
@@ -235,43 +235,43 @@ QString QScriptIndenter::trimmedCodeLine(const QString &t)
int index = yyLinizerState.tokens.size() - 1;
for (; index != -1; --index) {
const QScriptIncrementalScanner::Token &token = yyLinizerState.tokens.at(index);
if (token.isNot(QScriptIncrementalScanner::Token::Comment))
const QmlJSScanner::Token &token = yyLinizerState.tokens.at(index);
if (token.isNot(QmlJSScanner::Token::Comment))
break;
}
bool isBinding = false;
foreach (const QScriptIncrementalScanner::Token &token, yyLinizerState.tokens) {
if (token.is(QScriptIncrementalScanner::Token::Colon)) {
foreach (const QmlJSScanner::Token &token, yyLinizerState.tokens) {
if (token.is(QmlJSScanner::Token::Colon)) {
isBinding = true;
break;
}
}
if (index != -1) {
const QScriptIncrementalScanner::Token &last = yyLinizerState.tokens.at(index);
const QmlJSScanner::Token &last = yyLinizerState.tokens.at(index);
switch (last.kind) {
case QScriptIncrementalScanner::Token::LeftParenthesis:
case QScriptIncrementalScanner::Token::LeftBrace:
case QScriptIncrementalScanner::Token::Semicolon:
case QScriptIncrementalScanner::Token::Operator:
case QmlJSScanner::Token::LeftParenthesis:
case QmlJSScanner::Token::LeftBrace:
case QmlJSScanner::Token::Semicolon:
case QmlJSScanner::Token::Operator:
break;
case QScriptIncrementalScanner::Token::RightParenthesis:
case QScriptIncrementalScanner::Token::RightBrace:
case QmlJSScanner::Token::RightParenthesis:
case QmlJSScanner::Token::RightBrace:
if (isBinding)
trimmed.append(QLatin1Char(';'));
break;
case QScriptIncrementalScanner::Token::Colon:
case QScriptIncrementalScanner::Token::LeftBracket:
case QScriptIncrementalScanner::Token::RightBracket:
case QmlJSScanner::Token::Colon:
case QmlJSScanner::Token::LeftBracket:
case QmlJSScanner::Token::RightBracket:
trimmed.append(QLatin1Char(';'));
break;
case QScriptIncrementalScanner::Token::Identifier:
case QScriptIncrementalScanner::Token::Keyword:
case QmlJSScanner::Token::Identifier:
case QmlJSScanner::Token::Keyword:
if (t.midRef(last.offset, last.length) != QLatin1String("else"))
trimmed.append(QLatin1Char(';'));
break;
@@ -289,7 +289,7 @@ QString QScriptIndenter::trimmedCodeLine(const QString &t)
Returns '(' if the last parenthesis is opening, ')' if it is
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();
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 false.
*/
bool QScriptIndenter::okay(QChar typedIn, QChar okayCh) const
bool QmlJSIndenter::okay(QChar typedIn, QChar okayCh) const
{
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
constructs. Empty lines are skipped.
*/
bool QScriptIndenter::readLine()
bool QmlJSIndenter::readLine()
{
int k;
@@ -395,7 +395,7 @@ bool QScriptIndenter::readLine()
Resets the linizer to its initial state, with yyLine containing the
line above the bottom line of the program.
*/
void QScriptIndenter::startLinizer()
void QmlJSIndenter::startLinizer()
{
yyLinizerState.braceDepth = 0;
yyLinizerState.pendingRightBrace = false;
@@ -415,7 +415,7 @@ void QScriptIndenter::startLinizer()
potentially the whole line) is part of a C-style comment;
otherwise returns false.
*/
bool QScriptIndenter::bottomLineStartsInMultilineComment()
bool QmlJSIndenter::bottomLineStartsInMultilineComment()
{
QTextBlock currentLine = yyProgram.lastBlock().previous();
QTextBlock previousLine = currentLine.previous();
@@ -435,7 +435,7 @@ bool QScriptIndenter::bottomLineStartsInMultilineComment()
Essentially, we're trying to align against some text on the
previous line.
*/
int QScriptIndenter::indentWhenBottomLineStartsInMultiLineComment()
int QmlJSIndenter::indentWhenBottomLineStartsInMultiLineComment()
{
QTextBlock block = yyProgram.lastBlock().previous();
QString blockText;
@@ -468,7 +468,7 @@ int QScriptIndenter::indentWhenBottomLineStartsInMultiLineComment()
if (x)
y;
*/
bool QScriptIndenter::matchBracelessControlStatement()
bool QmlJSIndenter::matchBracelessControlStatement()
{
int delimDepth = 0;
@@ -553,7 +553,7 @@ bool QScriptIndenter::matchBracelessControlStatement()
f + // unfinished continuation line
g; // continuation line
*/
bool QScriptIndenter::isUnfinishedLine()
bool QmlJSIndenter::isUnfinishedLine()
{
bool unf = false;
@@ -600,7 +600,7 @@ bool QScriptIndenter::isUnfinishedLine()
Returns true if yyLine is a continuation line; otherwise returns
false.
*/
bool QScriptIndenter::isContinuationLine()
bool QmlJSIndenter::isContinuationLine()
{
bool cont = false;
@@ -619,7 +619,7 @@ bool QScriptIndenter::isContinuationLine()
or other bracked left opened on a previous line, or some interesting
operator such as '='.
*/
int QScriptIndenter::indentForContinuationLine()
int QmlJSIndenter::indentForContinuationLine()
{
int braceDepth = 0;
int delimDepth = 0;
@@ -863,7 +863,7 @@ int QScriptIndenter::indentForContinuationLine()
accommodate people with irregular indentation schemes. A hook line
near at hand is much more reliable than a remote one.
*/
int QScriptIndenter::indentForStandaloneLine()
int QmlJSIndenter::indentForStandaloneLine()
{
for (int i = 0; i < SmallRoof; i++) {
if (!*yyLeftBraceFollows) {
@@ -948,7 +948,7 @@ int QScriptIndenter::indentForStandaloneLine()
slighly more liberal if typedIn is always null. The user might be
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)
return 0;

View File

@@ -27,11 +27,11 @@
**
**************************************************************************/
#ifndef QTSCRIPTINDENTER_H
#define QTSCRIPTINDENTER_H
#ifndef QMLJSINDENTER_H
#define QMLJSINDENTER_H
#include <qmljs/qml_global.h>
#include <qmljs/qscriptincrementalscanner.h>
#include <qmljs/qmljs_global.h>
#include <qmljs/qmljsscanner.h>
#include <QtCore/QRegExp>
#include <QtCore/QStringList>
@@ -39,13 +39,13 @@
namespace QmlJS {
class QML_EXPORT QScriptIndenter
class QMLJS_EXPORT QmlJSIndenter
{
Q_DISABLE_COPY(QScriptIndenter)
Q_DISABLE_COPY(QmlJSIndenter)
public:
QScriptIndenter();
~QScriptIndenter();
QmlJSIndenter();
~QmlJSIndenter();
void setTabSize(int size);
void setIndentSize(int size);
@@ -103,7 +103,7 @@ private:
bool leftBraceFollows;
bool pendingRightBrace;
QString line;
QList<QScriptIncrementalScanner::Token> tokens;
QList<QmlJSScanner::Token> tokens;
QTextBlock iter;
};
@@ -136,5 +136,5 @@ private:
} // namespace QmlJS
#endif // QTSCRIPTINDENTER_H
#endif // QMLJSINDENTER_H

View File

@@ -27,17 +27,17 @@
**
**************************************************************************/
#include "qmlmetatypebackend.h"
#include "qmltypesystem.h"
#include "qmljsmetatypebackend.h"
#include "qmljstypesystem.h"
using namespace Qml;
using namespace QmlJS;
QmlMetaTypeBackend::QmlMetaTypeBackend(QmlTypeSystem *typeSystem):
MetaTypeBackend::MetaTypeBackend(TypeSystem *typeSystem):
m_typeSystem(typeSystem)
{
Q_ASSERT(typeSystem);
}
QmlMetaTypeBackend::~QmlMetaTypeBackend()
MetaTypeBackend::~MetaTypeBackend()
{
}

View File

@@ -30,29 +30,29 @@
#ifndef QMLMETATYPEBACKEND_H
#define QMLMETATYPEBACKEND_H
#include <qmljs/qml_global.h>
#include <qmljs/qmlpackageinfo.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljs_global.h>
#include <qmljs/qmljspackageinfo.h>
#include <qmljs/qmljssymbol.h>
namespace Qml {
namespace QmlJS {
class QmlTypeSystem;
class TypeSystem;
class QML_EXPORT QmlMetaTypeBackend
class QMLJS_EXPORT MetaTypeBackend
{
public:
QmlMetaTypeBackend(QmlTypeSystem *typeSystem);
virtual ~QmlMetaTypeBackend() = 0;
MetaTypeBackend(TypeSystem *typeSystem);
virtual ~MetaTypeBackend() = 0;
virtual QList<QmlSymbol *> availableTypes(const QString &package, int majorVersion, int minorVersion) = 0;
virtual QmlSymbol *resolve(const QString &typeName, const QList<PackageInfo> &packages) = 0;
virtual QList<Symbol *> availableTypes(const QString &package, int majorVersion, int minorVersion) = 0;
virtual Symbol *resolve(const QString &typeName, const QList<PackageInfo> &packages) = 0;
protected:
QmlTypeSystem *typeSystem() const
TypeSystem *typeSystem() const
{ return m_typeSystem; }
private:
QmlTypeSystem *m_typeSystem;
TypeSystem *m_typeSystem;
};
} // namespace Qml

View File

@@ -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):
m_name(name),

View File

@@ -30,13 +30,13 @@
#ifndef PACKAGEINFO_H
#define PACKAGEINFO_H
#include <qmljs/qml_global.h>
#include <qmljs/qmljs_global.h>
#include <QtCore/QString>
namespace Qml {
namespace QmlJS {
class QML_EXPORT PackageInfo
class QMLJS_EXPORT PackageInfo
{
public:
PackageInfo(const QString &name, int majorVersion, int minorVersion);

View File

@@ -27,28 +27,28 @@
**
**************************************************************************/
#include <qmljs/qscriptincrementalscanner.h>
#include <qmljs/qmljsscanner.h>
#include <QTextCharFormat>
using namespace QmlJS;
QScriptIncrementalScanner::QScriptIncrementalScanner()
QmlJSScanner::QmlJSScanner()
{
reset();
}
QScriptIncrementalScanner::~QScriptIncrementalScanner()
QmlJSScanner::~QmlJSScanner()
{}
void QScriptIncrementalScanner::reset()
void QmlJSScanner::reset()
{
m_endState = -1;
m_firstNonSpace = -1;
m_tokens.clear();
}
QList<QScriptIncrementalScanner::Token> QScriptIncrementalScanner::operator()(const QString &text, int startState)
QList<QmlJSScanner::Token> QmlJSScanner::operator()(const QString &text, int startState)
{
reset();
@@ -301,7 +301,7 @@ QList<QScriptIncrementalScanner::Token> QScriptIncrementalScanner::operator()(co
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) {
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;
@@ -348,7 +348,7 @@ void QScriptIncrementalScanner::insertCharToken(int start, const char c)
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) {
Token &t(m_tokens[i]);

View File

@@ -27,10 +27,10 @@
**
**************************************************************************/
#ifndef QSCRIPTINCREMENTALSCANNER_H
#define QSCRIPTINCREMENTALSCANNER_H
#ifndef QMLJSSCANNER_H
#define QMLJSSCANNER_H
#include <qmljs/qml_global.h>
#include <qmljs/qmljs_global.h>
#include <QtCore/QList>
#include <QtCore/QSet>
@@ -38,7 +38,7 @@
namespace QmlJS {
class QML_EXPORT QScriptIncrementalScanner
class QMLJS_EXPORT QmlJSScanner
{
public:
@@ -72,15 +72,15 @@ public:
};
public:
QScriptIncrementalScanner();
virtual ~QScriptIncrementalScanner();
QmlJSScanner();
virtual ~QmlJSScanner();
void setKeywords(const QSet<QString> keywords)
{ m_keywords = keywords;; }
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
{ return m_endState; }
@@ -88,7 +88,7 @@ public:
int firstNonSpace() const
{ return m_firstNonSpace; }
QList<QScriptIncrementalScanner::Token> tokens() const
QList<QmlJSScanner::Token> tokens() const
{ return m_tokens; }
private:
@@ -110,9 +110,9 @@ private:
QSet<QString> m_keywords;
int m_endState;
int m_firstNonSpace;
QList<QScriptIncrementalScanner::Token> m_tokens;
QList<QmlJSScanner::Token> m_tokens;
};
} // namespace QmlJS
#endif // QSCRIPTINCREMENTALSCANNER_H
#endif // QMLJSSCANNER_H

View File

@@ -27,56 +27,56 @@
**
**************************************************************************/
#include "qmlsymbol.h"
#include "qmljssymbol.h"
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
using namespace Qml;
using namespace QmlJS;
using namespace QmlJS;
using namespace QmlJS::AST;
QmlSymbol::~QmlSymbol()
Symbol::~Symbol()
{
}
bool QmlSymbol::isBuildInSymbol()
{ return asBuildInSymbol() != 0; }
bool Symbol::isBuildInSymbol()
{ return asPrimitiveSymbol() != 0; }
bool QmlSymbol::isSymbolFromFile()
bool Symbol::isSymbolFromFile()
{ return asSymbolFromFile() != 0; }
bool QmlSymbol::isIdSymbol()
bool Symbol::isIdSymbol()
{ return asIdSymbol() != 0; }
bool QmlSymbol::isPropertyDefinitionSymbol()
bool Symbol::isPropertyDefinitionSymbol()
{ return asPropertyDefinitionSymbol() != 0; }
QmlBuildInSymbol *QmlSymbol::asBuildInSymbol()
PrimitiveSymbol *Symbol::asPrimitiveSymbol()
{ return 0; }
QmlSymbolFromFile *QmlSymbol::asSymbolFromFile()
SymbolFromFile *Symbol::asSymbolFromFile()
{ return 0; }
QmlIdSymbol *QmlSymbol::asIdSymbol()
IdSymbol *Symbol::asIdSymbol()
{ return 0; }
QmlPropertyDefinitionSymbol *QmlSymbol::asPropertyDefinitionSymbol()
PropertyDefinitionSymbol *Symbol::asPropertyDefinitionSymbol()
{ return 0; }
QmlBuildInSymbol::~QmlBuildInSymbol()
PrimitiveSymbol::~PrimitiveSymbol()
{}
QmlBuildInSymbol *QmlBuildInSymbol::asBuildInSymbol()
PrimitiveSymbol *PrimitiveSymbol::asPrimitiveSymbol()
{ return this; }
QmlSymbolWithMembers::~QmlSymbolWithMembers()
SymbolWithMembers::~SymbolWithMembers()
{ qDeleteAll(_members); }
const QmlSymbol::List QmlSymbolWithMembers::members()
const Symbol::List SymbolWithMembers::members()
{ return _members; }
QmlSymbolFromFile::QmlSymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node):
SymbolFromFile::SymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node):
_fileName(fileName),
_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; }
int QmlSymbolFromFile::line() const
int SymbolFromFile::line() const
{ return _node->firstSourceLocation().startLine; }
int QmlSymbolFromFile::column() const
int SymbolFromFile::column() const
{ return _node->firstSourceLocation().startColumn; }
static inline QString toString(UiQualifiedId *qId)
@@ -126,7 +126,7 @@ static inline QString toString(UiQualifiedId *qId)
return result;
}
const QString QmlSymbolFromFile::name() const
const QString SymbolFromFile::name() const
{
if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(_node))
return toString(objectBinding->qualifiedId);
@@ -140,23 +140,23 @@ const QString QmlSymbolFromFile::name() const
return QString::null;
}
const QmlSymbol::List QmlSymbolFromFile::members()
const Symbol::List SymbolFromFile::members()
{
if (!todo.isEmpty()) {
foreach (Node *todoNode, todo) {
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))
_members.append(new QmlSymbolFromFile(fileName(), objectDefinition));
_members.append(new SymbolFromFile(fileName(), objectDefinition));
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))
_members.append(new QmlPropertyDefinitionSymbol(fileName(), publicMember));
_members.append(new PropertyDefinitionSymbol(fileName(), publicMember));
else if (UiScriptBinding *scriptBinding = cast<UiScriptBinding*>(todoNode)) {
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
_members.append(new QmlSymbolFromFile(fileName(), scriptBinding));
_members.append(new SymbolFromFile(fileName(), scriptBinding));
}
}
@@ -166,14 +166,14 @@ const QmlSymbol::List QmlSymbolFromFile::members()
return _members;
}
bool QmlSymbolFromFile::isProperty() const
bool SymbolFromFile::isProperty() const
{ return cast<UiObjectDefinition*>(_node) == 0; }
QmlSymbolFromFile *QmlSymbolFromFile::findMember(QmlJS::AST::Node *memberNode)
SymbolFromFile *SymbolFromFile::findMember(QmlJS::AST::Node *memberNode)
{
List symbols = members();
foreach (QmlSymbol *symbol, symbols)
foreach (Symbol *symbol, symbols)
if (symbol->isSymbolFromFile())
if (memberNode == symbol->asSymbolFromFile()->node())
return symbol->asSymbolFromFile();
@@ -181,24 +181,24 @@ QmlSymbolFromFile *QmlSymbolFromFile::findMember(QmlJS::AST::Node *memberNode)
return 0;
}
QmlIdSymbol::QmlIdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, QmlSymbolFromFile *parentNode):
QmlSymbolFromFile(fileName, idNode),
IdSymbol::IdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, SymbolFromFile *parentNode):
SymbolFromFile(fileName, idNode),
_parentNode(parentNode)
{}
QmlIdSymbol::~QmlIdSymbol()
IdSymbol::~IdSymbol()
{}
QmlIdSymbol *QmlIdSymbol::asIdSymbol()
IdSymbol *IdSymbol::asIdSymbol()
{ return this; }
int QmlIdSymbol::line() const
int IdSymbol::line() const
{ return idNode()->statement->firstSourceLocation().startLine; }
int QmlIdSymbol::column() const
int IdSymbol::column() const
{ return idNode()->statement->firstSourceLocation().startColumn; }
const QString QmlIdSymbol::id() const
const QString IdSymbol::id() const
{
if (ExpressionStatement *e = cast<ExpressionStatement*>(idNode()->statement))
if (IdentifierExpression *i = cast<IdentifierExpression*>(e->expression))
@@ -208,27 +208,27 @@ const QString QmlIdSymbol::id() const
return QString();
}
QmlJS::AST::UiScriptBinding *QmlIdSymbol::idNode() const
QmlJS::AST::UiScriptBinding *IdSymbol::idNode() const
{ return cast<UiScriptBinding*>(node()); }
QmlPropertyDefinitionSymbol::QmlPropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode):
QmlSymbolFromFile(fileName, propertyNode)
PropertyDefinitionSymbol::PropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode):
SymbolFromFile(fileName, propertyNode)
{}
QmlPropertyDefinitionSymbol::~QmlPropertyDefinitionSymbol()
PropertyDefinitionSymbol::~PropertyDefinitionSymbol()
{}
QmlPropertyDefinitionSymbol *QmlPropertyDefinitionSymbol::asPropertyDefinitionSymbol()
PropertyDefinitionSymbol *PropertyDefinitionSymbol::asPropertyDefinitionSymbol()
{ return this; }
int QmlPropertyDefinitionSymbol::line() const
int PropertyDefinitionSymbol::line() const
{ return propertyNode()->identifierToken.startLine; }
int QmlPropertyDefinitionSymbol::column() const
int PropertyDefinitionSymbol::column() const
{ return propertyNode()->identifierToken.startColumn; }
QmlJS::AST::UiPublicMember *QmlPropertyDefinitionSymbol::propertyNode() const
QmlJS::AST::UiPublicMember *PropertyDefinitionSymbol::propertyNode() const
{ return cast<UiPublicMember*>(node()); }
const QString QmlPropertyDefinitionSymbol::name() const
const QString PropertyDefinitionSymbol::name() const
{ return propertyNode()->name->asString(); }

View File

@@ -31,20 +31,20 @@
#define QMLSYMBOL_H
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/qml_global.h>
#include <qmljs/qmljs_global.h>
#include <QList>
#include <QString>
namespace Qml {
namespace QmlJS {
class QML_EXPORT QmlSymbol
class QMLJS_EXPORT Symbol
{
public:
typedef QList<QmlSymbol *> List;
typedef QList<Symbol *> List;
public:
virtual ~QmlSymbol() = 0;
virtual ~Symbol() = 0;
virtual const QString name() const = 0;
virtual const List members() = 0;
@@ -55,28 +55,28 @@ public:
bool isIdSymbol();
bool isPropertyDefinitionSymbol();
virtual class QmlBuildInSymbol *asBuildInSymbol();
virtual class QmlSymbolFromFile *asSymbolFromFile();
virtual class QmlIdSymbol *asIdSymbol();
virtual class QmlPropertyDefinitionSymbol *asPropertyDefinitionSymbol();
virtual class PrimitiveSymbol *asPrimitiveSymbol();
virtual class SymbolFromFile *asSymbolFromFile();
virtual class IdSymbol *asIdSymbol();
virtual class PropertyDefinitionSymbol *asPropertyDefinitionSymbol();
};
class QML_EXPORT QmlBuildInSymbol: public QmlSymbol
class QMLJS_EXPORT PrimitiveSymbol: public Symbol
{
public:
virtual ~QmlBuildInSymbol() = 0;
virtual ~PrimitiveSymbol() = 0;
virtual QmlBuildInSymbol *asBuildInSymbol();
virtual PrimitiveSymbol *asPrimitiveSymbol();
virtual QmlBuildInSymbol *type() const = 0;
using QmlSymbol::members;
virtual PrimitiveSymbol *type() const = 0;
using Symbol::members;
virtual List members(bool includeBaseClassMembers) = 0;
};
class QML_EXPORT QmlSymbolWithMembers: public QmlSymbol
class QMLJS_EXPORT SymbolWithMembers: public Symbol
{
public:
virtual ~QmlSymbolWithMembers() = 0;
virtual ~SymbolWithMembers() = 0;
virtual const List members();
@@ -84,13 +84,13 @@ protected:
List _members;
};
class QML_EXPORT QmlSymbolFromFile: public QmlSymbolWithMembers
class QMLJS_EXPORT SymbolFromFile: public SymbolWithMembers
{
public:
QmlSymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node);
virtual ~QmlSymbolFromFile();
SymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node);
virtual ~SymbolFromFile();
virtual QmlSymbolFromFile *asSymbolFromFile();
virtual SymbolFromFile *asSymbolFromFile();
QString fileName() const
{ return _fileName; }
@@ -104,7 +104,7 @@ public:
virtual const QString name() const;
virtual const List members();
virtual bool isProperty() const;
virtual QmlSymbolFromFile *findMember(QmlJS::AST::Node *memberNode);
virtual SymbolFromFile *findMember(QmlJS::AST::Node *memberNode);
private:
void fillTodo(QmlJS::AST::UiObjectMemberList *members);
@@ -115,18 +115,18 @@ private:
QList<QmlJS::AST::Node*> todo;
};
class QML_EXPORT QmlIdSymbol: public QmlSymbolFromFile
class QMLJS_EXPORT IdSymbol: public SymbolFromFile
{
public:
QmlIdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, QmlSymbolFromFile *parentNode);
virtual ~QmlIdSymbol();
IdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, SymbolFromFile *parentNode);
virtual ~IdSymbol();
QmlIdSymbol *asIdSymbol();
IdSymbol *asIdSymbol();
virtual int line() const;
virtual int column() const;
QmlSymbolFromFile *parentNode() const
SymbolFromFile *parentNode() const
{ return _parentNode; }
virtual const QString name() const
@@ -138,16 +138,16 @@ private:
QmlJS::AST::UiScriptBinding *idNode() const;
private:
QmlSymbolFromFile *_parentNode;
SymbolFromFile *_parentNode;
};
class QML_EXPORT QmlPropertyDefinitionSymbol: public QmlSymbolFromFile
class QMLJS_EXPORT PropertyDefinitionSymbol: public SymbolFromFile
{
public:
QmlPropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode);
virtual ~QmlPropertyDefinitionSymbol();
PropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode);
virtual ~PropertyDefinitionSymbol();
QmlPropertyDefinitionSymbol *asPropertyDefinitionSymbol();
PropertyDefinitionSymbol *asPropertyDefinitionSymbol();
virtual int line() const;
virtual int column() const;

View File

@@ -27,8 +27,8 @@
**
**************************************************************************/
#include "qmlmetatypebackend.h"
#include "qmltypesystem.h"
#include "qmljsmetatypebackend.h"
#include "qmljstypesystem.h"
#ifdef BUILD_DECLARATIVE_BACKEND
# include "qtdeclarativemetatypebackend.h"
@@ -36,34 +36,34 @@
#include <QDebug>
using namespace Qml;
using namespace QmlJS;
QmlTypeSystem::QmlTypeSystem()
TypeSystem::TypeSystem()
{
#ifdef BUILD_DECLARATIVE_BACKEND
backends.append(new Internal::QtDeclarativeMetaTypeBackend(this));
#endif // BUILD_DECLARATIVE_BACKEND
}
QmlTypeSystem::~QmlTypeSystem()
TypeSystem::~TypeSystem()
{
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));
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)
if (QmlSymbol *symbol = backend->resolve(typeName, packages))
foreach (MetaTypeBackend *backend, backends)
if (Symbol *symbol = backend->resolve(typeName, packages))
return symbol;
return 0;

View File

@@ -30,30 +30,30 @@
#ifndef QMLTYPESYSTEM_H
#define QMLTYPESYSTEM_H
#include <qmljs/qml_global.h>
#include <qmljs/qmlpackageinfo.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljs_global.h>
#include <qmljs/qmljspackageinfo.h>
#include <qmljs/qmljssymbol.h>
#include <QtCore/QList>
#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
public:
QmlTypeSystem();
virtual ~QmlTypeSystem();
TypeSystem();
virtual ~TypeSystem();
QList<QmlSymbol *> availableTypes(const QString &package, int majorVersion, int minorVersion);
QmlSymbol *resolve(const QString &typeName, const QList<PackageInfo> &packages);
QList<Symbol *> availableTypes(const QString &package, int majorVersion, int minorVersion);
Symbol *resolve(const QString &typeName, const QList<PackageInfo> &packages);
private:
QList<QmlMetaTypeBackend *> backends;
QList<MetaTypeBackend *> backends;
};
} // namespace Qml

View File

@@ -31,17 +31,17 @@
#include <QDebug>
namespace Qml {
namespace QmlJS {
namespace Internal {
class QmlDeclarativeSymbol: public QmlBuildInSymbol
class DeclarativeSymbol: public PrimitiveSymbol
{
public:
virtual ~QmlDeclarativeSymbol()
virtual ~DeclarativeSymbol()
{}
protected:
QmlDeclarativeSymbol(QtDeclarativeMetaTypeBackend* backend):
DeclarativeSymbol(QtDeclarativeMetaTypeBackend* backend):
m_backend(backend)
{ Q_ASSERT(backend); }
@@ -52,24 +52,24 @@ private:
QtDeclarativeMetaTypeBackend* m_backend;
};
class QmlDeclarativeObjectSymbol: public QmlDeclarativeSymbol
class DeclarativeObjectSymbol: public DeclarativeSymbol
{
QmlDeclarativeObjectSymbol(const QmlDeclarativeObjectSymbol &);
QmlDeclarativeObjectSymbol &operator=(const QmlDeclarativeObjectSymbol &);
DeclarativeObjectSymbol(const DeclarativeObjectSymbol &);
DeclarativeObjectSymbol &operator=(const DeclarativeObjectSymbol &);
public:
QmlDeclarativeObjectSymbol(QtDeclarativeMetaTypeBackend* backend):
QmlDeclarativeSymbol(backend)
DeclarativeObjectSymbol(QtDeclarativeMetaTypeBackend* backend):
DeclarativeSymbol(backend)
{
}
virtual ~QmlDeclarativeObjectSymbol()
virtual ~DeclarativeObjectSymbol()
{ qDeleteAll(m_members); }
virtual const QString name() const
{ return m_name; }
virtual QmlBuildInSymbol *type() const
virtual PrimitiveSymbol *type() const
{ return 0; }
virtual const List members()
@@ -114,24 +114,24 @@ private:
List m_members;
};
class QmlDeclarativePropertySymbol: public QmlDeclarativeSymbol
class DeclarativePropertySymbol: public DeclarativeSymbol
{
QmlDeclarativePropertySymbol(const QmlDeclarativePropertySymbol &);
QmlDeclarativePropertySymbol &operator=(const QmlDeclarativePropertySymbol &);
DeclarativePropertySymbol(const DeclarativePropertySymbol &);
DeclarativePropertySymbol &operator=(const DeclarativePropertySymbol &);
public:
QmlDeclarativePropertySymbol(QtDeclarativeMetaTypeBackend* backend):
QmlDeclarativeSymbol(backend)
DeclarativePropertySymbol(QtDeclarativeMetaTypeBackend* backend):
DeclarativeSymbol(backend)
{
}
virtual ~QmlDeclarativePropertySymbol()
virtual ~DeclarativePropertySymbol()
{}
virtual const QString name() const
{ return QString(); }
virtual QmlBuildInSymbol *type() const
virtual PrimitiveSymbol *type() const
{ return 0; }
virtual const List members()
@@ -153,11 +153,11 @@ private:
} // namespace Internal
} // namespace Qml
using namespace Qml;
using namespace Qml::Internal;
using namespace QmlJS;
using namespace QmlJS::Internal;
QtDeclarativeMetaTypeBackend::QtDeclarativeMetaTypeBackend(QmlTypeSystem *typeSystem):
QmlMetaTypeBackend(typeSystem)
QtDeclarativeMetaTypeBackend::QtDeclarativeMetaTypeBackend(TypeSystem *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;
}
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;

View File

@@ -30,37 +30,37 @@
#ifndef QTDECLARATIVEMETATYPEBACKEND_H
#define QTDECLARATIVEMETATYPEBACKEND_H
#include <qmljs/qmlmetatypebackend.h>
#include <qmljs/qmljsmetatypebackend.h>
#include <QtCore/QList>
namespace Qml {
namespace QmlJS {
namespace Internal {
class QmlDeclarativeSymbol;
class QmlDeclarativeObjectSymbol;
class QmlDeclarativePropertySymbol;
class DeclarativeSymbol;
class DeclarativeObjectSymbol;
class DeclarativePropertySymbol;
class QtDeclarativeMetaTypeBackend: public QmlMetaTypeBackend
class QtDeclarativeMetaTypeBackend: public MetaTypeBackend
{
friend class QmlDeclarativeSymbol;
friend class QmlDeclarativeObjectSymbol;
friend class QmlDeclarativePropertySymbol;
friend class DeclarativeSymbol;
friend class DeclarativeObjectSymbol;
friend class DeclarativePropertySymbol;
public:
QtDeclarativeMetaTypeBackend(QmlTypeSystem *typeSystem);
QtDeclarativeMetaTypeBackend(TypeSystem *typeSystem);
~QtDeclarativeMetaTypeBackend();
virtual QList<QmlSymbol *> availableTypes(const QString &package, int majorVersion, int minorVersion);
virtual QmlSymbol *resolve(const QString &typeName, const QList<PackageInfo> &packages);
virtual QList<Symbol *> availableTypes(const QString &package, int majorVersion, int minorVersion);
virtual Symbol *resolve(const QString &typeName, const QList<PackageInfo> &packages);
protected:
// QList<QmlSymbol *> members(const Qml::NodeMetaInfo &metaInfo);
// QList<QmlSymbol *> inheritedMembers(const Qml::NodeMetaInfo &metaInfo);
// QmlDeclarativeSymbol *typeOf(const Qml::PropertyMetaInfo &metaInfo);
// QList<QmlSymbol *> members(const QmlJS::NodeMetaInfo &metaInfo);
// QList<QmlSymbol *> inheritedMembers(const QmlJS::NodeMetaInfo &metaInfo);
// QmlDeclarativeSymbol *typeOf(const QmlJS::PropertyMetaInfo &metaInfo);
private:
// QmlDeclarativeSymbol *getSymbol(const Qml::NodeMetaInfo &metaInfo);
// QmlDeclarativeSymbol *getSymbol(const QmlJS::NodeMetaInfo &metaInfo);
private:
// QMap<QString, QmlDeclarativeSymbol*> m_symbols;

View File

@@ -31,12 +31,12 @@
#include <qmljs/parser/qmljsast_p.h>
using namespace Qml;
using namespace QmlJS;
using namespace QmlDesigner;
using namespace QmlJS::AST;
ASTObjectTextExtractor::ASTObjectTextExtractor(const QString &text):
m_document(QmlDocument::create("<ASTObjectTextExtractor>"))
m_document(Document::create("<ASTObjectTextExtractor>"))
{
m_document->setSource(text);
m_document->parseQml();

View File

@@ -31,7 +31,7 @@
#define ASTOBJECTTEXTEXTRACTOR_H
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmljsdocument.h>
#include <QtCore/QString>
@@ -49,7 +49,7 @@ protected:
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
private:
Qml::QmlDocument::Ptr m_document;
QmlJS::Document::Ptr m_document;
quint32 m_location;
QString m_text;
};

View File

@@ -31,12 +31,12 @@
#include <qmljs/parser/qmljsast_p.h>
using namespace Qml;
using namespace QmlJS;
using namespace QmlDesigner;
using namespace QmlJS::AST;
FirstDefinitionFinder::FirstDefinitionFinder(const QString &text):
m_doc(QmlDocument::create("<internal>"))
m_doc(Document::create("<internal>"))
{
m_doc->setSource(text);
bool ok = m_doc->parseQml();

View File

@@ -31,7 +31,7 @@
#define FIRSTDEFINITIONFINDER_H
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmljsdocument.h>
namespace QmlDesigner {
@@ -51,7 +51,7 @@ protected:
void extractFirstObjectDefinition(QmlJS::AST::UiObjectInitializer* ast);
private:
Qml::QmlDocument::Ptr m_doc;
QmlJS::Document::Ptr m_doc;
quint32 m_offset;
QmlJS::AST::UiObjectDefinition *m_firstObjectDefinition;

View File

@@ -31,12 +31,12 @@
#include <qmljs/parser/qmljsast_p.h>
using namespace Qml;
using namespace QmlJS;
using namespace QmlDesigner;
using namespace QmlJS::AST;
ObjectLengthCalculator::ObjectLengthCalculator(const QString &text):
m_doc(QmlDocument::create("<internal>"))
m_doc(Document::create("<internal>"))
{
m_doc->setSource(text);
bool ok = m_doc->parseQml();

View File

@@ -31,7 +31,7 @@
#define OBJECTLENGTHCALCULATOR_H
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmljsdocument.h>
namespace QmlDesigner {
@@ -49,7 +49,7 @@ protected:
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
private:
Qml::QmlDocument::Ptr m_doc;
QmlJS::Document::Ptr m_doc;
quint32 m_offset;
quint32 m_length;
};

View File

@@ -40,11 +40,11 @@
#include "removepropertyvisitor.h"
#include "removeuiobjectmembervisitor.h"
using namespace Qml;
using namespace QmlJS;
using namespace QmlDesigner;
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),
textModifier(&modifier),
m_propertyOrder(propertyOrder)
@@ -57,7 +57,7 @@ bool QmlRefactoring::reparseDocument()
// qDebug() << "QmlRefactoring::reparseDocument() new QML source:" << newSource;
QmlDocument::Ptr tmpDocument(QmlDocument::create("<ModelToTextMerger>"));
Document::Ptr tmpDocument(Document::create("<ModelToTextMerger>"));
tmpDocument->setSource(newSource);
if (tmpDocument->parseQml()) {

View File

@@ -32,7 +32,7 @@
#include <import.h>
#include <textmodifier.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmljsdocument.h>
#include <QSet>
#include <QString>
@@ -51,7 +51,7 @@ 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();
@@ -70,7 +70,7 @@ public:
bool removeProperty(int parentLocation, const QString &name);
private:
Qml::QmlDocument::Ptr qmlDocument;
QmlJS::Document::Ptr qmlDocument;
TextModifier *textModifier;
QStringList m_propertyOrder;
};

View File

@@ -33,7 +33,7 @@
#include "rewriteactioncompressor.h"
#include "rewriterview.h"
#include <qmljs/qmldocument.h>
#include <qmljs/qmljsdocument.h>
#include <variantproperty.h>
#include <nodelistproperty.h>
#include <nodeproperty.h>
@@ -44,7 +44,7 @@
#define INDENT_DEPTH 4
#undef DUMP_REWRITE_ACTIONS
using namespace Qml;
using namespace QmlJS;
using namespace QmlDesigner;
using namespace QmlDesigner::Internal;
@@ -199,7 +199,7 @@ void ModelToTextMerger::applyChanges()
if (m_rewriteActions.isEmpty())
return;
QmlDocument::Ptr tmpDocument(QmlDocument::create(QLatin1String("<ModelToTextMerger>")));
Document::Ptr tmpDocument(Document::create(QLatin1String("<ModelToTextMerger>")));
tmpDocument->setSource(m_rewriterView->textModifier()->text());
if (!tmpDocument->parseQml()) {
qDebug() << "*** Possible problem: QML file wasn't parsed correctly.";

View File

@@ -34,7 +34,7 @@
#include "qmllookupcontext.h"
#include "qmlresolveexpression.h"
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljssymbol.h>
#include <texteditor/basetexteditor.h>
#include <QtDebug>
@@ -42,7 +42,7 @@
using namespace QmlJSEditor;
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),
m_modelManager(modelManager),
m_editor(0),
@@ -90,7 +90,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
m_startPosition = pos;
m_completions.clear();
Qml::QmlDocument::Ptr qmlDocument = edit->qmlDocument();
QmlJS::Document::Ptr qmlDocument = edit->qmlDocument();
// qDebug() << "*** document:" << qmlDocument;
if (qmlDocument.isNull())
return pos;
@@ -112,10 +112,10 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
QmlLookupContext context(expressionUnderCursor.expressionScopes(), qmlDocument, m_modelManager->snapshot(), m_typeSystem);
QmlResolveExpression resolver(context);
// 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";
foreach (Qml::QmlSymbol *symbol, symbols) {
foreach (QmlJS::Symbol *symbol, symbols) {
QString word;
if (symbol->isIdSymbol()) {

View File

@@ -30,7 +30,7 @@
#ifndef QMLCODECOMPLETION_H
#define QMLCODECOMPLETION_H
#include <qmljs/qmltypesystem.h>
#include <qmljs/qmljstypesystem.h>
#include <texteditor/icompletioncollector.h>
namespace TextEditor {
@@ -48,7 +48,7 @@ class QmlCodeCompletion: public TextEditor::ICompletionCollector
Q_OBJECT
public:
QmlCodeCompletion(QmlModelManagerInterface *modelManager, Qml::QmlTypeSystem *typeSystem, QObject *parent = 0);
QmlCodeCompletion(QmlModelManagerInterface *modelManager, QmlJS::TypeSystem *typeSystem, QObject *parent = 0);
virtual ~QmlCodeCompletion();
Qt::CaseSensitivity caseSensitivity() const;
@@ -68,7 +68,7 @@ private:
int m_startPosition;
QList<TextEditor::CompletionItem> m_completions;
Qt::CaseSensitivity m_caseSensitivity;
Qml::QmlTypeSystem *m_typeSystem;
QmlJS::TypeSystem *m_typeSystem;
};

View File

@@ -38,7 +38,6 @@
#include <QDebug>
using namespace Qml;
using namespace QmlJS;
using namespace QmlJS::AST;
@@ -124,7 +123,7 @@ namespace QmlJSEditor {
class ScopeCalculator: protected Visitor
{
public:
QStack<QmlSymbol*> operator()(const QmlDocument::Ptr &doc, int pos)
QStack<Symbol*> operator()(const Document::Ptr &doc, int pos)
{
_doc = doc;
_pos = pos;
@@ -179,7 +178,7 @@ namespace QmlJSEditor {
private:
void push(Node *node)
{
QmlSymbolFromFile* symbol;
SymbolFromFile* symbol;
if (_currentSymbol) {
symbol = _currentSymbol->findMember(node);
@@ -196,10 +195,10 @@ namespace QmlJSEditor {
}
private:
QmlDocument::Ptr _doc;
Document::Ptr _doc;
quint32 _pos;
QStack<QmlSymbol*> _scopes;
QmlSymbolFromFile* _currentSymbol;
QStack<Symbol*> _scopes;
SymbolFromFile* _currentSymbol;
};
}
}
@@ -220,7 +219,7 @@ QmlExpressionUnderCursor::~QmlExpressionUnderCursor()
}
void QmlExpressionUnderCursor::operator()(const QTextCursor &cursor,
const QmlDocument::Ptr &doc)
const Document::Ptr &doc)
{
if (_engine) { delete _engine; _engine = 0; }
if (_nodePool) { delete _nodePool; _nodePool = 0; }

View File

@@ -31,8 +31,8 @@
#define QMLEXPRESSIONUNDERCURSOR_H
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljssymbol.h>
#include <QStack>
#include <QTextBlock>
@@ -52,9 +52,9 @@ public:
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; }
QmlJS::AST::Node *expressionNode() const
@@ -73,7 +73,7 @@ private:
QmlJS::AST::UiObjectMember *tryBinding(const QString &text);
private:
QStack<Qml::QmlSymbol *> _expressionScopes;
QStack<QmlJS::Symbol *> _expressionScopes;
QmlJS::AST::Node *_expressionNode;
int _expressionOffset;
int _expressionLength;

View File

@@ -30,7 +30,7 @@
#ifndef QMLSYNTAXHIGHLIGHTER_H
#define QMLSYNTAXHIGHLIGHTER_H
#include <qmljs/qscripthighlighter.h>
#include <qmljs/qmljshighlighter.h>
#include <texteditor/basetexteditor.h>
namespace QmlJSEditor {

View File

@@ -38,7 +38,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <debugger/debuggerconstants.h>
#include <extensionsystem/pluginmanager.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljssymbol.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
@@ -52,7 +52,7 @@
#include <QtHelp/QHelpEngineCore>
using namespace Core;
using namespace Qml;
using namespace QmlJS;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
@@ -128,7 +128,7 @@ void QmlHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int p
updateHelpIdAndTooltip(editor, pos);
}
static QString buildHelpId(QmlSymbol *symbol)
static QString buildHelpId(Symbol *symbol)
{
if (!symbol)
return QString();
@@ -152,7 +152,7 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
const Snapshot documents = m_modelManager->snapshot();
const QString fileName = editor->file()->fileName();
QmlDocument::Ptr doc = documents.value(fileName);
Document::Ptr doc = documents.value(fileName);
if (!doc)
return; // nothing to do
@@ -188,18 +188,18 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
QmlExpressionUnderCursor expressionUnderCursor;
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);
QmlResolveExpression resolver(context);
QmlSymbol *resolvedSymbol = resolver.typeOf(expressionUnderCursor.expressionNode());
Symbol *resolvedSymbol = resolver.typeOf(expressionUnderCursor.expressionNode());
if (resolvedSymbol) {
symbolName = resolvedSymbol->name();
if (resolvedSymbol->isBuildInSymbol())
m_helpId = buildHelpId(resolvedSymbol);
else if (QmlSymbolFromFile *symbolFromFile = resolvedSymbol->asSymbolFromFile())
else if (SymbolFromFile *symbolFromFile = resolvedSymbol->asSymbolFromFile())
m_toolTip = symbolFromFile->fileName();
}
}

View File

@@ -37,14 +37,14 @@
#include "qmllookupcontext.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/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmlidcollector.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsidcollector.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
@@ -74,7 +74,6 @@ enum {
UPDATE_USES_DEFAULT_INTERVAL = 150
};
using namespace Qml;
using namespace QmlJS;
using namespace QmlJS::AST;
@@ -359,11 +358,11 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
baseTextDocument()->setSyntaxHighlighter(new QmlHighlighter);
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) {
connect(m_modelManager, SIGNAL(documentUpdated(Qml::QmlDocument::Ptr)),
this, SLOT(onDocumentUpdated(Qml::QmlDocument::Ptr)));
connect(m_modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
}
}
@@ -415,7 +414,7 @@ void QmlJSTextEditor::updateDocumentNow()
m_modelManager->updateSourceFiles(QStringList() << fileName);
}
void QmlJSTextEditor::onDocumentUpdated(Qml::QmlDocument::Ptr doc)
void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
{
if (file()->fileName() != doc->fileName())
return;
@@ -617,13 +616,13 @@ bool QmlJSTextEditor::isElectricCharacter(const QChar &ch) const
return false;
}
bool QmlJSTextEditor::isClosingBrace(const QList<QScriptIncrementalScanner::Token> &tokens) const
bool QmlJSTextEditor::isClosingBrace(const QList<QmlJSScanner::Token> &tokens) const
{
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;
@@ -632,7 +631,7 @@ bool QmlJSTextEditor::isClosingBrace(const QList<QScriptIncrementalScanner::Toke
void QmlJSTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
{
TextEditor::TabSettings ts = tabSettings();
QScriptIndenter indenter;
QmlJSIndenter indenter;
indenter.setTabSize(ts.m_tabSize);
indenter.setIndentSize(ts.m_indentSize);
@@ -678,7 +677,7 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
return link;
const Snapshot snapshot = m_modelManager->snapshot();
QmlDocument::Ptr doc = snapshot.document(file()->fileName());
Document::Ptr doc = snapshot.document(file()->fileName());
if (!doc)
return link;
@@ -702,12 +701,12 @@ TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &
QmlLookupContext context(expressionUnderCursor.expressionScopes(), doc, snapshot, m_typeSystem);
QmlResolveExpression resolver(context);
QmlSymbol *symbol = resolver.typeOf(expressionUnderCursor.expressionNode());
Symbol *symbol = resolver.typeOf(expressionUnderCursor.expressionNode());
if (!symbol)
return link;
if (const QmlSymbolFromFile *target = symbol->asSymbolFromFile()) {
if (const SymbolFromFile *target = symbol->asSymbolFromFile()) {
link.pos = expressionUnderCursor.expressionOffset();
link.length = expressionUnderCursor.expressionLength();
link.fileName = target->fileName();
@@ -794,32 +793,32 @@ bool QmlJSTextEditor::contextAllowsAutoParentheses(const QTextCursor &cursor, co
const QString blockText = cursor.block().text();
const int blockState = blockStartState(cursor.block());
QScriptIncrementalScanner tokenize;
const QList<QScriptIncrementalScanner::Token> tokens = tokenize(blockText, blockState);
QmlJSScanner tokenize;
const QList<QmlJSScanner::Token> tokens = tokenize(blockText, blockState);
const int pos = cursor.columnNumber();
int tokenIndex = 0;
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.end())
break;
else if (pos == token.end() && (token.is(QScriptIncrementalScanner::Token::Comment) ||
token.is(QScriptIncrementalScanner::Token::String)))
else if (pos == token.end() && (token.is(QmlJSScanner::Token::Comment) ||
token.is(QmlJSScanner::Token::String)))
break;
}
}
if (tokenIndex != tokens.size()) {
const QScriptIncrementalScanner::Token &token = tokens.at(tokenIndex);
const QmlJSScanner::Token &token = tokens.at(tokenIndex);
switch (token.kind) {
case QScriptIncrementalScanner::Token::Comment:
case QmlJSScanner::Token::Comment:
return false;
case QScriptIncrementalScanner::Token::String: {
case QmlJSScanner::Token::String: {
const QStringRef tokenText = blockText.midRef(token.offset, token.length);
const QChar quote = tokenText.at(0);

View File

@@ -30,8 +30,8 @@
#ifndef QMLJSEDITOR_H
#define QMLJSEDITOR_H
#include <qmljs/qmldocument.h>
#include <qmljs/qscriptincrementalscanner.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsscanner.h>
#include <texteditor/basetexteditor.h>
QT_BEGIN_NAMESPACE
@@ -43,8 +43,8 @@ namespace Core {
class ICore;
}
namespace Qml {
class QmlTypeSystem;
namespace QmlJS {
class TypeSystem;
}
namespace QmlJSEditor {
@@ -109,13 +109,13 @@ public:
virtual void unCommentSelection();
Qml::QmlDocument::Ptr qmlDocument() const { return m_document; }
QmlJS::Document::Ptr qmlDocument() const { return m_document; }
public slots:
virtual void setFontSettings(const TextEditor::FontSettings &);
private slots:
void onDocumentUpdated(Qml::QmlDocument::Ptr doc);
void onDocumentUpdated(QmlJS::Document::Ptr doc);
void updateDocument();
void updateDocumentNow();
@@ -145,7 +145,7 @@ protected:
private:
virtual bool isElectricCharacter(const QChar &ch) const;
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;
@@ -158,9 +158,9 @@ private:
QMap<QString, QList<QmlJS::AST::SourceLocation> > m_ids; // ### use QMultiMap
int m_idsRevision;
QList<QmlJS::DiagnosticMessage> m_diagnosticMessages;
Qml::QmlDocument::Ptr m_document;
QmlJS::Document::Ptr m_document;
QmlModelManagerInterface *m_modelManager;
Qml::QmlTypeSystem *m_typeSystem;
QmlJS::TypeSystem *m_typeSystem;
QTextCharFormat m_occurrencesFormat;
};

View File

@@ -92,7 +92,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
m_modelManager = new QmlModelManager(this);
addAutoReleasedObject(m_modelManager);
Qml::QmlTypeSystem *typeSystem = new Qml::QmlTypeSystem;
QmlJS::TypeSystem *typeSystem = new QmlJS::TypeSystem;
addAutoReleasedObject(typeSystem);
QList<int> context;

View File

@@ -33,20 +33,19 @@
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
#include <qmljs/qmltypesystem.h>
#include <qmljs/qmljstypesystem.h>
#include <QDebug>
using namespace Qml;
using namespace QmlJS;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
using namespace QmlJS;
using namespace QmlJS::AST;
QmlLookupContext::QmlLookupContext(const QStack<QmlSymbol *> &scopes,
const QmlDocument::Ptr &doc,
QmlLookupContext::QmlLookupContext(const QStack<Symbol *> &scopes,
const Document::Ptr &doc,
const Snapshot &snapshot,
QmlTypeSystem *typeSystem):
TypeSystem *typeSystem):
_scopes(scopes),
_doc(doc),
_snapshot(snapshot),
@@ -55,13 +54,13 @@ QmlLookupContext::QmlLookupContext(const QStack<QmlSymbol *> &scopes,
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())
return -1;
for (int i = startIdx; i >= 0; --i) {
QmlSymbol *current = scopes.at(i);
Symbol *current = scopes.at(i);
if (current->isSymbolFromFile()) {
Node *node = current->asSymbolFromFile()->node();
@@ -75,7 +74,7 @@ static inline int findFirstQmlObjectScope(const QStack<QmlSymbol*> &scopes, int
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);
if (idx < 1)
@@ -89,14 +88,14 @@ static inline QmlSymbol *resolveParent(const QStack<QmlSymbol*> &scopes)
return scopes.at(idx);
}
QmlSymbol *QmlLookupContext::resolve(const QString &name)
Symbol *QmlLookupContext::resolve(const QString &name)
{
// find element type names
if (QmlSymbol *type = resolveType(name))
if (Symbol *type = resolveType(name))
return type;
// find ids
const QmlDocument::IdTable ids = _doc->ids();
const Document::IdTable ids = _doc->ids();
if (ids.contains(name))
return ids[name];
@@ -110,12 +109,12 @@ QmlSymbol *QmlLookupContext::resolve(const QString &name)
// find properties of the scope object
int scopeObjectIndex = findFirstQmlObjectScope(_scopes, _scopes.size() - 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;
// find properties of the component's root object
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;
// component chain
@@ -130,10 +129,10 @@ QmlSymbol *QmlLookupContext::resolve(const QString &name)
return 0;
}
QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fileName)
Symbol *QmlLookupContext::resolveType(const QString &name, const QString &fileName)
{
// TODO: handle import-as.
QmlDocument::Ptr document = _snapshot[fileName];
Document::Ptr document = _snapshot[fileName];
if (document.isNull())
return 0;
@@ -157,9 +156,9 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
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)) {
QmlDocument::Ptr importedDoc = importedTypes.value(name);
Document::Ptr importedDoc = importedTypes.value(name);
return importedDoc->symbols().at(0);
}
@@ -169,17 +168,17 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
return resolveBuildinType(name);
}
QmlSymbol *QmlLookupContext::resolveBuildinType(const QString &name)
Symbol *QmlLookupContext::resolveBuildinType(const QString &name)
{
QList<Qml::PackageInfo> packages;
QList<QmlJS::PackageInfo> packages;
// FIXME:
packages.append(PackageInfo("Qt", 4, 6));
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)
return symbol;
@@ -198,14 +197,14 @@ QmlSymbol *QmlLookupContext::resolveProperty(const QString &name, QmlSymbol *sco
if (typeName == 0)
return 0;
QmlSymbol *typeSymbol = resolveType(toString(typeName), fileName);
Symbol *typeSymbol = resolveType(toString(typeName), fileName);
if (!typeSymbol)
return 0;
if (typeSymbol->isSymbolFromFile()) {
return resolveProperty(name, typeSymbol->asSymbolFromFile(), typeSymbol->asSymbolFromFile()->fileName());
} else if (QmlBuildInSymbol *builtinSymbol = typeSymbol->asBuildInSymbol()) {
foreach (QmlSymbol *member, builtinSymbol->members(true)) {
} else if (PrimitiveSymbol *builtinSymbol = typeSymbol->asPrimitiveSymbol()) {
foreach (Symbol *member, builtinSymbol->members(true)) {
if (member->isProperty() && member->name() == name)
return member;
}
@@ -231,12 +230,12 @@ QString QmlLookupContext::toString(UiQualifiedId *id)
return str;
}
QList<QmlSymbol*> QmlLookupContext::visibleSymbolsInScope()
QList<Symbol*> QmlLookupContext::visibleSymbolsInScope()
{
QList<QmlSymbol*> result;
QList<Symbol*> result;
if (!_scopes.isEmpty()) {
QmlSymbol *scope = _scopes.top();
Symbol *scope = _scopes.top();
// add members defined in this symbol:
result.append(scope->members());
@@ -248,9 +247,9 @@ QList<QmlSymbol*> QmlLookupContext::visibleSymbolsInScope()
return result;
}
QList<QmlSymbol*> QmlLookupContext::visibleTypes()
QList<Symbol*> QmlLookupContext::visibleTypes()
{
QList<QmlSymbol*> result;
QList<Symbol*> result;
UiProgram *program = _doc->qmlProgram();
if (!program)
@@ -267,8 +266,8 @@ QList<QmlSymbol*> QmlLookupContext::visibleTypes()
// TODO: handle "import as".
const QMap<QString, QmlDocument::Ptr> types = _snapshot.componentsDefinedByImportedDocuments(_doc, path);
foreach (const QmlDocument::Ptr typeDoc, types) {
const QMap<QString, Document::Ptr> types = _snapshot.componentsDefinedByImportedDocuments(_doc, path);
foreach (const Document::Ptr typeDoc, types) {
result.append(typeDoc->symbols().at(0));
}
}
@@ -278,22 +277,22 @@ QList<QmlSymbol*> QmlLookupContext::visibleTypes()
return result;
}
QList<QmlSymbol*> QmlLookupContext::expandType(Qml::QmlSymbol *symbol)
QList<Symbol*> QmlLookupContext::expandType(QmlJS::Symbol *symbol)
{
if (symbol == 0) {
return QList<QmlSymbol*>();
} else if (QmlBuildInSymbol *buildInSymbol = symbol->asBuildInSymbol()) {
return QList<Symbol*>();
} else if (PrimitiveSymbol *buildInSymbol = symbol->asPrimitiveSymbol()) {
return buildInSymbol->members(true);
} else if (QmlSymbolFromFile *symbolFromFile = symbol->asSymbolFromFile()){
QList<QmlSymbol*> result;
} else if (SymbolFromFile *symbolFromFile = symbol->asSymbolFromFile()){
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(expandType(superTypeSymbol));
}
return result;
} else {
return QList<QmlSymbol*>();
return QList<Symbol*>();
}
}

View File

@@ -30,10 +30,10 @@
#ifndef QMLLOOKUPCONTEXT_H
#define QMLLOOKUPCONTEXT_H
#include <qmljs/qmltypesystem.h>
#include <qmljs/qmljstypesystem.h>
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljssymbol.h>
#include <QStack>
@@ -43,37 +43,37 @@ namespace Internal {
class QmlLookupContext
{
public:
QmlLookupContext(const QStack<Qml::QmlSymbol *> &scopes,
const Qml::QmlDocument::Ptr &doc,
const Qml::Snapshot &snapshot,
Qml::QmlTypeSystem *typeSystem);
QmlLookupContext(const QStack<QmlJS::Symbol *> &scopes,
const QmlJS::Document::Ptr &doc,
const QmlJS::Snapshot &snapshot,
QmlJS::TypeSystem *typeSystem);
Qml::QmlSymbol *resolve(const QString &name);
Qml::QmlSymbol *resolveType(const QString &name)
QmlJS::Symbol *resolve(const QString &name);
QmlJS::Symbol *resolveType(const QString &name)
{ 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()); }
Qml::QmlDocument::Ptr document() const
QmlJS::Document::Ptr document() const
{ return _doc; }
QList<Qml::QmlSymbol*> visibleSymbolsInScope();
QList<Qml::QmlSymbol*> visibleTypes();
QList<QmlJS::Symbol*> visibleSymbolsInScope();
QList<QmlJS::Symbol*> visibleTypes();
QList<Qml::QmlSymbol*> expandType(Qml::QmlSymbol *symbol);
QList<QmlJS::Symbol*> expandType(QmlJS::Symbol *symbol);
private:
Qml::QmlSymbol *resolveType(const QString &name, const QString &fileName);
Qml::QmlSymbol *resolveProperty(const QString &name, Qml::QmlSymbol *scope, const QString &fileName);
Qml::QmlSymbol *resolveBuildinType(const QString &name);
QmlJS::Symbol *resolveType(const QString &name, const QString &fileName);
QmlJS::Symbol *resolveProperty(const QString &name, QmlJS::Symbol *scope, const QString &fileName);
QmlJS::Symbol *resolveBuildinType(const QString &name);
static QString toString(QmlJS::AST::UiQualifiedId *id);
private:
QStack<Qml::QmlSymbol *> _scopes;
Qml::QmlDocument::Ptr _doc;
Qml::Snapshot _snapshot;
Qml::QmlTypeSystem *m_typeSystem;
QStack<QmlJS::Symbol *> _scopes;
QmlJS::Document::Ptr _doc;
QmlJS::Snapshot _snapshot;
QmlJS::TypeSystem *m_typeSystem;
};
} // namespace Internal

View File

@@ -51,13 +51,13 @@ QmlModelManager::QmlModelManager(QObject *parent):
{
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)),
this, SLOT(onDocumentUpdated(Qml::QmlDocument::Ptr)));
connect(this, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
}
Qml::Snapshot QmlModelManager::snapshot() const
QmlJS::Snapshot QmlModelManager::snapshot() const
{
QMutexLocker locker(&m_mutex);
@@ -118,10 +118,10 @@ QMap<QString, QString> QmlModelManager::buildWorkingCopyList()
return workingCopy;
}
void QmlModelManager::emitDocumentUpdated(Qml::QmlDocument::Ptr doc)
void QmlModelManager::emitDocumentUpdated(QmlJS::Document::Ptr doc)
{ emit documentUpdated(doc); }
void QmlModelManager::onDocumentUpdated(Qml::QmlDocument::Ptr doc)
void QmlModelManager::onDocumentUpdated(QmlJS::Document::Ptr doc)
{
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);
{

View File

@@ -32,7 +32,7 @@
#include "qmlmodelmanagerinterface.h"
#include <qmljs/qmldocument.h>
#include <qmljs/qmljsdocument.h>
#include <QFuture>
#include <QFutureSynchronizer>
@@ -52,10 +52,10 @@ class QmlModelManager: public QmlModelManagerInterface
public:
QmlModelManager(QObject *parent = 0);
virtual Qml::Snapshot snapshot() const;
virtual QmlJS::Snapshot snapshot() const;
virtual void updateSourceFiles(const QStringList &files);
void emitDocumentUpdated(Qml::QmlDocument::Ptr doc);
void emitDocumentUpdated(QmlJS::Document::Ptr doc);
Q_SIGNALS:
void projectPathChanged(const QString &projectPath);
@@ -63,7 +63,7 @@ Q_SIGNALS:
private Q_SLOTS:
// this should be executed in the GUI thread.
void onDocumentUpdated(Qml::QmlDocument::Ptr doc);
void onDocumentUpdated(QmlJS::Document::Ptr doc);
protected:
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
@@ -77,7 +77,7 @@ protected:
private:
mutable QMutex m_mutex;
Core::ICore *m_core;
Qml::Snapshot _snapshot;
QmlJS::Snapshot _snapshot;
QFutureSynchronizer<void> m_synchronizer;
};

View File

@@ -32,14 +32,14 @@
#include "qmljseditor_global.h"
#include <qmljs/qmldocument.h>
#include <qmljs/qmltypesystem.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljstypesystem.h>
#include <QObject>
#include <QStringList>
#include <QSharedPointer>
namespace Qml {
namespace QmlJS {
class Snapshot;
}
@@ -53,11 +53,11 @@ public:
QmlModelManagerInterface(QObject *parent = 0);
virtual ~QmlModelManagerInterface();
virtual Qml::Snapshot snapshot() const = 0;
virtual QmlJS::Snapshot snapshot() const = 0;
virtual void updateSourceFiles(const QStringList &files) = 0;
signals:
void documentUpdated(Qml::QmlDocument::Ptr doc);
void documentUpdated(QmlJS::Document::Ptr doc);
};
} // namespace QmlJSEditor

View File

@@ -32,7 +32,6 @@
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
using namespace Qml;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
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);
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->isIdSymbol())
symbol = symbol->asIdSymbol()->parentNode();
@@ -66,7 +65,7 @@ QList<QmlSymbol*> QmlResolveExpression::visibleSymbols(Node *node)
}
if (node) {
foreach (QmlIdSymbol *idSymbol, _context.document()->ids().values())
foreach (IdSymbol *idSymbol, _context.document()->ids().values())
result.append(idSymbol);
}
@@ -75,9 +74,9 @@ QList<QmlSymbol*> QmlResolveExpression::visibleSymbols(Node *node)
return result;
}
QmlSymbol *QmlResolveExpression::switchValue(QmlSymbol *value)
Symbol *QmlResolveExpression::switchValue(Symbol *value)
{
QmlSymbol *previousValue = _value;
Symbol *previousValue = _value;
_value = value;
return previousValue;
}
@@ -107,7 +106,7 @@ bool QmlResolveExpression::visit(FieldMemberExpression *ast)
{
const QString memberName = ast->name->asString();
QmlSymbol *base = typeOf(ast->base);
Symbol *base = typeOf(ast->base);
if (!base)
return false;
@@ -117,7 +116,7 @@ bool QmlResolveExpression::visit(FieldMemberExpression *ast)
if (!base)
return false;
foreach (QmlSymbol *memberSymbol, base->members())
foreach (Symbol *memberSymbol, base->members())
if (memberSymbol->name() == memberName)
_value = memberSymbol;

View File

@@ -33,7 +33,7 @@
#include "qmllookupcontext.h"
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/qmlsymbol.h>
#include <qmljs/qmljssymbol.h>
namespace QmlJSEditor {
namespace Internal {
@@ -43,13 +43,13 @@ class QmlResolveExpression: protected QmlJS::AST::Visitor
public:
QmlResolveExpression(const QmlLookupContext &context);
Qml::QmlSymbol *typeOf(QmlJS::AST::Node *node);
QList<Qml::QmlSymbol*> visibleSymbols(QmlJS::AST::Node *node);
QmlJS::Symbol *typeOf(QmlJS::AST::Node *node);
QList<QmlJS::Symbol*> visibleSymbols(QmlJS::AST::Node *node);
protected:
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::IdentifierExpression *ast);
@@ -57,7 +57,7 @@ protected:
private:
QmlLookupContext _context;
Qml::QmlSymbol *_value;
QmlJS::Symbol *_value;
};
} // namespace Internal

View File

@@ -100,8 +100,8 @@ void QmlProjectPlugin::extensionsInitialized()
QmlJSEditor::QmlModelManagerInterface *modelManager = pluginManager->getObject<QmlJSEditor::QmlModelManagerInterface>();
Q_ASSERT(modelManager);
connect(modelManager, SIGNAL(documentUpdated(Qml::QmlDocument::Ptr)),
m_qmlTaskManager, SLOT(documentUpdated(Qml::QmlDocument::Ptr)));
connect(modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
m_qmlTaskManager, SLOT(documentUpdated(QmlJS::Document::Ptr)));
}
Q_EXPORT_PLUGIN(QmlProjectPlugin)

View File

@@ -48,7 +48,7 @@ void QmlTaskManager::setTaskWindow(ProjectExplorer::TaskWindow *taskWindow)
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*
m_taskWindow->clearTasks(Constants::TASK_CATEGORY_QML);

View File

@@ -31,7 +31,7 @@
#define QMLTASKMANAGER_H
#include <projectexplorer/taskwindow.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmljsdocument.h>
#include <QtCore/QObject>
@@ -46,7 +46,7 @@ public:
void setTaskWindow(ProjectExplorer::TaskWindow *taskWindow);
public slots:
void documentUpdated(Qml::QmlDocument::Ptr doc);
void documentUpdated(QmlJS::Document::Ptr doc);
private:
ProjectExplorer::TaskWindow *m_taskWindow;

View File

@@ -3,14 +3,13 @@
#include <QObject>
#include <QFile>
#include <qmljs/qmldocument.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmllookupcontext.h>
#include <typeinfo>
using namespace Qml;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
using namespace QmlJS;
@@ -35,10 +34,10 @@ private Q_SLOTS:
void localRootLookup();
protected:
QmlDocument::Ptr basicSymbolTest(const QString &input) const
Document::Ptr basicSymbolTest(const QString &input) const
{
const QLatin1String filename("<lookup test>");
QmlDocument::Ptr doc = QmlDocument::create(filename);
Document::Ptr doc = Document::create(filename);
doc->setSource(input);
doc->parseQml();
@@ -56,21 +55,21 @@ protected:
return doc;
}
Snapshot snapshot(const QmlDocument::Ptr &doc) const
Snapshot snapshot(const Document::Ptr &doc) const
{
Snapshot snapshot;
snapshot.insert(doc);
return snapshot;
}
QmlTypeSystem *typeSystem() {
TypeSystem *typeSystem() {
if (!_typeSystem)
_typeSystem = new QmlTypeSystem;
_typeSystem = new TypeSystem;
return _typeSystem;
}
private:
QmlTypeSystem *_typeSystem;
TypeSystem *_typeSystem;
};
void tst_Lookup::basicSymbolTest()
@@ -86,7 +85,7 @@ void tst_Lookup::basicSymbolTest()
"}\n"
);
QmlDocument::Ptr doc = basicSymbolTest(input);
Document::Ptr doc = basicSymbolTest(input);
QVERIFY(doc->isParsedCorrectly());
UiProgram *program = doc->qmlProgram();
@@ -108,16 +107,16 @@ void tst_Lookup::basicSymbolTest()
QVERIFY(xBinding->qualifiedId->name);
QCOMPARE(xBinding->qualifiedId->name->asString(), QLatin1String("x"));
QmlSymbol::List docSymbols = doc->symbols();
Symbol::List docSymbols = doc->symbols();
QCOMPARE(docSymbols.size(), 1);
QmlSymbol *rectSymbol = docSymbols.at(0);
Symbol *rectSymbol = docSymbols.at(0);
QCOMPARE(rectSymbol->name(), QLatin1String("Rectangle"));
QCOMPARE(rectSymbol->members().size(), 4);
QmlSymbolFromFile *rectFromFile = rectSymbol->asSymbolFromFile();
SymbolFromFile *rectFromFile = rectSymbol->asSymbolFromFile();
QVERIFY(rectFromFile);
QmlSymbolFromFile *xSymbol = rectFromFile->findMember(xBinding);
SymbolFromFile *xSymbol = rectFromFile->findMember(xBinding);
QVERIFY(xSymbol);
QCOMPARE(xSymbol->name(), QLatin1String("x"));
}
@@ -129,26 +128,26 @@ void tst_Lookup::basicLookupTest()
"Item{}\n"
);
QmlDocument::Ptr doc = basicSymbolTest(input);
Document::Ptr doc = basicSymbolTest(input);
QVERIFY(doc->isParsedCorrectly());
UiProgram *program = doc->qmlProgram();
QVERIFY(program);
QStack<QmlSymbol *> emptyScope;
QStack<Symbol *> emptyScope;
QmlLookupContext context(emptyScope, doc, snapshot(doc), typeSystem());
QmlSymbol *rectSymbol = context.resolveType(QLatin1String("Text"));
Symbol *rectSymbol = context.resolveType(QLatin1String("Text"));
QVERIFY(rectSymbol);
QmlBuildInSymbol *buildInRect = rectSymbol->asBuildInSymbol();
PrimitiveSymbol *buildInRect = rectSymbol->asPrimitiveSymbol();
QVERIFY(buildInRect);
QCOMPARE(buildInRect->name(), QLatin1String("Text"));
QmlSymbol::List allBuildInRectMembers = buildInRect->members(true);
Symbol::List allBuildInRectMembers = buildInRect->members(true);
QVERIFY(!allBuildInRectMembers.isEmpty());
bool xPropFound = false;
bool fontPropFound = false;
foreach (QmlSymbol *symbol, allBuildInRectMembers) {
foreach (Symbol *symbol, allBuildInRectMembers) {
if (symbol->name() == QLatin1String("x"))
xPropFound = true;
else if (symbol->name() == QLatin1String("font"))
@@ -157,12 +156,12 @@ void tst_Lookup::basicLookupTest()
QVERIFY(xPropFound);
QVERIFY(fontPropFound);
QmlSymbol::List buildInRectMembers = buildInRect->members(false);
Symbol::List buildInRectMembers = buildInRect->members(false);
QVERIFY(!buildInRectMembers.isEmpty());
QSKIP("Getting properties _without_ the inerited properties doesn't work.", SkipSingle);
fontPropFound = false;
foreach (QmlSymbol *symbol, buildInRectMembers) {
foreach (Symbol *symbol, buildInRectMembers) {
if (symbol->name() == QLatin1String("x"))
QFAIL("Text has x property");
else if (symbol->name() == QLatin1String("font"))
@@ -176,7 +175,7 @@ void tst_Lookup::localIdLookup()
QFile input(":/data/localIdLookup.qml");
QVERIFY(input.open(QIODevice::ReadOnly));
QmlDocument::Ptr doc = basicSymbolTest(input.readAll());
Document::Ptr doc = basicSymbolTest(input.readAll());
QVERIFY(doc->isParsedCorrectly());
QStringList symbolNames;
@@ -192,17 +191,17 @@ void tst_Lookup::localIdLookup()
}
// try lookup
QStack<QmlSymbol *> scopes;
QStack<Symbol *> scopes;
foreach (const QString &contextSymbolName, symbolNames) {
scopes.push_back(doc->ids()[contextSymbolName]->parentNode());
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
foreach (const QString &lookupSymbolName, symbolNames) {
QmlSymbol *resolvedSymbol = context.resolve(lookupSymbolName);
QmlIdSymbol *targetSymbol = doc->ids()[lookupSymbolName];
Symbol *resolvedSymbol = context.resolve(lookupSymbolName);
IdSymbol *targetSymbol = doc->ids()[lookupSymbolName];
QCOMPARE(resolvedSymbol, targetSymbol);
QmlIdSymbol *resolvedId = resolvedSymbol->asIdSymbol();
IdSymbol *resolvedId = resolvedSymbol->asIdSymbol();
QVERIFY(resolvedId);
QCOMPARE(resolvedId->parentNode(), targetSymbol->parentNode());
}
@@ -214,7 +213,7 @@ void tst_Lookup::localScriptMethodLookup()
QFile input(":/data/localScriptMethodLookup.qml");
QVERIFY(input.open(QIODevice::ReadOnly));
QmlDocument::Ptr doc = basicSymbolTest(input.readAll());
Document::Ptr doc = basicSymbolTest(input.readAll());
QVERIFY(doc->isParsedCorrectly());
QStringList symbolNames;
@@ -233,13 +232,13 @@ void tst_Lookup::localScriptMethodLookup()
}
// try lookup
QStack<QmlSymbol *> scopes;
QStack<Symbol *> scopes;
foreach (const QString &contextSymbolName, symbolNames) {
scopes.push_back(doc->ids()[contextSymbolName]->parentNode());
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
foreach (const QString &functionName, functionNames) {
QmlSymbol *symbol = context.resolve(functionName);
Symbol *symbol = context.resolve(functionName);
QVERIFY(symbol);
QVERIFY(!symbol->isProperty());
// verify that it's a function
@@ -252,7 +251,7 @@ void tst_Lookup::localScopeLookup()
QFile input(":/data/localScopeLookup.qml");
QVERIFY(input.open(QIODevice::ReadOnly));
QmlDocument::Ptr doc = basicSymbolTest(input.readAll());
Document::Ptr doc = basicSymbolTest(input.readAll());
QVERIFY(doc->isParsedCorrectly());
QStringList symbolNames;
@@ -266,13 +265,13 @@ void tst_Lookup::localScopeLookup()
}
// try lookup
QStack<QmlSymbol *> scopes;
QStack<Symbol *> scopes;
foreach (const QString &contextSymbolName, symbolNames) {
QmlSymbol *parent = doc->ids()[contextSymbolName]->parentNode();
Symbol *parent = doc->ids()[contextSymbolName]->parentNode();
scopes.push_back(parent);
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
QmlSymbol *symbol;
Symbol *symbol;
symbol = context.resolve("prop");
QVERIFY(symbol);
QVERIFY(symbol->isPropertyDefinitionSymbol());
@@ -290,7 +289,7 @@ void tst_Lookup::localRootLookup()
QFile input(":/data/localRootLookup.qml");
QVERIFY(input.open(QIODevice::ReadOnly));
QmlDocument::Ptr doc = basicSymbolTest(input.readAll());
Document::Ptr doc = basicSymbolTest(input.readAll());
QVERIFY(doc->isParsedCorrectly());
QStringList symbolNames;
@@ -299,18 +298,18 @@ void tst_Lookup::localRootLookup()
symbolNames.append("theChild");
// check symbol existence and build scopes
QStack<QmlSymbol *> scopes;
QStack<Symbol *> scopes;
foreach (const QString &symbolName, symbolNames) {
QmlIdSymbol *id = doc->ids()[symbolName];
IdSymbol *id = doc->ids()[symbolName];
QVERIFY(id);
scopes.push_back(id->parentNode());
}
// try lookup
QmlSymbol *parent = scopes.front();
Symbol *parent = scopes.front();
QmlLookupContext context(scopes, doc, snapshot(doc), typeSystem());
QmlSymbol *symbol;
Symbol *symbol;
symbol = context.resolve("prop");
QVERIFY(symbol);
QVERIFY(symbol->isPropertyDefinitionSymbol());