forked from qt-creator/qt-creator
QmlJS: Complete '{' instad of ':' at the end of 'A on b' bindings.
Task-number: QTCREATORBUG-2642 Reviewed-by: Erik Verbruggen
This commit is contained in:
@@ -132,7 +132,6 @@ void CompletionContextFinder::checkBinding()
|
||||
int i = m_startTokenIndex;
|
||||
int colonCount = 0;
|
||||
bool delimiterFound = false;
|
||||
bool firstToken = true;
|
||||
bool identifierExpected = false;
|
||||
bool dotExpected = false;
|
||||
while (!delimiterFound) {
|
||||
@@ -158,19 +157,19 @@ void CompletionContextFinder::checkBinding()
|
||||
++colonCount;
|
||||
identifierExpected = true;
|
||||
dotExpected = false;
|
||||
m_behaviorBinding = false;
|
||||
m_bindingPropertyName.clear();
|
||||
break;
|
||||
|
||||
case Token::Identifier: {
|
||||
QStringRef tokenString = yyLine->midRef(token.begin(), token.length);
|
||||
if (firstToken && tokenString == QLatin1String("on")) {
|
||||
m_behaviorBinding = true;
|
||||
} else if (identifierExpected) {
|
||||
dotExpected = false;
|
||||
if (identifierExpected) {
|
||||
m_bindingPropertyName.prepend(tokenString.toString());
|
||||
identifierExpected = false;
|
||||
dotExpected = true;
|
||||
} else {
|
||||
dotExpected = false;
|
||||
} else if (tokenString == QLatin1String("on")) {
|
||||
m_behaviorBinding = true;
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -190,7 +189,6 @@ void CompletionContextFinder::checkBinding()
|
||||
}
|
||||
|
||||
--i;
|
||||
firstToken = false;
|
||||
}
|
||||
|
||||
YY_RESTORE();
|
||||
|
||||
@@ -678,7 +678,7 @@ void CodeCompletion::addCompletions(const QStringList &newCompletions,
|
||||
|
||||
void CodeCompletion::addCompletionsPropertyLhs(
|
||||
const QHash<QString, const Interpreter::Value *> &newCompletions,
|
||||
const QIcon &icon, int order)
|
||||
const QIcon &icon, int order, bool afterOn)
|
||||
{
|
||||
QHashIterator<QString, const Interpreter::Value *> it(newCompletions);
|
||||
while (it.hasNext()) {
|
||||
@@ -686,15 +686,19 @@ void CodeCompletion::addCompletionsPropertyLhs(
|
||||
|
||||
TextEditor::CompletionItem item(this);
|
||||
item.text = it.key();
|
||||
|
||||
QLatin1String postfix(": ");
|
||||
if (afterOn)
|
||||
postfix = QLatin1String(" {");
|
||||
if (const Interpreter::QmlObjectValue *qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(it.value())) {
|
||||
// to distinguish "anchors." from "gradient:" we check if the right hand side
|
||||
// type is instantiatable or is the prototype of an instantiatable object
|
||||
if (qmlValue->hasChildInPackage())
|
||||
item.text.append(QLatin1String(": "));
|
||||
item.text.append(postfix);
|
||||
else
|
||||
item.text.append(QLatin1Char('.'));
|
||||
} else {
|
||||
item.text.append(QLatin1String(": "));
|
||||
item.text.append(postfix);
|
||||
}
|
||||
item.icon = icon;
|
||||
item.order = order;
|
||||
@@ -817,7 +821,7 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
idPropertyCompletion.order = PropertyOrder;
|
||||
m_completions.append(idPropertyCompletion);
|
||||
|
||||
addCompletionsPropertyLhs(enumerateProperties(qmlScopeType), symbolIcon, PropertyOrder);
|
||||
addCompletionsPropertyLhs(enumerateProperties(qmlScopeType), symbolIcon, PropertyOrder, contextFinder.isAfterOnInLhsOfBinding());
|
||||
if (const Interpreter::ObjectValue *qmlTypes = context->scopeChain().qmlTypes)
|
||||
addCompletions(enumerateProperties(qmlTypes), symbolIcon, TypeOrder);
|
||||
|
||||
@@ -895,7 +899,7 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
if (value && completionOperator == QLatin1Char('.')) { // member completion
|
||||
EnumerateProperties enumerateProperties(context);
|
||||
if (contextFinder.isInLhsOfBinding() && qmlScopeType && expressionUnderCursor.text().at(0).isLower())
|
||||
addCompletionsPropertyLhs(enumerateProperties(value), symbolIcon, PropertyOrder);
|
||||
addCompletionsPropertyLhs(enumerateProperties(value), symbolIcon, PropertyOrder, contextFinder.isAfterOnInLhsOfBinding());
|
||||
else
|
||||
addCompletions(enumerateProperties(value), symbolIcon, SymbolOrder);
|
||||
} else if (value && completionOperator == QLatin1Char('(') && m_startPosition == editor->position()) {
|
||||
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
const QIcon &icon, int relevance);
|
||||
void addCompletionsPropertyLhs(
|
||||
const QHash<QString, const QmlJS::Interpreter::Value *> &newCompletions,
|
||||
const QIcon &icon, int relevance);
|
||||
const QIcon &icon, int relevance, bool afterOn);
|
||||
|
||||
QmlJS::ModelManagerInterface *m_modelManager;
|
||||
TextEditor::ITextEditable *m_editor;
|
||||
|
||||
Reference in New Issue
Block a user