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
1e7b4063
Commit
1e7b4063
authored
Jul 29, 2009
by
Roberto Raggi
Browse files
Added Snapshot::dependsOn().
Snapshot::dependsOn(fn) returns the files in the snapshot that depends on fn.
parent
7e65890c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/CppDocument.cpp
View file @
1e7b4063
...
...
@@ -40,9 +40,9 @@
#include <AST.h>
#include <Scope.h>
#include <QByteArray>
#include <Q
File
>
#include <QtDebug>
#include <
QtCore/
QByteArray>
#include <Q
tCore/QBitArray
>
#include <
QtCore/
QtDebug>
using
namespace
CPlusPlus
;
...
...
@@ -419,3 +419,78 @@ void Snapshot::simplified_helper(Document::Ptr doc, Snapshot *snapshot) const
}
}
}
QStringList
Snapshot
::
dependsOn
(
const
QString
&
fileName
)
const
{
const
int
n
=
size
();
QVector
<
QString
>
files
(
n
);
QHash
<
QString
,
int
>
fileIndex
;
QHash
<
int
,
QList
<
int
>
>
includes
;
QMapIterator
<
QString
,
Document
::
Ptr
>
it
(
*
this
);
for
(
int
i
=
0
;
it
.
hasNext
();
++
i
)
{
it
.
next
();
files
[
i
]
=
it
.
key
();
fileIndex
[
it
.
key
()]
=
i
;
}
int
index
=
fileIndex
.
value
(
fileName
,
-
1
);
if
(
index
==
-
1
)
{
qWarning
()
<<
fileName
<<
"not in the snapshot"
;
return
QStringList
();
}
QVector
<
QBitArray
>
includeMap
(
files
.
size
());
for
(
int
i
=
0
;
i
<
files
.
size
();
++
i
)
{
if
(
Document
::
Ptr
doc
=
value
(
files
.
at
(
i
)))
{
QBitArray
bitmap
(
files
.
size
());
QList
<
int
>
directIncludes
;
foreach
(
const
QString
&
includedFile
,
doc
->
includedFiles
())
{
int
index
=
fileIndex
.
value
(
includedFile
);
if
(
index
==
-
1
)
continue
;
else
if
(
!
directIncludes
.
contains
(
index
))
directIncludes
.
append
(
index
);
bitmap
.
setBit
(
index
,
true
);
}
includeMap
[
i
]
=
bitmap
;
includes
[
i
]
=
directIncludes
;
}
}
bool
changed
;
do
{
changed
=
false
;
for
(
int
i
=
0
;
i
<
files
.
size
();
++
i
)
{
QBitArray
bitmap
=
includeMap
.
value
(
i
);
QBitArray
previousBitmap
=
bitmap
;
foreach
(
int
includedFileIndex
,
includes
.
value
(
i
))
{
bitmap
|=
includeMap
.
value
(
includedFileIndex
);
}
if
(
bitmap
!=
previousBitmap
)
{
includeMap
[
i
]
=
bitmap
;
changed
=
true
;
}
}
}
while
(
changed
);
QStringList
deps
;
for
(
int
i
=
0
;
i
<
files
.
size
();
++
i
)
{
const
QBitArray
&
bits
=
includeMap
.
at
(
i
);
if
(
bits
.
testBit
(
index
))
deps
.
append
(
files
.
at
(
i
));
}
return
deps
;
}
src/libs/cplusplus/CppDocument.h
View file @
1e7b4063
...
...
@@ -291,6 +291,8 @@ public:
QSharedPointer
<
NamespaceBinding
>
globalNamespaceBinding
(
Document
::
Ptr
doc
)
const
;
QStringList
dependsOn
(
const
QString
&
fileName
)
const
;
void
insert
(
Document
::
Ptr
doc
);
using
_Base
::
insert
;
...
...
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