Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
510f8ccc
Commit
510f8ccc
authored
Oct 08, 2009
by
Roberto Raggi
Browse files
Improved the detection of #include-like directives.
parent
b4a17a03
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/cpptools/cppcodecompletion.cpp
View file @
510f8ccc
...
...
@@ -690,21 +690,16 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
}
// Check for include preprocessor directive
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
;
for
(;
i
<
tokens
.
size
();
++
i
)
{
const
SimpleToken
&
token
=
tokens
.
at
(
i
);
if
(
token
.
position
()
==
tk
.
position
())
{
if
(
i
==
0
)
// no token on the left, but might be on a previous line
break
;
const
SimpleToken
&
previousToken
=
tokens
.
at
(
i
-
1
);
if
(
previousToken
.
is
(
T_IDENTIFIER
))
{
if
(
previousToken
.
text
()
==
QLatin1String
(
"include"
)
||
previousToken
.
text
()
==
QLatin1String
(
"import"
))
{
include
=
true
;
break
;
}
const
QList
<
SimpleToken
>
&
tokens
=
tokenUnderCursor
.
tokens
();
if
(
tokens
.
size
()
>=
3
)
{
if
(
tokens
.
at
(
0
).
is
(
T_POUND
)
&&
tokens
.
at
(
1
).
is
(
T_IDENTIFIER
)
&&
(
tokens
.
at
(
2
).
is
(
T_STRING_LITERAL
)
||
tokens
.
at
(
2
).
is
(
T_ANGLE_STRING_LITERAL
)))
{
QStringRef
directive
=
tokens
.
at
(
1
).
text
();
if
(
directive
==
QLatin1String
(
"include"
)
||
directive
==
QLatin1String
(
"include_next"
)
||
directive
==
QLatin1String
(
"import"
))
{
include
=
true
;
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment