2010-07-09 15:47:07 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-07-09 15:47:07 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2010-07-09 15:47:07 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-07-09 15:47:07 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2010-07-09 15:47:07 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-01-28 14:53:53 +01:00
|
|
|
#ifndef QMLJSLINK_H
|
|
|
|
|
#define QMLJSLINK_H
|
|
|
|
|
|
2010-02-02 15:55:17 +01:00
|
|
|
#include <qmljs/qmljsdocument.h>
|
2011-07-05 12:06:41 +02:00
|
|
|
#include <qmljs/qmljscontext.h>
|
2010-01-28 14:53:53 +01:00
|
|
|
#include <qmljs/parser/qmljsastfwd_p.h>
|
2011-02-25 16:16:37 +01:00
|
|
|
#include <languageutils/componentversion.h>
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2010-05-19 13:32:11 +02:00
|
|
|
#include <QtCore/QCoreApplication>
|
2010-01-28 14:53:53 +01:00
|
|
|
|
|
|
|
|
namespace QmlJS {
|
|
|
|
|
|
2010-02-04 10:19:37 +01:00
|
|
|
class NameId;
|
2010-09-16 15:29:37 +02:00
|
|
|
class LinkPrivate;
|
2010-02-04 10:19:37 +01:00
|
|
|
|
2010-02-02 15:55:17 +01:00
|
|
|
/*
|
2010-02-04 10:19:37 +01:00
|
|
|
Helper for building a context.
|
2010-02-02 15:55:17 +01:00
|
|
|
*/
|
2010-03-31 10:03:18 +02:00
|
|
|
class QMLJS_EXPORT Link
|
2010-01-28 14:53:53 +01:00
|
|
|
{
|
2010-09-16 15:29:37 +02:00
|
|
|
Q_DECLARE_PRIVATE(Link)
|
2010-05-19 13:42:56 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(QmlJS::Link)
|
|
|
|
|
|
2010-01-28 14:53:53 +01:00
|
|
|
public:
|
2011-07-01 13:41:40 +02:00
|
|
|
Link(const Snapshot &snapshot, const QStringList &importPaths);
|
2011-05-06 13:31:30 +02:00
|
|
|
|
|
|
|
|
// Link all documents in snapshot, collecting all diagnostic messages (if messages != 0)
|
2011-07-01 13:41:40 +02:00
|
|
|
Interpreter::Context operator()(QHash<QString, QList<DiagnosticMessage> > *messages = 0);
|
2011-04-21 11:09:29 +02:00
|
|
|
|
|
|
|
|
// Link all documents in snapshot, appending the diagnostic messages
|
|
|
|
|
// for 'doc' in 'messages'
|
2011-07-01 13:41:40 +02:00
|
|
|
Interpreter::Context operator()(const Document::Ptr &doc, QList<DiagnosticMessage> *messages);
|
2010-02-02 15:55:17 +01:00
|
|
|
|
2011-04-21 11:09:29 +02:00
|
|
|
~Link();
|
2010-03-25 14:47:28 +01:00
|
|
|
|
2010-01-28 14:53:53 +01:00
|
|
|
private:
|
2010-02-02 17:06:48 +01:00
|
|
|
static AST::UiQualifiedId *qualifiedTypeNameId(AST::Node *node);
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2011-07-05 12:06:41 +02:00
|
|
|
Interpreter::Context::ImportsPerDocument linkImports();
|
2010-02-02 15:55:17 +01:00
|
|
|
|
2011-05-27 10:43:06 +02:00
|
|
|
void populateImportedTypes(Interpreter::Imports *imports, Document::Ptr doc);
|
|
|
|
|
Interpreter::Import importFileOrDirectory(
|
2011-05-12 15:29:00 +02:00
|
|
|
Document::Ptr doc,
|
|
|
|
|
const Interpreter::ImportInfo &importInfo);
|
2011-05-27 10:43:06 +02:00
|
|
|
Interpreter::Import importNonFile(
|
2011-05-12 15:29:00 +02:00
|
|
|
Document::Ptr doc,
|
|
|
|
|
const Interpreter::ImportInfo &importInfo);
|
2010-02-03 15:59:15 +01:00
|
|
|
void importObject(Bind *bind, const QString &name, Interpreter::ObjectValue *object, NameId *targetNamespace);
|
2010-02-02 15:55:17 +01:00
|
|
|
|
2011-03-10 14:49:38 +01:00
|
|
|
bool importLibrary(Document::Ptr doc,
|
|
|
|
|
const QString &libraryPath,
|
2011-05-27 10:43:06 +02:00
|
|
|
Interpreter::Import *import,
|
2011-03-10 14:49:38 +01:00
|
|
|
const QString &importPath = QString());
|
2011-02-25 16:16:37 +01:00
|
|
|
void loadQmldirComponents(Interpreter::ObjectValue *import,
|
|
|
|
|
LanguageUtils::ComponentVersion version,
|
|
|
|
|
const LibraryInfo &libraryInfo,
|
|
|
|
|
const QString &libraryPath);
|
2011-05-27 10:43:06 +02:00
|
|
|
void loadImplicitDirectoryImports(Interpreter::Imports *imports, Document::Ptr doc);
|
|
|
|
|
void loadImplicitDefaultImports(Interpreter::Imports *imports);
|
2011-02-25 16:16:37 +01:00
|
|
|
|
2010-03-29 11:32:11 +02:00
|
|
|
void error(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message);
|
2010-11-24 09:30:46 +01:00
|
|
|
void warning(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message);
|
2011-04-21 11:09:29 +02:00
|
|
|
void appendDiagnostic(const Document::Ptr &doc, const DiagnosticMessage &message);
|
2010-03-29 11:32:11 +02:00
|
|
|
|
2010-02-02 15:55:17 +01:00
|
|
|
private:
|
2010-09-16 15:29:37 +02:00
|
|
|
QScopedPointer<LinkPrivate> d_ptr;
|
2010-01-28 14:53:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace QmlJS
|
|
|
|
|
|
|
|
|
|
#endif // QMLJSLINK_H
|