QmlJS: Fix completion context when cursor is to the right of inserted ;

Done-with: Erik Verbruggen
This commit is contained in:
Christian Kamm
2010-04-30 14:22:55 +02:00
parent 0970a8e6d2
commit 44a155c612
4 changed files with 10 additions and 2 deletions

View File

@@ -31,6 +31,9 @@ CompletionContextFinder::CompletionContextFinder(const QTextCursor &cursor)
break;
}
if (m_startTokenIndex == yyLinizerState.tokens.size() - 1 && yyLinizerState.insertedSemicolon)
--m_startTokenIndex;
getQmlObjectTypeName(m_startTokenIndex);
checkBinding();
}

View File

@@ -208,6 +208,7 @@ QString LineInfo::trimmedCodeLine(const QString &t)
const Token sc(trimmed.size(), 1, Token::Semicolon);
yyLinizerState.tokens.append(sc);
trimmed.append(QLatin1Char(';'));
yyLinizerState.insertedSemicolon = true;
}
}
@@ -276,6 +277,8 @@ bool LineInfo::readLine()
(firstNonWhiteSpace(yyLinizerState.line) == QLatin1Char('{'));
do {
yyLinizerState.insertedSemicolon = false;
if (yyLinizerState.iter == yyProgram.firstBlock()) {
yyLinizerState.line.clear();
return false;
@@ -332,6 +335,7 @@ void LineInfo::startLinizer()
{
yyLinizerState.braceDepth = 0;
yyLinizerState.pendingRightBrace = false;
yyLinizerState.insertedSemicolon = false;
yyLine = &yyLinizerState.line;
yyBraceDepth = &yyLinizerState.braceDepth;

View File

@@ -84,12 +84,14 @@ protected:
LinizerState()
: braceDepth(0),
leftBraceFollows(false),
pendingRightBrace(false)
pendingRightBrace(false),
insertedSemicolon(false)
{ }
int braceDepth;
bool leftBraceFollows;
bool pendingRightBrace;
bool insertedSemicolon;
QString line;
QList<Token> tokens;
QTextBlock iter;

View File

@@ -690,7 +690,6 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
if (contextFinder.isInRhsOfBinding() && qmlScopeType) {
doQmlKeywordCompletion = false;
qDebug() << "property name: " << contextFinder.bindingPropertyName();
if (!contextFinder.bindingPropertyName().isEmpty()) {
const Interpreter::Value *value = qmlScopeType;