Commit 39c2575a authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Removed obsolete code

Done with: Erik
parent d89b7ecb
......@@ -16,36 +16,19 @@ HEADERS += \
$$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 \
$$PWD/qmljsinterpreter.h \
$$PWD/qmljsmetatypesystem.h
$$PWD/qmljsinterpreter.h
SOURCES += \
$$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 \
$$PWD/qmljsinterpreter.cpp \
$$PWD/qmljsmetatypesystem.cpp
contains(QT_CONFIG, declarative) {
QT += declarative
HEADERS += \
$$PWD/qtdeclarativemetatypebackend.h
SOURCES += \
$$PWD/qtdeclarativemetatypebackend.cpp
} else {
DEFINES += NO_DECLARATIVE_BACKEND
}
......
......@@ -27,7 +27,6 @@
**
**************************************************************************/
#include "qmljsidcollector.h"
#include "qmljsdocument.h"
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljslexer_p.h>
......@@ -70,8 +69,6 @@ Document::~Document()
if (_pool)
delete _pool;
qDeleteAll(_symbols);
}
Document::Ptr Document::create(const QString &fileName)
......@@ -136,7 +133,6 @@ bool Document::parseQml()
_engine = new Engine();
_pool = new NodePool(_fileName, _engine);
_ids.clear();
Lexer lexer(_engine);
Parser parser(_engine);
......@@ -147,17 +143,6 @@ bool Document::parseQml()
_ast = parser.ast();
_diagnosticMessages = parser.diagnosticMessages();
if (qmlProgram()) {
for (QmlJS::AST::UiObjectMemberList *iter = qmlProgram()->members; iter; iter = iter->next)
if (iter->member)
_symbols.append(new SymbolFromFile(_fileName, iter->member));
Internal::IdCollector collect;
_ids = collect(*this);
if (_diagnosticMessages.isEmpty())
_diagnosticMessages = collect.diagnosticMessages();
}
return _parsedCorrectly;
}
......@@ -169,7 +154,6 @@ bool Document::parseJavaScript()
_engine = new Engine();
_pool = new NodePool(_fileName, _engine);
_ids.clear();
Lexer lexer(_engine);
Parser parser(_engine);
......@@ -191,7 +175,6 @@ bool Document::parseExpression()
_engine = new Engine();
_pool = new NodePool(_fileName, _engine);
_ids.clear();
Lexer lexer(_engine);
Parser parser(_engine);
......@@ -207,16 +190,6 @@ bool Document::parseExpression()
return _parsedCorrectly;
}
SymbolFromFile *Document::findSymbol(QmlJS::AST::Node *node) const
{
foreach (Symbol *symbol, _symbols)
if (symbol->isSymbolFromFile())
if (symbol->asSymbolFromFile()->node() == node)
return symbol->asSymbolFromFile();
return 0;
}
Snapshot::Snapshot()
{
}
......
......@@ -37,7 +37,6 @@
#include "parser/qmljsengine_p.h"
#include "qmljs_global.h"
#include "qmljssymbol.h"
namespace QmlJS {
......@@ -46,7 +45,6 @@ class QMLJS_EXPORT Document
public:
typedef QSharedPointer<Document> Ptr;
typedef QList<Document::Ptr> PtrList;
typedef QMap<QString, IdSymbol*> IdTable;
protected:
Document(const QString &fileName);
......@@ -76,16 +74,10 @@ public:
int documentRevision() const;
void setDocumentRevision(int documentRevision);
IdTable ids() const { return _ids; }
QString fileName() const { return _fileName; }
QString path() const { return _path; }
QString componentName() const { return _componentName; }
QmlJS::SymbolFromFile *findSymbol(QmlJS::AST::Node *node) const;
QmlJS::Symbol::List symbols() const
{ return _symbols; }
private:
QmlJS::Engine *_engine;
QmlJS::NodePool *_pool;
......@@ -97,8 +89,6 @@ private:
QString _path;
QString _componentName;
QString _source;
IdTable _ids;
QmlJS::Symbol::List _symbols;
};
class QMLJS_EXPORT Snapshot
......
/**************************************************************************
**
** 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 <QDebug>
#include <qmljs/parser/qmljsast_p.h>
#include "qmljsidcollector.h"
using namespace QmlJS;
using namespace QmlJS::AST;
using namespace QmlJS;
using namespace QmlJS::Internal;
QMap<QString, IdSymbol*> IdCollector::operator()(QmlJS::Document &doc)
{
_doc = &doc;
_ids.clear();
_currentSymbol = 0;
Node::accept(doc.qmlProgram(), this);
return _ids;
}
bool IdCollector::visit(UiArrayBinding *ast)
{
SymbolFromFile *oldSymbol = switchSymbol(ast);
Node::accept(ast->members, this);
_currentSymbol = oldSymbol;
return false;
}
bool IdCollector::visit(QmlJS::AST::UiObjectBinding *ast)
{
SymbolFromFile *oldSymbol = switchSymbol(ast);
Node::accept(ast->initializer, this);
_currentSymbol = oldSymbol;
return false;
}
bool IdCollector::visit(QmlJS::AST::UiObjectDefinition *ast)
{
SymbolFromFile *oldSymbol = switchSymbol(ast);
Node::accept(ast->initializer, this);
_currentSymbol = oldSymbol;
return false;
}
bool IdCollector::visit(QmlJS::AST::UiScriptBinding *ast)
{
if (!(ast->qualifiedId->next) && ast->qualifiedId->name->asString() == "id")
if (ExpressionStatement *e = cast<ExpressionStatement*>(ast->statement))
if (IdentifierExpression *i = cast<IdentifierExpression*>(e->expression))
if (i->name)
addId(i->name->asString(), ast);
return false;
}
SymbolFromFile *IdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node)
{
SymbolFromFile *newSymbol = 0;
if (_currentSymbol == 0) {
newSymbol = _doc->findSymbol(node);
} else {
newSymbol = _currentSymbol->findMember(node);
}
SymbolFromFile *oldSymbol = _currentSymbol;
if (newSymbol) {
_currentSymbol = newSymbol;
} else {
QString filename = _doc->fileName();
qWarning() << "Scope without symbol @"<<filename<<":"<<node->firstSourceLocation().startLine<<":"<<node->firstSourceLocation().startColumn;
}
return oldSymbol;
}
void IdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
{
if (!_currentSymbol)
return;
if (_ids.contains(id)) {
_diagnosticMessages.append(DiagnosticMessage(DiagnosticMessage::Warning, ast->statement->firstSourceLocation(), "Duplicate ID"));
} else {
if (SymbolFromFile *symbol = _currentSymbol->findMember(ast))
if (IdSymbol *idSymbol = symbol->asIdSymbol())
_ids[id] = idSymbol;
}
}
/**************************************************************************
**
** 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 QMLIDCOLLECTOR_H
#define QMLIDCOLLECTOR_H
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/parser/qmljsengine_p.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljssymbol.h>
#include <QMap>
#include <QPair>
#include <QStack>
#include <QString>
namespace QmlJS {
namespace Internal {
class QMLJS_EXPORT IdCollector: protected AST::Visitor
{
public:
QMap<QString, IdSymbol*> operator()(Document &doc);
QList<DiagnosticMessage> diagnosticMessages()
{ return _diagnosticMessages; }
protected:
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:
SymbolFromFile *switchSymbol(AST::UiObjectMember *node);
void addId(const QString &id, AST::UiScriptBinding *ast);
private:
Document *_doc;
QMap<QString, IdSymbol*> _ids;
SymbolFromFile *_currentSymbol;
QList<DiagnosticMessage> _diagnosticMessages;
};
} // namespace Internal
} // namespace Qml
#endif // QMLIDCOLLECTOR_H
/**************************************************************************
**
** 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 "qmljsmetatypebackend.h"
#include "qmljstypesystem.h"
using namespace QmlJS;
MetaTypeBackend::MetaTypeBackend(TypeSystem *typeSystem):
m_typeSystem(typeSystem)
{
Q_ASSERT(typeSystem);
}
MetaTypeBackend::~MetaTypeBackend()
{
}
/**************************************************************************
**
** 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 QMLMETATYPEBACKEND_H
#define QMLMETATYPEBACKEND_H
#include <qmljs/qmljs_global.h>
#include <qmljs/qmljspackageinfo.h>
#include <qmljs/qmljssymbol.h>
namespace QmlJS {
class TypeSystem;
class QMLJS_EXPORT MetaTypeBackend
{
public:
MetaTypeBackend(TypeSystem *typeSystem);
virtual ~MetaTypeBackend() = 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:
TypeSystem *typeSystem() const
{ return m_typeSystem; }
private:
TypeSystem *m_typeSystem;
};
} // namespace Qml
#endif // QMLMETATYPEBACKEND_H
/**************************************************************************
**
** 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 "qmljspackageinfo.h"
using namespace QmlJS;
PackageInfo::PackageInfo(const QString &name, int majorVersion, int minorVersion):
m_name(name),
m_majorVersion(majorVersion),
m_minorVersion(minorVersion)
{
}
/**************************************************************************
**
** 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 PACKAGEINFO_H
#define PACKAGEINFO_H
#include <qmljs/qmljs_global.h>
#include <QtCore/QString>
namespace QmlJS {
class QMLJS_EXPORT PackageInfo
{
public:
PackageInfo(const QString &name, int majorVersion, int minorVersion);
QString name() const
{ return m_name; }
int majorVersion() const
{ return m_majorVersion; }
int minorVersion() const
{ return m_minorVersion; }
private:
QString m_name;
int m_majorVersion;
int m_minorVersion;
};
} // namespace Qml
#endif // PACKAGEINFO_H
/**************************************************************************
**
** 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 "qmljssymbol.h"
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
using namespace QmlJS;
using namespace QmlJS;
using namespace QmlJS::AST;
Symbol::~Symbol()
{
}
bool Symbol::isBuildInSymbol()
{ return asPrimitiveSymbol() != 0; }
bool Symbol::isSymbolFromFile()
{ return asSymbolFromFile() != 0; }
bool Symbol::isIdSymbol()
{ return asIdSymbol() != 0; }
bool Symbol::isPropertyDefinitionSymbol()
{ return asPropertyDefinitionSymbol() != 0; }
PrimitiveSymbol *Symbol::asPrimitiveSymbol()
{ return 0; }
SymbolFromFile *Symbol::asSymbolFromFile()
{ return 0; }
IdSymbol *Symbol::asIdSymbol()
{ return 0; }