Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
41b4af05
Commit
41b4af05
authored
Aug 11, 2010
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of the prefix findOrInsert for the functions in CPlusPlus::Control.
parent
f74ba9da
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
78 additions
and
49 deletions
+78
-49
src/libs/cplusplus/CppDocument.cpp
src/libs/cplusplus/CppDocument.cpp
+1
-1
src/libs/cplusplus/CppRewriter.cpp
src/libs/cplusplus/CppRewriter.cpp
+1
-1
src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp
src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp
+2
-2
src/libs/cplusplus/FindUsages.cpp
src/libs/cplusplus/FindUsages.cpp
+1
-1
src/libs/cplusplus/LookupContext.cpp
src/libs/cplusplus/LookupContext.cpp
+5
-0
src/libs/cplusplus/LookupContext.h
src/libs/cplusplus/LookupContext.h
+1
-0
src/libs/cplusplus/ResolveExpression.cpp
src/libs/cplusplus/ResolveExpression.cpp
+2
-2
src/libs/cplusplus/TypePrettyPrinter.cpp
src/libs/cplusplus/TypePrettyPrinter.cpp
+22
-0
src/libs/cplusplus/TypePrettyPrinter.h
src/libs/cplusplus/TypePrettyPrinter.h
+1
-0
src/plugins/cppeditor/cppquickfixes.cpp
src/plugins/cppeditor/cppquickfixes.cpp
+1
-1
src/shared/cplusplus/CheckDeclaration.cpp
src/shared/cplusplus/CheckDeclaration.cpp
+1
-1
src/shared/cplusplus/CheckName.cpp
src/shared/cplusplus/CheckName.cpp
+1
-1
src/shared/cplusplus/CheckStatement.cpp
src/shared/cplusplus/CheckStatement.cpp
+3
-3
src/shared/cplusplus/Control.cpp
src/shared/cplusplus/Control.cpp
+20
-20
src/shared/cplusplus/Control.h
src/shared/cplusplus/Control.h
+6
-6
src/shared/cplusplus/Lexer.cpp
src/shared/cplusplus/Lexer.cpp
+7
-7
src/shared/cplusplus/TranslationUnit.cpp
src/shared/cplusplus/TranslationUnit.cpp
+3
-3
No files found.
src/libs/cplusplus/CppDocument.cpp
View file @
41b4af05
...
...
@@ -215,7 +215,7 @@ Document::Document(const QString &fileName)
_control
->
setDiagnosticClient
(
new
DocumentDiagnosticClient
(
this
,
&
_diagnosticMessages
));
const
QByteArray
localFileName
=
fileName
.
toUtf8
();
const
StringLiteral
*
fileId
=
_control
->
findOrInsertS
tringLiteral
(
localFileName
.
constData
(),
const
StringLiteral
*
fileId
=
_control
->
s
tringLiteral
(
localFileName
.
constData
(),
localFileName
.
size
());
_translationUnit
=
new
TranslationUnit
(
_control
,
fileId
);
_translationUnit
->
setQtMocRunEnabled
(
true
);
...
...
src/libs/cplusplus/CppRewriter.cpp
View file @
41b4af05
...
...
@@ -220,7 +220,7 @@ public:
if
(
!
other
)
return
0
;
return
control
()
->
findOrInsertI
dentifier
(
other
->
chars
(),
other
->
size
());
return
control
()
->
i
dentifier
(
other
->
chars
(),
other
->
size
());
}
public:
...
...
src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp
View file @
41b4af05
...
...
@@ -262,7 +262,7 @@ private:
return
name
;
else
if
(
const
Name
*
nameId
=
name
->
asNameId
())
{
const
Identifier
*
id
=
control
()
->
findOrInsertI
dentifier
(
nameId
->
identifier
()
->
chars
(),
const
Identifier
*
id
=
control
()
->
i
dentifier
(
nameId
->
identifier
()
->
chars
(),
nameId
->
identifier
()
->
size
());
return
control
()
->
nameId
(
id
);
...
...
@@ -272,7 +272,7 @@ private:
FullySpecifiedType
argTy
=
templId
->
templateArgumentAt
(
templateArgIndex
);
arguments
[
templateArgIndex
]
=
q
->
apply
(
argTy
);
}
const
Identifier
*
id
=
control
()
->
findOrInsertI
dentifier
(
templId
->
identifier
()
->
chars
(),
const
Identifier
*
id
=
control
()
->
i
dentifier
(
templId
->
identifier
()
->
chars
(),
templId
->
identifier
()
->
size
());
return
control
()
->
templateNameId
(
id
,
arguments
.
data
(),
arguments
.
size
());
...
...
src/libs/cplusplus/FindUsages.cpp
View file @
41b4af05
...
...
@@ -91,7 +91,7 @@ void FindUsages::operator()(Symbol *symbol)
_declSymbolFullyQualifiedName
=
LookupContext
::
fullyQualifiedName
(
symbol
);
// get the canonical id
_id
=
_doc
->
control
()
->
findOrInsertI
dentifier
(
_id
->
chars
(),
_id
->
size
());
_id
=
_doc
->
control
()
->
i
dentifier
(
_id
->
chars
(),
_id
->
size
());
if
(
AST
*
ast
=
_doc
->
translationUnit
()
->
ast
())
translationUnit
(
ast
->
asTranslationUnit
());
...
...
src/libs/cplusplus/LookupContext.cpp
View file @
41b4af05
...
...
@@ -788,6 +788,11 @@ ClassOrNamespace *CreateBindings::enterGlobalClassOrNamespace(Symbol *symbol)
return
switchCurrentClassOrNamespace
(
entity
);
}
bool
CreateBindings
::
visit
(
Template
*
templ
)
{
return
false
;
}
bool
CreateBindings
::
visit
(
Namespace
*
ns
)
{
ClassOrNamespace
*
previous
=
enterClassOrNamespaceBinding
(
ns
);
...
...
src/libs/cplusplus/LookupContext.h
View file @
41b4af05
...
...
@@ -162,6 +162,7 @@ protected:
/// Creates bindings for the symbols reachable from the \a root symbol.
void
process
(
Symbol
*
root
);
virtual
bool
visit
(
Template
*
templ
);
virtual
bool
visit
(
Namespace
*
ns
);
virtual
bool
visit
(
Class
*
klass
);
virtual
bool
visit
(
ForwardClassDeclaration
*
klass
);
...
...
src/libs/cplusplus/ResolveExpression.cpp
View file @
41b4af05
...
...
@@ -234,8 +234,8 @@ bool ResolveExpression::visit(NewExpressionAST *ast)
bool
ResolveExpression
::
visit
(
TypeidExpressionAST
*
)
{
const
Name
*
stdName
=
control
()
->
nameId
(
control
()
->
findOrInsertI
dentifier
(
"std"
));
const
Name
*
tiName
=
control
()
->
nameId
(
control
()
->
findOrInsertI
dentifier
(
"type_info"
));
const
Name
*
stdName
=
control
()
->
nameId
(
control
()
->
i
dentifier
(
"std"
));
const
Name
*
tiName
=
control
()
->
nameId
(
control
()
->
i
dentifier
(
"type_info"
));
const
Name
*
q
=
control
()
->
qualifiedNameId
(
control
()
->
qualifiedNameId
(
/* :: */
0
,
stdName
),
tiName
);
FullySpecifiedType
ty
(
control
()
->
namedType
(
q
));
...
...
src/libs/cplusplus/TypePrettyPrinter.cpp
View file @
41b4af05
...
...
@@ -140,6 +140,28 @@ void TypePrettyPrinter::visit(Namespace *type)
prependCv
(
_fullySpecifiedType
);
}
void
TypePrettyPrinter
::
visit
(
Template
*
type
)
{
const
unsigned
argc
=
type
->
templateParameterCount
();
QString
decl
;
decl
+=
QLatin1String
(
"template <"
);
for
(
unsigned
i
=
0
;
i
<
argc
;
++
i
)
{
if
(
i
!=
0
)
decl
+=
QLatin1String
(
", "
);
decl
+=
QLatin1String
(
"T"
);
decl
+=
QString
::
number
(
i
+
1
);
}
decl
+=
QLatin1Char
(
'<'
);
if
(
Symbol
*
d
=
type
->
declaration
())
{
decl
+=
QLatin1Char
(
' '
);
decl
+=
overview
()
->
prettyType
(
d
->
type
(),
d
->
name
());
}
_text
.
prepend
(
decl
);
qWarning
()
<<
"here:"
<<
decl
;
prependCv
(
_fullySpecifiedType
);
}
void
TypePrettyPrinter
::
visit
(
Class
*
classTy
)
{
_text
.
prepend
(
overview
()
->
prettyName
(
classTy
->
name
()));
...
...
src/libs/cplusplus/TypePrettyPrinter.h
View file @
41b4af05
...
...
@@ -68,6 +68,7 @@ protected:
virtual
void
visit
(
NamedType
*
type
);
virtual
void
visit
(
Function
*
type
);
virtual
void
visit
(
Namespace
*
type
);
virtual
void
visit
(
Template
*
type
);
virtual
void
visit
(
Class
*
type
);
virtual
void
visit
(
Enum
*
type
);
...
...
src/plugins/cppeditor/cppquickfixes.cpp
View file @
41b4af05
...
...
@@ -976,7 +976,7 @@ public:
}
QSharedPointer
<
Control
>
control
=
state
.
context
().
control
();
const
Name
*
trName
=
control
->
nameId
(
control
->
findOrInsertI
dentifier
(
"tr"
));
const
Name
*
trName
=
control
->
nameId
(
control
->
i
dentifier
(
"tr"
));
// Check whether we are in a method:
for
(
int
i
=
path
.
size
()
-
1
;
i
>=
0
;
--
i
)
...
...
src/shared/cplusplus/CheckDeclaration.cpp
View file @
41b4af05
...
...
@@ -437,7 +437,7 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast)
buffer
+=
' '
;
buffer
+=
tk
.
spell
();
}
const
StringLiteral
*
initializer
=
control
()
->
findOrInsertS
tringLiteral
(
buffer
.
c_str
(),
buffer
.
size
());
const
StringLiteral
*
initializer
=
control
()
->
s
tringLiteral
(
buffer
.
c_str
(),
buffer
.
size
());
arg
->
setInitializer
(
initializer
);
}
arg
->
setType
(
argTy
);
...
...
src/shared/cplusplus/CheckName.cpp
View file @
41b4af05
...
...
@@ -377,7 +377,7 @@ bool CheckName::visit(ObjCSelectorAST *ast)
bool
hasArgs
=
false
;
for
(
ObjCSelectorArgumentListAST
*
it
=
ast
->
selector_argument_list
;
it
;
it
=
it
->
next
)
{
if
(
it
->
value
->
name_token
)
{
const
Identifier
*
id
=
control
()
->
findOrInsertI
dentifier
(
spell
(
it
->
value
->
name_token
));
const
Identifier
*
id
=
control
()
->
i
dentifier
(
spell
(
it
->
value
->
name_token
));
const
NameId
*
nameId
=
control
()
->
nameId
(
id
);
names
.
push_back
(
nameId
);
...
...
src/shared/cplusplus/CheckStatement.cpp
View file @
41b4af05
...
...
@@ -377,9 +377,9 @@ bool CheckStatement::visit(QtMemberDeclarationAST *ast)
const
Name
*
name
=
0
;
if
(
tokenKind
(
ast
->
q_token
)
==
T_Q_D
)
name
=
control
()
->
nameId
(
control
()
->
findOrInsertI
dentifier
(
"d"
));
name
=
control
()
->
nameId
(
control
()
->
i
dentifier
(
"d"
));
else
name
=
control
()
->
nameId
(
control
()
->
findOrInsertI
dentifier
(
"q"
));
name
=
control
()
->
nameId
(
control
()
->
i
dentifier
(
"q"
));
FullySpecifiedType
declTy
=
semantic
()
->
check
(
ast
->
type_id
,
_scope
);
...
...
@@ -390,7 +390,7 @@ bool CheckStatement::visit(QtMemberDeclarationAST *ast)
privateClass
+=
nameId
->
identifier
()
->
chars
();
privateClass
+=
"Private"
;
const
Name
*
privName
=
control
()
->
nameId
(
control
()
->
findOrInsertI
dentifier
(
privateClass
.
c_str
(),
const
Name
*
privName
=
control
()
->
nameId
(
control
()
->
i
dentifier
(
privateClass
.
c_str
(),
privateClass
.
size
()));
declTy
.
setType
(
control
()
->
namedType
(
privName
));
}
...
...
src/shared/cplusplus/Control.cpp
View file @
41b4af05
...
...
@@ -536,17 +536,17 @@ Control::Control()
{
d
=
new
Data
(
this
);
d
->
deprecatedId
=
findOrInsertI
dentifier
(
"deprecated"
);
d
->
unavailableId
=
findOrInsertI
dentifier
(
"unavailable"
);
d
->
objcGetterId
=
findOrInsertI
dentifier
(
"getter"
);
d
->
objcSetterId
=
findOrInsertI
dentifier
(
"setter"
);
d
->
objcReadwriteId
=
findOrInsertI
dentifier
(
"readwrite"
);
d
->
objcReadonlyId
=
findOrInsertI
dentifier
(
"readonly"
);
d
->
objcAssignId
=
findOrInsertI
dentifier
(
"assign"
);
d
->
objcRetainId
=
findOrInsertI
dentifier
(
"retain"
);
d
->
objcCopyId
=
findOrInsertI
dentifier
(
"copy"
);
d
->
objcNonatomicId
=
findOrInsertI
dentifier
(
"nonatomic"
);
d
->
deprecatedId
=
i
dentifier
(
"deprecated"
);
d
->
unavailableId
=
i
dentifier
(
"unavailable"
);
d
->
objcGetterId
=
i
dentifier
(
"getter"
);
d
->
objcSetterId
=
i
dentifier
(
"setter"
);
d
->
objcReadwriteId
=
i
dentifier
(
"readwrite"
);
d
->
objcReadonlyId
=
i
dentifier
(
"readonly"
);
d
->
objcAssignId
=
i
dentifier
(
"assign"
);
d
->
objcRetainId
=
i
dentifier
(
"retain"
);
d
->
objcCopyId
=
i
dentifier
(
"copy"
);
d
->
objcNonatomicId
=
i
dentifier
(
"nonatomic"
);
}
Control
::~
Control
()
...
...
@@ -571,13 +571,13 @@ void Control::setDiagnosticClient(DiagnosticClient *diagnosticClient)
const
Identifier
*
Control
::
findIdentifier
(
const
char
*
chars
,
unsigned
size
)
const
{
return
d
->
identifiers
.
findLiteral
(
chars
,
size
);
}
const
Identifier
*
Control
::
findOrInsertI
dentifier
(
const
char
*
chars
,
unsigned
size
)
const
Identifier
*
Control
::
i
dentifier
(
const
char
*
chars
,
unsigned
size
)
{
return
d
->
identifiers
.
findOrInsertLiteral
(
chars
,
size
);
}
const
Identifier
*
Control
::
findOrInsertI
dentifier
(
const
char
*
chars
)
const
Identifier
*
Control
::
i
dentifier
(
const
char
*
chars
)
{
unsigned
length
=
std
::
strlen
(
chars
);
return
findOrInsertI
dentifier
(
chars
,
length
);
return
i
dentifier
(
chars
,
length
);
}
Control
::
IdentifierIterator
Control
::
firstIdentifier
()
const
...
...
@@ -598,22 +598,22 @@ Control::NumericLiteralIterator Control::firstNumericLiteral() const
Control
::
NumericLiteralIterator
Control
::
lastNumericLiteral
()
const
{
return
d
->
numericLiterals
.
end
();
}
const
StringLiteral
*
Control
::
findOrInsertS
tringLiteral
(
const
char
*
chars
,
unsigned
size
)
const
StringLiteral
*
Control
::
s
tringLiteral
(
const
char
*
chars
,
unsigned
size
)
{
return
d
->
stringLiterals
.
findOrInsertLiteral
(
chars
,
size
);
}
const
StringLiteral
*
Control
::
findOrInsertS
tringLiteral
(
const
char
*
chars
)
const
StringLiteral
*
Control
::
s
tringLiteral
(
const
char
*
chars
)
{
unsigned
length
=
std
::
strlen
(
chars
);
return
findOrInsertS
tringLiteral
(
chars
,
length
);
return
s
tringLiteral
(
chars
,
length
);
}
const
NumericLiteral
*
Control
::
findOrInsertN
umericLiteral
(
const
char
*
chars
,
unsigned
size
)
const
NumericLiteral
*
Control
::
n
umericLiteral
(
const
char
*
chars
,
unsigned
size
)
{
return
d
->
numericLiterals
.
findOrInsertLiteral
(
chars
,
size
);
}
const
NumericLiteral
*
Control
::
findOrInsertN
umericLiteral
(
const
char
*
chars
)
const
NumericLiteral
*
Control
::
n
umericLiteral
(
const
char
*
chars
)
{
unsigned
length
=
std
::
strlen
(
chars
);
return
findOrInsertN
umericLiteral
(
chars
,
length
);
return
n
umericLiteral
(
chars
,
length
);
}
const
NameId
*
Control
::
nameId
(
const
Identifier
*
id
)
...
...
src/shared/cplusplus/Control.h
View file @
41b4af05
...
...
@@ -190,8 +190,8 @@ public:
const
Identifier
*
objcNonatomicId
()
const
;
const
Identifier
*
findIdentifier
(
const
char
*
chars
,
unsigned
size
)
const
;
const
Identifier
*
findOrInsertI
dentifier
(
const
char
*
chars
,
unsigned
size
);
const
Identifier
*
findOrInsertI
dentifier
(
const
char
*
chars
);
const
Identifier
*
i
dentifier
(
const
char
*
chars
,
unsigned
size
);
const
Identifier
*
i
dentifier
(
const
char
*
chars
);
typedef
const
Identifier
*
const
*
IdentifierIterator
;
typedef
const
StringLiteral
*
const
*
StringLiteralIterator
;
...
...
@@ -206,11 +206,11 @@ public:
NumericLiteralIterator
firstNumericLiteral
()
const
;
NumericLiteralIterator
lastNumericLiteral
()
const
;
const
StringLiteral
*
findOrInsertS
tringLiteral
(
const
char
*
chars
,
unsigned
size
);
const
StringLiteral
*
findOrInsertS
tringLiteral
(
const
char
*
chars
);
const
StringLiteral
*
s
tringLiteral
(
const
char
*
chars
,
unsigned
size
);
const
StringLiteral
*
s
tringLiteral
(
const
char
*
chars
);
const
NumericLiteral
*
findOrInsertN
umericLiteral
(
const
char
*
chars
,
unsigned
size
);
const
NumericLiteral
*
findOrInsertN
umericLiteral
(
const
char
*
chars
);
const
NumericLiteral
*
n
umericLiteral
(
const
char
*
chars
,
unsigned
size
);
const
NumericLiteral
*
n
umericLiteral
(
const
char
*
chars
);
bool
hasSymbol
(
Symbol
*
symbol
)
const
;
...
...
src/shared/cplusplus/Lexer.cpp
View file @
41b4af05
...
...
@@ -281,7 +281,7 @@ void Lexer::scan_helper(Token *tok)
yyinp
();
if
(
control
())
tok
->
string
=
control
()
->
findOrInsertS
tringLiteral
(
yytext
,
yylen
);
tok
->
string
=
control
()
->
s
tringLiteral
(
yytext
,
yylen
);
}
break
;
case
'{'
:
...
...
@@ -361,7 +361,7 @@ void Lexer::scan_helper(Token *tok)
int
yylen
=
_currentChar
-
yytext
;
tok
->
f
.
kind
=
T_NUMERIC_LITERAL
;
if
(
control
())
tok
->
number
=
control
()
->
findOrInsertN
umericLiteral
(
yytext
,
yylen
);
tok
->
number
=
control
()
->
n
umericLiteral
(
yytext
,
yylen
);
}
else
{
tok
->
f
.
kind
=
T_DOT
;
}
...
...
@@ -564,7 +564,7 @@ void Lexer::scan_helper(Token *tok)
if
(
_yychar
==
'>'
)
yyinp
();
if
(
control
())
tok
->
string
=
control
()
->
findOrInsertS
tringLiteral
(
yytext
,
yylen
);
tok
->
string
=
control
()
->
s
tringLiteral
(
yytext
,
yylen
);
tok
->
f
.
kind
=
T_ANGLE_STRING_LITERAL
;
}
else
if
(
_yychar
==
'<'
)
{
yyinp
();
...
...
@@ -642,7 +642,7 @@ void Lexer::scan_helper(Token *tok)
yyinp
();
if
(
control
())
tok
->
string
=
control
()
->
findOrInsertS
tringLiteral
(
yytext
,
yylen
);
tok
->
string
=
control
()
->
s
tringLiteral
(
yytext
,
yylen
);
break
;
}
...
...
@@ -679,7 +679,7 @@ void Lexer::scan_helper(Token *tok)
yyinp
();
if
(
control
())
tok
->
string
=
control
()
->
findOrInsertS
tringLiteral
(
yytext
,
yylen
);
tok
->
string
=
control
()
->
s
tringLiteral
(
yytext
,
yylen
);
}
else
if
(
std
::
isalpha
(
ch
)
||
ch
==
'_'
||
ch
==
'$'
)
{
const
char
*
yytext
=
_currentChar
-
1
;
while
(
std
::
isalnum
(
_yychar
)
||
_yychar
==
'_'
||
_yychar
==
'$'
)
...
...
@@ -694,7 +694,7 @@ void Lexer::scan_helper(Token *tok)
tok
->
f
.
kind
=
classifyOperator
(
yytext
,
yylen
);
if
(
control
())
tok
->
identifier
=
control
()
->
findOrInsertI
dentifier
(
yytext
,
yylen
);
tok
->
identifier
=
control
()
->
i
dentifier
(
yytext
,
yylen
);
}
break
;
}
else
if
(
std
::
isdigit
(
ch
))
{
...
...
@@ -715,7 +715,7 @@ void Lexer::scan_helper(Token *tok)
int
yylen
=
_currentChar
-
yytext
;
tok
->
f
.
kind
=
T_NUMERIC_LITERAL
;
if
(
control
())
tok
->
number
=
control
()
->
findOrInsertN
umericLiteral
(
yytext
,
yylen
);
tok
->
number
=
control
()
->
n
umericLiteral
(
yytext
,
yylen
);
break
;
}
else
{
tok
->
f
.
kind
=
T_ERROR
;
...
...
src/shared/cplusplus/TranslationUnit.cpp
View file @
41b4af05
...
...
@@ -188,8 +188,8 @@ void TranslationUnit::tokenize()
pushLineOffset
(
0
);
pushPreprocessorLine
(
0
,
1
,
fileId
());
const
Identifier
*
lineId
=
control
()
->
findOrInsertI
dentifier
(
"line"
);
const
Identifier
*
genId
=
control
()
->
findOrInsertI
dentifier
(
"gen"
);
const
Identifier
*
lineId
=
control
()
->
i
dentifier
(
"line"
);
const
Identifier
*
genId
=
control
()
->
i
dentifier
(
"gen"
);
bool
generated
=
false
;
Token
tk
;
...
...
@@ -218,7 +218,7 @@ void TranslationUnit::tokenize()
unsigned
line
=
(
unsigned
)
strtoul
(
tk
.
spell
(),
0
,
0
);
lex
(
&
tk
);
if
(
!
tk
.
f
.
newline
&&
tk
.
is
(
T_STRING_LITERAL
))
{
const
StringLiteral
*
fileName
=
control
()
->
findOrInsertS
tringLiteral
(
tk
.
string
->
chars
(),
const
StringLiteral
*
fileName
=
control
()
->
s
tringLiteral
(
tk
.
string
->
chars
(),
tk
.
string
->
size
());
pushPreprocessorLine
(
offset
,
line
,
fileName
);
lex
(
&
tk
);
...
...
Write
Preview
Markdown
is supported
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