Disable the QML black magic thingie when working on JS files.

This commit is contained in:
Roberto Raggi
2010-01-26 11:51:44 +01:00
parent 1ba889a1bf
commit cb688f05f3

View File

@@ -787,6 +787,10 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
const QFileInfo currentFileInfo(fileName);
const QString currentFilePath = currentFileInfo.absolutePath();
bool isQmlFile = false;
if (currentFileInfo.suffix() == QLatin1String("qml"))
isQmlFile = true;
const QIcon componentIcon = iconForColor(Qt::yellow);
const QIcon symbolIcon = iconForColor(Qt::darkCyan);
@@ -840,7 +844,10 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
}
// Set up the current scope chain.
Interpreter::ObjectValue *scope = interp.newObject(/* prototype = */ 0);
Interpreter::ObjectValue *scope = interp.globalObject();
if (isQmlFile) {
scope = interp.newObject(/* prototype = */ 0);
AST::UiObjectMember *declaringMember = 0;
AST::UiObjectMember *parentMember = 0;
@@ -899,6 +906,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
if (parentItem)
scope->setProperty(QLatin1String("parent"), parentItem);
}
// Search for the operator that triggered the completion.
QChar completionOperator;
@@ -995,6 +1003,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
return -1;
}
if (isQmlFile) {
if (completionOperator.isNull()
|| completionOperator.isSpace()
|| completionOperator == QLatin1Char('{')
@@ -1004,6 +1013,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
updateSnippets();
m_completions.append(m_snippets);
}
}
if (! m_completions.isEmpty())
return m_startPosition;