aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/qmljs/qmljscompletioncontextfinder.cpp
diff options
context:
space:
mode:
authorChristian Kamm <[email protected]>2010-04-29 14:30:30 +0200
committerChristian Kamm <[email protected]>2010-04-29 16:05:25 +0200
commita48032b6166d9f715077218791b6bd4a60c82653 (patch)
tree9a67b4793c1ba6bf19788bbce3dc353259480405 /src/libs/qmljs/qmljscompletioncontextfinder.cpp
parent953f0daa50a32fa2539a1a3dadcb5524b4b60b34 (diff)
QmlJS: Improve completion for object bindings with 'on'.
Done-with: Erik Verbruggen
Diffstat (limited to 'src/libs/qmljs/qmljscompletioncontextfinder.cpp')
-rw-r--r--src/libs/qmljs/qmljscompletioncontextfinder.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/libs/qmljs/qmljscompletioncontextfinder.cpp b/src/libs/qmljs/qmljscompletioncontextfinder.cpp
index dec1659a413..c1abc515c09 100644
--- a/src/libs/qmljs/qmljscompletioncontextfinder.cpp
+++ b/src/libs/qmljs/qmljscompletioncontextfinder.cpp
@@ -17,6 +17,7 @@ using namespace QmlJS;
CompletionContextFinder::CompletionContextFinder(const QTextCursor &cursor)
: m_cursor(cursor)
, m_colonCount(-1)
+ , m_behaviorBinding(false)
{
QTextBlock lastBlock = cursor.block();
if (lastBlock.next().isValid())
@@ -90,6 +91,7 @@ void CompletionContextFinder::checkBinding()
int i = m_startTokenIndex;
int colonCount = 0;
bool delimiterFound = false;
+ bool firstToken = true;
while (!delimiterFound) {
if (i < 0) {
if (!readLine())
@@ -113,11 +115,17 @@ void CompletionContextFinder::checkBinding()
++colonCount;
break;
+ case Token::Identifier:
+ if (firstToken && yyLine->midRef(token.begin(), token.length) == QLatin1String("on"))
+ m_behaviorBinding = true;
+ break;
+
default:
break;
}
--i;
+ firstToken = false;
}
YY_RESTORE();
@@ -145,6 +153,15 @@ bool CompletionContextFinder::isInRhsOfBinding() const
return isInQmlContext() && m_colonCount == 1;
}
+/*!
+ \return true if the cursor after "Type on" in the left hand side
+ of a binding, false otherwise.
+*/
+bool CompletionContextFinder::isAfterOnInLhsOfBinding() const
+{
+ return isInLhsOfBinding() && m_behaviorBinding;
+}
+
int CompletionContextFinder::findOpeningBrace(int startTokenIndex)
{
YY_SAVE();
@@ -211,8 +228,3 @@ int CompletionContextFinder::findOpeningBrace(int startTokenIndex)
YY_RESTORE();
return -1;
}
-
-bool CompletionContextFinder::inQmlBindingRhs()
-{
- return false;
-}