data: refresh with java imports
* coati regards import dependencies when refreshing a project
This commit is contained in:
@@ -49,8 +49,8 @@ public class JavaIndexer
|
||||
}
|
||||
CompilationUnit cu = JavaParser.parse(new StringReader(fileContent), true);
|
||||
|
||||
// JavaAstVisitor astVisitor = new JavaAstVisitor(address, filePath, new FileContent(fileContent), typeSolver);
|
||||
JavaAstVisitor astVisitor = new ASTDumper(address, filePath, new FileContent(fileContent), typeSolver);
|
||||
JavaAstVisitor astVisitor = new JavaAstVisitor(address, filePath, new FileContent(fileContent), typeSolver);
|
||||
// JavaAstVisitor astVisitor = new ASTDumper(address, filePath, new FileContent(fileContent), typeSolver);
|
||||
cu.accept(astVisitor, null);
|
||||
}
|
||||
catch (ParseException e)
|
||||
|
||||
@@ -285,31 +285,13 @@ void PersistentStorage::clearCaches()
|
||||
std::set<FilePath> PersistentStorage::getDependingFilePaths(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
for (const FilePath& filePath: filePaths)
|
||||
{
|
||||
std::set<FilePath> dependingFilePathsSubset = getDependingFilePaths(filePath);
|
||||
dependingFilePaths.insert(dependingFilePathsSubset.begin(), dependingFilePathsSubset.end());
|
||||
}
|
||||
return dependingFilePaths;
|
||||
}
|
||||
|
||||
std::set<FilePath> PersistentStorage::getDependingFilePaths(const FilePath& filePath)
|
||||
{
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
|
||||
std::vector<StorageEdge> incomingEdges = m_sqliteStorage.getEdgesByTargetType(
|
||||
getFileNodeId(filePath), Edge::typeToInt(Edge::EDGE_INCLUDE)
|
||||
);
|
||||
for (const StorageEdge& incomingEdge: incomingEdges)
|
||||
{
|
||||
FilePath dependingFilePath = getFileNodePath(incomingEdge.sourceNodeId);
|
||||
dependingFilePaths.insert(dependingFilePath);
|
||||
std::set<FilePath> dependingFilePathsForIncludes = getDependingFilePathsForIncludes(filePaths);
|
||||
dependingFilePaths.insert(dependingFilePathsForIncludes.begin(), dependingFilePathsForIncludes.end());
|
||||
|
||||
std::set<FilePath> dependingFilePathsSubset = getDependingFilePaths(dependingFilePath);
|
||||
dependingFilePaths.insert(dependingFilePathsSubset.begin(), dependingFilePathsSubset.end());
|
||||
}
|
||||
std::set<FilePath> dependingFilePathsForImports = getDependingFilePathsForImports(filePaths);
|
||||
dependingFilePaths.insert(dependingFilePathsForImports.begin(), dependingFilePathsForImports.end());
|
||||
|
||||
return dependingFilePaths;
|
||||
}
|
||||
@@ -1163,6 +1145,90 @@ FilePath PersistentStorage::getFileNodePath(Id fileId) const
|
||||
return FilePath();
|
||||
}
|
||||
|
||||
std::set<FilePath> PersistentStorage::getDependingFilePathsForIncludes(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
for (const FilePath& filePath: filePaths)
|
||||
{
|
||||
std::set<FilePath> dependingFilePathsSubset = getDependingFilePathsForIncludes(filePath);
|
||||
dependingFilePaths.insert(dependingFilePathsSubset.begin(), dependingFilePathsSubset.end());
|
||||
}
|
||||
return dependingFilePaths;
|
||||
}
|
||||
|
||||
std::set<FilePath> PersistentStorage::getDependingFilePathsForIncludes(const FilePath& filePath)
|
||||
{
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
|
||||
std::vector<StorageEdge> incomingEdges = m_sqliteStorage.getEdgesByTargetType(
|
||||
getFileNodeId(filePath), Edge::typeToInt(Edge::EDGE_INCLUDE)
|
||||
);
|
||||
for (const StorageEdge& incomingEdge: incomingEdges)
|
||||
{
|
||||
FilePath dependingFilePath = getFileNodePath(incomingEdge.sourceNodeId);
|
||||
dependingFilePaths.insert(dependingFilePath);
|
||||
|
||||
std::set<FilePath> dependingFilePathsSubset = getDependingFilePathsForIncludes(dependingFilePath);
|
||||
dependingFilePaths.insert(dependingFilePathsSubset.begin(), dependingFilePathsSubset.end());
|
||||
}
|
||||
|
||||
return dependingFilePaths;
|
||||
}
|
||||
|
||||
std::set<FilePath> PersistentStorage::getDependingFilePathsForImports(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
std::map<Id, std::set<Id>> fileIdToDependingFileIds;
|
||||
|
||||
for (const StorageEdge& importEdge: m_sqliteStorage.getEdgesByType(Edge::typeToInt(Edge::EDGE_IMPORT)))
|
||||
{
|
||||
for (const StorageSourceLocation& importedElementLoc: m_sqliteStorage.getTokenLocationsForElementId(importEdge.targetNodeId))
|
||||
{
|
||||
fileIdToDependingFileIds[importedElementLoc.fileNodeId].insert(importEdge.sourceNodeId);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<Id> dependingFileNodeIds;
|
||||
|
||||
std::set<Id> working;
|
||||
for (const FilePath& filePath: filePaths)
|
||||
{
|
||||
working.insert(getFileNodeId(filePath));
|
||||
}
|
||||
|
||||
std::set<Id> tempWorking;
|
||||
while (working.size() > 0)
|
||||
{
|
||||
for (Id id: working)
|
||||
{
|
||||
std::map<Id, std::set<Id>>::const_iterator it = fileIdToDependingFileIds.find(id);
|
||||
if (it != fileIdToDependingFileIds.end())
|
||||
{
|
||||
for (Id dependingFileNodeId: it->second)
|
||||
{
|
||||
const size_t countBeforeInsert = dependingFileNodeIds.size();
|
||||
dependingFileNodeIds.insert(dependingFileNodeId);
|
||||
const size_t countAfterInsert = dependingFileNodeIds.size();
|
||||
if (countBeforeInsert != countAfterInsert)
|
||||
{
|
||||
tempWorking.insert(dependingFileNodeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
working = tempWorking;
|
||||
tempWorking.clear();
|
||||
}
|
||||
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
|
||||
for (Id id: dependingFileNodeIds)
|
||||
{
|
||||
dependingFilePaths.insert(getFileNodePath(id));
|
||||
}
|
||||
|
||||
return dependingFilePaths;
|
||||
}
|
||||
|
||||
Id PersistentStorage::getLastVisibleParentNodeId(const Id nodeId) const
|
||||
{
|
||||
return m_hierarchyCache.getLastVisibleParentNodeId(nodeId);
|
||||
|
||||
@@ -60,7 +60,6 @@ public:
|
||||
void clearCaches();
|
||||
|
||||
std::set<FilePath> getDependingFilePaths(const std::set<FilePath>& filePaths);
|
||||
std::set<FilePath> getDependingFilePaths(const FilePath& filePath);
|
||||
|
||||
void clearFileElements(const std::vector<FilePath>& filePaths);
|
||||
|
||||
@@ -123,6 +122,10 @@ private:
|
||||
Id getFileNodeId(const FilePath& filePath) const;
|
||||
FilePath getFileNodePath(Id fileId) const;
|
||||
|
||||
std::set<FilePath> getDependingFilePathsForIncludes(const std::set<FilePath>& filePaths);
|
||||
std::set<FilePath> getDependingFilePathsForIncludes(const FilePath& filePath);
|
||||
std::set<FilePath> getDependingFilePathsForImports(const std::set<FilePath>& filePaths);
|
||||
|
||||
Id getLastVisibleParentNodeId(const Id nodeId) const;
|
||||
std::vector<Id> getAllChildNodeIds(const Id nodeId) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user