summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFawzi Mohamed <fawzi.mohamed@digia.com>2014-07-22 19:06:44 +0200
committerFawzi Mohamed <fawzi.mohamed@digia.com>2014-07-30 15:07:35 +0200
commit02bdf30f458c0cdc19d1547e22029d41839e5100 (patch)
tree75e306de0dbcad10ac80c99dcb4dfa1bc4ad5be1 /src
parentfaa0e5b96cdda7fbcf383e1210e01858303ea168 (diff)
downloadqt-creator-02bdf30f458c0cdc19d1547e22029d41839e5100.tar.gz
qmljs: improve handling of qml dialects
Language::Enum -> QmlDialect * class instead of enum * moved Language specific operations to it (from Document) * nicer handling QStringList -> PathsAndLanguages * store language along with path, to perform a correct scan and improve path handling Change-Id: If69d35c63cfeb48aa670b51870916cd0c40f1916 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs/qmljs/qmljs-lib.pri6
-rw-r--r--src/libs/qmljs/qmljs.qbs1
-rw-r--r--src/libs/qmljs/qmljsbind.cpp10
-rw-r--r--src/libs/qmljs/qmljsbundle.cpp8
-rw-r--r--src/libs/qmljs/qmljsbundle.h8
-rw-r--r--src/libs/qmljs/qmljsdialect.cpp330
-rw-r--r--src/libs/qmljs/qmljsdialect.h174
-rw-r--r--src/libs/qmljs/qmljsdocument.cpp104
-rw-r--r--src/libs/qmljs/qmljsdocument.h18
-rw-r--r--src/libs/qmljs/qmljsimportdependencies.cpp6
-rw-r--r--src/libs/qmljs/qmljsimportdependencies.h5
-rw-r--r--src/libs/qmljs/qmljslink.cpp2
-rw-r--r--src/libs/qmljs/qmljsmodelmanagerinterface.cpp224
-rw-r--r--src/libs/qmljs/qmljsmodelmanagerinterface.h27
-rw-r--r--src/libs/qmljs/qmljsscopechain.cpp2
-rw-r--r--src/libs/qmljs/qmljsviewercontext.cpp38
-rw-r--r--src/libs/qmljs/qmljsviewercontext.h7
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.cpp5
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/model/plaintexteditmodifier.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp4
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.cpp6
-rw-r--r--src/plugins/qmljseditor/qmlexpressionundercursor.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljsfindreferences.cpp6
-rw-r--r--src/plugins/qmljseditor/qmljssemantichighlighter.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp2
-rw-r--r--src/plugins/qmljseditor/qmltaskmanager.cpp4
-rw-r--r--src/plugins/qmljstools/qmljsbundleprovider.cpp26
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp16
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.h2
-rw-r--r--src/plugins/qmljstools/qmljsrefactoringchanges.cpp2
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp2
-rw-r--r--src/plugins/qmlprojectmanager/qmlproject.cpp4
39 files changed, 751 insertions, 318 deletions
diff --git a/src/libs/qmljs/qmljs-lib.pri b/src/libs/qmljs/qmljs-lib.pri
index f4e1d88f97..756bed8ec4 100644
--- a/src/libs/qmljs/qmljs-lib.pri
+++ b/src/libs/qmljs/qmljs-lib.pri
@@ -44,7 +44,8 @@ HEADERS += \
$$PWD/qmljsconstants.h \
$$PWD/qmljsimportdependencies.h \
$$PWD/qmljsviewercontext.h \
- $$PWD/qmljsdescribevalue.h
+ $$PWD/qmljsdescribevalue.h \
+ $$PWD/qmljsdialect.h
SOURCES += \
$$PWD/qmljsbind.cpp \
@@ -80,7 +81,8 @@ SOURCES += \
$$PWD/qmljsqrcparser.cpp \
$$PWD/qmljsimportdependencies.cpp \
$$PWD/qmljsviewercontext.cpp \
- $$PWD/qmljsdescribevalue.cpp
+ $$PWD/qmljsdescribevalue.cpp \
+ $$PWD/qmljsdialect.cpp
RESOURCES += \
diff --git a/src/libs/qmljs/qmljs.qbs b/src/libs/qmljs/qmljs.qbs
index 68ebcd51c0..1bd85d4e56 100644
--- a/src/libs/qmljs/qmljs.qbs
+++ b/src/libs/qmljs/qmljs.qbs
@@ -41,6 +41,7 @@ QtcLibrary {
"qmljsimportdependencies.cpp", "qmljsimportdependencies.h",
"qmljsindenter.cpp", "qmljsindenter.h",
"qmljsinterpreter.cpp", "qmljsinterpreter.h",
+ "qmljsdialect.cpp", "qmljsdialect.h",
"qmljslineinfo.cpp", "qmljslineinfo.h",
"qmljslink.cpp", "qmljslink.h",
"qmljsmodelmanagerinterface.cpp", "qmljsmodelmanagerinterface.h",
diff --git a/src/libs/qmljs/qmljsbind.cpp b/src/libs/qmljs/qmljsbind.cpp
index cc7bb31bd3..56ed80d856 100644
--- a/src/libs/qmljs/qmljsbind.cpp
+++ b/src/libs/qmljs/qmljsbind.cpp
@@ -202,18 +202,18 @@ bool Bind::visit(UiImport *ast)
const QString importId = ast->importId.toString();
ImportInfo import = ImportInfo::moduleImport(toString(ast->importUri), version,
importId, ast);
- if (_doc->language() == Language::Qml) {
+ if (_doc->language() == Dialect::Qml) {
const QString importStr = import.name() + importId;
if (ModelManagerInterface::instance()) {
QmlLanguageBundles langBundles = ModelManagerInterface::instance()->extendedBundles();
- QmlBundle qq1 = langBundles.bundleForLanguage(Language::QmlQtQuick1);
- QmlBundle qq2 = langBundles.bundleForLanguage(Language::QmlQtQuick2);
+ QmlBundle qq1 = langBundles.bundleForLanguage(Dialect::QmlQtQuick1);
+ QmlBundle qq2 = langBundles.bundleForLanguage(Dialect::QmlQtQuick2);
bool isQQ1 = qq1.supportedImports().contains(importStr);
bool isQQ2 = qq2.supportedImports().contains(importStr);
if (isQQ1 && ! isQQ2)
- _doc->setLanguage(Language::QmlQtQuick1);
+ _doc->setLanguage(Dialect::QmlQtQuick1);
if (isQQ2 && ! isQQ1)
- _doc->setLanguage(Language::QmlQtQuick2);
+ _doc->setLanguage(Dialect::QmlQtQuick2);
}
}
_imports += import;
diff --git a/src/libs/qmljs/qmljsbundle.cpp b/src/libs/qmljs/qmljsbundle.cpp
index 28b1d951d3..a775a2f86c 100644
--- a/src/libs/qmljs/qmljsbundle.cpp
+++ b/src/libs/qmljs/qmljsbundle.cpp
@@ -288,14 +288,14 @@ bool QmlBundle::readFrom(QString path, QStringList *errors)
return errs.isEmpty();
}
-QmlBundle QmlLanguageBundles::bundleForLanguage(Language::Enum l) const
+QmlBundle QmlLanguageBundles::bundleForLanguage(Dialect l) const
{
if (m_bundles.contains(l))
return m_bundles.value(l);
return QmlBundle();
}
-void QmlLanguageBundles::mergeBundleForLanguage(Language::Enum l, const QmlBundle &bundle)
+void QmlLanguageBundles::mergeBundleForLanguage(Dialect l, const QmlBundle &bundle)
{
if (bundle.isEmpty())
return;
@@ -305,14 +305,14 @@ void QmlLanguageBundles::mergeBundleForLanguage(Language::Enum l, const QmlBundl
m_bundles.insert(l,bundle);
}
-QList<Language::Enum> QmlLanguageBundles::languages() const
+QList<Dialect> QmlLanguageBundles::languages() const
{
return m_bundles.keys();
}
void QmlLanguageBundles::mergeLanguageBundles(const QmlLanguageBundles &o)
{
- foreach (Language::Enum l, o.languages())
+ foreach (Dialect l, o.languages())
mergeBundleForLanguage(l, o.bundleForLanguage(l));
}
diff --git a/src/libs/qmljs/qmljsbundle.h b/src/libs/qmljs/qmljsbundle.h
index 3026c66ffd..d5d88bb431 100644
--- a/src/libs/qmljs/qmljsbundle.h
+++ b/src/libs/qmljs/qmljsbundle.h
@@ -100,12 +100,12 @@ private:
class QMLJS_EXPORT QmlLanguageBundles
{
public:
- QmlBundle bundleForLanguage(Language::Enum l) const;
- void mergeBundleForLanguage(Language::Enum l, const QmlBundle &bundle);
- QList<Language::Enum> languages() const;
+ QmlBundle bundleForLanguage(Dialect l) const;
+ void mergeBundleForLanguage(Dialect l, const QmlBundle &bundle);
+ QList<Dialect> languages() const;
void mergeLanguageBundles(const QmlLanguageBundles &);
private:
- QHash<Language::Enum,QmlBundle> m_bundles;
+ QHash<Dialect,QmlBundle> m_bundles;
};
} // namespace QmlJS
diff --git a/src/libs/qmljs/qmljsdialect.cpp b/src/libs/qmljs/qmljsdialect.cpp
new file mode 100644
index 0000000000..74c05629b5
--- /dev/null
+++ b/src/libs/qmljs/qmljsdialect.cpp
@@ -0,0 +1,330 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "qmljsdialect.h"
+
+namespace QmlJS {
+
+
+bool Dialect::isQmlLikeLanguage() const
+{
+ switch (m_dialect) {
+ case Dialect::Qml:
+ case Dialect::QmlQtQuick1:
+ case Dialect::QmlQtQuick2:
+ case Dialect::QmlQbs:
+ case Dialect::QmlProject:
+ case Dialect::QmlTypeInfo:
+ case Dialect::AnyLanguage:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool Dialect::isFullySupportedLanguage() const
+{
+ switch (m_dialect) {
+ case Dialect::JavaScript:
+ case Dialect::Json:
+ case Dialect::Qml:
+ case Dialect::QmlQtQuick1:
+ case Dialect::QmlQtQuick2:
+ return true;
+ case Dialect::NoLanguage:
+ case Dialect::AnyLanguage:
+ case Dialect::QmlQbs:
+ case Dialect::QmlProject:
+ case Dialect::QmlTypeInfo:
+ break;
+ }
+ return false;
+}
+
+bool Dialect::isQmlLikeOrJsLanguage() const
+{
+ switch (m_dialect) {
+ case Dialect::Qml:
+ case Dialect::QmlQtQuick1:
+ case Dialect::QmlQtQuick2:
+ case Dialect::QmlQbs:
+ case Dialect::QmlProject:
+ case Dialect::QmlTypeInfo:
+ case Dialect::JavaScript:
+ case Dialect::AnyLanguage:
+ return true;
+ default:
+ return false;
+ }
+}
+
+QString Dialect::toString() const
+{
+ switch (m_dialect) {
+ case Dialect::JavaScript:
+ return QLatin1String("JavaScript");
+ case Dialect::Json:
+ return QLatin1String("Json");
+ case Dialect::Qml:
+ return QLatin1String("Qml");
+ case Dialect::QmlQtQuick1:
+ return QLatin1String("QmlQtQuick1");
+ case Dialect::QmlQtQuick2:
+ return QLatin1String("QmlQtQuick2");
+ case Dialect::NoLanguage:
+ return QLatin1String("NoLanguage");
+ case Dialect::AnyLanguage:
+ return QLatin1String("AnyLanguage");
+ case Dialect::QmlQbs:
+ return QLatin1String("QmlQbs");
+ case Dialect::QmlProject:
+ return QLatin1String("QmlProject");
+ case Dialect::QmlTypeInfo:
+ break;
+ }
+ return QLatin1String("QmlTypeInfo");
+}
+
+bool Dialect::operator ==(const Dialect &o) const {
+ return m_dialect == o.m_dialect;
+}
+
+bool Dialect::operator <(const Dialect &o) const {
+ return m_dialect < o.m_dialect;
+}
+
+Dialect Dialect::mergeLanguages(const Dialect &l1, const Dialect &l2)
+{
+ if (l1 == Dialect::NoLanguage)
+ return l2;
+ if (l2 == Dialect::NoLanguage)
+ return l1;
+ QList<Dialect> ll1 = l1.companionLanguages();
+ QList<Dialect> ll2 = l2.companionLanguages();
+ bool i1 = ll1.contains(l2);
+ bool i2 = ll2.contains(l1);
+ if (i1 && i2) {
+ if (ll1.size() > ll2.size())
+ return l1;
+ if (ll2.size() > ll1.size())
+ return l2;
+ if (l1 < l2)
+ return l1;
+ return l2;
+ }
+ if (i1 && !i2)
+ return l1;
+ if (i2 && !i1)
+ return l2;
+ QList<Dialect> qmlLangs = Dialect(Qml).companionLanguages();
+ if (qmlLangs.contains(l1) && qmlLangs.contains(l2))
+ return Dialect::Qml;
+ return Dialect::AnyLanguage;
+}
+
+void Dialect::mergeLanguage(const Dialect &l2) {
+ *this = mergeLanguages(*this, l2);
+}
+
+bool Dialect::restrictLanguage(const Dialect &l2)
+{
+ if (*this == l2)
+ return true;
+ QList<Dialect> ll1 = companionLanguages();
+ QList<Dialect> ll2 = l2.companionLanguages();
+ bool i1 = ll1.contains(l2);
+ bool i2 = ll2.contains(*this);
+ if (i1 && i2) {
+ if (ll1.size() < ll2.size())
+ return true;
+ if (ll2.size() < ll1.size()) {
+ *this = l2;
+ return true;
+ }
+ if (m_dialect < l2.m_dialect)
+ return true;
+ *this = l2;
+ return true;
+ }
+ if (i1 && !i2) {
+ *this = l2;
+ return true;
+ }
+ if (i2 && !i1)
+ return true;
+ QList<Dialect> qmlLangs = Dialect(Qml).companionLanguages();
+ if (qmlLangs.contains(*this) && qmlLangs.contains(l2))
+ *this = Dialect::Qml;
+ *this = Dialect::AnyLanguage;
+ return false;
+}
+
+QList<Dialect> Dialect::companionLanguages() const
+{
+ QList<Dialect> langs;
+ langs << *this;
+ switch (m_dialect) {
+ case Dialect::JavaScript:
+ case Dialect::Json:
+ case Dialect::QmlProject:
+ case Dialect::QmlTypeInfo:
+ break;
+ case Dialect::QmlQbs:
+ langs << Dialect::JavaScript;
+ break;
+ case Dialect::Qml:
+ langs << Dialect::QmlQtQuick1 << Dialect::QmlQtQuick2 << Dialect::JavaScript;
+ break;
+ case Dialect::QmlQtQuick1:
+ case Dialect::QmlQtQuick2:
+ langs << Dialect::Qml << Dialect::JavaScript;
+ break;
+ case Dialect::AnyLanguage:
+ langs << Dialect::JavaScript << Dialect::Json << Dialect::QmlProject << Dialect:: QmlQbs
+ << Dialect::QmlTypeInfo << Dialect::QmlQtQuick1 << Dialect::QmlQtQuick2
+ << Dialect::Qml;
+ break;
+ case Dialect::NoLanguage:
+ return QList<Dialect>(); // return at least itself?
+ }
+ if (*this != Dialect::AnyLanguage)
+ langs << Dialect::AnyLanguage;
+ return langs;
+}
+
+uint qHash(const Dialect &o)
+{
+ return uint(o.dialect());
+}
+
+QDebug operator << (QDebug &dbg, const Dialect &dialect)
+{
+ dbg << dialect.toString();
+ return dbg;
+}
+
+PathAndLanguage::PathAndLanguage(const Utils::FileName &path, Dialect language)
+ : m_path(path), m_language(language)
+{ }
+
+bool PathAndLanguage::operator ==(const PathAndLanguage &other) const
+{
+ return path() == other.path() && language() == other.language();
+}
+
+bool PathAndLanguage::operator <(const PathAndLanguage &other) const
+{
+ if (path() < other.path())
+ return true;
+ if (path() > other.path())
+ return false;
+ if (language() == other.language())
+ return false;
+ bool i1 = other.language().companionLanguages().contains(language());
+ bool i2 = language().companionLanguages().contains(other.language());
+ if (i1 && !i2)
+ return true;
+ if (i2 && !i1)
+ return false;
+ return language() < other.language();
+}
+
+QDebug operator << (QDebug &dbg, const PathAndLanguage &pathAndLanguage)
+{
+ dbg << "{ path:" << pathAndLanguage.path() << " language:" << pathAndLanguage.language().toString() << "}";
+ return dbg;
+}
+
+bool PathsAndLanguages::maybeInsert(const PathAndLanguage &pathAndLanguage) {
+ for (int i = 0; i < m_list.size(); ++i) {
+ PathAndLanguage currentElement = m_list.at(i);
+ if (currentElement.path() == pathAndLanguage.path()) {
+ int j = i;
+ do {
+ if (pathAndLanguage.language() < currentElement.language()) {
+ if (currentElement.language() == pathAndLanguage.language())
+ return false;
+ break;
+ }
+ ++j;
+ if (j == m_list.length())
+ break;
+ currentElement = m_list.at(j);
+ } while (currentElement.path() == pathAndLanguage.path());
+ m_list.insert(j, pathAndLanguage);
+ return true;
+ }
+ }
+ m_list.append(pathAndLanguage);
+ return true;
+}
+
+void PathsAndLanguages::compact() {
+ int oldCompactionPlace = 0;
+ Utils::FileName oldPath = m_list.first().path();
+ QList<PathAndLanguage> compactedList;
+ bool restrictFailed = false;
+ for (int i = 1; i < m_list.length(); ++i) {
+ Utils::FileName newPath = m_list.at(i).path();
+ if (newPath == oldPath) {
+ int newCompactionPlace = i - 1;
+ compactedList << m_list.mid(oldCompactionPlace, newCompactionPlace - oldCompactionPlace);
+ LanguageMerger merger;
+ merger.merge(m_list.at(i - 1).language());
+ do {
+ merger.merge(m_list.at(i++).language());
+ if (++i == m_list.length())
+ break;
+ newPath = m_list.at(i).path();
+ } while (newPath == oldPath);
+ oldCompactionPlace = i;
+ compactedList << PathAndLanguage(oldPath, merger.mergedLanguage());
+ if (merger.restrictFailed())
+ restrictFailed = true;
+ }
+ oldPath = newPath;
+ }
+ if (oldCompactionPlace == 0)
+ return;
+ if (restrictFailed)
+ qCWarning(qmljsLog) << "failed to restrict PathAndLanguages " << m_list;
+ m_list = compactedList;
+}
+
+void LanguageMerger::merge(Dialect l)
+{
+ bool restrictSuccedeed = m_specificLanguage.restrictLanguage(l);
+ m_specificLanguage.mergeLanguage(m_minimalSpecificLanguage);
+ if (!restrictSuccedeed) {
+ m_minimalSpecificLanguage = m_specificLanguage;
+ m_restrictFailed = true;
+ }
+}
+
+} // namespace QmlJS
diff --git a/src/libs/qmljs/qmljsdialect.h b/src/libs/qmljs/qmljsdialect.h
new file mode 100644
index 0000000000..3ee6f26c12
--- /dev/null
+++ b/src/libs/qmljs/qmljsdialect.h
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QMLJSDIALECT_H
+#define QMLJSDIALECT_H
+
+#include "qmljsconstants.h"
+
+#include <utils/fileutils.h>
+
+#include <QString>
+
+namespace QmlJS {
+
+class QMLJS_EXPORT Dialect {
+public:
+ enum Enum
+ {
+ NoLanguage = 0,
+ JavaScript = 1,
+ Json = 2,
+ Qml = 3,
+ QmlQtQuick1 = 4,
+ QmlQtQuick2 = 5,
+ QmlQbs = 6,
+ QmlProject = 7,
+ QmlTypeInfo = 8,
+ AnyLanguage = 9,
+ };
+ Dialect(Enum dialect = NoLanguage)
+ : m_dialect(dialect)
+ { }
+ static Dialect mergeLanguages(const Dialect &l1, const Dialect &l2);
+
+ bool isQmlLikeLanguage() const;
+ bool isFullySupportedLanguage() const;
+ bool isQmlLikeOrJsLanguage() const;
+ QList<Dialect> companionLanguages() const;
+ bool restrictLanguage(const Dialect &l2);
+ QString toString() const;
+ bool operator ==(const Dialect &o) const;
+ bool operator !=(const Dialect &o) const {
+ return !(*this == o);
+ }
+ bool operator <(const Dialect &o) const;
+ Enum dialect() const {
+ return m_dialect;
+ }
+ void mergeLanguage(const Dialect &l2);
+private:
+ Enum m_dialect;
+};
+
+QMLJS_EXPORT uint qHash(const Dialect &o);
+
+QMLJS_EXPORT QDebug operator << (QDebug &dbg, const Dialect &dialect);
+
+class QMLJS_EXPORT PathAndLanguage {
+public:
+ PathAndLanguage(const Utils::FileName &path = Utils::FileName(), Dialect language = Dialect::AnyLanguage);
+ PathAndLanguage(const PathAndLanguage &o)
+ : m_path(o.path()), m_language(o.language())
+ { }
+ Utils::FileName path() const {
+ return m_path;
+ }
+ Dialect language() const {
+ return m_language;
+ }
+ bool operator ==(const PathAndLanguage &other) const;
+ bool operator < (const PathAndLanguage &other) const;
+private:
+ Utils::FileName m_path;
+ Dialect m_language;
+};
+
+// tries to find the "most specific" language still compatible with all requested ones
+class QMLJS_EXPORT LanguageMerger
+{
+public:
+ LanguageMerger()
+ : m_specificLanguage(Dialect::AnyLanguage),
+ m_minimalSpecificLanguage(Dialect::NoLanguage),
+ m_restrictFailed(false)
+ { }
+
+ void merge(Dialect l);
+
+ Dialect mergedLanguage() const {
+ return m_specificLanguage;
+ }
+ bool restrictFailed() const {
+ return m_restrictFailed;
+ }
+private:
+ Dialect m_specificLanguage;
+ Dialect m_minimalSpecificLanguage;
+ bool m_restrictFailed;
+};
+
+
+QMLJS_EXPORT QDebug operator << (QDebug &dbg, const PathAndLanguage &pathAndLanguage);
+
+class QMLJS_EXPORT PathsAndLanguages
+{
+public:
+ explicit PathsAndLanguages()
+ { }
+ explicit PathsAndLanguages(const QList<PathAndLanguage> &list)
+ : m_list(list)
+ { }
+ PathsAndLanguages(const PathsAndLanguages &o)
+ : m_list(o.m_list)
+ { }
+
+ bool maybeInsert(const Utils::FileName &path, Dialect language = Dialect::AnyLanguage) {
+ return maybeInsert(PathAndLanguage(path, language));
+ }
+
+ bool maybeInsert(const PathAndLanguage &pathAndLanguage);
+
+ PathAndLanguage at(int i) const {
+ return m_list.at(i);
+ }
+ int size() const {
+ return m_list.size();
+ }
+ int length() const {
+ return m_list.length();
+ }
+ void clear() {
+ m_list.clear();
+ }
+ // foreach support
+ typedef QList<PathAndLanguage>::const_iterator const_iterator;
+ const_iterator begin() const {
+ return m_list.begin();
+ }
+ const_iterator end() const {
+ return m_list.end();
+ }
+ void compact();
+private:
+ QList<PathAndLanguage> m_list;
+};
+
+} // namespace QmlJS
+#endif // QMLJSDIALECT_H
diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp
index cf7fd70bd1..4987dd1a25 100644
--- a/src/libs/qmljs/qmljsdocument.cpp
+++ b/src/libs/qmljs/qmljsdocument.cpp
@@ -88,93 +88,7 @@ using namespace QmlJS::AST;
threads finish and new information becomes available.
*/
-
-bool Document::isQmlLikeLanguage(Language::Enum language)
-{
- switch (language) {
- case Language::Qml:
- case Language::QmlQtQuick1:
- case Language::QmlQtQuick2:
- case Language::QmlQbs:
- case Language::QmlProject:
- case Language::QmlTypeInfo:
- case Language::AnyLanguage:
- return true;
- default:
- return false;
- }
-}
-
-bool Document::isFullySupportedLanguage(Language::Enum language)
-{
- switch (language) {
- case Language::JavaScript:
- case Language::Json:
- case Language::Qml:
- case Language::QmlQtQuick1:
- case Language::QmlQtQuick2:
- return true;
- case Language::NoLanguage:
- case Language::AnyLanguage:
- case Language::QmlQbs:
- case Language::QmlProject:
- case Language::QmlTypeInfo:
- break;
- }
- return false;
-}
-
-bool Document::isQmlLikeOrJsLanguage(Language::Enum language)
-{
- switch (language) {
- case Language::Qml:
- case Language::QmlQtQuick1:
- case Language::QmlQtQuick2:
- case Language::QmlQbs:
- case Language::QmlProject:
- case Language::QmlTypeInfo:
- case Language::JavaScript:
- case Language::AnyLanguage:
- return true;
- default:
- return false;
- }
-}
-
-QList<Language::Enum> Document::companionLanguages(Language::Enum language)
-{
- QList<Language::Enum> langs;
- langs << language;
- switch (language) {
- case Language::JavaScript:
- case Language::Json:
- case Language::QmlProject:
- case Language::QmlTypeInfo:
- break;
- case Language::QmlQbs:
- langs << Language::JavaScript;
- break;
- case Language::Qml:
- langs << Language::QmlQtQuick1 << Language::QmlQtQuick2 << Language::JavaScript;
- break;
- case Language::QmlQtQuick1:
- case Language::QmlQtQuick2:
- langs << Language::Qml << Language::JavaScript;
- break;
- case Language::AnyLanguage:
- langs << Language::JavaScript << Language::Json << Language::QmlProject << Language:: QmlQbs
- << Language::QmlTypeInfo << Language::QmlQtQuick1 << Language::QmlQtQuick2
- << Language::Qml;
- break;
- case Language::NoLanguage:
- return QList<Language::Enum>(); // return at least itself?
- }
- if (language != Language::AnyLanguage)
- langs << Language::AnyLanguage;
- return langs;
-}
-
-Document::Document(const QString &fileName, Language::Enum language)
+Document::Document(const QString &fileName, Dialect language)
: _engine(0)
, _ast(0)
, _bind(0)
@@ -186,7 +100,7 @@ Document::Document(const QString &fileName, Language::Enum language)
QFileInfo fileInfo(fileName);
_path = QDir::cleanPath(fileInfo.absolutePath());
- if (isQmlLikeLanguage(language)) {
+ if (language.isQmlLikeLanguage()) {
_componentName = fileInfo.baseName();
if (! _componentName.isEmpty()) {
@@ -207,7 +121,7 @@ Document::~Document()
delete _engine;
}
-Document::MutablePtr Document::create(const QString &fileName, Language::Enum language)
+Document::MutablePtr Document::create(const QString &fileName, Dialect language)
{
Document::MutablePtr doc(new Document(fileName, language));
doc->_ptr = doc;
@@ -221,15 +135,15 @@ Document::Ptr Document::ptr() const
bool Document::isQmlDocument() const
{
- return isQmlLikeLanguage(_language);
+ return _language.isQmlLikeLanguage();
}
-Language::Enum Document::language() const
+Dialect Document::language() const
{
return _language;
}
-void Document::setLanguage(Language::Enum l)
+void Document::setLanguage(Dialect l)
{
_language = l;
}
@@ -357,7 +271,7 @@ bool Document::parse_helper(int startToken)
Parser parser(_engine);
QString source = _source;
- lexer.setCode(source, /*line = */ 1, /*qmlMode = */isQmlLikeLanguage(_language));
+ lexer.setCode(source, /*line = */ 1, /*qmlMode = */_language.isQmlLikeLanguage());
CollectDirectives collectDirectives(path());
_engine->setDirectives(&collectDirectives);
@@ -539,7 +453,7 @@ void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info)
if (!info.wasFound()) return;
CoreImport cImport;
cImport.importId = path;
- cImport.language = Language::AnyLanguage;
+ cImport.language = Dialect::AnyLanguage;
QSet<ImportKey> packages;
foreach (const ModuleApiInfo &moduleInfo, info.moduleApis()) {
ImportKey iKey(ImportType::Library, moduleInfo.uri, moduleInfo.version.majorVersion(),
@@ -638,7 +552,7 @@ QmlJS::ImportDependencies *Snapshot::importDependencies()
Document::MutablePtr Snapshot::documentFromSource(
const QString &code, const QString &fileName,
- Language::Enum language) const
+ Dialect language) const
{
Document::MutablePtr newDoc = Document::create(fileName, language);
diff --git a/src/libs/qmljs/qmljsdocument.h b/src/libs/qmljs/qmljsdocument.h
index 1a0a331de9..9a02be006b 100644
--- a/src/libs/qmljs/qmljsdocument.h
+++ b/src/libs/qmljs/qmljsdocument.h
@@ -35,6 +35,7 @@
#include <languageutils/fakemetaobject.h>
+#include "qmljsdialect.h"
#include "parser/qmldirparser_p.h"
#include "parser/qmljsengine_p.h"
#include "qmljs_global.h"
@@ -52,24 +53,19 @@ class QMLJS_EXPORT Document
public:
typedef QSharedPointer<const Document> Ptr;
typedef QSharedPointer<Document> MutablePtr;
-
- static bool isQmlLikeLanguage(Language::Enum languge);
- static bool isFullySupportedLanguage(Language::Enum language);
- static bool isQmlLikeOrJsLanguage(Language::Enum language);
- static QList<Language::Enum> companionLanguages(Language::Enum language);
protected:
- Document(const QString &fileName, Language::Enum language);
+ Document(const QString &fileName, Dialect language);
public:
~Document();
- static MutablePtr create(const QString &fileName, Language::Enum language);
+ static MutablePtr create(const QString &fileName, Dialect language);
Document::Ptr ptr() const;
bool isQmlDocument() const;
- Language::Enum language() const;
- void setLanguage(Language::Enum l);
+ Dialect language() const;
+ void setLanguage(Dialect l);
QString importId() const;
QByteArray fingerprint() const;
@@ -117,7 +113,7 @@ private:
QWeakPointer<Document> _ptr;
QByteArray _fingerprint;
int _editorRevision;
- Language::Enum _language;
+ Dialect _language;
bool _parsedCorrectly;
// for documentFromSource
@@ -246,7 +242,7 @@ public:
Document::MutablePtr documentFromSource(const QString &code,
const QString &fileName,
- Language::Enum language) const;
+ Dialect language) const;
};
} // namespace QmlJS
diff --git a/src/libs/qmljs/qmljsimportdependencies.cpp b/src/libs/qmljs/qmljsimportdependencies.cpp
index dd3e2e70b8..4b39016c94 100644
--- a/src/libs/qmljs/qmljsimportdependencies.cpp
+++ b/src/libs/qmljs/qmljsimportdependencies.cpp
@@ -509,10 +509,10 @@ bool operator !=(const Export &i1, const Export &i2)
return !(i1 == i2);
}
-CoreImport::CoreImport() : language(Language::Qml) { }
+CoreImport::CoreImport() : language(Dialect::Qml) { }
CoreImport::CoreImport(const QString &importId, const QList<Export> &possibleExports,
- Language::Enum language, const QByteArray &fingerprint)
+ Dialect language, const QByteArray &fingerprint)
: importId(importId), possibleExports(possibleExports), language(language),
fingerprint(fingerprint)
{ }
@@ -787,7 +787,7 @@ void ImportDependencies::addExport(const QString &importId, const ImportKey &imp
{
if (!m_coreImports.contains(importId)) {
CoreImport newImport(importId);
- newImport.language = Language::AnyLanguage;
+ newImport.language = Dialect::AnyLanguage;
newImport.possibleExports.append(Export(importKey, requiredPath, false, typeName));
m_coreImports.insert(newImport.importId, newImport);
m_importCache[importKey].append(importId);
diff --git a/src/libs/qmljs/qmljsimportdependencies.h b/src/libs/qmljs/qmljsimportdependencies.h
index 8a412b754e..cabd0df9af 100644
--- a/src/libs/qmljs/qmljsimportdependencies.h
+++ b/src/libs/qmljs/qmljsimportdependencies.h
@@ -31,6 +31,7 @@
#define QMLJSIMPORTCACHE_H
#include "qmljsviewercontext.h"
+#include "qmljsdialect.h"
#include <languageutils/componentversion.h>
#include <utils/qtcoverride.h>
@@ -147,10 +148,10 @@ class QMLJS_EXPORT CoreImport
public:
CoreImport();
CoreImport(const QString &importId, const QList<Export> &possibleExports = QList<Export>(),
- Language::Enum language = Language::Qml, const QByteArray &fingerprint = QByteArray());
+ Dialect language = Dialect::Qml, const QByteArray &fingerprint = QByteArray());
QString importId;
QList<Export> possibleExports;
- Language::Enum language;
+ Dialect language;
QByteArray fingerprint;
bool valid();
};
diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp
index e0006e4b83..76379ed3d7 100644
--- a/src/libs/qmljs/qmljslink.cpp
+++ b/src/libs/qmljs/qmljslink.cpp
@@ -333,7 +333,7 @@ Import LinkPrivate::importFileOrDirectory(Document::Ptr doc, const ImportInfo &i
->filesInQrcPath(path));
while (iter.hasNext()) {
iter.next();
- if (Document::isQmlLikeLanguage(ModelManagerInterface::guessLanguageOfFile(iter.key()))) {
+ if (ModelManagerInterface::guessLanguageOfFile(iter.key()).isQmlLikeLanguage()) {
Document::Ptr importedDoc = snapshot.document(iter.value().at(0));
if (importedDoc && importedDoc->bind()->rootObjectValue()) {
const QString targetName = QFileInfo(iter.key()).baseName();
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
index 396bc90f3a..eb72166154 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
@@ -34,6 +34,7 @@
#include "qmljsmodelmanagerinterface.h"
#include "qmljsplugindumper.h"
#include "qmljstypedescriptionreader.h"
+#include "qmljsdialect.h"
#include <cplusplus/cppmodelmanagerbase.h>
#include <utils/hostosinfo.h>
@@ -113,6 +114,9 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo");
+ qRegisterMetaType<QmlJS::Dialect>("QmlJS::Dialect");
+ qRegisterMetaType<QmlJS::PathAndLanguage>("QmlJS::PathAndLanguage");
+ qRegisterMetaType<QmlJS::PathsAndLanguages>("QmlJS::PathsAndLanguages");
m_defaultProjectInfo.qtImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
@@ -134,39 +138,39 @@ ModelManagerInterface::~ModelManagerInterface()
g_instance = 0;
}
-static QHash<QString, Language::Enum> defaultLanguageMapping()
+static QHash<QString, Dialect> defaultLanguageMapping()
{
- QHash<QString, Language::Enum> res;
- res[QLatin1String("js")] = Language::JavaScript;
- res[QLatin1String("qml")] = Language::Qml;
- res[QLatin1String("qmltypes")] = Language::QmlTypeInfo;
- res[QLatin1String("qmlproject")] = Language::QmlProject;
- res[QLatin1String("json")] = Language::Json;
- res[QLatin1String("qbs")] = Language::QmlQbs;
+ QHash<QString, Dialect> res;
+ res[QLatin1String("js")] = Dialect::JavaScript;
+ res[QLatin1String("qml")] = Dialect::Qml;
+ res[QLatin1String("qmltypes")] = Dialect::QmlTypeInfo;
+ res[QLatin1String("qmlproject")] = Dialect::QmlProject;
+ res[QLatin1String("json")] = Dialect::Json;
+ res[QLatin1String("qbs")] = Dialect::QmlQbs;
return res;
}
-Language::Enum ModelManagerInterface::guessLanguageOfFile(const QString &fileName)
+Dialect ModelManagerInterface::guessLanguageOfFile(const QString &fileName)
{
- QHash<QString, Language::Enum> lMapping;
+ QHash<QString, Dialect> lMapping;
if (instance())
lMapping = instance()->languageForSuffix();
else
lMapping = defaultLanguageMapping();
const QFileInfo info(fileName);
const QString fileSuffix = info.suffix();
- return lMapping.value(fileSuffix, Language::NoLanguage);
+ return lMapping.value(fileSuffix, Dialect::NoLanguage);
}
-QStringList ModelManagerInterface::globPatternsForLanguages(const QList<Language::Enum> languages)
+QStringList ModelManagerInterface::globPatternsForLanguages(const QList<Dialect> languages)
{
- QHash<QString, Language::Enum> lMapping;
+ QHash<QString, Dialect> lMapping;
if (instance())
lMapping = instance()->languageForSuffix();
else
lMapping = defaultLanguageMapping();
QStringList patterns;
- QHashIterator<QString,Language::Enum> i(lMapping);
+ QHashIterator<QString,Dialect> i(lMapping);
while (i.hasNext()) {
i.next();
if (languages.contains(i.value()))
@@ -203,7 +207,7 @@ void ModelManagerInterface::activateScan()
}
}
-QHash<QString, Language::Enum> ModelManagerInterface::languageForSuffix() const
+QHash<QString, Dialect> ModelManagerInterface::languageForSuffix() const
{
return defaultLanguageMapping();
}
@@ -294,7 +298,7 @@ QFuture<void> ModelManagerInterface::refreshSourceFiles(const QStringList &sourc
QFuture<void> result = QtConcurrent::run(&ModelManagerInterface::parse,
workingCopyInternal(), sourceFiles,
- this, Language::Qml,
+ this, Dialect(Dialect::Qml),
emitDocumentOnDiskChanged);
if (m_synchronizer.futures().size() > 10) {
@@ -334,7 +338,7 @@ void ModelManagerInterface::fileChangedOnDisk(const QString &path)
{
QtConcurrent::run(&ModelManagerInterface::parse,
workingCopyInternal(), QStringList() << path,
- this, Language::AnyLanguage, true);
+ this, Dialect(Dialect::AnyLanguage), true);
}
void ModelManagerInterface::removeFiles(const QStringList &files)
@@ -394,8 +398,8 @@ bool pInfoLessThanImports(const ModelManagerInterface::ProjectInfo &p1, const Mo
return true;
if (p1.qtImportsPath > p2.qtImportsPath)
return false;
- QStringList s1 = p1.importPaths;
- QStringList s2 = p2.importPaths;
+ const PathsAndLanguages &s1 = p1.importPaths;
+ const PathsAndLanguages &s2 = p2.importPaths;
if (s1.size() < s2.size())
return true;
if (s1.size() > s2.size())
@@ -403,7 +407,7 @@ bool pInfoLessThanImports(const ModelManagerInterface::ProjectInfo &p1, const Mo
for (int i = 0; i < s1.size(); ++i) {
if (s1.at(i) < s2.at(i))
return true;
- else if (s1.at(i) > s2.at(i))
+ else if (s2.at(i) < s1.at(i))
return false;
}
return false;
@@ -603,9 +607,8 @@ ModelManagerInterface::ProjectInfo ModelManagerInterface::projectInfoForPath(QSt
res.qtImportsPath = pInfo.qtImportsPath;
if (res.qtQmlPath.isEmpty())
res.qtQmlPath = pInfo.qtQmlPath;
- foreach (const QString &path, pInfo.importPaths)
- if (!res.importPaths.contains(path))
- res.importPaths.append(path);
+ for (int i = 0; i < pInfo.importPaths.size(); ++i)
+ res.importPaths.maybeInsert(pInfo.importPaths.at(i));
}
return res;
}
@@ -643,7 +646,7 @@ void ModelManagerInterface::updateLibraryInfo(const QString &path, const Library
emit libraryInfoUpdated(path, info);
}
-static QStringList filesInDirectoryForLanguages(const QString &path, QList<Language::Enum> languages)
+static QStringList filesInDirectoryForLanguages(const QString &path, QList<Dialect> languages)
{
const QStringList pattern = ModelManagerInterface::globPatternsForLanguages(languages);
QStringList files;
@@ -663,7 +666,7 @@ static void findNewImplicitImports(const Document::Ptr &doc, const Snapshot &sna
if (snapshot.documentsInDirectory(doc->path()).isEmpty()) {
if (! scannedPaths->contains(doc->path())) {
*importedFiles += filesInDirectoryForLanguages(doc->path(),
- Document::companionLanguages(doc->language()));
+ doc->language().companionLanguages());
scannedPaths->insert(doc->path());
}
}
@@ -682,7 +685,7 @@ static void findNewFileImports(const Document::Ptr &doc, const Snapshot &snapsho
if (snapshot.documentsInDirectory(importName).isEmpty()) {
if (! scannedPaths->contains(importName)) {
*importedFiles += filesInDirectoryForLanguages(importName,
- Document::companionLanguages(doc->language()));
+ doc->language().companionLanguages());
scannedPaths->insert(importName);
}
}
@@ -696,7 +699,7 @@ static void findNewFileImports(const Document::Ptr &doc, const Snapshot &snapsho
QMapIterator<QString,QStringList> dirContents(ModelManagerInterface::instance()->filesInQrcPath(importName));
while (dirContents.hasNext()) {
dirContents.next();
- if (Document::isQmlLikeOrJsLanguage(ModelManagerInterface::guessLanguageOfFile(dirContents.key()))) {
+ if (ModelManagerInterface::guessLanguageOfFile(dirContents.key()).isQmlLikeOrJsLanguage()) {
foreach (const QString &filePath, dirContents.value()) {
if (! snapshot.document(filePath))
*importedFiles += filePath;
@@ -759,7 +762,7 @@ static bool findNewQmlLibraryInPath(const QString &path,
const QString path = QDir::cleanPath(componentFileInfo.absolutePath());
if (! scannedPaths->contains(path)) {
*importedFiles += filesInDirectoryForLanguages(path,
- Document::companionLanguages(Language::AnyLanguage));
+ Dialect(Dialect::AnyLanguage).companionLanguages());
scannedPaths->insert(path);
}
}
@@ -806,7 +809,7 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
importedFiles, scannedPaths, newLibraries, false);
// scan dir and lib imports
- const QStringList importPaths = modelManager->importPaths();
+ const PathsAndLanguages importPaths = modelManager->importPaths();
foreach (const ImportInfo &import, doc->bind()->imports()) {
if (import.type() == ImportType::Directory) {
const QString targetPath = import.path();
@@ -817,8 +820,8 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
if (import.type() == ImportType::Library) {
if (!import.version().isValid())
continue;
- foreach (const QString &importPath, importPaths) {
- const QString targetPath = QDir(importPath).filePath(import.path());
+ foreach (const PathAndLanguage &importPath, importPaths) {
+ const QString targetPath = importPath.path().toFileInfo().dir().filePath(import.path());
findNewQmlLibrary(targetPath, import.version(), snapshot, modelManager,
importedFiles, scannedPaths, newLibraries);
}
@@ -831,7 +834,7 @@ void ModelManagerInterface::parseLoop(QSet<QString> &scannedPaths,
WorkingCopy workingCopy,
QStringList files,
ModelManagerInterface *modelManager,
- Language::Enum mainLanguage,
+ Dialect mainLanguage,
bool emitDocChangedOnDisk,
std::function<bool(qreal)> reportProgress)
{
@@ -841,14 +844,14 @@ void ModelManagerInterface::parseLoop(QSet<QString> &scannedPaths,
const QString fileName = files.at(i);
- Language::Enum language = guessLanguageOfFile(fileName);
- if (language == Language::NoLanguage) {
+ Dialect language = guessLanguageOfFile(fileName);
+ if (language == Dialect::NoLanguage) {
if (fileName.endsWith(QLatin1String(".qrc")))
modelManager->updateQrcFile(fileName);
continue;
}
- if (language == Language::Qml
- && (mainLanguage == Language::QmlQtQuick1 || mainLanguage == Language::QmlQtQuick2))
+ if (language == Dialect::Qml
+ && (mainLanguage == Dialect::QmlQtQuick1 || mainLanguage == Dialect::QmlQtQuick2))
language = mainLanguage;
QString contents;
int documentRevision = 0;
@@ -917,7 +920,7 @@ void ModelManagerInterface::parse(QFutureInterface<void> &future,
WorkingCopy workingCopy,
QStringList files,
ModelManagerInterface *modelManager,
- Language::Enum mainLanguage,
+ Dialect mainLanguage,
bool emitDocChangedOnDisk)
{
FutureReporter reporter(future);
@@ -935,15 +938,15 @@ void ModelManagerInterface::parse(QFutureInterface<void> &future,
struct ScanItem {
QString path;
int depth;
- ScanItem(QString path = QString(), int depth = 0)
- : path(path), depth(depth)
+ Dialect language;
+ ScanItem(QString path = QString(), int depth = 0, Dialect language = Dialect::AnyLanguage)
+ : path(path), depth(depth), language(language)
{ }
};
void ModelManagerInterface::importScan(QFutureInterface<void> &future,
ModelManagerInterface::WorkingCopy workingCopy,
- QStringList paths, ModelManagerInterface *modelManager,
- Language::Enum language,
+ PathsAndLanguages paths, ModelManagerInterface *modelManager,
bool emitDocChangedOnDisk)
{
// paths we have scanned for files and added to the files list
@@ -959,11 +962,12 @@ void ModelManagerInterface::importScan(QFutureInterface<void> &future,
pathsToScan.reserve(paths.size());
{
QMutexLocker l(&modelManager->m_mutex);
- foreach (const QString &path, paths) {
- QString cPath = QDir::cleanPath(path);
+ for (int i = 0; i < paths.size(); ++i) {
+ PathAndLanguage pAndL = paths.at(i);
+ QString cPath = QDir::cleanPath(pAndL.path().toString());
if (modelManager->m_scannedPaths.contains(cPath))
continue;
- pathsToScan.append(ScanItem(cPath));
+ pathsToScan.append(ScanItem(cPath, 0, pAndL.language()));
modelManager->m_scannedPaths.insert(cPath);
}
}
@@ -983,14 +987,14 @@ void ModelManagerInterface::importScan(QFutureInterface<void> &future,
&scannedPaths, &newLibraries, true)
&& !libOnly && snapshot.documentsInDirectory(toScan.path).isEmpty())
importedFiles += filesInDirectoryForLanguages(toScan.path,
- Document::companionLanguages(language));
+ toScan.language.companionLanguages());
workDone += 1;
future.setProgressValue(progressRange * workDone / totalWork);
if (!importedFiles.isEmpty()) {
FutureReporter reporter(future, progressRange * pathBudget / (4 * totalWork),
progressRange * workDone / totalWork);
parseLoop(scannedPaths, newLibraries, workingCopy, importedFiles, modelManager,
- language, emitDocChangedOnDisk, reporter); // run in parallel??
+ toScan.language, emitDocChangedOnDisk, reporter); // run in parallel??
importedFiles.clear();
}
workDone += pathBudget / 4 - 1;
@@ -1004,8 +1008,8 @@ void ModelManagerInterface::importScan(QFutureInterface<void> &future,
QStringList subDirs(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot));
workDone += 1;
totalWork += pathBudget / 2 * subDirs.size() - pathBudget * 3 / 4 + 1;
- foreach (const QString &path, subDirs)
- pathsToScan.append(ScanItem(dir.absoluteFilePath(path), toScan.depth + 1));
+ foreach (const QString path, subDirs)
+ pathsToScan.append(ScanItem(dir.absoluteFilePath(path), toScan.depth + 1, toScan.language));
} else {
workDone += pathBudget * 3 / 4;
}
@@ -1015,12 +1019,12 @@ void ModelManagerInterface::importScan(QFutureInterface<void> &future,
if (future.isCanceled()) {
// assume no work has been done
QMutexLocker l(&modelManager->m_mutex);
- foreach (const QString &path, paths)
- modelManager->m_scannedPaths.remove(path);
+ for (int i = 0; i < paths.size(); ++i)
+ modelManager->m_scannedPaths.remove(paths.at(i).path().toString());
}
}
-QStringList ModelManagerInterface::importPaths() const
+PathsAndLanguages ModelManagerInterface::importPaths() const
{
QMutexLocker l(&m_mutex);
return m_allImportPaths;
@@ -1038,23 +1042,20 @@ QmlLanguageBundles ModelManagerInterface::extendedBundles() const
return m_extendedBundles;
}
-void ModelManagerInterface::maybeScan(const QStringList &importPaths,
- Language::Enum defaultLanguage)
+void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
{
- QStringList pathToScan;
+ PathsAndLanguages pathToScan;
{
QMutexLocker l(&m_mutex);
- foreach (const QString &importPath, importPaths)
- if (!m_scannedPaths.contains(importPath)) {
- pathToScan.append(importPath);
- }
+ foreach (const PathAndLanguage &importPath, importPaths)
+ if (!m_scannedPaths.contains(importPath.path().toString()))
+ pathToScan.maybeInsert(importPath);
}
- if (pathToScan.count() > 1) {
+ if (pathToScan.length() > 1) {
QFuture<void> result = QtConcurrent::run(&ModelManagerInterface::importScan,
workingCopyInternal(), pathToScan,
- this, defaultLanguage,
- true);
+ this, true);
if (m_synchronizer.futures().size() > 10) {
QList<QFuture<void> > futures = m_synchronizer.futures();
@@ -1075,33 +1076,37 @@ void ModelManagerInterface::maybeScan(const QStringList &importPaths,
void ModelManagerInterface::updateImportPaths()
{
- QStringList allImportPaths;
+ PathsAndLanguages allImportPaths;
QmlLanguageBundles activeBundles;
QmlLanguageBundles extendedBundles;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> pInfoIter(m_projects);
- QHashIterator<Language::Enum, QmlJS::ViewerContext> vCtxsIter = m_defaultVContexts;
+ QHashIterator<Dialect, QmlJS::ViewerContext> vCtxsIter = m_defaultVContexts;
while (pInfoIter.hasNext()) {
pInfoIter.next();
- foreach (const QString &path, pInfoIter.value().importPaths) {
- const QString canonicalPath = QFileInfo(path).canonicalFilePath();
+ const PathsAndLanguages &iPaths = pInfoIter.value().importPaths;
+ for (int i = 0; i < iPaths.size(); ++i) {
+ PathAndLanguage pAndL = iPaths.at(i);
+ const QString canonicalPath = pAndL.path().toFileInfo().canonicalFilePath();
if (!canonicalPath.isEmpty())
- allImportPaths += canonicalPath;
+ allImportPaths.maybeInsert(Utils::FileName::fromString(canonicalPath),
+ pAndL.language());
}
}
while (vCtxsIter.hasNext()) {
vCtxsIter.next();
- allImportPaths << vCtxsIter.value().paths;
+ foreach (const QString &path, vCtxsIter.value().paths)
+ allImportPaths.maybeInsert(Utils::FileName::fromString(path), vCtxsIter.value().language);
}
pInfoIter.toFront();
while (pInfoIter.hasNext()) {
pInfoIter.next();
activeBundles.mergeLanguageBundles(pInfoIter.value().activeBundle);
- foreach (Language::Enum l, pInfoIter.value().activeBundle.languages()) {
+ foreach (Dialect l, pInfoIter.value().activeBundle.languages()) {
foreach (const QString &path, pInfoIter.value().activeBundle.bundleForLanguage(l)
.searchPaths().stringList()) {
const QString canonicalPath = QFileInfo(path).canonicalFilePath();
if (!canonicalPath.isEmpty())
- allImportPaths += canonicalPath;
+ allImportPaths.maybeInsert(Utils::FileName::fromString(canonicalPath), l);
}
}
}
@@ -1109,28 +1114,29 @@ void ModelManagerInterface::updateImportPaths()
while (pInfoIter.hasNext()) {
pInfoIter.next();
QString pathAtt = pInfoIter.value().qtQmlPath;
- if (!pathAtt.isEmpty() && (allImportPaths.isEmpty() || allImportPaths.last() != pathAtt))
- allImportPaths.append(pathAtt);
+ if (!pathAtt.isEmpty())
+ allImportPaths.maybeInsert(Utils::FileName::fromString(pathAtt), Dialect::QmlQtQuick2);
}
{
QString pathAtt = defaultProjectInfo().qtQmlPath;
- if (!pathAtt.isEmpty() && (allImportPaths.isEmpty() || allImportPaths.last() != pathAtt))
- allImportPaths.append(pathAtt);
+ if (!pathAtt.isEmpty())
+ allImportPaths.maybeInsert(Utils::FileName::fromString(pathAtt), Dialect::QmlQtQuick2);
}
pInfoIter.toFront();
while (pInfoIter.hasNext()) {
pInfoIter.next();
QString pathAtt = pInfoIter.value().qtImportsPath;
- if (!pathAtt.isEmpty() && (allImportPaths.isEmpty() || allImportPaths.last() != pathAtt))
- allImportPaths.append(pathAtt);
+ if (!pathAtt.isEmpty())
+ allImportPaths.maybeInsert(Utils::FileName::fromString(pathAtt), Dialect::QmlQtQuick1);
}
{
QString pathAtt = defaultProjectInfo().qtImportsPath;
- if (!pathAtt.isEmpty() && (allImportPaths.isEmpty() || allImportPaths.last() != pathAtt))
- allImportPaths.append(pathAtt);
+ if (!pathAtt.isEmpty())
+ allImportPaths.maybeInsert(Utils::FileName::fromString(pathAtt), Dialect::QmlQtQuick1);
}
- allImportPaths += m_defaultImportPaths;
- allImportPaths.removeDuplicates();
+ foreach (const QString &path, m_defaultImportPaths)
+ allImportPaths.maybeInsert(Utils::FileName::fromString(path), Dialect::Qml);
+ allImportPaths.compact();
{
QMutexLocker l(&m_mutex);
@@ -1152,7 +1158,7 @@ void ModelManagerInterface::updateImportPaths()
if (!m_shouldScanImports)
return;
- maybeScan(allImportPaths, Language::Qml);
+ maybeScan(allImportPaths);
}
void ModelManagerInterface::loadPluginTypes(const QString &libraryPath, const QString &importPath,
@@ -1298,10 +1304,10 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
ViewerContext res = vCtx;
if (!doc.isNull()
- && ((vCtx.language == Language::AnyLanguage && doc->language() != Language::NoLanguage)
- || (vCtx.language == Language::Qml
- && (doc->language() == Language::QmlQtQuick1
- || doc->language() == Language::QmlQtQuick2))))
+ && ((vCtx.language == Dialect::AnyLanguage && doc->language() != Dialect::NoLanguage)
+ || (vCtx.language == Dialect::Qml
+ && (doc->language() == Dialect::QmlQtQuick1
+ || doc->language() == Dialect::QmlQtQuick2))))
res.language = doc->language();
ProjectInfo info;
if (!doc.isNull())
@@ -1322,17 +1328,17 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
{
foreach (const QString &path, defaultVCtx.paths)
res.maybeAddPath(path);
- switch (res.language) {
- case Language::AnyLanguage:
- case Language::Qml:
+ switch (res.language.dialect()) {
+ case Dialect::AnyLanguage:
+ case Dialect::Qml:
res.maybeAddPath(info.qtQmlPath);
// fallthrough
- case Language::QmlQtQuick1:
+ case Dialect::QmlQtQuick1:
res.maybeAddPath(info.qtImportsPath);
// fallthrough
- case Language::QmlQtQuick2:
+ case Dialect::QmlQtQuick2:
{
- if (res.language == Language::QmlQtQuick2)
+ if (res.language == Dialect::QmlQtQuick2)
res.maybeAddPath(info.qtQmlPath);
QList<ProjectInfo> allProjects;
{
@@ -1340,18 +1346,22 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
allProjects = m_projects.values();
}
std::sort(allProjects.begin(), allProjects.end(), &pInfoLessThanImports);
+ QList<Dialect> languages = res.language.companionLanguages();
foreach (const ProjectInfo &pInfo, allProjects) {
- foreach (const QString &path, pInfo.importPaths)
- res.maybeAddPath(path);
+ for (int i = 0; i< pInfo.importPaths.size(); ++i) {
+ PathAndLanguage pAndL = pInfo.importPaths.at(i);
+ if (languages.contains(pAndL.language()) || pAndL.language().companionLanguages().contains(res.language))
+ res.maybeAddPath(pAndL.path().toString());
+ }
}
break;
}
- case Language::NoLanguage:
- case Language::JavaScript:
- case Language::QmlTypeInfo:
- case Language::Json:
- case Language::QmlQbs:
- case Language::QmlProject:
+ case Dialect::NoLanguage:
+ case Dialect::JavaScript:
+ case Dialect::QmlTypeInfo:
+ case Dialect::Json:
+ case Dialect::QmlQbs:
+ case Dialect::QmlProject:
break;
}
break;
@@ -1362,11 +1372,11 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
case ViewerContext::AddDefaultPaths:
foreach (const QString &path, defaultVCtx.paths)
res.maybeAddPath(path);
- if (res.language == Language::AnyLanguage || res.language == Language::Qml
- || res.language == Language::QmlQtQuick2)
+ if (res.language == Dialect::AnyLanguage || res.language == Dialect::Qml
+ || res.language == Dialect::QmlQtQuick2)
res.maybeAddPath(info.qtImportsPath);
- if (res.language == Language::AnyLanguage || res.language == Language::Qml
- || res.language == Language::QmlQtQuick1)
+ if (res.language == Dialect::AnyLanguage || res.language == Dialect::Qml
+ || res.language == Dialect::QmlQtQuick1)
res.maybeAddPath(info.qtQmlPath);
break;
}
@@ -1374,15 +1384,15 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
return res;
}
-ViewerContext ModelManagerInterface::defaultVContext(Language::Enum language,
+ViewerContext ModelManagerInterface::defaultVContext(Dialect language,
const Document::Ptr &doc,
bool autoComplete) const
{
if (!doc.isNull()) {
- if (language == Language::AnyLanguage && doc->language() != Language::NoLanguage)
+ if (language == Dialect::AnyLanguage && doc->language() != Dialect::NoLanguage)
language = doc->language();
- else if (language == Language::Qml &&
- (doc->language() == Language::QmlQtQuick1 || doc->language() == Language::QmlQtQuick2))
+ else if (language == Dialect::Qml &&
+ (doc->language() == Dialect::QmlQtQuick1 || doc->language() == Dialect::QmlQtQuick2))
language = doc->language();
}
ViewerContext defaultCtx;
@@ -1425,7 +1435,7 @@ Document::Ptr ModelManagerInterface::ensuredGetDocumentForPath(const QString &fi
{
QmlJS::Document::Ptr document = newestSnapshot().document(filePath);
if (!document) {
- document = QmlJS::Document::create(filePath, QmlJS::Language::Qml);
+ document = QmlJS::Document::create(filePath, QmlJS::Dialect::Qml);
QMutexLocker lock(&m_mutex);
m_newestSnapshot.insert(document);
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h
index 593fc83358..b1cac13837 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.h
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h
@@ -36,9 +36,11 @@
#include "qmljsdocument.h"
#include "qmljsqrcparser.h"
#include "qmljsviewercontext.h"
+#include "qmljsdialect.h"
#include <cplusplus/CppDocument.h>
#include <utils/environment.h>
+#include <utils/fileutils.h>
#include <QFuture>
#include <QFutureSynchronizer>
@@ -93,7 +95,7 @@ public:
public: // attributes
QPointer<ProjectExplorer::Project> project;
QStringList sourceFiles;
- QStringList importPaths;
+ PathsAndLanguages importPaths;
QStringList activeResourceFiles;
QStringList allResourceFiles;
@@ -148,8 +150,8 @@ public:
ModelManagerInterface(QObject *parent = 0);
virtual ~ModelManagerInterface();
- static Language::Enum guessLanguageOfFile(const QString &fileName);
- static QStringList globPatternsForLanguages(const QList<Language::Enum> languages);
+ static Dialect guessLanguageOfFile(const QString &fileName);
+ static QStringList globPatternsForLanguages(const QList<Dialect> languages);
static ModelManagerInterface *instance();
static void writeWarning(const QString &msg);
static WorkingCopy workingCopy();
@@ -182,7 +184,7 @@ public:
void updateQrcFile(const QString &path);
ProjectInfo projectInfoForPath(QString path) const;
- QStringList importPaths() const;
+ PathsAndLanguages importPaths() const;
QmlJS::QmlLanguageBundles activeBundles() const;
QmlJS::QmlLanguageBundles extendedBundles() const;
@@ -193,7 +195,7 @@ public:
LibraryInfo builtins(const Document::Ptr &doc) const;
ViewerContext completeVContext(const ViewerContext &vCtx,
const Document::Ptr &doc = Document::Ptr(0)) const;
- ViewerContext defaultVContext(Language::Enum language = Language::Qml,
+ ViewerContext defaultVContext(Dialect language = Dialect::Qml,
const Document::Ptr &doc = Document::Ptr(0),
bool autoComplete = true) const;
void setDefaultVContext(const ViewerContext &vContext);
@@ -223,7 +225,7 @@ protected slots:
virtual void startCppQmlTypeUpdate();
protected:
QMutex *mutex() const;
- virtual QHash<QString,Language::Enum> languageForSuffix() const;
+ virtual QHash<QString,Dialect> languageForSuffix() const;
virtual void writeMessageInternal(const QString &msg) const;
virtual WorkingCopy workingCopyInternal() const;
virtual void addTaskInternal(QFuture<void> result, const QString &msg, const char *taskId) const;
@@ -233,26 +235,25 @@ protected:
static void parseLoop(QSet<QString> &scannedPaths, QSet<QString> &newLibraries,
WorkingCopy workingCopyInternal, QStringList files, ModelManagerInterface *modelManager,
- QmlJS::Language::Enum mainLanguage, bool emitDocChangedOnDisk,
+ QmlJS::Dialect mainLanguage, bool emitDocChangedOnDisk,
std::function<bool (qreal)> reportProgress);
static void parse(QFutureInterface<void> &future,
WorkingCopy workingCopyInternal,
QStringList files,
ModelManagerInterface *modelManager,
- QmlJS::Language::Enum mainLanguage,
+ QmlJS::Dialect mainLanguage,
bool emitDocChangedOnDisk);
static void importScan(QFutureInterface<void> &future,
WorkingCopy workingCopyInternal,
- QStringList paths,
+ PathsAndLanguages paths,
ModelManagerInterface *modelManager,
- QmlJS::Language::Enum mainLanguage,
bool emitDocChangedOnDisk);
static void updateCppQmlTypes(QFutureInterface<void> &interface,
ModelManagerInterface *qmlModelManager,
CPlusPlus::Snapshot snapshot,
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > documents);
- void maybeScan(const QStringList &importPaths, Language::Enum defaultLanguage);
+ void maybeScan(const PathsAndLanguages &importPaths);
void updateImportPaths();
void loadQmlTypeDescriptionsInternal(const QString &path);
void setDefaultProject(const ProjectInfo &pInfo, ProjectExplorer::Project *p);
@@ -261,11 +262,11 @@ private:
mutable QMutex m_mutex;
QmlJS::Snapshot m_validSnapshot;
QmlJS::Snapshot m_newestSnapshot;
- QStringList m_allImportPaths;
+ PathsAndLanguages m_allImportPaths;
QStringList m_defaultImportPaths;
QmlJS::QmlLanguageBundles m_activeBundles;
QmlJS::QmlLanguageBundles m_extendedBundles;
- QHash<Language::Enum, QmlJS::ViewerContext> m_defaultVContexts;
+ QHash<Dialect, QmlJS::ViewerContext> m_defaultVContexts;
bool m_shouldScanImports;
QSet<QString> m_scannedPaths;
diff --git a/src/libs/qmljs/qmljsscopechain.cpp b/src/libs/qmljs/qmljsscopechain.cpp
index 4113e47cd3..60df0e0b19 100644
--- a/src/libs/qmljs/qmljsscopechain.cpp
+++ b/src/libs/qmljs/qmljsscopechain.cpp
@@ -258,7 +258,7 @@ void ScopeChain::update() const
m_all += m_cppContextProperties;
// the root scope in js files doesn't see instantiating components
- if (m_document->language() != Language::JavaScript || m_jsScopes.count() != 1) {
+ if (m_document->language() != Dialect::JavaScript || m_jsScopes.count() != 1) {
if (m_qmlComponentScope) {
foreach (const QmlComponentChain *parent, m_qmlComponentScope->instantiatingComponents())
collectScopes(parent, &m_all);
diff --git a/src/libs/qmljs/qmljsviewercontext.cpp b/src/libs/qmljs/qmljsviewercontext.cpp
index cec6605145..14482f1158 100644
--- a/src/libs/qmljs/qmljsviewercontext.cpp
+++ b/src/libs/qmljs/qmljsviewercontext.cpp
@@ -40,11 +40,11 @@ namespace QmlJS {
Screen information will also most likely need to be added here.
*/
ViewerContext::ViewerContext()
- : language(Language::Qml), flags(AddAllPaths)
+ : language(Dialect::Qml), flags(AddAllPaths)
{ }
ViewerContext::ViewerContext(QStringList selectors, QStringList paths,
- QmlJS::Language::Enum language,
+ QmlJS::Dialect language,
QmlJS::ViewerContext::Flags flags)
: selectors(selectors), paths(paths), language(language),
flags(flags)
@@ -54,27 +54,27 @@ ViewerContext::ViewerContext(QStringList selectors, QStringList paths,
/*
which languages might be imported in this context
*/
-bool ViewerContext::languageIsCompatible(Language::Enum l) const
+bool ViewerContext::languageIsCompatible(Dialect l) const
{
- if (l == Language::AnyLanguage && language != Language::NoLanguage)
+ if (l == Dialect::AnyLanguage && language != Dialect::NoLanguage)
return true;
- switch (language) {
- case Language::JavaScript:
- case Language::Json:
- case Language::QmlProject:
- case Language::QmlQbs:
- case Language::QmlTypeInfo:
+ switch (language.dialect()) {
+ case Dialect::JavaScript:
+ case Dialect::Json:
+ case Dialect::QmlProject:
+ case Dialect::QmlQbs:
+ case Dialect::QmlTypeInfo:
return language == l;
- case Language::Qml:
- return l == Language::Qml || l == Language::QmlQtQuick1 || l == Language::QmlQtQuick2
- || l == Language::JavaScript;
- case Language::QmlQtQuick1:
- return l == Language::Qml || l == Language::QmlQtQuick1 || l == Language::JavaScript;
- case Language::QmlQtQuick2:
- return l == Language::Qml || l == Language::QmlQtQuick2 || l == Language::JavaScript;
- case Language::AnyLanguage:
+ case Dialect::Qml:
+ return l == Dialect::Qml || l == Dialect::QmlQtQuick1 || l == Dialect::QmlQtQuick2
+ || l == Dialect::JavaScript;
+ case Dialect::QmlQtQuick1:
+ return l == Dialect::Qml || l == Dialect::QmlQtQuick1 || l == Dialect::JavaScript;
+ case Dialect::QmlQtQuick2:
+ return l == Dialect::Qml || l == Dialect::QmlQtQuick2 || l == Dialect::JavaScript;
+ case Dialect::AnyLanguage:
return true;
- case Language::NoLanguage:
+ case Dialect::NoLanguage:
break;
}
return false;
diff --git a/src/libs/qmljs/qmljsviewercontext.h b/src/libs/qmljs/qmljsviewercontext.h
index f4b3639226..1e5c7c262a 100644
--- a/src/libs/qmljs/qmljsviewercontext.h
+++ b/src/libs/qmljs/qmljsviewercontext.h
@@ -32,6 +32,7 @@
#include "qmljs_global.h"
#include "qmljsconstants.h"
+#include "qmljsdialect.h"
#include <QStringList>
@@ -50,15 +51,15 @@ public:
ViewerContext();
ViewerContext(QStringList selectors, QStringList paths,
- Language::Enum language = Language::Qml,
+ Dialect language = Dialect::Qml,
Flags flags = AddAllPaths);
- bool languageIsCompatible(Language::Enum l) const;
+ bool languageIsCompatible(Dialect l) const;
void maybeAddPath(const QString &path);
QStringList selectors;
QStringList paths;
- Language::Enum language;
+ Dialect language;
Flags flags;
};
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
index ccfcc4d7a2..83ac0be0f4 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
@@ -610,7 +610,9 @@ void QmakeProject::updateQmlJSCodeModel()
bool hasQmlLib = false;
foreach (QmakeProFileNode *node, proFiles) {
- projectInfo.importPaths.append(node->variableValue(QmlImportPathVar));
+ foreach (const QString &path, node->variableValue(QmlImportPathVar))
+ projectInfo.importPaths.maybeInsert(Utils::FileName::fromString(path),
+ QmlJS::Dialect::Qml);
projectInfo.activeResourceFiles.append(node->variableValue(ExactResourceVar));
projectInfo.allResourceFiles.append(node->variableValue(ResourceVar));
if (!hasQmlLib) {
@@ -630,7 +632,6 @@ void QmakeProject::updateQmlJSCodeModel()
pl.add(ProjectExplorer::Constants::LANG_QMLJS);
setProjectLanguages(pl);
- projectInfo.importPaths.removeDuplicates();
projectInfo.activeResourceFiles.removeDuplicates();
projectInfo.allResourceFiles.removeDuplicates();
diff --git a/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.cpp b/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.cpp
index c247d90f13..c3eb6e8c7d 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.cpp
@@ -36,7 +36,7 @@ using namespace QmlDesigner;
using namespace QmlJS::AST;
ASTObjectTextExtractor::ASTObjectTextExtractor(const QString &text):
- m_document(Document::create("<ASTObjectTextExtractor>", Language::Qml))
+ m_document(Document::create("<ASTObjectTextExtractor>", Dialect::Qml))
{
m_document->setSource(text);
m_document->parseQml();
diff --git a/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.cpp b/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.cpp
index 340b27a4b2..b044dfabb2 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.cpp
@@ -38,7 +38,7 @@ using namespace QmlDesigner;
using namespace QmlJS::AST;
FirstDefinitionFinder::FirstDefinitionFinder(const QString &text):
- m_doc(Document::create("<internal>", Language::Qml))
+ m_doc(Document::create("<internal>", Dialect::Qml))
{
m_doc->setSource(text);
bool ok = m_doc->parseQml();
diff --git a/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.cpp b/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.cpp
index 6ce6a7aaff..c9d920d387 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.cpp
@@ -36,7 +36,7 @@ using namespace QmlDesigner;
using namespace QmlJS::AST;
ObjectLengthCalculator::ObjectLengthCalculator():
- m_doc(Document::create("<internal>", Language::Qml))
+ m_doc(Document::create("<internal>", Dialect::Qml))
{
}
diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp
index 7dc79a2074..51b80a588f 100644
--- a/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp
+++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrefactoring.cpp
@@ -59,7 +59,7 @@ bool QmlRefactoring::reparseDocument()
// qDebug() << "QmlRefactoring::reparseDocument() new QML source:" << newSource;
- Document::MutablePtr tmpDocument(Document::create("<ModelToTextMerger>", Language::Qml));
+ Document::MutablePtr tmpDocument(Document::create("<ModelToTextMerger>", Dialect::Qml));
tmpDocument->setSource(newSource);
if (tmpDocument->parseQml()) {
diff --git a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
index fc92f460d1..74b8234653 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
@@ -82,7 +82,7 @@ static inline bool checkIfDerivedFromItem(const QString &fileName)
QmlJS::Document::MutablePtr document =
QmlJS::Document::create(fileName.isEmpty() ?
- QStringLiteral("<internal>") : fileName, QmlJS::Language::Qml);
+ QStringLiteral("<internal>") : fileName, QmlJS::Dialect::Qml);
document->setSource(source);
document->parseQml();
diff --git a/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp b/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
index b493514c77..1623e1ab21 100644
--- a/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
@@ -222,7 +222,7 @@ void ModelToTextMerger::applyChanges()
if (m_rewriteActions.isEmpty())
return;
- Document::MutablePtr tmpDocument(Document::create(QStringLiteral("<ModelToTextMerger>"), Language::Qml));
+ Document::MutablePtr tmpDocument(Document::create(QStringLiteral("<ModelToTextMerger>"), Dialect::Qml));
tmpDocument->setSource(m_rewriterView->textModifier()->text());
if (!tmpDocument->parseQml()) {
qDebug() << "*** Possible problem: QML file wasn't parsed correctly.";
diff --git a/src/plugins/qmldesigner/designercore/model/plaintexteditmodifier.cpp b/src/plugins/qmldesigner/designercore/model/plaintexteditmodifier.cpp
index 71c22c9d3d..25eadec4e1 100644
--- a/src/plugins/qmldesigner/designercore/model/plaintexteditmodifier.cpp
+++ b/src/plugins/qmldesigner/designercore/model/plaintexteditmodifier.cpp
@@ -204,7 +204,7 @@ QStringList PlainTextEditModifier::importPaths() const
QString documentFilePath = textDocument()->baseUrl().toLocalFile();
if (!documentFilePath.isEmpty()) {
QmlJS::Document::Ptr qmljsDocument = modelManager->snapshot().document(documentFilePath);
- return modelManager->defaultVContext(QmlJS::Language::Qml, qmljsDocument, true).paths;
+ return modelManager->defaultVContext(QmlJS::Dialect::Qml, qmljsDocument, true).paths;
}
}
diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
index 8a1ba2e664..7807e91aad 100644
--- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
@@ -828,7 +828,7 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
try {
Snapshot snapshot = m_rewriterView->textModifier()->qmljsSnapshot();
const QString fileName = url.toLocalFile();
- Document::MutablePtr doc = Document::create(fileName.isEmpty() ? QStringLiteral("<internal>") : fileName, Language::Qml);
+ Document::MutablePtr doc = Document::create(fileName.isEmpty() ? QStringLiteral("<internal>") : fileName, Dialect::Qml);
doc->setSource(data);
doc->parseQml();
@@ -841,7 +841,7 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
return false;
}
snapshot.insert(doc);
- QmlJS::ViewerContext vContext = QmlJS::ModelManagerInterface::instance()->defaultVContext(Language::Qml, doc, true);
+ QmlJS::ViewerContext vContext = QmlJS::ModelManagerInterface::instance()->defaultVContext(Dialect::Qml, doc, true);
ReadingContext ctxt(snapshot, doc, vContext);
m_scopeChain = QSharedPointer<const ScopeChain>(
new ScopeChain(ctxt.scopeChain()));
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp
index 8a08aaf055..2c846eb851 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.cpp
+++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp
@@ -364,9 +364,9 @@ static bool checkIfEditorIsQtQuick(Core::IEditor *editor)
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance();
QmlJS::Document::Ptr document = modelManager->ensuredGetDocumentForPath(editor->document()->filePath());
if (!document.isNull())
- return document->language() == QmlJS::Language::QmlQtQuick1
- || document->language() == QmlJS::Language::QmlQtQuick2
- || document->language() == QmlJS::Language::Qml;
+ return document->language() == QmlJS::Dialect::QmlQtQuick1
+ || document->language() == QmlJS::Dialect::QmlQtQuick2
+ || document->language() == QmlJS::Dialect::Qml;
}
return false;
diff --git a/src/plugins/qmljseditor/qmlexpressionundercursor.cpp b/src/plugins/qmljseditor/qmlexpressionundercursor.cpp
index 39f2b09f14..aa6510f43a 100644
--- a/src/plugins/qmljseditor/qmlexpressionundercursor.cpp
+++ b/src/plugins/qmljseditor/qmlexpressionundercursor.cpp
@@ -134,7 +134,7 @@ QmlJS::AST::ExpressionNode *QmlExpressionUnderCursor::operator()(const QTextCurs
_text = expressionUnderCursor(cursor);
Document::MutablePtr newDoc = Document::create(
- QLatin1String("<expression>"), Language::JavaScript);
+ QLatin1String("<expression>"), Dialect::JavaScript);
newDoc->setSource(_text);
newDoc->parseExpression();
exprDoc = newDoc;
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index 1b2c3ff137..51e656203d 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -232,7 +232,7 @@ void QmlJSTextEditorWidget::updateCodeWarnings(QmlJS::Document::Ptr doc)
{
if (doc->ast()) {
setExtraSelections(CodeWarningsSelection, QList<QTextEdit::ExtraSelection>());
- } else if (Document::isFullySupportedLanguage(doc->language())) {
+ } else if (doc->language().isFullySupportedLanguage()) {
// show parsing errors
QList<QTextEdit::ExtraSelection> selections;
appendExtraSelectionsForMessages(&selections, doc->diagnosticMessages(), document());
diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp
index 0af1dbd349..01698457ce 100644
--- a/src/plugins/qmljseditor/qmljsfindreferences.cpp
+++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp
@@ -812,14 +812,14 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
if (oldDoc && oldDoc->editorRevision() == it.value().second)
continue;
- Language::Enum language;
+ Dialect language;
if (oldDoc)
language = oldDoc->language();
else
language = ModelManagerInterface::guessLanguageOfFile(fileName);
- if (language == Language::NoLanguage) {
+ if (language == Dialect::NoLanguage) {
qCDebug(qmljsLog) << "NoLanguage in qmljsfindreferences.cpp find_helper for " << fileName;
- language = Language::AnyLanguage;
+ language = Dialect::AnyLanguage;
}
Document::MutablePtr newDoc = snapshot.documentFromSource(
diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
index 4d76c94eae..f597d29078 100644
--- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
+++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
@@ -434,7 +434,7 @@ private:
void run()
{
int nMessages = 0;
- if (Document::isFullySupportedLanguage(m_scopeChain.document()->language())) {
+ if (m_scopeChain.document()->language().isFullySupportedLanguage()) {
nMessages = m_scopeChain.document()->diagnosticMessages().size()
+ m_semanticInfo.semanticMessages.size()
+ m_semanticInfo.staticAnalysisMessages.size();
diff --git a/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp b/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp
index 84d280aa24..3a5743945a 100644
--- a/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp
+++ b/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp
@@ -128,7 +128,7 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D
ScopeChain *scopeChain = new ScopeChain(doc, semanticInfo.context);
semanticInfo.setRootScopeChain(QSharedPointer<const ScopeChain>(scopeChain));
- if (doc->language() == Language::Json) {
+ if (doc->language() == Dialect::Json) {
Utils::JsonSchema *schema =
QmlJSEditorPlugin::instance()->jsonManager()->schemaForFile(doc->fileName());
if (schema) {
diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp
index cf3e35ead3..dbc50b59d3 100644
--- a/src/plugins/qmljseditor/qmltaskmanager.cpp
+++ b/src/plugins/qmljseditor/qmltaskmanager.cpp
@@ -109,7 +109,7 @@ void QmlTaskManager::collectMessages(
FileErrorMessages result;
result.fileName = fileName;
- if (Document::isFullySupportedLanguage(document->language())) {
+ if (document->language().isFullySupportedLanguage()) {
result.tasks = convertToTasks(document->diagnosticMessages(),
Utils::FileName::fromString(fileName),
Core::Id(Constants::TASK_CATEGORY_QML));
@@ -161,7 +161,7 @@ void QmlTaskManager::updateMessagesNow(bool updateSemantic)
QFuture<FileErrorMessages> future =
QtConcurrent::run<FileErrorMessages>(
&collectMessages, modelManager->newestSnapshot(), modelManager->projectInfos(),
- modelManager->defaultVContext(Language::AnyLanguage), updateSemantic);
+ modelManager->defaultVContext(Dialect::AnyLanguage), updateSemantic);
m_messageCollector.setFuture(future);
}
diff --git a/src/plugins/qmljstools/qmljsbundleprovider.cpp b/src/plugins/qmljstools/qmljsbundleprovider.cpp
index 1c065c2c81..5b125591f1 100644
--- a/src/plugins/qmljstools/qmljsbundleprovider.cpp
+++ b/src/plugins/qmljstools/qmljsbundleprovider.cpp
@@ -112,21 +112,21 @@ void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
{
QHash<QString,QString> myReplacements = replacements;
- bundles.mergeBundleForLanguage(Language::QmlQbs, defaultQbsBundle());
- bundles.mergeBundleForLanguage(Language::QmlTypeInfo, defaultQmltypesBundle());
- bundles.mergeBundleForLanguage(Language::QmlProject, defaultQmlprojectBundle());
+ bundles.mergeBundleForLanguage(Dialect::QmlQbs, defaultQbsBundle());
+ bundles.mergeBundleForLanguage(Dialect::QmlTypeInfo, defaultQmltypesBundle());
+ bundles.mergeBundleForLanguage(Dialect::QmlProject, defaultQmlprojectBundle());
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(kit);
if (!qtVersion) {
QmlBundle b1(defaultQt4QtQuick1Bundle());
- bundles.mergeBundleForLanguage(Language::Qml, b1);
- bundles.mergeBundleForLanguage(Language::QmlQtQuick1, b1);
+ bundles.mergeBundleForLanguage(Dialect::Qml, b1);
+ bundles.mergeBundleForLanguage(Dialect::QmlQtQuick1, b1);
QmlBundle b11(defaultQt5QtQuick1Bundle());
- bundles.mergeBundleForLanguage(Language::Qml, b11);
- bundles.mergeBundleForLanguage(Language::QmlQtQuick1, b11);
+ bundles.mergeBundleForLanguage(Dialect::Qml, b11);
+ bundles.mergeBundleForLanguage(Dialect::QmlQtQuick1, b11);
QmlBundle b2(defaultQt5QtQuick2Bundle());
- bundles.mergeBundleForLanguage(Language::Qml, b2);
- bundles.mergeBundleForLanguage(Language::QmlQtQuick2, b2);
+ bundles.mergeBundleForLanguage(Dialect::Qml, b2);
+ bundles.mergeBundleForLanguage(Dialect::QmlQtQuick2, b2);
return;
}
QString qtImportsPath = qtVersion->qmakeProperty("QT_INSTALL_IMPORTS");
@@ -157,8 +157,8 @@ void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
qtQuick1Bundle.merge(defaultQt5QtQuick1Bundle());
}
qtQuick1Bundle.replaceVars(myReplacements);
- bundles.mergeBundleForLanguage(Language::Qml, qtQuick1Bundle);
- bundles.mergeBundleForLanguage(Language::QmlQtQuick1, qtQuick1Bundle);
+ bundles.mergeBundleForLanguage(Dialect::Qml, qtQuick1Bundle);
+ bundles.mergeBundleForLanguage(Dialect::QmlQtQuick1, qtQuick1Bundle);
}
if (features.contains(Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_2))) {
myReplacements.insert(QLatin1String("$(CURRENT_DIRECTORY)"), qtQmlPath);
@@ -179,8 +179,8 @@ void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
qtQuick2Bundle.merge(defaultQt5QtQuick2Bundle());
}
qtQuick2Bundle.replaceVars(myReplacements);
- bundles.mergeBundleForLanguage(Language::Qml, qtQuick2Bundle);
- bundles.mergeBundleForLanguage(Language::QmlQtQuick2, qtQuick2Bundle);
+ bundles.mergeBundleForLanguage(Dialect::Qml, qtQuick2Bundle);
+ bundles.mergeBundleForLanguage(Dialect::QmlQtQuick2, qtQuick2Bundle);
}
}
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index 7f95370e8d..fc3f0f744b 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -174,26 +174,26 @@ void QmlJSTools::setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &
}
}
-QHash<QString,QmlJS::Language::Enum> ModelManager::languageForSuffix() const
+QHash<QString,QmlJS::Dialect> ModelManager::languageForSuffix() const
{
- QHash<QString,QmlJS::Language::Enum> res = ModelManagerInterface::languageForSuffix();
+ QHash<QString,QmlJS::Dialect> res = ModelManagerInterface::languageForSuffix();
if (ICore::instance()) {
MimeType jsSourceTy = MimeDatabase::findByType(QLatin1String(Constants::JS_MIMETYPE));
foreach (const QString &suffix, jsSourceTy.suffixes())
- res[suffix] = Language::JavaScript;
+ res[suffix] = Dialect::JavaScript;
MimeType qmlSourceTy = MimeDatabase::findByType(QLatin1String(Constants::QML_MIMETYPE));
foreach (const QString &suffix, qmlSourceTy.suffixes())
- res[suffix] = Language::Qml;
+ res[suffix] = Dialect::Qml;
MimeType qbsSourceTy = MimeDatabase::findByType(QLatin1String(Constants::QBS_MIMETYPE));
foreach (const QString &suffix, qbsSourceTy.suffixes())
- res[suffix] = Language::QmlQbs;
+ res[suffix] = Dialect::QmlQbs;
MimeType qmlProjectSourceTy = MimeDatabase::findByType(QLatin1String(Constants::QMLPROJECT_MIMETYPE));
foreach (const QString &suffix, qmlProjectSourceTy.suffixes())
- res[suffix] = Language::QmlProject;
+ res[suffix] = Dialect::QmlProject;
MimeType jsonSourceTy = MimeDatabase::findByType(QLatin1String(Constants::JSON_MIMETYPE));
foreach (const QString &suffix, jsonSourceTy.suffixes())
- res[suffix] = Language::Json;
+ res[suffix] = Dialect::Json;
}
return res;
}
@@ -226,7 +226,7 @@ void ModelManager::delayedInitialization()
SLOT(updateDefaultProjectInfo()));
QmlJS::ViewerContext qbsVContext;
- qbsVContext.language = Language::QmlQbs;
+ qbsVContext.language = Dialect::QmlQbs;
qbsVContext.maybeAddPath(ICore::resourcePath() + QLatin1String("/qbs"));
setDefaultVContext(qbsVContext);
}
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.h b/src/plugins/qmljstools/qmljsmodelmanager.h
index ec49e637f2..ca0b2504a1 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.h
+++ b/src/plugins/qmljstools/qmljsmodelmanager.h
@@ -68,7 +68,7 @@ public:
void delayedInitialization();
protected:
- QHash<QString, QmlJS::Language::Enum> languageForSuffix() const QTC_OVERRIDE;
+ QHash<QString, QmlJS::Dialect> languageForSuffix() const QTC_OVERRIDE;
void writeMessageInternal(const QString &msg) const QTC_OVERRIDE;
WorkingCopy workingCopyInternal() const QTC_OVERRIDE;
void addTaskInternal(QFuture<void> result, const QString &msg, const char *taskId) const QTC_OVERRIDE;
diff --git a/src/plugins/qmljstools/qmljsrefactoringchanges.cpp b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp
index 4ef9bb2206..fb1c14f036 100644
--- a/src/plugins/qmljstools/qmljsrefactoringchanges.cpp
+++ b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp
@@ -124,7 +124,7 @@ QmlJSRefactoringFile::QmlJSRefactoringFile(const QString &fileName, const QShare
: RefactoringFile(fileName, data)
{
// the RefactoringFile is invalid if its not for a file with qml or js code
- if (ModelManagerInterface::guessLanguageOfFile(fileName) == Language::NoLanguage)
+ if (ModelManagerInterface::guessLanguageOfFile(fileName) == Dialect::NoLanguage)
m_fileName.clear();
}
diff --git a/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp b/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp
index 38b0808774..be79adeaca 100644
--- a/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp
@@ -136,7 +136,7 @@ void QmlProfilerDetailsRewriter::requestDetailsForLocation(int requestId,
QFileInfo fileInfo(localFile);
if (!fileInfo.exists() || !fileInfo.isReadable())
return;
- if (!QmlJS::Document::isQmlLikeLanguage(QmlJS::ModelManagerInterface::guessLanguageOfFile(localFile)))
+ if (!QmlJS::ModelManagerInterface::guessLanguageOfFile(localFile).isQmlLikeLanguage())
return;
PendingEvent ev = {location, localFile, requestId};
diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp
index ed46381952..5b45fb560e 100644
--- a/src/plugins/qmlprojectmanager/qmlproject.cpp
+++ b/src/plugins/qmlprojectmanager/qmlproject.cpp
@@ -201,7 +201,9 @@ void QmlProject::refresh(RefreshOptions options)
QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
modelManager()->defaultProjectInfoForProject(this);
- projectInfo.importPaths = customImportPaths();
+ foreach (const QString &searchPath, customImportPaths())
+ projectInfo.importPaths.maybeInsert(Utils::FileName::fromString(searchPath),
+ QmlJS::Dialect::Qml);
modelManager()->updateProjectInfo(projectInfo, this);
}