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
f229a761
Commit
f229a761
authored
Dec 18, 2009
by
Erik Verbruggen
Browse files
Added highlighting for locals in ObjC methods.
parent
918856ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppeditor.cpp
View file @
f229a761
...
...
@@ -201,13 +201,23 @@ public:
bool
hasD
;
bool
hasQ
;
void
operator
()(
FunctionDefini
tionAST
*
ast
)
void
operator
()(
Declara
tionAST
*
ast
)
{
localUses
.
clear
();
if
(
ast
&&
ast
->
symbol
)
{
_functionScope
=
ast
->
symbol
->
members
();
accept
(
ast
);
if
(
!
ast
)
return
;
if
(
FunctionDefinitionAST
*
def
=
ast
->
asFunctionDefinition
())
{
if
(
def
->
symbol
)
{
_functionScope
=
def
->
symbol
->
members
();
accept
(
ast
);
}
}
else
if
(
ObjCMethodDeclarationAST
*
decl
=
ast
->
asObjCMethodDeclaration
())
{
if
(
decl
->
method_prototype
->
symbol
)
{
_functionScope
=
decl
->
method_prototype
->
symbol
->
members
();
accept
(
ast
);
}
}
}
...
...
@@ -392,7 +402,7 @@ class FunctionDefinitionUnderCursor: protected ASTVisitor
{
unsigned
_line
;
unsigned
_column
;
FunctionDefini
tionAST
*
_functionDefinition
;
Declara
tionAST
*
_functionDefinition
;
public:
FunctionDefinitionUnderCursor
(
TranslationUnit
*
translationUnit
)
...
...
@@ -400,7 +410,7 @@ public:
_line
(
0
),
_column
(
0
)
{
}
FunctionDefini
tionAST
*
operator
()(
AST
*
ast
,
unsigned
line
,
unsigned
column
)
Declara
tionAST
*
operator
()(
AST
*
ast
,
unsigned
line
,
unsigned
column
)
{
_functionDefinition
=
0
;
_line
=
line
;
...
...
@@ -416,22 +426,34 @@ protected:
return
false
;
else
if
(
FunctionDefinitionAST
*
def
=
ast
->
asFunctionDefinition
())
{
unsigned
startLine
,
startColumn
;
unsigned
endLine
,
endColumn
;
getTokenStartPosition
(
def
->
firstToken
(),
&
startLine
,
&
startColumn
);
getTokenEndPosition
(
def
->
lastToken
()
-
1
,
&
endLine
,
&
endColumn
);
if
(
_line
>
startLine
||
(
_line
==
startLine
&&
_column
>=
startColumn
))
{
if
(
_line
<
endLine
||
(
_line
==
endLine
&&
_column
<
endColumn
))
{
_functionDefinition
=
def
;
return
false
;
}
}
return
checkDeclaration
(
def
);
}
else
if
(
ObjCMethodDeclarationAST
*
method
=
ast
->
asObjCMethodDeclaration
())
{
if
(
method
->
function_body
)
return
checkDeclaration
(
method
);
}
return
true
;
}
private:
bool
checkDeclaration
(
DeclarationAST
*
ast
)
{
unsigned
startLine
,
startColumn
;
unsigned
endLine
,
endColumn
;
getTokenStartPosition
(
ast
->
firstToken
(),
&
startLine
,
&
startColumn
);
getTokenEndPosition
(
ast
->
lastToken
()
-
1
,
&
endLine
,
&
endColumn
);
if
(
_line
>
startLine
||
(
_line
==
startLine
&&
_column
>=
startColumn
))
{
if
(
_line
<
endLine
||
(
_line
==
endLine
&&
_column
<
endColumn
))
{
_functionDefinition
=
ast
;
return
false
;
}
}
return
true
;
}
};
class
ProcessDeclarators
:
protected
ASTVisitor
...
...
@@ -2195,7 +2217,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
AST
*
ast
=
translationUnit
->
ast
();
FunctionDefinitionUnderCursor
functionDefinitionUnderCursor
(
translationUnit
);
FunctionDefini
tionAST
*
currentFunctionDefinition
=
functionDefinitionUnderCursor
(
ast
,
source
.
line
,
source
.
column
);
Declara
tionAST
*
currentFunctionDefinition
=
functionDefinitionUnderCursor
(
ast
,
source
.
line
,
source
.
column
);
FindLocalUses
useTable
(
translationUnit
);
useTable
(
currentFunctionDefinition
);
...
...
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