QmlJS: Try to implicitly import libraries in the same directory.

In QML, the current directory that holds a QML file is imported
implicitly. If it contains a qmldir file, the library is imported.

Since there is no explicit import statement, Creator can't know the URI
of this library. However, if type information is available for it
already - either through a previous dump or a qmltypes file - we can
guess the URI by looking at the contained exports.

Task-number: QTCREATORBUG-3768
This commit is contained in:
Christian Kamm
2011-02-25 16:16:37 +01:00
parent 42077be2a0
commit aeb8c352ee
3 changed files with 120 additions and 43 deletions

View File

@@ -37,6 +37,7 @@
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsinterpreter.h>
#include <qmljs/parser/qmljsastfwd_p.h>
#include <languageutils/componentversion.h>
#include <QtCore/QCoreApplication>
@@ -73,6 +74,14 @@ private:
Interpreter::ObjectValue *importNonFile(Document::Ptr doc, const Interpreter::ImportInfo &importInfo);
void importObject(Bind *bind, const QString &name, Interpreter::ObjectValue *object, NameId *targetNamespace);
void loadQmldirComponents(Interpreter::ObjectValue *import,
LanguageUtils::ComponentVersion version,
const LibraryInfo &libraryInfo,
const QString &libraryPath);
void loadImplicitDirectoryImports(Interpreter::TypeEnvironment *typeEnv, Document::Ptr doc);
void loadImplicitLibraryImports(Interpreter::TypeEnvironment *typeEnv, const QString &path);
void loadImplicitDefaultImports(Interpreter::TypeEnvironment *typeEnv);
void error(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message);
void warning(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message);