forked from qt-creator/qt-creator
Improved the detection of #include-like directives.
This commit is contained in:
@@ -690,21 +690,16 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
|
|||||||
}
|
}
|
||||||
// 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 (k == T_STRING_LITERAL || k == T_ANGLE_STRING_LITERAL || k == T_SLASH) {
|
||||||
const QList<SimpleToken> &tokens = tokenUnderCursor.tokens();
|
|
||||||
int i = 0;
|
|
||||||
bool include = false;
|
bool include = false;
|
||||||
for (; i < tokens.size(); ++i) {
|
const QList<SimpleToken> &tokens = tokenUnderCursor.tokens();
|
||||||
const SimpleToken &token = tokens.at(i);
|
if (tokens.size() >= 3) {
|
||||||
if (token.position() == tk.position()) {
|
if (tokens.at(0).is(T_POUND) && tokens.at(1).is(T_IDENTIFIER) && (tokens.at(2).is(T_STRING_LITERAL) ||
|
||||||
if (i == 0) // no token on the left, but might be on a previous line
|
tokens.at(2).is(T_ANGLE_STRING_LITERAL))) {
|
||||||
break;
|
QStringRef directive = tokens.at(1).text();
|
||||||
const SimpleToken &previousToken = tokens.at(i - 1);
|
if (directive == QLatin1String("include") ||
|
||||||
if (previousToken.is(T_IDENTIFIER)) {
|
directive == QLatin1String("include_next") ||
|
||||||
if (previousToken.text() == QLatin1String("include") ||
|
directive == QLatin1String("import")) {
|
||||||
previousToken.text() == QLatin1String("import")) {
|
|
||||||
include = true;
|
include = true;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user