Merge branch '1.3' of scm.dev.nokia.troll.no:creator/mainline into 1.3

This commit is contained in:
Friedemann Kleint
2009-10-20 16:37:42 +02:00

View File

@@ -562,63 +562,63 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
const QChar ch3 = pos > 1 ? editor->characterAt(pos - 3) : QChar(); const QChar ch3 = pos > 1 ? editor->characterAt(pos - 3) : QChar();
int start = pos; int start = pos;
int k = T_EOF_SYMBOL; int completionKind = T_EOF_SYMBOL;
switch (ch.toLatin1()) { switch (ch.toLatin1()) {
case '.': case '.':
if (ch2 != QLatin1Char('.')) { if (ch2 != QLatin1Char('.')) {
k = T_DOT; completionKind = T_DOT;
--start; --start;
} }
break; break;
case ',': case ',':
k = T_COMMA; completionKind = T_COMMA;
--start; --start;
break; break;
case '(': case '(':
if (wantFunctionCall) { if (wantFunctionCall) {
k = T_LPAREN; completionKind = T_LPAREN;
--start; --start;
} }
break; break;
case ':': case ':':
if (ch3 != QLatin1Char(':') && ch2 == QLatin1Char(':')) { if (ch3 != QLatin1Char(':') && ch2 == QLatin1Char(':')) {
k = T_COLON_COLON; completionKind = T_COLON_COLON;
start -= 2; start -= 2;
} }
break; break;
case '>': case '>':
if (ch2 == QLatin1Char('-')) { if (ch2 == QLatin1Char('-')) {
k = T_ARROW; completionKind = T_ARROW;
start -= 2; start -= 2;
} }
break; break;
case '*': case '*':
if (ch2 == QLatin1Char('.')) { if (ch2 == QLatin1Char('.')) {
k = T_DOT_STAR; completionKind = T_DOT_STAR;
start -= 2; start -= 2;
} else if (ch3 == QLatin1Char('-') && ch2 == QLatin1Char('>')) { } else if (ch3 == QLatin1Char('-') && ch2 == QLatin1Char('>')) {
k = T_ARROW_STAR; completionKind = T_ARROW_STAR;
start -= 3; start -= 3;
} }
break; break;
case '\\': case '\\':
case '@': case '@':
if (ch2.isNull() || ch2.isSpace()) { if (ch2.isNull() || ch2.isSpace()) {
k = T_DOXY_COMMENT; completionKind = T_DOXY_COMMENT;
--start; --start;
} }
break; break;
case '<': case '<':
k = T_ANGLE_STRING_LITERAL; completionKind = T_ANGLE_STRING_LITERAL;
--start; --start;
break; break;
case '"': case '"':
k = T_STRING_LITERAL; completionKind = T_STRING_LITERAL;
--start; --start;
break; break;
case '/': case '/':
k = T_SLASH; completionKind = T_SLASH;
--start; --start;
break; break;
} }
@@ -631,20 +631,20 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
tc.setPosition(pos); tc.setPosition(pos);
// Include completion: make sure the quote character is the first one on the line // Include completion: make sure the quote character is the first one on the line
if (k == T_STRING_LITERAL) { if (completionKind == T_STRING_LITERAL) {
QTextCursor s = tc; QTextCursor s = tc;
s.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor); s.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
QString sel = s.selectedText(); QString sel = s.selectedText();
if (sel.indexOf(QLatin1Char('"')) < sel.length() - 1) { if (sel.indexOf(QLatin1Char('"')) < sel.length() - 1) {
k = T_EOF_SYMBOL; completionKind = T_EOF_SYMBOL;
start = pos; start = pos;
} }
} }
if (k == T_COMMA) { if (completionKind == T_COMMA) {
ExpressionUnderCursor expressionUnderCursor; ExpressionUnderCursor expressionUnderCursor;
if (expressionUnderCursor.startOfFunctionCall(tc) == -1) { if (expressionUnderCursor.startOfFunctionCall(tc) == -1) {
k = T_EOF_SYMBOL; completionKind = T_EOF_SYMBOL;
start = pos; start = pos;
} }
} }
@@ -652,24 +652,24 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
static CPlusPlus::TokenUnderCursor tokenUnderCursor; static CPlusPlus::TokenUnderCursor tokenUnderCursor;
const SimpleToken tk = tokenUnderCursor(tc); const SimpleToken tk = tokenUnderCursor(tc);
if (k == T_DOXY_COMMENT && tk.isNot(T_DOXY_COMMENT)) { if (completionKind == T_DOXY_COMMENT && !(tk.is(T_DOXY_COMMENT) || tk.is(T_CPP_DOXY_COMMENT))) {
k = T_EOF_SYMBOL; completionKind = T_EOF_SYMBOL;
start = pos; start = pos;
} }
// Don't complete in comments or strings, but still check for include completion // Don't complete in comments or strings, but still check for include completion
else if (tk.is(T_COMMENT) || (tk.isLiteral() && else if (tk.is(T_COMMENT) || tk.is(T_CPP_COMMENT) ||
(k != T_STRING_LITERAL (tk.isLiteral() && (completionKind != T_STRING_LITERAL
&& k != T_ANGLE_STRING_LITERAL && completionKind != T_ANGLE_STRING_LITERAL
&& k != T_SLASH))) { && completionKind != T_SLASH))) {
k = T_EOF_SYMBOL; completionKind = T_EOF_SYMBOL;
start = pos; start = pos;
} }
// Include completion: can be triggered by slash, but only in a string // Include completion: can be triggered by slash, but only in a string
else if (k == T_SLASH && (tk.isNot(T_STRING_LITERAL) && tk.isNot(T_ANGLE_STRING_LITERAL))) { else if (completionKind == T_SLASH && (tk.isNot(T_STRING_LITERAL) && tk.isNot(T_ANGLE_STRING_LITERAL))) {
k = T_EOF_SYMBOL; completionKind = T_EOF_SYMBOL;
start = pos; start = pos;
} }
else if (k == T_LPAREN) { else if (completionKind == T_LPAREN) {
const QList<SimpleToken> &tokens = tokenUnderCursor.tokens(); const QList<SimpleToken> &tokens = tokenUnderCursor.tokens();
int i = 0; int i = 0;
for (; i < tokens.size(); ++i) { for (; i < tokens.size(); ++i) {
@@ -685,12 +685,12 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
} }
if (i == tokens.size()) { if (i == tokens.size()) {
k = T_EOF_SYMBOL; completionKind = T_EOF_SYMBOL;
start = pos; start = pos;
} }
} }
// Check for include preprocessor directive // Check for include preprocessor directive
else if (k == T_STRING_LITERAL || k == T_ANGLE_STRING_LITERAL || k == T_SLASH) { else if (completionKind == T_STRING_LITERAL || completionKind == T_ANGLE_STRING_LITERAL || completionKind == T_SLASH) {
bool include = false; bool include = false;
const QList<SimpleToken> &tokens = tokenUnderCursor.tokens(); const QList<SimpleToken> &tokens = tokenUnderCursor.tokens();
if (tokens.size() >= 3) { if (tokens.size() >= 3) {
@@ -706,13 +706,13 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
} }
if (!include) { if (!include) {
k = T_EOF_SYMBOL; completionKind = T_EOF_SYMBOL;
start = pos; start = pos;
} }
} }
if (kind) if (kind)
*kind = k; *kind = completionKind;
return start; return start;
} }