summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2010-04-30 14:22:55 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2010-04-30 14:22:55 +0200
commit44a155c6128d874da0902d6d3c95f159e486ec22 (patch)
tree9e15f4b95109a7d7819247ef50c7cfd9d2b33b64
parent0970a8e6d2c7fb4742bf7bef2899ce76478ecc89 (diff)
downloadqt-creator-44a155c6128d874da0902d6d3c95f159e486ec22.tar.gz
QmlJS: Fix completion context when cursor is to the right of inserted ;
Done-with: Erik Verbruggen
-rw-r--r--src/libs/qmljs/qmljscompletioncontextfinder.cpp3
-rw-r--r--src/libs/qmljs/qmljslineinfo.cpp4
-rw-r--r--src/libs/qmljs/qmljslineinfo.h4
-rw-r--r--src/plugins/qmljseditor/qmljscodecompletion.cpp1
4 files changed, 10 insertions, 2 deletions
diff --git a/src/libs/qmljs/qmljscompletioncontextfinder.cpp b/src/libs/qmljs/qmljscompletioncontextfinder.cpp
index 0fd7ab856b..645472c220 100644
--- a/src/libs/qmljs/qmljscompletioncontextfinder.cpp
+++ b/src/libs/qmljs/qmljscompletioncontextfinder.cpp
@@ -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();
}
diff --git a/src/libs/qmljs/qmljslineinfo.cpp b/src/libs/qmljs/qmljslineinfo.cpp
index a4c8837d1b..5bae0d727c 100644
--- a/src/libs/qmljs/qmljslineinfo.cpp
+++ b/src/libs/qmljs/qmljslineinfo.cpp
@@ -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;
diff --git a/src/libs/qmljs/qmljslineinfo.h b/src/libs/qmljs/qmljslineinfo.h
index 2112e313f0..8173f9ddc7 100644
--- a/src/libs/qmljs/qmljslineinfo.h
+++ b/src/libs/qmljs/qmljslineinfo.h
@@ -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;
diff --git a/src/plugins/qmljseditor/qmljscodecompletion.cpp b/src/plugins/qmljseditor/qmljscodecompletion.cpp
index a5a5d15f57..aae8b16863 100644
--- a/src/plugins/qmljseditor/qmljscodecompletion.cpp
+++ b/src/plugins/qmljseditor/qmljscodecompletion.cpp
@@ -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;