Skip to content
Snippets Groups Projects
Commit e5635e09 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Temporary fix to get completion working in more cases. The "real" fix will...

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.
parent 2c3f1b91
No related branches found
No related tags found
No related merge requests found
...@@ -78,9 +78,10 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) ...@@ -78,9 +78,10 @@ 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;
if (program) { if (program) {
QmlExpressionUnderCursor expressionUnderCursor; QmlExpressionUnderCursor expressionUnderCursor;
...@@ -90,7 +91,9 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) ...@@ -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 ...@@ -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 ...@@ -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() ...@@ -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;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment