forked from qt-creator/qt-creator
Fixed function-like code completion.
This was a regression introduced in 8e4fb678fd
triggersCompletion should return `true' when the token at the left of the T_LPAREN
is an identifier, a SIGNAL, a SLOT or T_GREATER (for template functions).
This commit is contained in:
@@ -556,8 +556,8 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
|
|||||||
tokenize.setQtMocRunEnabled(true);
|
tokenize.setQtMocRunEnabled(true);
|
||||||
tokenize.setSkipComments(false);
|
tokenize.setSkipComments(false);
|
||||||
const QList<Token> &tokens = tokenize(tc.block().text());
|
const QList<Token> &tokens = tokenize(tc.block().text());
|
||||||
const int tokenIdx = SimpleLexer::tokenAt(tokens, tc.positionInBlock());
|
const int tokenIdx = SimpleLexer::tokenAt(tokens, qMax(0, tc.positionInBlock() - 1)); // get the token at the left of the cursor
|
||||||
const Token &tk = (tokenIdx == -1) ? Token() : tokens.at(tokenIdx);
|
const Token tk = (tokenIdx == -1) ? Token() : tokens.at(tokenIdx);
|
||||||
|
|
||||||
if (completionKind == T_DOXY_COMMENT && !(tk.is(T_DOXY_COMMENT) || tk.is(T_CPP_DOXY_COMMENT))) {
|
if (completionKind == T_DOXY_COMMENT && !(tk.is(T_DOXY_COMMENT) || tk.is(T_CPP_DOXY_COMMENT))) {
|
||||||
completionKind = T_EOF_SYMBOL;
|
completionKind = T_EOF_SYMBOL;
|
||||||
@@ -577,24 +577,22 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
|
|||||||
start = pos;
|
start = pos;
|
||||||
}
|
}
|
||||||
else if (completionKind == T_LPAREN) {
|
else if (completionKind == T_LPAREN) {
|
||||||
int i = 0;
|
if (tokenIdx > 0) {
|
||||||
for (; i < tokens.size(); ++i) {
|
const Token &previousToken = tokens.at(tokenIdx - 1); // look at the token at the left of T_LPAREN
|
||||||
const Token &token = tokens.at(i);
|
switch (previousToken.kind()) {
|
||||||
if (token.begin() == tk.begin()) {
|
case T_IDENTIFIER:
|
||||||
if (i == 0) // no token on the left, but might be on a previous line
|
case T_GREATER:
|
||||||
break;
|
case T_SIGNAL:
|
||||||
const Token &previousToken = tokens.at(i - 1);
|
case T_SLOT:
|
||||||
if (previousToken.is(T_IDENTIFIER) || previousToken.is(T_GREATER)
|
break; // good
|
||||||
|| previousToken.is(T_SIGNAL) || previousToken.is(T_SLOT))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == tokens.size()) {
|
default:
|
||||||
|
// that's a bad token :)
|
||||||
completionKind = T_EOF_SYMBOL;
|
completionKind = T_EOF_SYMBOL;
|
||||||
start = pos;
|
start = pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check for include preprocessor directive
|
// Check for include preprocessor directive
|
||||||
else if (completionKind == T_STRING_LITERAL || completionKind == T_ANGLE_STRING_LITERAL || completionKind == T_SLASH) {
|
else if (completionKind == T_STRING_LITERAL || completionKind == T_ANGLE_STRING_LITERAL || completionKind == T_SLASH) {
|
||||||
bool include = false;
|
bool include = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user