forked from qt-creator/qt-creator
Temporary fix to get completion working in more cases. The "real" fix will have to wait until the integration of the/a QML meta-type system.
This commit is contained in:
@@ -78,9 +78,10 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
if (!qmlDocument->program())
|
||||
qmlDocument = m_modelManager->snapshot().value(qmlDocument->fileName());
|
||||
|
||||
if (qmlDocument->program()) {
|
||||
// FIXME: this completion strategy is not going to work when the document was never parsed correctly.
|
||||
if (qmlDocument && qmlDocument->program()) {
|
||||
QmlJS::AST::UiProgram *program = qmlDocument->program();
|
||||
// qDebug() << "*** program:" << program;
|
||||
// qDebug() << "*** program:" << program;
|
||||
|
||||
if (program) {
|
||||
QmlExpressionUnderCursor expressionUnderCursor;
|
||||
@@ -90,7 +91,9 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
|
||||
QmlLookupContext context(expressionUnderCursor.expressionScopes(), qmlDocument, m_modelManager->snapshot());
|
||||
QmlResolveExpression resolver(context);
|
||||
// qDebug()<<"*** expression under cursor:"<<expressionUnderCursor.expressionNode();
|
||||
QList<QmlSymbol*> symbols = resolver.visibleSymbols(expressionUnderCursor.expressionNode());
|
||||
// qDebug()<<"***"<<symbols.size()<<"visible symbols";
|
||||
|
||||
foreach (QmlSymbol *symbol, symbols) {
|
||||
QString word;
|
||||
|
||||
@@ -94,6 +94,8 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
|
||||
if (!import)
|
||||
continue;
|
||||
|
||||
// TODO: handle Qt imports
|
||||
|
||||
if (!(import->fileName))
|
||||
continue;
|
||||
|
||||
@@ -107,6 +109,7 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: handle Qt imports, hack for now:
|
||||
return resolveBuildinType(name);
|
||||
}
|
||||
|
||||
@@ -297,5 +300,9 @@ QList<QmlSymbol*> QmlLookupContext::visibleTypes()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: handle Qt imports, hack for now:
|
||||
foreach (const QString &name, qmlMetaTypes)
|
||||
result.append(resolveBuildinType(name));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user