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:
Erik Verbruggen
2009-10-09 11:24:24 +02:00
parent 2c3f1b9103
commit e5635e091e
2 changed files with 12 additions and 2 deletions

View File

@@ -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;