summaryrefslogtreecommitdiff
path: root/src/plugins/qmljseditor
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-09-09 10:55:11 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2011-09-12 10:45:53 +0200
commit903c6b60cdd6c67b4fa5935d25213625e5f22724 (patch)
treed6169a5a010a027cf7e26ac6deb16fd551b3fbbd /src/plugins/qmljseditor
parent509eb894dda8c1542a379b3886f1d450c1f541e7 (diff)
downloadqt-creator-903c6b60cdd6c67b4fa5935d25213625e5f22724.tar.gz
QmlJS: Use mime types to distinguish qml and js files.
This allows adding patterns to the qml mime type in the options dialog. Previously they were always parsed as js. Change-Id: Ifa344fb6ab8cbcda02becef991cf6807615a1caa Reviewed-on: http://codereview.qt-project.org/4515 Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
Diffstat (limited to 'src/plugins/qmljseditor')
-rw-r--r--src/plugins/qmljseditor/qmlexpressionundercursor.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljsfindreferences.cpp13
-rw-r--r--src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp8
3 files changed, 19 insertions, 4 deletions
diff --git a/src/plugins/qmljseditor/qmlexpressionundercursor.cpp b/src/plugins/qmljseditor/qmlexpressionundercursor.cpp
index 8b9a8a66a4..60e90b60de 100644
--- a/src/plugins/qmljseditor/qmlexpressionundercursor.cpp
+++ b/src/plugins/qmljseditor/qmlexpressionundercursor.cpp
@@ -136,7 +136,7 @@ QmlJS::AST::ExpressionNode *QmlExpressionUnderCursor::operator()(const QTextCurs
ExpressionUnderCursor expressionUnderCursor;
_text = expressionUnderCursor(cursor);
- exprDoc = Document::create(QLatin1String("<expression>"));
+ exprDoc = Document::create(QLatin1String("<expression>"), Document::JavaScriptLanguage);
exprDoc->setSource(_text);
exprDoc->parseExpression();
diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp
index d8afb967fc..8581255843 100644
--- a/src/plugins/qmljseditor/qmljsfindreferences.cpp
+++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp
@@ -51,6 +51,7 @@
#include <qmljs/qmljscontext.h>
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/parser/qmljsast_p.h>
+#include <qmljstools/qmljsmodelmanager.h>
#include "qmljseditorconstants.h"
@@ -799,11 +800,19 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
QHashIterator< QString, QPair<QString, int> > it(workingCopy.all());
while (it.hasNext()) {
it.next();
- Document::Ptr oldDoc = snapshot.document(it.key());
+ const QString fileName = it.key();
+ Document::Ptr oldDoc = snapshot.document(fileName);
if (oldDoc && oldDoc->editorRevision() == it.value().second)
continue;
- Document::Ptr newDoc = snapshot.documentFromSource(it.key(), it.value().first);
+ Document::Language language;
+ if (oldDoc)
+ language = oldDoc->language();
+ else
+ language = QmlJSTools::languageOfFile(fileName);
+
+ Document::Ptr newDoc = snapshot.documentFromSource(it.value().first, fileName,
+ language);
newDoc->parse();
snapshot.insert(newDoc);
}
diff --git a/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp b/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp
index 6ba69bd424..8bc7c47a58 100644
--- a/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp
+++ b/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp
@@ -37,6 +37,7 @@
#include <qmljs/qmljscheck.h>
#include <qmljs/qmljscontext.h>
#include <qmljs/qmljslink.h>
+#include <qmljstools/qmljsmodelmanager.h>
namespace QmlJSEditor {
namespace Internal {
@@ -122,7 +123,12 @@ SemanticInfo SemanticInfoUpdater::semanticInfo(const SemanticInfoUpdaterSource &
if (! doc) {
snapshot = source.snapshot;
- doc = snapshot.documentFromSource(source.code, source.fileName);
+ QmlJS::Document::Language language;
+ if (m_lastSemanticInfo.document)
+ language = m_lastSemanticInfo.document->language();
+ else
+ language = QmlJSTools::languageOfFile(source.fileName);
+ doc = snapshot.documentFromSource(source.code, source.fileName, language);
doc->setEditorRevision(source.revision);
doc->parse();
snapshot.insert(doc);