Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
5d7def6d
Commit
5d7def6d
authored
Nov 17, 2009
by
Roberto Raggi
Browse files
Refactored the AST visitors.
Now, the ASTVisitor constructor takes a valid reference to a TranslationUnit.
parent
04a333ba
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/ASTParent.cpp
View file @
5d7def6d
...
...
@@ -32,8 +32,8 @@
using
namespace
CPlusPlus
;
ASTParent
::
ASTParent
(
Control
*
control
,
AST
*
rootNode
)
:
ASTVisitor
(
control
)
ASTParent
::
ASTParent
(
TranslationUnit
*
translationUnit
,
AST
*
rootNode
)
:
ASTVisitor
(
translationUnit
)
{
accept
(
rootNode
);
}
...
...
src/libs/cplusplus/ASTParent.h
View file @
5d7def6d
...
...
@@ -39,7 +39,7 @@ namespace CPlusPlus {
class
CPLUSPLUS_EXPORT
ASTParent
:
protected
ASTVisitor
{
public:
ASTParent
(
Control
*
control
,
AST
*
rootNode
);
ASTParent
(
TranslationUnit
*
transaltionUnit
,
AST
*
rootNode
);
virtual
~
ASTParent
();
AST
*
operator
()(
AST
*
ast
)
const
;
...
...
src/libs/cplusplus/CheckUndefinedSymbols.cpp
View file @
5d7def6d
...
...
@@ -41,7 +41,7 @@ using namespace CPlusPlus;
CheckUndefinedSymbols
::
CheckUndefinedSymbols
(
Document
::
Ptr
doc
)
:
ASTVisitor
(
doc
->
control
()),
_doc
(
doc
)
:
ASTVisitor
(
doc
->
translationUnit
()),
_doc
(
doc
)
{
}
CheckUndefinedSymbols
::~
CheckUndefinedSymbols
()
...
...
src/libs/cplusplus/CppDocument.cpp
View file @
5d7def6d
...
...
@@ -404,7 +404,7 @@ void Document::check(CheckMode mode)
if
(
!
isParsed
())
parse
();
Semantic
semantic
(
_
control
);
Semantic
semantic
(
_
translationUnit
);
if
(
mode
==
FastCheck
)
semantic
.
setSkipFunctionBodies
(
true
);
...
...
src/libs/cplusplus/FindUsages.cpp
View file @
5d7def6d
...
...
@@ -41,12 +41,12 @@
using
namespace
CPlusPlus
;
FindUsages
::
FindUsages
(
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
,
QFutureInterface
<
Usage
>
*
future
)
:
ASTVisitor
(
doc
->
control
()),
:
ASTVisitor
(
doc
->
translationUnit
()),
_future
(
future
),
_doc
(
doc
),
_snapshot
(
snapshot
),
_source
(
_doc
->
source
()),
_sem
(
doc
->
control
()),
_sem
(
doc
->
translationUnit
()),
_inSimpleDeclaration
(
0
)
{
_snapshot
.
insert
(
_doc
);
...
...
src/libs/cplusplus/ResolveExpression.cpp
View file @
5d7def6d
...
...
@@ -72,9 +72,9 @@ static QList<_Tp> removeDuplicates(const QList<_Tp> &results)
// ResolveExpression
/////////////////////////////////////////////////////////////////////
ResolveExpression
::
ResolveExpression
(
const
LookupContext
&
context
)
:
ASTVisitor
(
context
.
expressionDocument
()
->
control
()),
:
ASTVisitor
(
context
.
expressionDocument
()
->
translationUnit
()),
_context
(
context
),
sem
(
_
context
.
control
())
sem
(
context
.
expressionDocument
()
->
translationUnit
())
{
}
ResolveExpression
::~
ResolveExpression
()
...
...
src/plugins/cppeditor/cppeditor.cpp
View file @
5d7def6d
...
...
@@ -191,8 +191,8 @@ class FindUses: protected ASTVisitor
FindScope
findScope
;
public:
FindUses
(
Control
*
control
)
:
ASTVisitor
(
control
)
FindUses
(
TranslationUnit
*
translationUnit
)
:
ASTVisitor
(
translationUnit
)
{
}
// local and external uses.
...
...
@@ -382,8 +382,8 @@ class FunctionDefinitionUnderCursor: protected ASTVisitor
FunctionDefinitionAST
*
_functionDefinition
;
public:
FunctionDefinitionUnderCursor
(
Control
*
control
)
:
ASTVisitor
(
control
),
FunctionDefinitionUnderCursor
(
TranslationUnit
*
translationUnit
)
:
ASTVisitor
(
translationUnit
),
_line
(
0
),
_column
(
0
)
{
}
...
...
@@ -427,8 +427,9 @@ class ProcessDeclarators: protected ASTVisitor
bool
_visitFunctionDeclarator
;
public:
ProcessDeclarators
(
Control
*
control
)
:
ASTVisitor
(
control
),
_visitFunctionDeclarator
(
true
)
ProcessDeclarators
(
TranslationUnit
*
translationUnit
)
:
ASTVisitor
(
translationUnit
),
_visitFunctionDeclarator
(
true
)
{
}
QList
<
DeclaratorIdAST
*>
operator
()(
FunctionDefinitionAST
*
ast
)
...
...
@@ -2030,14 +2031,13 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
doc
->
check
();
}
Control
*
control
=
doc
->
control
();
TranslationUnit
*
translationUnit
=
doc
->
translationUnit
();
AST
*
ast
=
translationUnit
->
ast
();
FunctionDefinitionUnderCursor
functionDefinitionUnderCursor
(
control
);
FunctionDefinitionUnderCursor
functionDefinitionUnderCursor
(
translationUnit
);
FunctionDefinitionAST
*
currentFunctionDefinition
=
functionDefinitionUnderCursor
(
ast
,
source
.
line
,
source
.
column
);
FindUses
useTable
(
control
);
FindUses
useTable
(
translationUnit
);
useTable
(
currentFunctionDefinition
);
SemanticInfo
semanticInfo
;
...
...
src/plugins/cppeditor/cppquickfix.cpp
View file @
5d7def6d
...
...
@@ -54,7 +54,9 @@ class ASTPath: public ASTVisitor
public:
ASTPath
(
Document
::
Ptr
doc
)
:
ASTVisitor
(
doc
->
control
()),
_doc
(
doc
),
_line
(
0
),
_column
(
0
)
{}
:
ASTVisitor
(
doc
->
translationUnit
()),
_doc
(
doc
),
_line
(
0
),
_column
(
0
)
{}
QList
<
AST
*>
operator
()(
const
QTextCursor
&
cursor
)
{
...
...
src/shared/cplusplus/ASTVisitor.cpp
View file @
5d7def6d
...
...
@@ -53,8 +53,8 @@
using
namespace
CPlusPlus
;
ASTVisitor
::
ASTVisitor
(
Control
*
control
)
:
_
control
(
control
)
ASTVisitor
::
ASTVisitor
(
TranslationUnit
*
translationUnit
)
:
_
translationUnit
(
translationUnit
)
{
}
ASTVisitor
::~
ASTVisitor
()
...
...
@@ -64,10 +64,18 @@ void ASTVisitor::accept(AST *ast)
{
AST
::
accept
(
ast
,
this
);
}
Control
*
ASTVisitor
::
control
()
const
{
return
_control
;
}
{
if
(
_translationUnit
)
return
_translationUnit
->
control
();
return
0
;
}
TranslationUnit
*
ASTVisitor
::
translationUnit
()
const
{
return
_control
->
translationUnit
();
}
{
return
_translationUnit
;
}
void
ASTVisitor
::
setTranslationUnit
(
TranslationUnit
*
translationUnit
)
{
_translationUnit
=
translationUnit
;
}
unsigned
ASTVisitor
::
tokenCount
()
const
{
return
translationUnit
()
->
tokenCount
();
}
...
...
src/shared/cplusplus/ASTVisitor.h
View file @
5d7def6d
...
...
@@ -61,12 +61,13 @@ class CPLUSPLUS_EXPORT ASTVisitor
void
operator
=
(
const
ASTVisitor
&
other
);
public:
ASTVisitor
(
Control
*
control
);
ASTVisitor
(
TranslationUnit
*
unit
);
virtual
~
ASTVisitor
();
Control
*
control
()
const
;
TranslationUnit
*
translationUnit
()
const
;
void
setTranslationUnit
(
TranslationUnit
*
translationUnit
);
Control
*
control
()
const
;
unsigned
tokenCount
()
const
;
const
Token
&
tokenAt
(
unsigned
index
)
const
;
int
tokenKind
(
unsigned
index
)
const
;
...
...
@@ -352,7 +353,7 @@ public:
virtual
void
endVisit
(
ObjCSynchronizedStatementAST
*
)
{
}
private:
Control
*
_control
;
TranslationUnit
*
_translationUnit
;
};
}
// end of namespace CPlusPlus
...
...
src/shared/cplusplus/Semantic.cpp
View file @
5d7def6d
...
...
@@ -64,9 +64,10 @@ using namespace CPlusPlus;
class
Semantic
::
Data
{
public:
Data
(
Semantic
*
semantic
,
Control
*
control
)
Data
(
Semantic
*
semantic
,
TranslationUnit
*
translationUnit
)
:
semantic
(
semantic
),
control
(
control
),
translationUnit
(
translationUnit
),
control
(
translationUnit
->
control
()),
skipFunctionBodies
(
false
),
visibility
(
Symbol
::
Public
),
ojbcVisibility
(
Symbol
::
Protected
),
...
...
@@ -90,6 +91,7 @@ public:
}
Semantic
*
semantic
;
TranslationUnit
*
translationUnit
;
Control
*
control
;
bool
skipFunctionBodies
;
int
visibility
;
...
...
@@ -103,9 +105,9 @@ public:
CheckName
*
checkName
;
};
Semantic
::
Semantic
(
Control
*
control
)
Semantic
::
Semantic
(
TranslationUnit
*
translationUnit
)
{
d
=
new
Data
(
this
,
control
);
d
=
new
Data
(
this
,
translationUnit
);
d
->
checkSpecifier
=
new
CheckSpecifier
(
this
);
d
->
checkDeclaration
=
new
CheckDeclaration
(
this
);
d
->
checkDeclarator
=
new
CheckDeclarator
(
this
);
...
...
@@ -117,6 +119,9 @@ Semantic::Semantic(Control *control)
Semantic
::~
Semantic
()
{
delete
d
;
}
TranslationUnit
*
Semantic
::
translationUnit
()
const
{
return
d
->
translationUnit
;
}
Control
*
Semantic
::
control
()
const
{
return
d
->
control
;
}
...
...
src/shared/cplusplus/Semantic.h
View file @
5d7def6d
...
...
@@ -61,9 +61,10 @@ class CPLUSPLUS_EXPORT Semantic
void
operator
=
(
const
Semantic
&
other
);
public:
Semantic
(
Control
*
control
);
Semantic
(
TranslationUnit
*
translationUnit
);
virtual
~
Semantic
();
TranslationUnit
*
translationUnit
()
const
;
Control
*
control
()
const
;
FullySpecifiedType
check
(
SpecifierListAST
*
specifier
,
Scope
*
scope
);
...
...
src/shared/cplusplus/SemanticCheck.cpp
View file @
5d7def6d
...
...
@@ -52,7 +52,7 @@
using
namespace
CPlusPlus
;
SemanticCheck
::
SemanticCheck
(
Semantic
*
semantic
)
:
ASTVisitor
(
semantic
->
control
()),
:
ASTVisitor
(
semantic
->
translationUnit
()),
_semantic
(
semantic
)
{
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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