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
Thomas Schöps
kdevelop
Commits
f4f15382
Commit
f4f15382
authored
Sep 12, 2018
by
Friedrich W. H. Kossebau
Browse files
Use more API style foo(), not getFoo(), for getting "foo"
parent
9d104f58
Changes
59
Hide whitespace changes
Inline
Side-by-side
kdevplatform/debugger/variable/variablecollection.cpp
View file @
f4f15382
...
...
@@ -545,7 +545,7 @@ QString VariableProvider::textHint(KTextEditor::View* view, const KTextEditor::C
w
=
view
;
m_collection
->
m_activeTooltip
=
new
VariableToolTip
(
w
,
global
+
QPoint
(
30
,
30
),
expression
);
m_collection
->
m_activeTooltip
->
setHandleRect
(
KTextEditorHelpers
::
getI
temBoundingRect
(
view
,
expressionRange
));
m_collection
->
m_activeTooltip
->
setHandleRect
(
KTextEditorHelpers
::
i
temBoundingRect
(
view
,
expressionRange
));
return
QString
();
}
...
...
kdevplatform/language/classmodel/classmodel.cpp
View file @
f4f15382
...
...
@@ -107,7 +107,7 @@ int ClassModel::rowCount(const QModelIndex& parent) const
if
(
parent
.
isValid
()
)
node
=
static_cast
<
Node
*>
(
parent
.
internalPointer
());
return
node
->
getC
hildren
().
size
();
return
node
->
c
hildren
().
size
();
}
QVariant
ClassModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
...
...
@@ -122,7 +122,7 @@ QVariant ClassModel::data(const QModelIndex& index, int role) const
if
(
role
==
Qt
::
DecorationRole
)
{
QIcon
icon
=
node
->
getC
achedIcon
();
QIcon
icon
=
node
->
c
achedIcon
();
return
icon
.
isNull
()
?
QVariant
()
:
icon
;
}
...
...
@@ -161,10 +161,10 @@ QModelIndex ClassModel::index(int row, int column, const QModelIndex& parent) co
if
(
parent
.
isValid
()
)
node
=
static_cast
<
Node
*>
(
parent
.
internalPointer
());
if
(
row
>=
node
->
getC
hildren
().
size
()
)
if
(
row
>=
node
->
c
hildren
().
size
()
)
return
QModelIndex
();
return
index
(
node
->
getC
hildren
()[
row
]);
return
index
(
node
->
c
hildren
()[
row
]);
}
QModelIndex
ClassModel
::
parent
(
const
QModelIndex
&
childIndex
)
const
...
...
@@ -174,10 +174,10 @@ QModelIndex ClassModel::parent(const QModelIndex& childIndex) const
Node
*
childNode
=
static_cast
<
Node
*>
(
childIndex
.
internalPointer
());
if
(
childNode
->
getP
arent
()
==
m_topNode
)
if
(
childNode
->
p
arent
()
==
m_topNode
)
return
QModelIndex
();
return
index
(
childNode
->
getP
arent
()
);
return
index
(
childNode
->
p
arent
()
);
}
QModelIndex
ClassModel
::
index
(
ClassModelNodes
::
Node
*
a_node
)
const
...
...
@@ -187,7 +187,7 @@ QModelIndex ClassModel::index(ClassModelNodes::Node* a_node) const
}
// If no parent exists, we have an invalid index (root node or not part of a model).
if
(
a_node
->
getP
arent
()
==
nullptr
)
if
(
a_node
->
p
arent
()
==
nullptr
)
return
QModelIndex
();
return
createIndex
(
a_node
->
row
(),
0
,
a_node
);
...
...
@@ -201,13 +201,13 @@ KDevelop::DUChainBase* ClassModel::duObjectForIndex(const QModelIndex& a_index)
Node
*
node
=
static_cast
<
Node
*>
(
a_index
.
internalPointer
());
if
(
IdentifierNode
*
identifierNode
=
dynamic_cast
<
IdentifierNode
*>
(
node
)
)
return
identifierNode
->
getD
eclaration
();
return
identifierNode
->
d
eclaration
();
// Non was found.
return
nullptr
;
}
QModelIndex
ClassModel
::
getI
ndexForIdentifier
(
const
KDevelop
::
IndexedQualifiedIdentifier
&
a_id
)
QModelIndex
ClassModel
::
i
ndexForIdentifier
(
const
KDevelop
::
IndexedQualifiedIdentifier
&
a_id
)
{
ClassNode
*
node
=
m_allClassesNode
->
findClassNode
(
a_id
);
if
(
node
==
nullptr
)
...
...
kdevplatform/language/classmodel/classmodel.h
View file @
f4f15382
...
...
@@ -93,7 +93,7 @@ public:
KDevelop
::
DUChainBase
*
duObjectForIndex
(
const
QModelIndex
&
a_index
);
/// Call this to retrieve the index for the node associated with the specified id.
QModelIndex
getI
ndexForIdentifier
(
const
KDevelop
::
IndexedQualifiedIdentifier
&
a_id
);
QModelIndex
i
ndexForIdentifier
(
const
KDevelop
::
IndexedQualifiedIdentifier
&
a_id
);
/// Return the model index associated with the given node.
QModelIndex
index
(
ClassModelNodes
::
Node
*
a_node
)
const
;
...
...
kdevplatform/language/classmodel/classmodelnode.cpp
View file @
f4f15382
...
...
@@ -49,7 +49,7 @@ IdentifierNode::IdentifierNode(KDevelop::Declaration* a_decl,
{
}
Declaration
*
IdentifierNode
::
getD
eclaration
()
Declaration
*
IdentifierNode
::
d
eclaration
()
{
if
(
!
m_cachedDeclaration
)
m_cachedDeclaration
=
m_indexedDeclaration
.
declaration
();
...
...
@@ -61,7 +61,7 @@ bool IdentifierNode::getIcon(QIcon& a_resultIcon)
{
DUChainReadLocker
readLock
(
DUChain
::
lock
());
Declaration
*
decl
=
getD
eclaration
();
Declaration
*
decl
=
d
eclaration
();
if
(
decl
)
a_resultIcon
=
DUChainUtils
::
iconForDeclaration
(
decl
);
...
...
@@ -83,7 +83,7 @@ bool EnumNode::getIcon(QIcon& a_resultIcon)
{
DUChainReadLocker
readLock
(
DUChain
::
lock
());
ClassMemberDeclaration
*
decl
=
dynamic_cast
<
ClassMemberDeclaration
*>
(
getD
eclaration
());
ClassMemberDeclaration
*
decl
=
dynamic_cast
<
ClassMemberDeclaration
*>
(
d
eclaration
());
if
(
decl
==
nullptr
)
{
static
QIcon
Icon
=
QIcon
::
fromTheme
(
QStringLiteral
(
"enum"
));
...
...
@@ -115,7 +115,7 @@ void EnumNode::populateNode()
{
DUChainReadLocker
readLock
(
DUChain
::
lock
());
Declaration
*
decl
=
getD
eclaration
();
Declaration
*
decl
=
d
eclaration
();
if
(
decl
->
internalContext
()
)
foreach
(
Declaration
*
enumDecl
,
decl
->
internalContext
()
->
localDeclarations
()
)
...
...
@@ -147,7 +147,7 @@ void ClassNode::populateNode()
{
if
(
updateClassDeclarations
()
)
{
m_cachedUrl
=
getD
eclaration
()
->
url
();
m_cachedUrl
=
d
eclaration
()
->
url
();
ClassModelNodesController
::
self
().
registerForChanges
(
m_cachedUrl
,
this
);
}
}
...
...
@@ -159,7 +159,7 @@ void ClassNode::populateNode()
template
<
>
inline
bool
qMapLessThanKey
(
const
IndexedIdentifier
&
key1
,
const
IndexedIdentifier
&
key2
)
{
return
key1
.
getI
ndex
()
<
key2
.
getI
ndex
();
return
key1
.
i
ndex
()
<
key2
.
i
ndex
();
}
bool
ClassNode
::
updateClassDeclarations
()
...
...
@@ -167,7 +167,7 @@ bool ClassNode::updateClassDeclarations()
bool
hadChanges
=
false
;
SubIdentifiersMap
existingIdentifiers
=
m_subIdentifiers
;
ClassDeclaration
*
klass
=
dynamic_cast
<
ClassDeclaration
*>
(
getD
eclaration
());
ClassDeclaration
*
klass
=
dynamic_cast
<
ClassDeclaration
*>
(
d
eclaration
());
if
(
klass
)
{
...
...
@@ -278,7 +278,7 @@ ClassNode* ClassNode::findSubClass(const KDevelop::IndexedQualifiedIdentifier& a
if
(
classNode
==
nullptr
)
continue
;
if
(
classNode
->
getI
dentifier
()
==
a_id
)
if
(
classNode
->
i
dentifier
()
==
a_id
)
return
classNode
;
}
...
...
@@ -320,7 +320,7 @@ bool ClassMemberNode::getIcon(QIcon& a_resultIcon)
{
DUChainReadLocker
readLock
(
DUChain
::
lock
());
ClassMemberDeclaration
*
decl
=
dynamic_cast
<
ClassMemberDeclaration
*>
(
getD
eclaration
());
ClassMemberDeclaration
*
decl
=
dynamic_cast
<
ClassMemberDeclaration
*>
(
d
eclaration
());
if
(
decl
==
nullptr
)
return
false
;
...
...
@@ -391,7 +391,7 @@ void BaseClassesFolderNode::populateNode()
{
DUChainReadLocker
readLock
(
DUChain
::
lock
());
ClassDeclaration
*
klass
=
dynamic_cast
<
ClassDeclaration
*>
(
static_cast
<
ClassNode
*>
(
getP
arent
())
->
getD
eclaration
()
);
ClassDeclaration
*
klass
=
dynamic_cast
<
ClassDeclaration
*>
(
static_cast
<
ClassNode
*>
(
p
arent
())
->
d
eclaration
()
);
if
(
klass
)
{
// I use the imports instead of the baseClasses in the ClassDeclaration because I need
...
...
@@ -426,11 +426,11 @@ void DerivedClassesFolderNode::populateNode()
{
DUChainReadLocker
readLock
(
DUChain
::
lock
());
ClassDeclaration
*
klass
=
dynamic_cast
<
ClassDeclaration
*>
(
static_cast
<
ClassNode
*>
(
getP
arent
())
->
getD
eclaration
()
);
ClassDeclaration
*
klass
=
dynamic_cast
<
ClassDeclaration
*>
(
static_cast
<
ClassNode
*>
(
p
arent
())
->
d
eclaration
()
);
if
(
klass
)
{
uint
steps
=
10000
;
const
QList
<
Declaration
*>
inheriters
=
DUChainUtils
::
getI
nheriters
(
klass
,
steps
,
true
);
const
QList
<
Declaration
*>
inheriters
=
DUChainUtils
::
i
nheriters
(
klass
,
steps
,
true
);
for
(
Declaration
*
decl
:
inheriters
)
{
addNode
(
new
ClassNode
(
decl
,
m_model
)
);
...
...
@@ -490,12 +490,12 @@ struct SortNodesFunctor
{
bool
operator
()
(
Node
*
a_lhs
,
Node
*
a_rhs
)
{
if
(
a_lhs
->
getS
core
()
==
a_rhs
->
getS
core
()
)
if
(
a_lhs
->
s
core
()
==
a_rhs
->
s
core
()
)
{
return
a_lhs
->
getS
ortableString
()
<
a_rhs
->
getS
ortableString
();
return
a_lhs
->
s
ortableString
()
<
a_rhs
->
s
ortableString
();
}
else
return
a_lhs
->
getS
core
()
<
a_rhs
->
getS
core
();
return
a_lhs
->
s
core
()
<
a_rhs
->
s
core
();
}
};
...
...
@@ -526,7 +526,7 @@ int Node::row()
return
m_parentNode
->
m_children
.
indexOf
(
this
);
}
QIcon
ClassModelNodes
::
Node
::
getC
achedIcon
()
QIcon
ClassModelNodes
::
Node
::
c
achedIcon
()
{
// Load the cached icon if it's null.
if
(
m_cachedIcon
.
isNull
()
)
...
...
kdevplatform/language/classmodel/classmodelnode.h
View file @
f4f15382
...
...
@@ -75,7 +75,7 @@ public: // Operations
public:
// Info retrieval
/// Return the parent associated with this node.
Node
*
getP
arent
()
const
{
return
m_parentNode
;
}
Node
*
p
arent
()
const
{
return
m_parentNode
;
}
/// Get my index in the parent node
int
row
();
...
...
@@ -84,21 +84,21 @@ public: // Info retrieval
QString
displayName
()
const
{
return
m_displayName
;
}
/// Returns a list of child nodes
const
QList
<
Node
*>&
getC
hildren
()
const
{
return
m_children
;
}
const
QList
<
Node
*>&
c
hildren
()
const
{
return
m_children
;
}
/// Return an icon representation for the node.
/// @note It calls the internal getIcon and caches the result.
QIcon
getC
achedIcon
();
QIcon
c
achedIcon
();
public:
// overridables
/// Return a score when sorting the nodes.
virtual
int
getS
core
()
const
=
0
;
virtual
int
s
core
()
const
=
0
;
/// Return true if the node contains sub-nodes.
virtual
bool
hasChildren
()
const
{
return
!
m_children
.
empty
();
}
/// We use this string when sorting items.
virtual
QString
getS
ortableString
()
const
{
return
m_displayName
;
}
virtual
QString
s
ortableString
()
const
{
return
m_displayName
;
}
protected:
/// fill a_resultIcon with a display icon for the node.
...
...
@@ -167,7 +167,7 @@ public:
public:
/// Returns the qualified identifier for this node by going through the tree
const
KDevelop
::
IndexedQualifiedIdentifier
&
getI
dentifier
()
const
{
return
m_identifier
;
}
const
KDevelop
::
IndexedQualifiedIdentifier
&
i
dentifier
()
const
{
return
m_identifier
;
}
public:
// Node overrides
bool
getIcon
(
QIcon
&
a_resultIcon
)
override
;
...
...
@@ -175,7 +175,7 @@ public: // Node overrides
public:
// Overridables
/// Return the associated declaration
/// @note DU CHAIN MUST BE LOCKED FOR READ
virtual
KDevelop
::
Declaration
*
getD
eclaration
();
virtual
KDevelop
::
Declaration
*
d
eclaration
();
private:
KDevelop
::
IndexedQualifiedIdentifier
m_identifier
;
...
...
@@ -193,7 +193,7 @@ public:
EnumNode
(
KDevelop
::
Declaration
*
a_decl
,
NodesModelInterface
*
a_model
);
public:
// Node overrides
int
getS
core
()
const
override
{
return
102
;
}
int
s
core
()
const
override
{
return
102
;
}
bool
getIcon
(
QIcon
&
a_resultIcon
)
override
;
void
populateNode
()
override
;
};
...
...
@@ -213,7 +213,7 @@ public:
ClassNode
*
findSubClass
(
const
KDevelop
::
IndexedQualifiedIdentifier
&
a_id
);
public:
// Node overrides
int
getS
core
()
const
override
{
return
300
;
}
int
s
core
()
const
override
{
return
300
;
}
void
populateNode
()
override
;
void
nodeCleared
()
override
;
bool
hasChildren
()
const
override
{
return
true
;
}
...
...
@@ -249,8 +249,8 @@ public:
FunctionNode
(
KDevelop
::
Declaration
*
a_decl
,
NodesModelInterface
*
a_model
);
public:
// Node overrides
int
getS
core
()
const
override
{
return
400
;
}
QString
getS
ortableString
()
const
override
{
return
m_sortableString
;
}
int
s
core
()
const
override
{
return
400
;
}
QString
s
ortableString
()
const
override
{
return
m_sortableString
;
}
private:
QString
m_sortableString
;
...
...
@@ -266,7 +266,7 @@ public:
ClassMemberNode
(
KDevelop
::
ClassMemberDeclaration
*
a_decl
,
NodesModelInterface
*
a_model
);
public:
// Node overrides
int
getS
core
()
const
override
{
return
500
;
}
int
s
core
()
const
override
{
return
500
;
}
bool
getIcon
(
QIcon
&
a_resultIcon
)
override
;
};
...
...
@@ -281,7 +281,7 @@ public:
public:
// Node overrides
bool
getIcon
(
QIcon
&
a_resultIcon
)
override
;
int
getS
core
()
const
override
{
return
100
;
}
int
s
core
()
const
override
{
return
100
;
}
};
//////////////////////////////////////////////////////////////////////////////
...
...
@@ -295,7 +295,7 @@ public:
public:
// Node overrides
bool
getIcon
(
QIcon
&
a_resultIcon
)
override
;
int
getS
core
()
const
override
{
return
100
;
}
int
s
core
()
const
override
{
return
100
;
}
};
//////////////////////////////////////////////////////////////////////////////
...
...
kdevplatform/language/classmodel/documentclassesfolder.cpp
View file @
f4f15382
...
...
@@ -49,7 +49,7 @@ public:
public:
// Node overrides
bool
getIcon
(
QIcon
&
a_resultIcon
)
override
;
int
getS
core
()
const
override
{
return
101
;
}
int
s
core
()
const
override
{
return
101
;
}
private:
/// The namespace identifier.
...
...
@@ -128,7 +128,7 @@ void DocumentClassesFolder::populateNode()
m_updateTimer
->
start
();
}
QSet
<
KDevelop
::
IndexedString
>
DocumentClassesFolder
::
getA
llOpenDocuments
()
QSet
<
KDevelop
::
IndexedString
>
DocumentClassesFolder
::
a
llOpenDocuments
()
const
{
return
m_openFiles
;
}
...
...
@@ -245,7 +245,7 @@ bool DocumentClassesFolder::updateDocument(const KDevelop::IndexedString& a_file
if
(
item
.
kind
&
CodeModelItem
::
Namespace
)
{
// This should create the namespace folder and add it to the cache.
getN
amespaceFolder
(
id
);
n
amespaceFolder
(
id
);
// Add to the locally created namespaces.
declaredNamespaces
.
insert
(
id
);
...
...
@@ -306,7 +306,7 @@ bool DocumentClassesFolder::updateDocument(const KDevelop::IndexedString& a_file
if
(
decls
->
declaration
()
->
kind
()
==
Declaration
::
Namespace
)
{
// This should create the namespace folder and add it to the cache.
parentNode
=
getN
amespaceFolder
(
parentIdentifier
);
parentNode
=
n
amespaceFolder
(
parentIdentifier
);
// Add to the locally created namespaces.
declaredNamespaces
.
insert
(
parentIdentifier
);
...
...
@@ -385,7 +385,7 @@ void DocumentClassesFolder::removeClassNode(ClassModelNodes::ClassNode* a_node)
{
// Get the parent namespace identifier.
QualifiedIdentifier
parentNamespaceIdentifier
;
if
(
auto
namespaceParent
=
dynamic_cast
<
StaticNamespaceFolderNode
*>
(
a_node
->
getP
arent
())
)
if
(
auto
namespaceParent
=
dynamic_cast
<
StaticNamespaceFolderNode
*>
(
a_node
->
p
arent
())
)
{
parentNamespaceIdentifier
=
namespaceParent
->
qualifiedIdentifier
();
}
...
...
@@ -418,7 +418,7 @@ void DocumentClassesFolder::removeEmptyNamespace(const QualifiedIdentifier& a_id
}
}
StaticNamespaceFolderNode
*
DocumentClassesFolder
::
getN
amespaceFolder
(
const
KDevelop
::
QualifiedIdentifier
&
a_identifier
)
StaticNamespaceFolderNode
*
DocumentClassesFolder
::
n
amespaceFolder
(
const
KDevelop
::
QualifiedIdentifier
&
a_identifier
)
{
// Stop condition.
if
(
a_identifier
.
count
()
==
0
)
...
...
@@ -429,7 +429,7 @@ StaticNamespaceFolderNode* DocumentClassesFolder::getNamespaceFolder(const KDeve
if
(
iter
==
m_namespaces
.
end
()
)
{
// It's not in the cache - create folders up to it.
Node
*
parentNode
=
getN
amespaceFolder
(
a_identifier
.
left
(
-
1
));
Node
*
parentNode
=
n
amespaceFolder
(
a_identifier
.
left
(
-
1
));
if
(
parentNode
==
nullptr
)
parentNode
=
this
;
...
...
kdevplatform/language/classmodel/documentclassesfolder.h
View file @
f4f15382
...
...
@@ -54,7 +54,7 @@ protected: // Documents list handling.
void
closeDocument
(
const
KDevelop
::
IndexedString
&
a_file
);
/// Returns a list of documents we have monitored.
QSet
<
KDevelop
::
IndexedString
>
getA
llOpenDocuments
();
QSet
<
KDevelop
::
IndexedString
>
a
llOpenDocuments
()
const
;
protected:
// Overridables
/// Override this to filter the found classes.
...
...
@@ -141,7 +141,7 @@ private:
/// Recursively create a namespace folder for the specified identifier if it doesn't
/// exist, cache it and return it (or just return it from the cache).
StaticNamespaceFolderNode
*
getN
amespaceFolder
(
const
KDevelop
::
QualifiedIdentifier
&
a_identifier
);
StaticNamespaceFolderNode
*
n
amespaceFolder
(
const
KDevelop
::
QualifiedIdentifier
&
a_identifier
);
/// Removes the given namespace identifier recursively if it's empty.
void
removeEmptyNamespace
(
const
KDevelop
::
QualifiedIdentifier
&
a_identifier
);
...
...
kdevplatform/language/codecompletion/codecompletiontesthelper.h
View file @
f4f15382
...
...
@@ -201,11 +201,12 @@ struct InsertIntoDUChain
}
///Helper function: get a declaration based on its qualified identifier
Declaration
*
getDeclaration
(
const
QString
&
id
)
{
Declaration
*
declaration
(
const
QString
&
id
)
{
get
();
if
(
!
topContext
())
return
nullptr
;
return
DeclarationId
(
IndexedQualifiedIdentifier
(
QualifiedIdentifier
(
id
))).
getD
eclaration
(
topContext
());
return
DeclarationId
(
IndexedQualifiedIdentifier
(
QualifiedIdentifier
(
id
))).
d
eclaration
(
topContext
());
}
TopDUContext
*
topContext
()
{
...
...
kdevplatform/language/codegen/codedescription.cpp
View file @
f4f15382
...
...
@@ -117,7 +117,7 @@ FunctionDescription::FunctionDescription(const DeclarationPointer& declaration)
DUChainPointer
<
FunctionDeclaration
>
function
=
declaration
.
dynamicCast
<
FunctionDeclaration
>
();
if
(
function
)
{
context
=
DUChainUtils
::
getA
rgumentContext
(
declaration
.
data
());
context
=
DUChainUtils
::
a
rgumentContext
(
declaration
.
data
());
}
DUChainPointer
<
ClassFunctionDeclaration
>
method
=
declaration
.
dynamicCast
<
ClassFunctionDeclaration
>
();
...
...
@@ -129,7 +129,7 @@ FunctionDescription::FunctionDescription(const DeclarationPointer& declaration)
isVirtual
=
method
->
isVirtual
();
isAbstract
=
method
->
isAbstract
();
isFinal
=
method
->
isFinal
();
isOverriding
=
(
DUChainUtils
::
getO
verridden
(
method
.
data
())
!=
nullptr
);
isOverriding
=
(
DUChainUtils
::
o
verridden
(
method
.
data
())
!=
nullptr
);
isStatic
=
method
->
isStatic
();
isSlot
=
method
->
isSlot
();
isSignal
=
method
->
isSignal
();
...
...
kdevplatform/language/codegen/templateclassgenerator.cpp
View file @
f4f15382
...
...
@@ -285,7 +285,7 @@ void TemplateClassGenerator::addBaseClass(const QString& base)
DUChainReadLocker
lock
;
PersistentSymbolTable
::
Declarations
decl
=
PersistentSymbolTable
::
self
().
getD
eclarations
(
IndexedQualifiedIdentifier
(
QualifiedIdentifier
(
desc
.
baseType
)));
PersistentSymbolTable
::
Declarations
decl
=
PersistentSymbolTable
::
self
().
d
eclarations
(
IndexedQualifiedIdentifier
(
QualifiedIdentifier
(
desc
.
baseType
)));
//Search for all super classes
for
(
PersistentSymbolTable
::
Declarations
::
Iterator
it
=
decl
.
iterator
();
it
;
++
it
)
...
...
kdevplatform/language/duchain/appendedlist.h
View file @
f4f15382
...
...
@@ -88,7 +88,7 @@ class TemporaryDataManager {
delete
m_items
.
at
(
a
);
}
inline
T
&
getI
tem
(
int
index
)
{
inline
T
&
i
tem
(
int
index
)
{
//For performance reasons this function does not lock the mutex, it's called too often and must be
//extremely fast. There is special measures in alloc() to make this safe.
Q_ASSERT
(
index
&
DynamicAppendedListMask
);
...
...
@@ -96,7 +96,7 @@ class TemporaryDataManager {
return
*
m_items
.
at
(
index
&
KDevelop
::
DynamicAppendedListRevertMask
);
}
///Allocates an item index, which from now on you can get using
getI
tem, until you call free(..) on the index.
///Allocates an item index, which from now on you can get using
i
tem
()
, until you call free(..) on the index.
///The returned item is not initialized and may contain random older content, so you should clear it after getting it for the first time
int
alloc
()
{
...
...
@@ -129,7 +129,7 @@ class TemporaryDataManager {
m_deleteLater
.
removeFirst
();
}
//The only function that does not lock the mutex is
getI
tem(..), because that function must be very efficient.
//The only function that does not lock the mutex is
i
tem(..), because that function must be very efficient.
//Since it's only a few instructions from the moment m_items is read to the moment it's used,
//deleting the old data after a few seconds should be safe.
m_deleteLater
.
append
(
qMakePair
(
now
,
oldItems
));
...
...
@@ -249,14 +249,14 @@ class TemporaryDataManager {
#define APPENDED_LIST_COMMON(container, type, name) \
uint name ## Data; \
unsigned int name ## Size() const { if((name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) return 0; if(!appendedListsDynamic()) return name ## Data; else return temporaryHash ## container ## name().
getI
tem(name ## Data).size(); } \
KDevVarLengthArray<type, 10>& name ## List() { name ## NeedDynamicList(); return temporaryHash ## container ## name().
getI
tem(name ## Data); }\
unsigned int name ## Size() const { if((name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) return 0; if(!appendedListsDynamic()) return name ## Data; else return temporaryHash ## container ## name().
i
tem(name ## Data).size(); } \
KDevVarLengthArray<type, 10>& name ## List() { name ## NeedDynamicList(); return temporaryHash ## container ## name().
i
tem(name ## Data); }\
template<class T> bool name ## Equals(const T& rhs) const { unsigned int size = name ## Size(); if(size != rhs.name ## Size()) return false; for(uint a = 0; a < size; ++a) {if(!(name()[a] == rhs.name()[a])) return false;} return true; } \
template<class T> void name ## CopyFrom( const T& rhs ) { \
if(rhs.name ## Size() == 0 && (name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) return; \
if(appendedListsDynamic()) { \
name ## NeedDynamicList(); \
KDevVarLengthArray<type, 10>& item( temporaryHash ## container ## name().
getI
tem(name ## Data) ); \
KDevVarLengthArray<type, 10>& item( temporaryHash ## container ## name().
i
tem(name ## Data) ); \
item.clear(); \
const type* otherCurr = rhs.name(); \
const type* otherEnd = otherCurr + rhs.name ## Size(); \
...
...
@@ -275,7 +275,7 @@ class TemporaryDataManager {
Q_ASSERT(appendedListsDynamic()); \
if((name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) {\
name ## Data = temporaryHash ## container ## name().alloc();\
Q_ASSERT(temporaryHash ## container ## name().
getI
tem(name ## Data).isEmpty()); \
Q_ASSERT(temporaryHash ## container ## name().
i
tem(name ## Data).isEmpty()); \
} \
} \
void name ## Initialize(bool dynamic) { name ## Data = (dynamic ? KDevelop::DynamicAppendedListMask : 0); } \
...
...
@@ -297,7 +297,7 @@ class TemporaryDataManager {
const type* name() const { \
if((name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) return nullptr; \
if(!appendedListsDynamic()) return reinterpret_cast<const type*>(reinterpret_cast<const char*>(this) + classSize() + offsetBehindBase()); \
else return temporaryHash ## container ## name().
getI
tem(name ## Data).data(); \
else return temporaryHash ## container ## name().
i
tem(name ## Data).data(); \
} \
unsigned int name ## OffsetBehind() const { return name ## Size() * sizeof(type) + offsetBehindBase(); } \
template<class T> bool name ## ListChainEquals( const T& rhs ) const { return name ## Equals(rhs); } \
...
...
@@ -310,7 +310,7 @@ class TemporaryDataManager {
const type* name() const {\
if((name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) return nullptr; \
if(!appendedListsDynamic()) return reinterpret_cast<const type*>(reinterpret_cast<const char*>(this) + classSize() + predecessor ## OffsetBehind()); \
else return temporaryHash ## container ## name().
getI
tem(name ## Data).data(); \
else return temporaryHash ## container ## name().
i
tem(name ## Data).data(); \
} \
unsigned int name ## OffsetBehind() const { return name ## Size() * sizeof(type) + predecessor ## OffsetBehind(); } \
template<class T> bool name ## ListChainEquals( const T& rhs ) const { return name ## Equals(rhs) && predecessor ## ListChainEquals(rhs); } \
...
...
kdevplatform/language/duchain/declaration.cpp
View file @
f4f15382
...
...
@@ -350,7 +350,7 @@ void Declaration::allocateOwnIndex() {
m_indexInTopContext
=
m_topContext
->
m_dynamicData
->
allocateDeclarationIndex
(
this
,
d_func
()
->
m_anonymousInContext
||
!
context
()
||
context
()
->
isAnonymous
());
Q_ASSERT
(
m_indexInTopContext
);
if
(
!
m_topContext
->
m_dynamicData
->
getD
eclarationForIndex
(
m_indexInTopContext
))
if
(
!
m_topContext
->
m_dynamicData
->
d
eclarationForIndex
(
m_indexInTopContext
))
qFatal
(
"Could not re-retrieve declaration
\n
index: %d"
,
m_indexInTopContext
);
}
...
...
kdevplatform/language/duchain/declarationid.cpp
View file @
f4f15382
...
...
@@ -95,7 +95,7 @@ IndexedInstantiationInformation DeclarationId::specialization() const
return
m_specialization
;
}
KDevVarLengthArray
<
Declaration
*>
DeclarationId
::
getD
eclarations
(
const
TopDUContext
*
top
)
const
KDevVarLengthArray
<
Declaration
*>
DeclarationId
::
d
eclarations
(
const
TopDUContext
*
top
)
const
{
KDevVarLengthArray
<
Declaration
*>
ret
;
...
...
@@ -106,7 +106,7 @@ KDevVarLengthArray<Declaration*> DeclarationId::getDeclarations(const TopDUConte
if
(
top
)
{
//Do filtering
PersistentSymbolTable
::
FilteredDeclarationIterator
filter
=
PersistentSymbolTable
::
self
().
getF
ilteredDeclarations
(
id
,
top
->
recursiveImportIndices
());
PersistentSymbolTable
::
self
().
f
ilteredDeclarations
(
id
,
top
->
recursiveImportIndices
());
for
(;
filter
;
++
filter
)
{
Declaration
*
decl
=
filter
->
data
();
if
(
decl
&&
m_indirectData
.
additionalIdentity
==
decl
->
additionalIdentity
())
{
...
...
@@ -116,7 +116,7 @@ KDevVarLengthArray<Declaration*> DeclarationId::getDeclarations(const TopDUConte
}
}
else
{
//Just accept anything
PersistentSymbolTable
::
Declarations
decls
=
PersistentSymbolTable
::
self
().
getD
eclarations
(
id
);
PersistentSymbolTable
::
Declarations
decls
=
PersistentSymbolTable
::
self
().
d
eclarations
(
id
);
PersistentSymbolTable
::
Declarations
::
Iterator
decl
=
decls
.
iterator
();
for
(;
decl
;
++
decl
)
{
const
IndexedDeclaration
&
iDecl
(
*
decl
);
...
...
@@ -151,7 +151,7 @@ KDevVarLengthArray<Declaration*> DeclarationId::getDeclarations(const TopDUConte
return
ret
;
}
Declaration
*
DeclarationId
::
getD
eclaration
(
const
TopDUContext
*
top
,
bool
instantiateIfRequired
)
const
Declaration
*
DeclarationId
::
d
eclaration
(
const
TopDUContext
*
top
,
bool
instantiateIfRequired
)
const
{
Declaration
*
ret
=
nullptr
;
...
...
@@ -162,7 +162,7 @@ Declaration* DeclarationId::getDeclaration(const TopDUContext* top, bool instant
if
(
top
)
{
//Do filtering
PersistentSymbolTable
::
FilteredDeclarationIterator
filter
=
PersistentSymbolTable
::
self
().
getF
ilteredDeclarations
(
id
,
top
->
recursiveImportIndices
());
PersistentSymbolTable
::
self
().
f
ilteredDeclarations
(
id
,
top
->
recursiveImportIndices
());
for
(;
filter
;
++
filter
)
{
Declaration
*
decl
=
filter
->
data
();
if
(
decl
&&
m_indirectData
.
additionalIdentity
==
decl
->
additionalIdentity
())
{
...
...
@@ -174,7 +174,7 @@ Declaration* DeclarationId::getDeclaration(const TopDUContext* top, bool instant
}
}
else
{
//Just accept anything
PersistentSymbolTable
::
Declarations
decls
=
PersistentSymbolTable
::
self
().
getD
eclarations
(
id
);
PersistentSymbolTable
::
Declarations
decls
=
PersistentSymbolTable
::
self
().
d
eclarations
(
id
);
PersistentSymbolTable
::
Declarations
::
Iterator
decl
=
decls
.
iterator
();
for
(;
decl
;
++
decl
)
{
const
IndexedDeclaration
&
iDecl
(
*
decl
);
...
...
@@ -226,7 +226,7 @@ QualifiedIdentifier DeclarationId::qualifiedIdentifier() const
return
baseIdentifier
;
return
m_specialization
.
information
().
applyToIdentifier
(
baseIdentifier
);
}
else
{
Declaration
*
decl
=
getD
eclaration
(
nullptr
);
Declaration
*
decl
=
d
eclaration
(
nullptr
);
if
(
decl
)
return
decl
->
qualifiedIdentifier
();
...
...
kdevplatform/language/duchain/declarationid.h
View file @
f4f15382
...
...
@@ -125,7 +125,7 @@ class KDEVPLATFORMLANGUAGE_EXPORT DeclarationId {
if
(
m_isDirect
)
return
KDevHash
()
<<
m_directData
.
hash
()
<<
m_specialization
.
index
();
else
return
KDevHash
()
<<
m_indirectData
.
identifier
.
getI
ndex
()
<<
m_indirectData
.
additionalIdentity
<<
m_specialization
.
index
();
return
KDevHash
()
<<
m_indirectData
.
identifier
.
i
ndex
()
<<
m_indirectData
.
additionalIdentity
<<
m_specialization
.
index
();
}
/**
...
...
@@ -136,13 +136,13 @@ class KDEVPLATFORMLANGUAGE_EXPORT DeclarationId {
* \param instantiateIfRequired Whether the declaration should be instantiated if required
* \returns the referenced Declaration, or null if none was found.
* */
Declaration
*
getD
eclaration
(
const
TopDUContext
*
context
,
bool
instantiateIfRequired
=
true
)
const
;
Declaration
*
d
eclaration
(
const
TopDUContext
*
context
,
bool
instantiateIfRequired
=
true
)
const
;