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,7 +78,8 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
|||||||
if (!qmlDocument->program())
|
if (!qmlDocument->program())
|
||||||
qmlDocument = m_modelManager->snapshot().value(qmlDocument->fileName());
|
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();
|
QmlJS::AST::UiProgram *program = qmlDocument->program();
|
||||||
// qDebug() << "*** program:" << program;
|
// qDebug() << "*** program:" << program;
|
||||||
|
|
||||||
@@ -90,7 +91,9 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
|||||||
|
|
||||||
QmlLookupContext context(expressionUnderCursor.expressionScopes(), qmlDocument, m_modelManager->snapshot());
|
QmlLookupContext context(expressionUnderCursor.expressionScopes(), qmlDocument, m_modelManager->snapshot());
|
||||||
QmlResolveExpression resolver(context);
|
QmlResolveExpression resolver(context);
|
||||||
|
// qDebug()<<"*** expression under cursor:"<<expressionUnderCursor.expressionNode();
|
||||||
QList<QmlSymbol*> symbols = resolver.visibleSymbols(expressionUnderCursor.expressionNode());
|
QList<QmlSymbol*> symbols = resolver.visibleSymbols(expressionUnderCursor.expressionNode());
|
||||||
|
// qDebug()<<"***"<<symbols.size()<<"visible symbols";
|
||||||
|
|
||||||
foreach (QmlSymbol *symbol, symbols) {
|
foreach (QmlSymbol *symbol, symbols) {
|
||||||
QString word;
|
QString word;
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
|
|||||||
if (!import)
|
if (!import)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// TODO: handle Qt imports
|
||||||
|
|
||||||
if (!(import->fileName))
|
if (!(import->fileName))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -107,6 +109,7 @@ QmlSymbol *QmlLookupContext::resolveType(const QString &name, const QString &fil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: handle Qt imports, hack for now:
|
||||||
return resolveBuildinType(name);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user