src: implemented move constructor/assignment for filepath
* improves indexing performance by roughly 5% * switched to use uniqu_ptr for boost path to get rid of including boost in header * added different methods to change the current FilePath or to make a copy and change that one * used these methods appropriately throughout the code base * removed exists() method from FileSystem because it is already contained in FilePath * added const in some places
This commit is contained in:
@@ -83,7 +83,7 @@ LicenseChecker::LicenseState LicenseChecker::checkCurrentLicense() const
|
||||
return LICENSE_EMPTY;
|
||||
}
|
||||
|
||||
if (!License::checkLocation(FilePath(appPath).absolute().str(), licenseCheck))
|
||||
if (!License::checkLocation(FilePath(appPath).makeAbsolute().str(), licenseCheck))
|
||||
{
|
||||
return LICENSE_MOVED;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ void IDECommunicationController::handleSetActiveTokenMessage(
|
||||
{
|
||||
const unsigned int cursorColumn = message.column;
|
||||
|
||||
const FilePath filePath = FilePath(message.fileLocation).canonical();
|
||||
const FilePath filePath = FilePath(message.fileLocation).makeCanonical();
|
||||
|
||||
if (FileSystem::getFileInfoForPath(filePath).lastWriteTime
|
||||
== m_storageAccess->getFileInfoForFilePath(filePath).lastWriteTime)
|
||||
|
||||
@@ -486,7 +486,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused)
|
||||
return getStyleForNodeType(
|
||||
NodeType::STYLE_BIG_NODE,
|
||||
"bundle",
|
||||
ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/bundle.png")),
|
||||
ResourcePaths::getGuiPath().concatenate(FilePath("graph_view/images/bundle.png")),
|
||||
true,
|
||||
false,
|
||||
isFocused,
|
||||
|
||||
@@ -228,19 +228,19 @@ FilePath NodeType::getIconPath() const
|
||||
if (isPackage())
|
||||
{
|
||||
// this icon cannot be changed
|
||||
return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/namespace.png"));
|
||||
return ResourcePaths::getGuiPath().concatenate(FilePath("graph_view/images/namespace.png"));
|
||||
}
|
||||
|
||||
switch (m_type)
|
||||
{
|
||||
case NodeType::NODE_ENUM:
|
||||
return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/enum.png"));
|
||||
return ResourcePaths::getGuiPath().concatenate(FilePath("graph_view/images/enum.png"));
|
||||
case NodeType::NODE_TYPEDEF:
|
||||
return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/typedef.png"));
|
||||
return ResourcePaths::getGuiPath().concatenate(FilePath("graph_view/images/typedef.png"));
|
||||
case NodeType::NODE_MACRO:
|
||||
return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/macro.png"));
|
||||
return ResourcePaths::getGuiPath().concatenate(FilePath("graph_view/images/macro.png"));
|
||||
case NodeType::NODE_FILE:
|
||||
return ResourcePaths::getGuiPath().concat(FilePath("graph_view/images/file.png"));
|
||||
return ResourcePaths::getGuiPath().concatenate(FilePath("graph_view/images/file.png"));
|
||||
default:
|
||||
return FilePath();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef NODE_TYPE_H
|
||||
#define NODE_TYPE_H
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
@@ -14,16 +14,12 @@ ParseLocation::ParseLocation(
|
||||
uint lineNumber,
|
||||
uint columnNumber
|
||||
)
|
||||
: filePath(filePath)
|
||||
: filePath(filePath.getCanonical())
|
||||
, startLineNumber(lineNumber)
|
||||
, startColumnNumber(columnNumber)
|
||||
, endLineNumber(lineNumber)
|
||||
, endColumnNumber(columnNumber)
|
||||
{
|
||||
if (this->filePath.exists())
|
||||
{
|
||||
this->filePath = this->filePath.canonical();
|
||||
}
|
||||
}
|
||||
|
||||
ParseLocation::ParseLocation(
|
||||
@@ -31,16 +27,12 @@ ParseLocation::ParseLocation(
|
||||
uint startLineNumber, uint startColumnNumber,
|
||||
uint endLineNumber, uint endColumnNumber
|
||||
)
|
||||
: filePath(filePath)
|
||||
: filePath(filePath.getCanonical())
|
||||
, startLineNumber(startLineNumber)
|
||||
, startColumnNumber(startColumnNumber)
|
||||
, endLineNumber(endLineNumber)
|
||||
, endColumnNumber(endColumnNumber)
|
||||
{
|
||||
if (this->filePath.exists())
|
||||
{
|
||||
this->filePath = this->filePath.canonical();
|
||||
}
|
||||
}
|
||||
|
||||
bool ParseLocation::isValid() const
|
||||
|
||||
@@ -75,7 +75,7 @@ void PersistentStorage::addSymbol(const StorageSymbol& data)
|
||||
|
||||
void PersistentStorage::addFile(const StorageFile& data)
|
||||
{
|
||||
StorageFile storedFile = m_sqliteIndexStorage.getFirstById<StorageFile>(data.id);
|
||||
const StorageFile storedFile = m_sqliteIndexStorage.getFirstById<StorageFile>(data.id);
|
||||
|
||||
if (storedFile.id == 0)
|
||||
{
|
||||
@@ -90,7 +90,7 @@ void PersistentStorage::addFile(const StorageFile& data)
|
||||
|
||||
Id PersistentStorage::addEdge(const StorageEdgeData& data)
|
||||
{
|
||||
StorageEdge storedEdge = m_sqliteIndexStorage.getEdgeBySourceTargetType(data.sourceNodeId, data.targetNodeId, data.type);
|
||||
const StorageEdge storedEdge = m_sqliteIndexStorage.getEdgeBySourceTargetType(data.sourceNodeId, data.targetNodeId, data.type);
|
||||
if (storedEdge.id == 0)
|
||||
{
|
||||
return m_sqliteIndexStorage.addEdge(data).id;
|
||||
@@ -100,7 +100,7 @@ Id PersistentStorage::addEdge(const StorageEdgeData& data)
|
||||
|
||||
Id PersistentStorage::addLocalSymbol(const StorageLocalSymbolData& data)
|
||||
{
|
||||
StorageLocalSymbol storedLocalSymbol = m_sqliteIndexStorage.getLocalSymbolByName(data.name);
|
||||
const StorageLocalSymbol storedLocalSymbol = m_sqliteIndexStorage.getLocalSymbolByName(data.name);
|
||||
if (storedLocalSymbol.id == 0)
|
||||
{
|
||||
return m_sqliteIndexStorage.addLocalSymbol(data).id;
|
||||
@@ -451,8 +451,8 @@ Id PersistentStorage::getIdForEdge(
|
||||
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy
|
||||
) const
|
||||
{
|
||||
Id sourceId = getNodeIdForNameHierarchy(fromNameHierarchy);
|
||||
Id targetId = getNodeIdForNameHierarchy(toNameHierarchy);
|
||||
const Id sourceId = getNodeIdForNameHierarchy(fromNameHierarchy);
|
||||
const Id targetId = getNodeIdForNameHierarchy(toNameHierarchy);
|
||||
return m_sqliteIndexStorage.getEdgeBySourceTargetType(sourceId, targetId, type).id;
|
||||
}
|
||||
|
||||
@@ -484,12 +484,11 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLo
|
||||
false, true
|
||||
).dispatch();
|
||||
|
||||
std::vector<FullTextSearchResult> allHits = m_fullTextSearchIndex.searchForTerm(searchTerm);
|
||||
int termLength = searchTerm.length();
|
||||
const int termLength = searchTerm.length();
|
||||
|
||||
for (FullTextSearchResult fileHits : allHits)
|
||||
for (const FullTextSearchResult& fileHits : m_fullTextSearchIndex.searchForTerm(searchTerm))
|
||||
{
|
||||
FilePath filePath = getFileNodePath(fileHits.fileId);
|
||||
const FilePath filePath = getFileNodePath(fileHits.fileId);
|
||||
std::shared_ptr<TextAccess> fileContent = getFileContent(filePath);
|
||||
|
||||
int charsTotal = 0;
|
||||
@@ -525,7 +524,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLo
|
||||
location.endColumnNumber = pos + termLength - charsTotal;
|
||||
|
||||
// Set first bit to 1 to avoid collisions
|
||||
Id locationId = ~(~Id(0) >> 1) + collection->getSourceLocationCount() + 1;
|
||||
const Id locationId = ~(~Id(0) >> 1) + collection->getSourceLocationCount() + 1;
|
||||
|
||||
collection->addSourceLocation(
|
||||
LOCATION_FULLTEXT_SEARCH,
|
||||
@@ -557,8 +556,8 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(const std::
|
||||
TRACE();
|
||||
|
||||
// search in indices
|
||||
size_t maxResultsCount = 100;
|
||||
size_t maxBestScoredResultsLength = 100;
|
||||
const size_t maxResultsCount = 100;
|
||||
const size_t maxBestScoredResultsLength = 100;
|
||||
|
||||
// create SearchMatches
|
||||
std::vector<SearchMatch> matches;
|
||||
@@ -603,7 +602,7 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(
|
||||
const std::string& query, const NodeTypeSet& acceptedNodeTypes, size_t maxResultsCount, size_t maxBestScoredResultsLength) const
|
||||
{
|
||||
// search in indices
|
||||
std::vector<SearchResult> results =
|
||||
const std::vector<SearchResult> results =
|
||||
m_symbolIndex.search(query, acceptedNodeTypes, maxResultsCount, maxBestScoredResultsLength);
|
||||
|
||||
// fetch StorageNodes for node ids
|
||||
@@ -685,7 +684,7 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(
|
||||
|
||||
std::vector<SearchMatch> PersistentStorage::getAutocompletionFileMatches(const std::string& query, size_t maxResultsCount) const
|
||||
{
|
||||
std::vector<SearchResult> results = m_fileIndex.search(
|
||||
const std::vector<SearchResult> results = m_fileIndex.search(
|
||||
query,
|
||||
NodeTypeSet::all().getWithMatchingKept([](const NodeType& type) { return type.isFile(); }),
|
||||
maxResultsCount,
|
||||
@@ -701,7 +700,7 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionFileMatches(const s
|
||||
match.name = result.text;
|
||||
match.tokenIds = utility::toVector(result.elementIds);
|
||||
|
||||
FilePath path(match.name);
|
||||
const FilePath path(match.name);
|
||||
match.text = path.fileName();
|
||||
match.subtext = path.str();
|
||||
|
||||
@@ -725,7 +724,7 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionCommandMatches(
|
||||
const std::string& query, NodeTypeSet acceptedNodeTypes) const
|
||||
{
|
||||
// search in indices
|
||||
std::vector<SearchResult> results = m_commandIndex.search(query, NodeTypeSet::all(), 0);
|
||||
const std::vector<SearchResult> results = m_commandIndex.search(query, NodeTypeSet::all(), 0);
|
||||
|
||||
// create SearchMatches
|
||||
std::vector<SearchMatch> matches;
|
||||
@@ -785,7 +784,7 @@ std::vector<SearchMatch> PersistentStorage::getSearchMatchesForTokenIds(const st
|
||||
StorageNode node = storageNodeMap[elementId];
|
||||
|
||||
SearchMatch match;
|
||||
NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
const NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
match.name = nameHierarchy.getQualifiedName();
|
||||
match.text = nameHierarchy.getRawName();
|
||||
|
||||
@@ -885,11 +884,11 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForActiveTokenIds(
|
||||
if (tokenIds.size() == 1)
|
||||
{
|
||||
const Id elementId = tokenIds[0];
|
||||
StorageNode node = m_sqliteIndexStorage.getFirstById<StorageNode>(elementId);
|
||||
const StorageNode node = m_sqliteIndexStorage.getFirstById<StorageNode>(elementId);
|
||||
|
||||
if (node.id > 0)
|
||||
{
|
||||
NodeType nodeType = utility::intToType(node.type);
|
||||
const NodeType nodeType = utility::intToType(node.type);
|
||||
if (nodeType.isPackage())
|
||||
{
|
||||
ids.clear();
|
||||
@@ -911,8 +910,7 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForActiveTokenIds(
|
||||
nodeIds.push_back(elementId);
|
||||
edgeIds.clear();
|
||||
|
||||
std::vector<StorageEdge> edges = m_sqliteIndexStorage.getEdgesBySourceOrTargetId(elementId);
|
||||
for (const StorageEdge& edge : edges)
|
||||
for (const StorageEdge& edge : m_sqliteIndexStorage.getEdgesBySourceOrTargetId(elementId))
|
||||
{
|
||||
Edge::EdgeType edgeType = Edge::intToType(edge.type);
|
||||
if (edgeType == Edge::EDGE_MEMBER)
|
||||
@@ -965,8 +963,7 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForActiveTokenIds(
|
||||
{
|
||||
if (nodeIds.size() != ids.size())
|
||||
{
|
||||
std::vector<StorageEdge> edges = m_sqliteIndexStorage.getAllByIds<StorageEdge>(ids);
|
||||
for (const StorageEdge& edge : edges)
|
||||
for (const StorageEdge& edge : m_sqliteIndexStorage.getAllByIds<StorageEdge>(ids))
|
||||
{
|
||||
if (edge.id > 0)
|
||||
{
|
||||
@@ -1082,8 +1079,8 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForTrail(
|
||||
{
|
||||
bool isForward = forward == !(Edge::intToType(edge.type) & (Edge::EDGE_OVERRIDE | Edge::EDGE_INHERITANCE));
|
||||
|
||||
Id nodeId = isForward ? edge.targetNodeId : edge.sourceNodeId;
|
||||
Id otherNodeId = isForward ? edge.sourceNodeId : edge.targetNodeId;
|
||||
const Id nodeId = isForward ? edge.targetNodeId : edge.sourceNodeId;
|
||||
const Id otherNodeId = isForward ? edge.sourceNodeId : edge.targetNodeId;
|
||||
|
||||
if (nodeIds.find(nodeId) == nodeIds.end())
|
||||
{
|
||||
@@ -1127,7 +1124,7 @@ std::vector<Id> PersistentStorage::getActiveTokenIdsForId(Id tokenId, Id* declar
|
||||
{
|
||||
*declarationId = tokenId;
|
||||
|
||||
std::vector<StorageEdge> incomingEdges = m_sqliteIndexStorage.getEdgesByTargetId(tokenId);
|
||||
const std::vector<StorageEdge> incomingEdges = m_sqliteIndexStorage.getEdgesByTargetId(tokenId);
|
||||
for (size_t i = 0; i < incomingEdges.size(); i++)
|
||||
{
|
||||
activeTokenIds.push_back(incomingEdges[i].id);
|
||||
@@ -1150,7 +1147,7 @@ std::vector<Id> PersistentStorage::getNodeIdsForLocationIds(const std::vector<Id
|
||||
{
|
||||
const Id elementId = occurrence.elementId;
|
||||
|
||||
StorageEdge edge = m_sqliteIndexStorage.getFirstById<StorageEdge>(elementId);
|
||||
const StorageEdge edge = m_sqliteIndexStorage.getFirstById<StorageEdge>(elementId);
|
||||
if (edge.id != 0)
|
||||
{
|
||||
auto it = m_symbolDefinitionKinds.find(edge.targetNodeId);
|
||||
@@ -1210,7 +1207,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getSourceLocationsF
|
||||
// check for non-indexed file
|
||||
if (path.empty() && m_symbolDefinitionKinds.find(tokenId) == m_symbolDefinitionKinds.end())
|
||||
{
|
||||
StorageNode fileNode = m_sqliteIndexStorage.getNodeById(tokenId);
|
||||
const StorageNode fileNode = m_sqliteIndexStorage.getNodeById(tokenId);
|
||||
if (NodeType(utility::intToType(fileNode.type)).isFile())
|
||||
{
|
||||
path = FilePath(NameHierarchy::deserialize(fileNode.serializedName).getQualifiedName());
|
||||
@@ -1248,7 +1245,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getSourceLocationsF
|
||||
auto it = locationIdToElementIdMap.find(sourceLocation.id);
|
||||
if (it != locationIdToElementIdMap.end())
|
||||
{
|
||||
LocationType type = intToLocationType(sourceLocation.type);
|
||||
const LocationType type = intToLocationType(sourceLocation.type);
|
||||
if (type == LOCATION_QUALIFIER)
|
||||
{
|
||||
continue;
|
||||
@@ -1257,10 +1254,10 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getSourceLocationsF
|
||||
FilePath path = getFileNodePath(sourceLocation.fileNodeId);
|
||||
if (path.empty())
|
||||
{
|
||||
StorageNode fileNode = m_sqliteIndexStorage.getNodeById(sourceLocation.fileNodeId);
|
||||
const StorageNode fileNode = m_sqliteIndexStorage.getNodeById(sourceLocation.fileNodeId);
|
||||
if (fileNode.id)
|
||||
{
|
||||
FilePath path2 = FilePath(NameHierarchy::deserialize(fileNode.serializedName).getQualifiedName());
|
||||
const FilePath path2 = FilePath(NameHierarchy::deserialize(fileNode.serializedName).getQualifiedName());
|
||||
if (path2.exists())
|
||||
{
|
||||
path = path2;
|
||||
@@ -1343,9 +1340,9 @@ std::shared_ptr<SourceLocationFile> PersistentStorage::getCommentLocationsInFile
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::shared_ptr<SourceLocationFile> file = std::make_shared<SourceLocationFile>(filePath, false, false);
|
||||
const std::shared_ptr<SourceLocationFile> file = std::make_shared<SourceLocationFile>(filePath, false, false);
|
||||
|
||||
std::vector<StorageCommentLocation> storageLocations = m_sqliteIndexStorage.getCommentLocationsInFile(filePath);
|
||||
const std::vector<StorageCommentLocation> storageLocations = m_sqliteIndexStorage.getCommentLocationsInFile(filePath);
|
||||
for (size_t i = 0; i < storageLocations.size(); i++)
|
||||
{
|
||||
file->addSourceLocation(
|
||||
@@ -1378,8 +1375,7 @@ std::vector<FileInfo> PersistentStorage::getFileInfosForFilePaths(const std::vec
|
||||
{
|
||||
std::vector<FileInfo> fileInfos;
|
||||
|
||||
std::vector<StorageFile> storageFiles = m_sqliteIndexStorage.getFilesByPaths(filePaths);
|
||||
for (const StorageFile& file : storageFiles)
|
||||
for (const StorageFile& file : m_sqliteIndexStorage.getFilesByPaths(filePaths))
|
||||
{
|
||||
fileInfos.push_back(FileInfo(FilePath(file.filePath), file.modificationTime));
|
||||
}
|
||||
@@ -1692,7 +1688,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector<Id>&
|
||||
StorageNode node = m_sqliteIndexStorage.getFirstById<StorageNode>(tokenIds[0]);
|
||||
if (node.id == 0 && origin == TOOLTIP_ORIGIN_CODE)
|
||||
{
|
||||
StorageEdge edge = m_sqliteIndexStorage.getFirstById<StorageEdge>(tokenIds[0]);
|
||||
const StorageEdge edge = m_sqliteIndexStorage.getFirstById<StorageEdge>(tokenIds[0]);
|
||||
|
||||
if (edge.id > 0)
|
||||
{
|
||||
@@ -1705,11 +1701,11 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector<Id>&
|
||||
return info;
|
||||
}
|
||||
|
||||
NodeType type = utility::intToType(node.type);
|
||||
const NodeType type = utility::intToType(node.type);
|
||||
info.title = type.getReadableTypeString();
|
||||
|
||||
DefinitionKind defKind = DEFINITION_NONE;
|
||||
StorageSymbol symbol = m_sqliteIndexStorage.getFirstById<StorageSymbol>(node.id);
|
||||
const StorageSymbol symbol = m_sqliteIndexStorage.getFirstById<StorageSymbol>(node.id);
|
||||
if (symbol.id > 0)
|
||||
{
|
||||
defKind = intToDefinitionKind(symbol.definitionKind);
|
||||
@@ -1717,7 +1713,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector<Id>&
|
||||
|
||||
if (type.isPotentialMember())
|
||||
{
|
||||
StorageComponentAccess access = m_sqliteIndexStorage.getComponentAccessByNodeId(node.id);
|
||||
const StorageComponentAccess access = m_sqliteIndexStorage.getComponentAccessByNodeId(node.id);
|
||||
if (access.nodeId != 0)
|
||||
{
|
||||
info.title = accessKindToString(intToAccessKind(access.type)) + " " + info.title;
|
||||
@@ -1768,8 +1764,8 @@ TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& no
|
||||
{
|
||||
TRACE();
|
||||
|
||||
const NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
TooltipSnippet snippet;
|
||||
NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
snippet.code = nameHierarchy.getQualifiedNameWithSignature();
|
||||
snippet.locationFile = std::make_shared<SourceLocationFile>(
|
||||
FilePath(nameHierarchy.getDelimiter() == NAME_DELIMITER_JAVA ? "main.java" : "main.cpp"), true, true);
|
||||
@@ -2093,7 +2089,7 @@ std::set<Id> PersistentStorage::getReferencing(
|
||||
|
||||
std::set<FilePath> PersistentStorage::getReferencedByIncludes(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
std::set<Id> ids = getReferenced(getFileNodeIds(filePaths), getFileIdToIncludingFileIdMap());
|
||||
const std::set<Id> ids = getReferenced(getFileNodeIds(filePaths), getFileIdToIncludingFileIdMap());
|
||||
|
||||
std::set<FilePath> paths;
|
||||
for (Id id: ids)
|
||||
@@ -2106,7 +2102,7 @@ std::set<FilePath> PersistentStorage::getReferencedByIncludes(const std::set<Fil
|
||||
|
||||
std::set<FilePath> PersistentStorage::getReferencedByImports(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
std::set<Id> ids = getReferenced(getFileNodeIds(filePaths), getFileIdToImportingFileIdMap());
|
||||
const std::set<Id> ids = getReferenced(getFileNodeIds(filePaths), getFileIdToImportingFileIdMap());
|
||||
|
||||
std::set<FilePath> paths;
|
||||
for (Id id: ids)
|
||||
@@ -2119,7 +2115,7 @@ std::set<FilePath> PersistentStorage::getReferencedByImports(const std::set<File
|
||||
|
||||
std::set<FilePath> PersistentStorage::getReferencingByIncludes(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
std::set<Id> ids = getReferencing(getFileNodeIds(filePaths), getFileIdToIncludingFileIdMap());
|
||||
const std::set<Id> ids = getReferencing(getFileNodeIds(filePaths), getFileIdToIncludingFileIdMap());
|
||||
|
||||
std::set<FilePath> paths;
|
||||
for (Id id: ids)
|
||||
@@ -2132,7 +2128,7 @@ std::set<FilePath> PersistentStorage::getReferencingByIncludes(const std::set<Fi
|
||||
|
||||
std::set<FilePath> PersistentStorage::getReferencingByImports(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
std::set<Id> ids = getReferencing(getFileNodeIds(filePaths), getFileIdToImportingFileIdMap());
|
||||
const std::set<Id> ids = getReferencing(getFileNodeIds(filePaths), getFileIdToImportingFileIdMap());
|
||||
|
||||
std::set<FilePath> paths;
|
||||
for (Id id: ids)
|
||||
@@ -2316,7 +2312,7 @@ void PersistentStorage::addAggregationEdgesToGraph(
|
||||
// get all children of the active node
|
||||
std::set<Id> childNodeIdsSet, edgeIdsSet;
|
||||
m_hierarchyCache.addAllChildIdsForNodeId(nodeId, &childNodeIdsSet, &edgeIdsSet);
|
||||
std::vector<Id> childNodeIds = utility::toVector(childNodeIdsSet);
|
||||
const std::vector<Id> childNodeIds = utility::toVector(childNodeIdsSet);
|
||||
if (childNodeIds.size() == 0 && edgesToAggregate.size() == 0)
|
||||
{
|
||||
return;
|
||||
@@ -2333,7 +2329,7 @@ void PersistentStorage::addAggregationEdgesToGraph(
|
||||
connectedNodeIds[isSource ? edge.targetNodeId : edge.sourceNodeId].push_back(edgeInfo);
|
||||
}
|
||||
|
||||
std::vector<StorageEdge> outgoingEdges = m_sqliteIndexStorage.getEdgesBySourceIds(childNodeIds);
|
||||
const std::vector<StorageEdge> outgoingEdges = m_sqliteIndexStorage.getEdgesBySourceIds(childNodeIds);
|
||||
for (const StorageEdge& outEdge : outgoingEdges)
|
||||
{
|
||||
EdgeInfo edgeInfo;
|
||||
@@ -2342,7 +2338,7 @@ void PersistentStorage::addAggregationEdgesToGraph(
|
||||
connectedNodeIds[outEdge.targetNodeId].push_back(edgeInfo);
|
||||
}
|
||||
|
||||
std::vector<StorageEdge> incomingEdges = m_sqliteIndexStorage.getEdgesByTargetIds(childNodeIds);
|
||||
const std::vector<StorageEdge> incomingEdges = m_sqliteIndexStorage.getEdgesByTargetIds(childNodeIds);
|
||||
for (const StorageEdge& inEdge : incomingEdges)
|
||||
{
|
||||
EdgeInfo edgeInfo;
|
||||
@@ -2352,12 +2348,12 @@ void PersistentStorage::addAggregationEdgesToGraph(
|
||||
}
|
||||
|
||||
// get all parent nodes of all connected nodes (up to last level except namespace/undefined)
|
||||
Id nodeParentNodeId = m_hierarchyCache.getLastVisibleParentNodeId(nodeId);
|
||||
const Id nodeParentNodeId = m_hierarchyCache.getLastVisibleParentNodeId(nodeId);
|
||||
|
||||
std::map<Id, std::vector<EdgeInfo>> connectedParentNodeIds;
|
||||
for (const std::pair<Id, std::vector<EdgeInfo>>& p : connectedNodeIds)
|
||||
{
|
||||
Id parentNodeId = m_hierarchyCache.getLastVisibleParentNodeId(p.first);
|
||||
const Id parentNodeId = m_hierarchyCache.getLastVisibleParentNodeId(p.first);
|
||||
|
||||
if (parentNodeId != nodeParentNodeId)
|
||||
{
|
||||
@@ -2396,7 +2392,7 @@ void PersistentStorage::addAggregationEdgesToGraph(
|
||||
}
|
||||
|
||||
// Set first bit to 1 to avoid collisions
|
||||
Id aggregationId = ~(~Id(0) >> 1) + *componentAggregation->getAggregationIds().begin();
|
||||
const Id aggregationId = ~(~Id(0) >> 1) + *componentAggregation->getAggregationIds().begin();
|
||||
|
||||
Edge* edge = graph->createEdge(aggregationId, Edge::EDGE_AGGREGATION, sourceNode, targetNode);
|
||||
edge->addComponentAggregation(componentAggregation);
|
||||
@@ -2483,9 +2479,9 @@ void PersistentStorage::addInheritanceChainsToGraph(const std::vector<Id>& activ
|
||||
for (const std::tuple<Id, Id, std::vector<Id>>& edge :
|
||||
m_hierarchyCache.getInheritanceEdgesForNodeId(nodeId, *nodeIdSets[(i + 1) % 2]))
|
||||
{
|
||||
Id sourceId = std::get<0>(edge);
|
||||
Id targetId = std::get<1>(edge);
|
||||
std::vector<Id> edgeIds = std::get<2>(edge);
|
||||
const Id sourceId = std::get<0>(edge);
|
||||
const Id targetId = std::get<1>(edge);
|
||||
const std::vector<Id> edgeIds = std::get<2>(edge);
|
||||
|
||||
if (!edgeIds.size() || (edgeIds.size() == 1 && graph->getEdgeById(edgeIds[0])))
|
||||
{
|
||||
@@ -2493,7 +2489,7 @@ void PersistentStorage::addInheritanceChainsToGraph(const std::vector<Id>& activ
|
||||
}
|
||||
|
||||
// Set first 2 bits to 1 to avoid collisions
|
||||
Id inheritanceEdgeId = ~(~Id(0) >> 2) + inheritanceEdgeCount++;
|
||||
const Id inheritanceEdgeId = ~(~Id(0) >> 2) + inheritanceEdgeCount++;
|
||||
|
||||
Edge* inheritanceEdge = graph->createEdge(
|
||||
inheritanceEdgeId, Edge::EDGE_INHERITANCE, graph->getNodeById(sourceId), graph->getNodeById(targetId));
|
||||
@@ -2510,7 +2506,7 @@ void PersistentStorage::buildFilePathMaps()
|
||||
|
||||
for (StorageFile& file: m_sqliteIndexStorage.getAll<StorageFile>())
|
||||
{
|
||||
FilePath path = FilePath(file.filePath);
|
||||
const FilePath path(file.filePath);
|
||||
|
||||
m_fileNodeIds.emplace(path, file.id);
|
||||
m_fileNodePaths.emplace(file.id, path);
|
||||
@@ -2532,7 +2528,7 @@ void PersistentStorage::buildSearchIndex()
|
||||
{
|
||||
TRACE();
|
||||
|
||||
FilePath dbPath = getDbFilePath();
|
||||
const FilePath dbPath = getDbFilePath();
|
||||
|
||||
for (StorageNode& node : m_sqliteIndexStorage.getAll<StorageNode>())
|
||||
{
|
||||
@@ -2546,7 +2542,7 @@ void PersistentStorage::buildSearchIndex()
|
||||
|
||||
if (filePath.exists())
|
||||
{
|
||||
filePath = filePath.relativeTo(dbPath);
|
||||
filePath.makeRelativeTo(dbPath);
|
||||
}
|
||||
|
||||
m_fileIndex.addNode(node.id, filePath.str(), type);
|
||||
@@ -2555,10 +2551,10 @@ void PersistentStorage::buildSearchIndex()
|
||||
else
|
||||
{
|
||||
auto it = m_symbolDefinitionKinds.find(node.id);
|
||||
DefinitionKind defKind = (it != m_symbolDefinitionKinds.end() ? it->second : DEFINITION_NONE);
|
||||
const DefinitionKind defKind = (it != m_symbolDefinitionKinds.end() ? it->second : DEFINITION_NONE);
|
||||
if (defKind != DEFINITION_IMPLICIT)
|
||||
{
|
||||
NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
const NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
|
||||
// we don't use the signature here, so elements with the same signature share the same node.
|
||||
std::string name = nameHierarchy.getQualifiedName();
|
||||
@@ -2618,13 +2614,13 @@ void PersistentStorage::buildMemberEdgeIdOrderMap()
|
||||
SourceLocationCollection collection;
|
||||
for (const StorageSourceLocation& location: m_sqliteIndexStorage.getAllByIds<StorageSourceLocation>(locationIds))
|
||||
{
|
||||
LocationType locType = intToLocationType(location.type);
|
||||
const LocationType locType = intToLocationType(location.type);
|
||||
if (locType != LOCATION_TOKEN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
FilePath path(m_fileNodePaths[location.fileNodeId]);
|
||||
const FilePath path(m_fileNodePaths[location.fileNodeId]);
|
||||
if (path.extension() == ".java")
|
||||
{
|
||||
collection.addSourceLocation(
|
||||
@@ -2666,7 +2662,7 @@ void PersistentStorage::buildHierarchyCache()
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::vector<StorageEdge> memberEdges = m_sqliteIndexStorage.getEdgesByType(Edge::typeToInt(Edge::EDGE_MEMBER));
|
||||
const std::vector<StorageEdge> memberEdges = m_sqliteIndexStorage.getEdgesByType(Edge::typeToInt(Edge::EDGE_MEMBER));
|
||||
|
||||
std::vector<Id> sourceNodeIds;
|
||||
for (const StorageEdge& edge : memberEdges)
|
||||
@@ -2674,10 +2670,8 @@ void PersistentStorage::buildHierarchyCache()
|
||||
sourceNodeIds.push_back(edge.sourceNodeId);
|
||||
}
|
||||
|
||||
std::vector<StorageNode> sourceNodes = m_sqliteIndexStorage.getAllByIds<StorageNode>(sourceNodeIds);
|
||||
|
||||
std::map<Id, NodeType> sourceNodeTypeMap;
|
||||
for (const StorageNode& node : sourceNodes)
|
||||
for (const StorageNode& node : m_sqliteIndexStorage.getAllByIds<StorageNode>(sourceNodeIds))
|
||||
{
|
||||
sourceNodeTypeMap.emplace(node.id, utility::intToType(node.type));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
const size_t SqliteIndexStorage::s_storageVersion = 15;
|
||||
|
||||
SqliteIndexStorage::SqliteIndexStorage(const FilePath& dbFilePath)
|
||||
: SqliteStorage(dbFilePath.canonical())
|
||||
: SqliteStorage(dbFilePath.getCanonical())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "utility/TimeStamp.h"
|
||||
|
||||
SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
|
||||
: m_dbFilePath(dbFilePath.canonical())
|
||||
: m_dbFilePath(dbFilePath.getCanonical())
|
||||
{
|
||||
m_database.open(m_dbFilePath.str().c_str());
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ void ApplicationSettings::setShowBuiltinTypesInGraph(bool showBuiltinTypes)
|
||||
|
||||
FilePath ApplicationSettings::getColorSchemePath() const
|
||||
{
|
||||
FilePath defaultPath(ResourcePaths::getColorSchemesPath().concat(FilePath("bright.xml")));
|
||||
FilePath defaultPath(ResourcePaths::getColorSchemesPath().concatenate(FilePath("bright.xml")));
|
||||
FilePath path(getValue<std::string>("application/color_scheme", defaultPath.str()));
|
||||
|
||||
if (path != defaultPath && !path.exists())
|
||||
@@ -423,7 +423,7 @@ std::vector<FilePath> ApplicationSettings::getRecentProjects() const
|
||||
}
|
||||
else
|
||||
{
|
||||
recentProjects.push_back(UserPaths::getUserDataPath().concat(project));
|
||||
recentProjects.push_back(UserPaths::getUserDataPath().concatenate(project));
|
||||
}
|
||||
}
|
||||
return recentProjects;
|
||||
|
||||
@@ -126,7 +126,7 @@ std::string ProjectSettings::getProjectName() const
|
||||
|
||||
FilePath ProjectSettings::getProjectDirectoryPath() const
|
||||
{
|
||||
return getFilePath().parentDirectory();
|
||||
return getFilePath().getParentDirectory();
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getDescription() const
|
||||
@@ -204,7 +204,7 @@ std::vector<FilePath> ProjectSettings::makePathsExpandedAndAbsolute(const std::v
|
||||
std::vector<FilePath> p = expandPaths(paths);
|
||||
|
||||
std::vector<FilePath> absPaths;
|
||||
FilePath basePath = getProjectDirectoryPath();
|
||||
const FilePath basePath = getProjectDirectoryPath();
|
||||
for (const FilePath& path : p)
|
||||
{
|
||||
if (path.isAbsolute())
|
||||
@@ -213,7 +213,7 @@ std::vector<FilePath> ProjectSettings::makePathsExpandedAndAbsolute(const std::v
|
||||
}
|
||||
else
|
||||
{
|
||||
absPaths.push_back(basePath.concat(path).canonical());
|
||||
absPaths.push_back(basePath.getConcatenated(path).makeCanonical());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ FilePath ProjectSettings::makePathExpandedAndAbsolute(const FilePath& path) cons
|
||||
return p;
|
||||
}
|
||||
|
||||
return getProjectDirectoryPath().concat(p).canonical();
|
||||
return getProjectDirectoryPath().concatenate(p).makeCanonical();
|
||||
}
|
||||
|
||||
SettingsMigrator ProjectSettings::getMigrations() const
|
||||
|
||||
@@ -14,15 +14,15 @@ void UserPaths::setUserDataPath(const FilePath& path)
|
||||
|
||||
FilePath UserPaths::getAppSettingsPath()
|
||||
{
|
||||
return getUserDataPath().concat(FilePath("ApplicationSettings.xml"));
|
||||
return getUserDataPath().concatenate(FilePath("ApplicationSettings.xml"));
|
||||
}
|
||||
|
||||
FilePath UserPaths::getWindowSettingsPath()
|
||||
{
|
||||
return getUserDataPath().concat(FilePath("window_settings.ini"));
|
||||
return getUserDataPath().concatenate(FilePath("window_settings.ini"));
|
||||
}
|
||||
|
||||
FilePath UserPaths::getLogPath()
|
||||
{
|
||||
return getUserDataPath().concat(FilePath("log/"));
|
||||
return getUserDataPath().concatenate(FilePath("log/"));
|
||||
}
|
||||
|
||||
@@ -218,7 +218,8 @@ bool CommandLineParser::startedWithLicense()
|
||||
|
||||
void CommandLineParser::processProjectfile()
|
||||
{
|
||||
m_projectFile = m_projectFile.absolute();
|
||||
m_projectFile.makeAbsolute();
|
||||
|
||||
const std::string errorstring =
|
||||
"Provided Projectfile is not valid:\n* Provided Projectfile('" + m_projectFile.fileName() + "') ";
|
||||
if (!m_projectFile.exists())
|
||||
|
||||
@@ -63,7 +63,7 @@ std::set<FilePath> FileManager::getAllSourceFilePathsRelative(const FilePath& ba
|
||||
{
|
||||
if (baseDirectory.exists())
|
||||
{
|
||||
absolutePaths.insert(path.relativeTo(baseDirectory));
|
||||
absolutePaths.insert(path.getRelativeTo(baseDirectory));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -78,7 +78,7 @@ std::vector<FilePath> FileManager::makeCanonical(const std::vector<FilePath>& fi
|
||||
std::vector<FilePath> ret;
|
||||
for (const FilePath& filePath: filePaths)
|
||||
{
|
||||
ret.push_back(filePath.canonical());
|
||||
ret.push_back(filePath.getCanonical());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
#include <regex>
|
||||
|
||||
#include "boost/filesystem/path.hpp"
|
||||
#include "boost/filesystem.hpp"
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
FilePath::FilePath()
|
||||
: m_path("")
|
||||
: m_path(std::make_unique<boost::filesystem::path>(""))
|
||||
, m_exists(false)
|
||||
, m_checkedExists(false)
|
||||
, m_isDirectory(false)
|
||||
@@ -18,7 +19,7 @@ FilePath::FilePath()
|
||||
}
|
||||
|
||||
FilePath::FilePath(const char* filePath)
|
||||
: m_path(filePath)
|
||||
: m_path(std::make_unique<boost::filesystem::path>(filePath))
|
||||
, m_exists(false)
|
||||
, m_checkedExists(false)
|
||||
, m_isDirectory(false)
|
||||
@@ -28,7 +29,7 @@ FilePath::FilePath(const char* filePath)
|
||||
}
|
||||
|
||||
FilePath::FilePath(const std::string& filePath)
|
||||
: m_path(filePath)
|
||||
: m_path(std::make_unique<boost::filesystem::path>(filePath))
|
||||
, m_exists(false)
|
||||
, m_checkedExists(false)
|
||||
, m_isDirectory(false)
|
||||
@@ -38,7 +39,7 @@ FilePath::FilePath(const std::string& filePath)
|
||||
}
|
||||
|
||||
FilePath::FilePath(const boost::filesystem::path& filePath)
|
||||
: m_path(filePath)
|
||||
: m_path(std::make_unique<boost::filesystem::path>(filePath))
|
||||
, m_exists(false)
|
||||
, m_checkedExists(false)
|
||||
, m_isDirectory(false)
|
||||
@@ -47,8 +48,28 @@ FilePath::FilePath(const boost::filesystem::path& filePath)
|
||||
{
|
||||
}
|
||||
|
||||
FilePath::FilePath(const FilePath& other)
|
||||
: m_path(std::make_unique<boost::filesystem::path>(other.getPath()))
|
||||
, m_exists(other.m_exists)
|
||||
, m_checkedExists(other.m_checkedExists)
|
||||
, m_isDirectory(other.m_isDirectory)
|
||||
, m_checkedIsDirectory(other.m_checkedIsDirectory)
|
||||
, m_canonicalized(other.m_canonicalized)
|
||||
{
|
||||
}
|
||||
|
||||
FilePath::FilePath(FilePath&& other)
|
||||
: m_path(std::move(other.m_path))
|
||||
, m_exists(other.m_exists)
|
||||
, m_checkedExists(other.m_checkedExists)
|
||||
, m_isDirectory(other.m_isDirectory)
|
||||
, m_checkedIsDirectory(other.m_checkedIsDirectory)
|
||||
, m_canonicalized(other.m_canonicalized)
|
||||
{
|
||||
}
|
||||
|
||||
FilePath::FilePath(const std::string& filePath, const std::string& base)
|
||||
: m_path(boost::filesystem::absolute(filePath, base))
|
||||
: m_path(std::make_unique<boost::filesystem::path>(boost::filesystem::absolute(filePath, base)))
|
||||
, m_exists(false)
|
||||
, m_checkedExists(false)
|
||||
, m_isDirectory(false)
|
||||
@@ -57,21 +78,25 @@ FilePath::FilePath(const std::string& filePath, const std::string& base)
|
||||
{
|
||||
}
|
||||
|
||||
boost::filesystem::path FilePath::path() const
|
||||
FilePath::~FilePath()
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
boost::filesystem::path FilePath::getPath() const
|
||||
{
|
||||
return boost::filesystem::path(*(m_path.get()));
|
||||
}
|
||||
|
||||
bool FilePath::empty() const
|
||||
{
|
||||
return m_path.empty();
|
||||
return m_path->empty();
|
||||
}
|
||||
|
||||
bool FilePath::exists() const
|
||||
{
|
||||
if (!m_checkedExists)
|
||||
{
|
||||
m_exists = boost::filesystem::exists(m_path);
|
||||
m_exists = boost::filesystem::exists(getPath());
|
||||
m_checkedExists = true;
|
||||
}
|
||||
|
||||
@@ -88,7 +113,7 @@ bool FilePath::isDirectory() const
|
||||
{
|
||||
if (!m_checkedIsDirectory)
|
||||
{
|
||||
m_isDirectory = boost::filesystem::is_directory(m_path);
|
||||
m_isDirectory = boost::filesystem::is_directory(getPath());
|
||||
m_checkedIsDirectory = true;
|
||||
}
|
||||
|
||||
@@ -97,12 +122,12 @@ bool FilePath::isDirectory() const
|
||||
|
||||
bool FilePath::isAbsolute() const
|
||||
{
|
||||
return m_path.is_absolute();
|
||||
return m_path->is_absolute();
|
||||
}
|
||||
|
||||
FilePath FilePath::parentDirectory() const
|
||||
FilePath FilePath::getParentDirectory() const
|
||||
{
|
||||
FilePath parentDirectory(m_path.parent_path());
|
||||
FilePath parentDirectory(m_path->parent_path());
|
||||
parentDirectory.m_checkedIsDirectory = true;
|
||||
parentDirectory.m_isDirectory = true;
|
||||
|
||||
@@ -111,25 +136,34 @@ FilePath FilePath::parentDirectory() const
|
||||
parentDirectory.m_checkedExists = true;
|
||||
parentDirectory.m_exists = true;
|
||||
}
|
||||
|
||||
return parentDirectory;
|
||||
}
|
||||
|
||||
FilePath FilePath::absolute() const
|
||||
FilePath& FilePath::makeAbsolute()
|
||||
{
|
||||
return FilePath(boost::filesystem::absolute(m_path));
|
||||
m_path = std::make_unique<boost::filesystem::path>(boost::filesystem::absolute(getPath()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
FilePath FilePath::canonical() const
|
||||
FilePath FilePath::getAbsolute() const
|
||||
{
|
||||
FilePath path(*this);
|
||||
path.makeAbsolute();
|
||||
return path;
|
||||
}
|
||||
|
||||
FilePath& FilePath::makeCanonical()
|
||||
{
|
||||
if (m_canonicalized || !exists())
|
||||
{
|
||||
return FilePath(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
boost::filesystem::path canonicalPath;
|
||||
|
||||
#if defined(_WIN32)
|
||||
boost::filesystem::path abs_p = boost::filesystem::absolute(m_path);
|
||||
boost::filesystem::path abs_p = boost::filesystem::absolute(getPath());
|
||||
for (boost::filesystem::path::iterator it = abs_p.begin(); it != abs_p.end(); ++it)
|
||||
{
|
||||
if (*it == "..")
|
||||
@@ -158,12 +192,18 @@ FilePath FilePath::canonical() const
|
||||
}
|
||||
}
|
||||
#else
|
||||
canonicalPath = boost::filesystem::canonical(m_path);
|
||||
canonicalPath = boost::filesystem::canonical(getPath());
|
||||
#endif
|
||||
m_path = std::make_unique<boost::filesystem::path>(canonicalPath);
|
||||
m_canonicalized = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FilePath ret(canonicalPath);
|
||||
ret.m_canonicalized = true;
|
||||
return ret;
|
||||
FilePath FilePath::getCanonical() const
|
||||
{
|
||||
FilePath path(*this);
|
||||
path.makeCanonical();
|
||||
return path;
|
||||
}
|
||||
|
||||
std::vector<FilePath> FilePath::expandEnvironmentVariables() const
|
||||
@@ -201,10 +241,10 @@ std::vector<FilePath> FilePath::expandEnvironmentVariables() const
|
||||
return paths;
|
||||
}
|
||||
|
||||
FilePath FilePath::relativeTo(const FilePath& other) const
|
||||
FilePath& FilePath::makeRelativeTo(const FilePath& other)
|
||||
{
|
||||
boost::filesystem::path a = this->canonical().m_path;
|
||||
boost::filesystem::path b = other.canonical().m_path;
|
||||
const boost::filesystem::path a = this->getCanonical().getPath();
|
||||
const boost::filesystem::path b = other.getCanonical().getPath();
|
||||
|
||||
if (a.root_path() != b.root_path())
|
||||
{
|
||||
@@ -245,12 +285,35 @@ FilePath FilePath::relativeTo(const FilePath& other) const
|
||||
r = "./";
|
||||
}
|
||||
|
||||
return FilePath(r);
|
||||
m_path = std::make_unique<boost::filesystem::path>(r);
|
||||
return *this;
|
||||
}
|
||||
|
||||
FilePath FilePath::concat(const FilePath& other) const
|
||||
|
||||
FilePath FilePath::getRelativeTo(const FilePath& other) const
|
||||
{
|
||||
return FilePath(boost::filesystem::path(m_path) / other.m_path);
|
||||
FilePath path(*this);
|
||||
path.makeRelativeTo(other);
|
||||
return path;
|
||||
}
|
||||
|
||||
FilePath& FilePath::concatenate(const FilePath& other)
|
||||
{
|
||||
m_path->operator/=(other.getPath());
|
||||
m_exists = false;
|
||||
m_checkedExists = false;
|
||||
m_isDirectory = false;
|
||||
m_checkedIsDirectory = false;
|
||||
m_canonicalized = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
FilePath FilePath::getConcatenated(const FilePath& other) const
|
||||
{
|
||||
FilePath path(*this);
|
||||
path.concatenate(other);
|
||||
return path;
|
||||
}
|
||||
|
||||
bool FilePath::contains(const FilePath& other) const
|
||||
@@ -260,8 +323,8 @@ bool FilePath::contains(const FilePath& other) const
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::filesystem::path dir = m_path;
|
||||
const boost::filesystem::path& dir2 = other.m_path;
|
||||
boost::filesystem::path dir = getPath();
|
||||
const std::unique_ptr<boost::filesystem::path>& dir2 = other.m_path;
|
||||
|
||||
if (dir.filename() == ".")
|
||||
{
|
||||
@@ -269,11 +332,11 @@ bool FilePath::contains(const FilePath& other) const
|
||||
}
|
||||
|
||||
auto it = dir.begin();
|
||||
auto it2 = dir2.begin();
|
||||
auto it2 = dir2->begin();
|
||||
|
||||
while (it != dir.end())
|
||||
{
|
||||
if (it2 == dir2.end())
|
||||
if (it2 == dir2->end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -292,7 +355,7 @@ bool FilePath::contains(const FilePath& other) const
|
||||
|
||||
std::string FilePath::str() const
|
||||
{
|
||||
return m_path.generic_string();
|
||||
return m_path->generic_string();
|
||||
}
|
||||
|
||||
std::string FilePath::getBackslashedString() const
|
||||
@@ -302,22 +365,22 @@ std::string FilePath::getBackslashedString() const
|
||||
|
||||
std::string FilePath::fileName() const
|
||||
{
|
||||
return m_path.filename().generic_string();
|
||||
return m_path->filename().generic_string();
|
||||
}
|
||||
|
||||
std::string FilePath::extension() const
|
||||
{
|
||||
return m_path.extension().generic_string();
|
||||
return m_path->extension().generic_string();
|
||||
}
|
||||
|
||||
FilePath FilePath::withoutExtension() const
|
||||
{
|
||||
return FilePath(boost::filesystem::path(m_path).replace_extension());
|
||||
return FilePath(getPath().replace_extension());
|
||||
}
|
||||
|
||||
FilePath FilePath::replaceExtension(const std::string& extension) const
|
||||
{
|
||||
return FilePath(boost::filesystem::path(m_path).replace_extension(extension));
|
||||
return FilePath(getPath().replace_extension(extension));
|
||||
}
|
||||
|
||||
bool FilePath::hasExtension(const std::vector<std::string>& extensions) const
|
||||
@@ -333,14 +396,36 @@ bool FilePath::hasExtension(const std::vector<std::string>& extensions) const
|
||||
return false;
|
||||
}
|
||||
|
||||
FilePath& FilePath::operator=(const FilePath& other)
|
||||
{
|
||||
m_path = std::make_unique<boost::filesystem::path>(other.getPath());
|
||||
m_exists = other.m_exists;
|
||||
m_checkedExists = other.m_checkedExists;
|
||||
m_isDirectory = other.m_isDirectory;
|
||||
m_checkedIsDirectory = other.m_checkedIsDirectory;
|
||||
m_canonicalized = other.m_canonicalized;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FilePath& FilePath::operator=(FilePath&& other)
|
||||
{
|
||||
m_path = std::move(other.m_path);
|
||||
m_exists = other.m_exists;
|
||||
m_checkedExists = other.m_checkedExists;
|
||||
m_isDirectory = other.m_isDirectory;
|
||||
m_checkedIsDirectory = other.m_checkedIsDirectory;
|
||||
m_canonicalized = other.m_canonicalized;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool FilePath::operator==(const FilePath& other) const
|
||||
{
|
||||
if (exists() && other.exists())
|
||||
{
|
||||
return boost::filesystem::equivalent(m_path, other.m_path);
|
||||
return boost::filesystem::equivalent(getPath(), other.getPath());
|
||||
}
|
||||
|
||||
return m_path.compare(other.m_path) == 0;
|
||||
return m_path->compare(other.getPath()) == 0;
|
||||
}
|
||||
|
||||
bool FilePath::operator!=(const FilePath& other) const
|
||||
@@ -350,5 +435,5 @@ bool FilePath::operator!=(const FilePath& other) const
|
||||
|
||||
bool FilePath::operator<(const FilePath& other) const
|
||||
{
|
||||
return m_path.compare(other.m_path) < 0;
|
||||
return m_path->compare(other.getPath()) < 0;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,15 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "boost/filesystem/path.hpp"
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
class path;
|
||||
}
|
||||
}
|
||||
|
||||
class FilePath
|
||||
{
|
||||
@@ -13,9 +20,12 @@ public:
|
||||
explicit FilePath(const char* filePath);
|
||||
explicit FilePath(const std::string& filePath);
|
||||
explicit FilePath(const boost::filesystem::path& filePath);
|
||||
FilePath(const FilePath& filePath);
|
||||
FilePath(FilePath&& other);
|
||||
FilePath(const std::string& filePath, const std::string& base);
|
||||
~FilePath();
|
||||
|
||||
boost::filesystem::path path() const;
|
||||
boost::filesystem::path getPath() const;
|
||||
|
||||
bool empty() const;
|
||||
bool exists() const;
|
||||
@@ -23,12 +33,16 @@ public:
|
||||
bool isDirectory() const;
|
||||
bool isAbsolute() const;
|
||||
|
||||
FilePath parentDirectory() const;
|
||||
FilePath getParentDirectory() const;
|
||||
|
||||
FilePath absolute() const;
|
||||
FilePath canonical() const;
|
||||
FilePath relativeTo(const FilePath& other) const;
|
||||
FilePath concat(const FilePath& other) const;
|
||||
FilePath& makeAbsolute();
|
||||
FilePath getAbsolute() const;
|
||||
FilePath& makeCanonical();
|
||||
FilePath getCanonical() const;
|
||||
FilePath& makeRelativeTo(const FilePath& other);
|
||||
FilePath getRelativeTo(const FilePath& other) const;
|
||||
FilePath& concatenate(const FilePath& other);
|
||||
FilePath getConcatenated(const FilePath& other) const;
|
||||
std::vector<FilePath> expandEnvironmentVariables() const;
|
||||
|
||||
bool contains(const FilePath& other) const;
|
||||
@@ -42,12 +56,14 @@ public:
|
||||
FilePath replaceExtension(const std::string& extension) const;
|
||||
bool hasExtension(const std::vector<std::string>& extensions) const;
|
||||
|
||||
FilePath& operator=(const FilePath& other);
|
||||
FilePath& operator=(FilePath&& other);
|
||||
bool operator==(const FilePath& other) const;
|
||||
bool operator!=(const FilePath& other) const;
|
||||
bool operator<(const FilePath& other) const;
|
||||
|
||||
private:
|
||||
boost::filesystem::path m_path;
|
||||
std::unique_ptr<boost::filesystem::path> m_path;
|
||||
|
||||
mutable bool m_exists;
|
||||
mutable bool m_checkedExists;
|
||||
|
||||
@@ -13,9 +13,9 @@ std::vector<FilePath> FileSystem::getFilePathsFromDirectory(
|
||||
std::set<std::string> ext(extensions.begin(), extensions.end());
|
||||
std::vector<FilePath> files;
|
||||
|
||||
if (boost::filesystem::is_directory(path.path()))
|
||||
if (path.isDirectory())
|
||||
{
|
||||
boost::filesystem::recursive_directory_iterator it(path.path());
|
||||
boost::filesystem::recursive_directory_iterator it(path.getPath());
|
||||
boost::filesystem::recursive_directory_iterator endit;
|
||||
while (it != endit)
|
||||
{
|
||||
@@ -44,9 +44,7 @@ FileInfo FileSystem::getFileInfoForPath(const FilePath& filePath)
|
||||
{
|
||||
if (filePath.exists())
|
||||
{
|
||||
std::time_t t = boost::filesystem::last_write_time(filePath.path());
|
||||
boost::posix_time::ptime lastWriteTime = boost::posix_time::from_time_t(t);
|
||||
return FileInfo(filePath, lastWriteTime);
|
||||
return FileInfo(filePath, getLastWriteTime(filePath));
|
||||
}
|
||||
return FileInfo();
|
||||
}
|
||||
@@ -69,7 +67,7 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
|
||||
{
|
||||
if (path.isDirectory())
|
||||
{
|
||||
boost::filesystem::recursive_directory_iterator it(path.path(), boost::filesystem::symlink_option::recurse);
|
||||
boost::filesystem::recursive_directory_iterator it(path.getPath(), boost::filesystem::symlink_option::recurse);
|
||||
boost::filesystem::recursive_directory_iterator endit;
|
||||
boost::system::error_code ec;
|
||||
for ( ; it != endit ; it.increment(ec) )
|
||||
@@ -113,25 +111,20 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
|
||||
continue;
|
||||
}
|
||||
filePaths.insert(p);
|
||||
|
||||
std::time_t t = boost::filesystem::last_write_time(*it);
|
||||
boost::posix_time::ptime lastWriteTime = boost::posix_time::from_time_t(t);
|
||||
files.push_back(FileInfo(FilePath(it->path()), lastWriteTime));
|
||||
files.push_back(getFileInfoForPath(FilePath(it->path())));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (path.exists() && (!ext.size() || ext.find(utility::toLowerCase(path.extension())) != ext.end()))
|
||||
{
|
||||
boost::filesystem::path p = boost::filesystem::canonical(path.path());
|
||||
const FilePath canonicalPath = path.getCanonical();
|
||||
boost::filesystem::path p = canonicalPath.getPath();
|
||||
if (filePaths.find(p) != filePaths.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
filePaths.insert(p);
|
||||
|
||||
std::time_t t = boost::filesystem::last_write_time(path.path());
|
||||
boost::posix_time::ptime lastWriteTime = boost::posix_time::from_time_t(t);
|
||||
files.push_back(FileInfo(path, lastWriteTime));
|
||||
files.push_back(getFileInfoForPath(canonicalPath));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +140,7 @@ std::set<FilePath> FileSystem::getSymLinkedDirectories(const std::vector<FilePat
|
||||
{
|
||||
if (path.isDirectory())
|
||||
{
|
||||
boost::filesystem::recursive_directory_iterator it(path.path(), boost::filesystem::symlink_option::recurse);
|
||||
boost::filesystem::recursive_directory_iterator it(path.getPath(), boost::filesystem::symlink_option::recurse);
|
||||
boost::filesystem::recursive_directory_iterator endit;
|
||||
boost::system::error_code ec;
|
||||
for ( ; it != endit ; it.increment(ec) )
|
||||
@@ -189,7 +182,7 @@ std::set<FilePath> FileSystem::getSymLinkedDirectories(const std::vector<FilePat
|
||||
|
||||
unsigned long long FileSystem::getFileByteSize(const FilePath& filePath)
|
||||
{
|
||||
return boost::filesystem::file_size(filePath.path());
|
||||
return boost::filesystem::file_size(filePath.getPath());
|
||||
}
|
||||
|
||||
TimeStamp FileSystem::getLastWriteTime(const FilePath& filePath)
|
||||
@@ -197,7 +190,7 @@ TimeStamp FileSystem::getLastWriteTime(const FilePath& filePath)
|
||||
boost::posix_time::ptime lastWriteTime;
|
||||
if (filePath.exists())
|
||||
{
|
||||
std::time_t t = boost::filesystem::last_write_time(filePath.path());
|
||||
std::time_t t = boost::filesystem::last_write_time(filePath.getPath());
|
||||
lastWriteTime = boost::posix_time::from_time_t(t);
|
||||
}
|
||||
return TimeStamp(lastWriteTime);
|
||||
@@ -208,14 +201,9 @@ std::string FileSystem::getTimeStringNow() // TODO: move to utility
|
||||
return boost::posix_time::to_iso_string(boost::posix_time::second_clock::universal_time());
|
||||
}
|
||||
|
||||
bool FileSystem::exists(const FilePath& path)
|
||||
{
|
||||
return boost::filesystem::exists(path.path());
|
||||
}
|
||||
|
||||
bool FileSystem::remove(const FilePath& path)
|
||||
{
|
||||
return boost::filesystem::remove(path.path());
|
||||
return boost::filesystem::remove(path.getPath());
|
||||
}
|
||||
|
||||
bool FileSystem::rename(const FilePath& from, const FilePath& to)
|
||||
@@ -225,7 +213,7 @@ bool FileSystem::rename(const FilePath& from, const FilePath& to)
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::filesystem::rename(from.path(), to.path());
|
||||
boost::filesystem::rename(from.getPath(), to.getPath());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -236,7 +224,7 @@ bool FileSystem::copyFile(const FilePath& from, const FilePath& to)
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::filesystem::copy_file(boost::filesystem::path(from.path()), boost::filesystem::path(to.path()));
|
||||
boost::filesystem::copy_file(from.getPath(), to.getPath());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -247,7 +235,7 @@ bool FileSystem::copy_directory(const FilePath& from, const FilePath& to)
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::filesystem::copy_directory(boost::filesystem::path(from.path()),boost::filesystem::path(to.path()));
|
||||
boost::filesystem::copy_directory(from.getPath(), to.getPath());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -274,7 +262,6 @@ std::vector<FilePath> FileSystem::getDirectSubDirectories(const FilePath& path)
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
std::vector<FilePath> FileSystem::getRecursiveSubDirectories(const FilePath &path)
|
||||
{
|
||||
std::vector<FilePath> v;
|
||||
|
||||
@@ -26,7 +26,6 @@ public:
|
||||
static TimeStamp getLastWriteTime(const FilePath& filePath);
|
||||
static std::string getTimeStringNow();
|
||||
|
||||
static bool exists(const FilePath& path);
|
||||
static bool remove(const FilePath& path);
|
||||
static bool rename(const FilePath& from, const FilePath& to);
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ std::vector<FilePath> IndexerCommandCxxCdb::getSourceFilesFromCDB(const FilePath
|
||||
{
|
||||
for (const clang::tooling::CompileCommand& command : cdb->getAllCompileCommands())
|
||||
{
|
||||
FilePath path = FilePath(command.Filename).canonical();
|
||||
FilePath path = FilePath(command.Filename).makeCanonical();
|
||||
if (!path.isAbsolute())
|
||||
{
|
||||
path = FilePath(command.Directory + '/' + command.Filename).canonical();
|
||||
path = FilePath(command.Directory + '/' + command.Filename).makeCanonical();
|
||||
}
|
||||
filePaths.push_back(path);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ FilePath CanonicalFilePathCache::getCanonicalFilePath(const std::string& path)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
const FilePath canonicalPath = FilePath(path).canonical();
|
||||
const FilePath canonicalPath = FilePath(path).makeCanonical();
|
||||
const std::string lowercaseCanonicalPath = utility::toLowerCase(canonicalPath.str());
|
||||
|
||||
m_map.insert(std::make_pair(lowercasePath, canonicalPath));
|
||||
|
||||
@@ -650,7 +650,7 @@ ParseLocation CxxAstVisitor::getParseLocation(const clang::SourceLocation& sourc
|
||||
ParseLocation parseLocation;
|
||||
if (sourceLocation.isValid())
|
||||
{
|
||||
clang::SourceManager& sourceManager = m_astContext->getSourceManager();
|
||||
const clang::SourceManager& sourceManager = m_astContext->getSourceManager();
|
||||
|
||||
clang::SourceLocation loc = sourceLocation;
|
||||
if (sourceManager.isMacroBodyExpansion(sourceLocation))
|
||||
@@ -662,8 +662,8 @@ ParseLocation CxxAstVisitor::getParseLocation(const clang::SourceLocation& sourc
|
||||
}
|
||||
}
|
||||
|
||||
clang::SourceLocation startLoc = sourceManager.getSpellingLoc(loc);
|
||||
clang::FileID fileId = sourceManager.getFileID(startLoc);
|
||||
const clang::SourceLocation startLoc = sourceManager.getSpellingLoc(loc);
|
||||
const clang::FileID fileId = sourceManager.getFileID(startLoc);
|
||||
|
||||
// find the location file
|
||||
if (!fileId.isInvalid())
|
||||
@@ -677,15 +677,15 @@ ParseLocation CxxAstVisitor::getParseLocation(const clang::SourceLocation& sourc
|
||||
|
||||
// find the start location
|
||||
{
|
||||
unsigned int offset = sourceManager.getFileOffset(startLoc);
|
||||
const unsigned int offset = sourceManager.getFileOffset(startLoc);
|
||||
parseLocation.startLineNumber = sourceManager.getLineNumber(fileId, offset);
|
||||
parseLocation.startColumnNumber = sourceManager.getColumnNumber(fileId, offset);
|
||||
}
|
||||
|
||||
// General case -- find the end of the token starting at loc.
|
||||
{
|
||||
clang::SourceLocation endSloc = m_preprocessor->getLocForEndOfToken(startLoc);
|
||||
unsigned int offset = sourceManager.getFileOffset(endSloc);
|
||||
const clang::SourceLocation endSloc = m_preprocessor->getLocForEndOfToken(startLoc);
|
||||
const unsigned int offset = sourceManager.getFileOffset(endSloc);
|
||||
parseLocation.endLineNumber = sourceManager.getLineNumber(fileId, offset);
|
||||
parseLocation.endColumnNumber = sourceManager.getColumnNumber(fileId, offset) - 1;
|
||||
}
|
||||
|
||||
@@ -886,7 +886,7 @@ bool CxxAstVisitorComponentIndexer::isLocatedInProjectFile(clang::SourceLocation
|
||||
fileId = sourceManager.getFileID(loc);
|
||||
}
|
||||
|
||||
if (!fileId.isInvalid())
|
||||
if (fileId.isValid())
|
||||
{
|
||||
auto it = m_inProjectFileMap.find(fileId);
|
||||
if (it != m_inProjectFileMap.end())
|
||||
@@ -898,7 +898,7 @@ bool CxxAstVisitorComponentIndexer::isLocatedInProjectFile(clang::SourceLocation
|
||||
if (fileEntry != nullptr && fileEntry->isValid())
|
||||
{
|
||||
FilePath filePath = getAstVisitor()->getCanonicalFilePathCache()->getCanonicalFilePath(fileEntry);
|
||||
bool ret = m_fileRegister->hasFilePath(filePath);
|
||||
const bool ret = m_fileRegister->hasFilePath(filePath);
|
||||
m_inProjectFileMap[fileId] = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -44,11 +44,11 @@ void PreprocessorCallbacks::FileChanged(
|
||||
|
||||
if (!m_fileRegister->fileIsIndexed(filePath))
|
||||
{
|
||||
m_currentPath = filePath;
|
||||
m_currentPath = std::move(filePath);
|
||||
|
||||
if (reason == EnterFile)
|
||||
{
|
||||
m_fileRegister->markFileIndexing(filePath);
|
||||
m_fileRegister->markFileIndexing(m_currentPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ std::string utility::getFileNameOfFileEntry(const clang::FileEntry* entry)
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = FilePath(entry->getName().str()).parentDirectory().concat(FilePath(FilePath(fileName).fileName())).str();
|
||||
fileName = FilePath(entry->getName().str()).getParentDirectory().concatenate(FilePath(FilePath(fileName).fileName())).str();
|
||||
}
|
||||
}
|
||||
return fileName;
|
||||
|
||||
@@ -58,7 +58,7 @@ std::vector<IncludeDirective> IncludeValidation::getUnresolvedIncludeDirectives(
|
||||
for (const IncludeDirective& includeDirective: getIncludeDirectives(filePath))
|
||||
{
|
||||
const FilePath resolvedIncludePath =
|
||||
resolveIncludeDirective(includeDirective, headerSearchDirectories).canonical();
|
||||
resolveIncludeDirective(includeDirective, headerSearchDirectories).makeCanonical();
|
||||
if (resolvedIncludePath.empty())
|
||||
{
|
||||
unresolvedIncludeDirectives.insert(includeDirective);
|
||||
@@ -142,7 +142,7 @@ FilePath IncludeValidation::resolveIncludeDirective(const IncludeDirective& incl
|
||||
|
||||
{
|
||||
// check for an include path relative to the including path
|
||||
FilePath resolvedIncludePath = includeDirective.getIncludingFile().parentDirectory().concat(includeDirective.getIncludedFile());
|
||||
const FilePath resolvedIncludePath = includeDirective.getIncludingFile().getParentDirectory().concatenate(includeDirective.getIncludedFile());
|
||||
if (resolvedIncludePath.exists())
|
||||
{
|
||||
return resolvedIncludePath;
|
||||
@@ -153,7 +153,7 @@ FilePath IncludeValidation::resolveIncludeDirective(const IncludeDirective& incl
|
||||
// check for an include path relative to the header search directories
|
||||
for (const FilePath& headerSearchDirectory: headerSearchDirectories)
|
||||
{
|
||||
FilePath resolvedIncludePath = headerSearchDirectory.concat(includeDirective.getIncludedFile());
|
||||
const FilePath resolvedIncludePath = headerSearchDirectory.getConcatenated(includeDirective.getIncludedFile());
|
||||
if (resolvedIncludePath.exists())
|
||||
{
|
||||
return resolvedIncludePath;
|
||||
|
||||
@@ -99,10 +99,10 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
|
||||
|
||||
for (const clang::tooling::CompileCommand& command: cdb->getAllCompileCommands())
|
||||
{
|
||||
FilePath sourcePath = FilePath(command.Filename).canonical();
|
||||
FilePath sourcePath = FilePath(command.Filename).makeCanonical();
|
||||
if (!sourcePath.isAbsolute())
|
||||
{
|
||||
sourcePath = FilePath(command.Directory + '/' + command.Filename).canonical();
|
||||
sourcePath = FilePath(command.Directory + '/' + command.Filename).makeCanonical();
|
||||
}
|
||||
|
||||
if (filesToIndex.find(sourcePath) != filesToIndex.end() &&
|
||||
|
||||
@@ -65,19 +65,19 @@ void utility::CompilationDatabase::init()
|
||||
|
||||
if (utility::isPrefix(frameworkIncludeFlag, argument))
|
||||
{
|
||||
frameworkHeaders.insert(FilePath(utility::trim(argument.substr(frameworkIncludeFlag.size())), command.Directory).canonical());
|
||||
frameworkHeaders.insert(FilePath(utility::trim(argument.substr(frameworkIncludeFlag.size())), command.Directory).makeCanonical());
|
||||
}
|
||||
else if (utility::isPrefix(systemIncludeFlag, argument))
|
||||
{
|
||||
systemHeaders.insert(FilePath(utility::trim(argument.substr(systemIncludeFlag.size())), command.Directory).canonical());
|
||||
systemHeaders.insert(FilePath(utility::trim(argument.substr(systemIncludeFlag.size())), command.Directory).makeCanonical());
|
||||
}
|
||||
else if (utility::isPrefix(quoteFlag, argument))
|
||||
{
|
||||
headers.insert(FilePath(utility::trim(argument.substr(quoteFlag.size())), command.Directory).canonical());
|
||||
headers.insert(FilePath(utility::trim(argument.substr(quoteFlag.size())), command.Directory).makeCanonical());
|
||||
}
|
||||
else if (utility::isPrefix(includeFlag, argument))
|
||||
{
|
||||
headers.insert(FilePath(utility::trim(argument.substr(includeFlag.size())), command.Directory).canonical());
|
||||
headers.insert(FilePath(utility::trim(argument.substr(includeFlag.size())), command.Directory).makeCanonical());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,28 +40,28 @@ void setupApp(int argc, char *argv[])
|
||||
|
||||
// This "copyFile" method does nothing if the copy destination already exist
|
||||
|
||||
#ifdef DEPLOY
|
||||
#ifdef DEPLOY
|
||||
// try to find files in Coati installation to migrate to Sourcetrail
|
||||
FilePath coatiUserDataPath = UserPaths::getUserDataPath().concat(FilePath("../"));
|
||||
FilePath coatiUserDataPath = UserPaths::getUserDataPath().concatenate(FilePath("../"));
|
||||
if (utility::getApplicationArchitectureType() == APPLICATION_ARCHITECTURE_X86_64)
|
||||
{
|
||||
coatiUserDataPath = coatiUserDataPath.concat(FilePath("Coati 64-bit"));
|
||||
coatiUserDataPath = coatiUserDataPath.concatenate(FilePath("Coati 64-bit"));
|
||||
}
|
||||
else
|
||||
{
|
||||
coatiUserDataPath = coatiUserDataPath.concat(FilePath("Coati"));
|
||||
coatiUserDataPath = coatiUserDataPath.concatenate(FilePath("Coati"));
|
||||
}
|
||||
|
||||
if (coatiUserDataPath.exists())
|
||||
{
|
||||
FileSystem::copyFile(coatiUserDataPath.concat(FilePath("ApplicationSettings.xml")), UserPaths::getAppSettingsPath());
|
||||
FileSystem::copyFile(coatiUserDataPath.concat(FilePath("window_settings.ini")), UserPaths::getWindowSettingsPath());
|
||||
FileSystem::copyFile(coatiUserDataPath.concatenate(FilePath("ApplicationSettings.xml")), UserPaths::getAppSettingsPath());
|
||||
FileSystem::copyFile(coatiUserDataPath.concatenate(FilePath("window_settings.ini")), UserPaths::getWindowSettingsPath());
|
||||
}
|
||||
#endif
|
||||
|
||||
// use files in fallback folder if Coati has not been installed and used before
|
||||
FileSystem::copyFile(ResourcePaths::getFallbackPath().concat(FilePath("ApplicationSettings.xml")), UserPaths::getAppSettingsPath());
|
||||
FileSystem::copyFile(ResourcePaths::getFallbackPath().concat(FilePath("window_settings.ini")), UserPaths::getWindowSettingsPath());
|
||||
FileSystem::copyFile(ResourcePaths::getFallbackPath().concatenate(FilePath("ApplicationSettings.xml")), UserPaths::getAppSettingsPath());
|
||||
FileSystem::copyFile(ResourcePaths::getFallbackPath().concatenate(FilePath("window_settings.ini")), UserPaths::getWindowSettingsPath());
|
||||
}
|
||||
|
||||
#endif // INCLUDES_WINDOWS_H
|
||||
|
||||
@@ -58,8 +58,8 @@ void QtListItemWidget::setText(QString text)
|
||||
FilePath relativeRoot = m_list->getRelativeRootDirectory();
|
||||
if (!relativeRoot.empty())
|
||||
{
|
||||
FilePath path(text.toStdString());
|
||||
FilePath relPath(path.relativeTo(relativeRoot));
|
||||
const FilePath path(text.toStdString());
|
||||
const FilePath relPath = path.getRelativeTo(relativeRoot);
|
||||
if (relPath.str().size() < path.str().size())
|
||||
{
|
||||
text = QString::fromStdString(relPath.str());
|
||||
@@ -77,10 +77,10 @@ void QtListItemWidget::setFocus()
|
||||
void QtListItemWidget::handleButtonPress()
|
||||
{
|
||||
FilePath path(m_data->text().toStdString());
|
||||
FilePath relativeRoot = m_list->getRelativeRootDirectory();
|
||||
const FilePath relativeRoot = m_list->getRelativeRootDirectory();
|
||||
if (!path.empty() && !path.isAbsolute() && !relativeRoot.empty())
|
||||
{
|
||||
path = relativeRoot.concat(path);
|
||||
path = relativeRoot.getConcatenated(path);
|
||||
}
|
||||
|
||||
QStringList list = QtFileDialog::getFileNamesAndDirectories(this, QString::fromStdString(path.str()));
|
||||
@@ -118,7 +118,7 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName,
|
||||
m_list->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
m_list->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/listbox.css"))).c_str());
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("window/listbox.css"))).c_str());
|
||||
layout->addWidget(m_list);
|
||||
|
||||
QWidget* buttonContainer = new QWidget(this);
|
||||
|
||||
@@ -127,7 +127,7 @@ QtHistoryList::QtHistoryList(const std::vector<SearchMatch>& history, size_t cur
|
||||
m_list->setItemWidget(item, line);
|
||||
}
|
||||
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("history_list/history_list.css"))).c_str());
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("history_list/history_list.css"))).c_str());
|
||||
|
||||
connect(m_list, &QListWidget::itemClicked, this, &QtHistoryList::onItemClicked);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ void QtLocationPicker::handleButtonPress()
|
||||
FilePath path(m_data->text().toStdString());
|
||||
if (!path.empty() && !path.isAbsolute() && !m_relativeRootDirectory.empty())
|
||||
{
|
||||
path = m_relativeRootDirectory.concat(path);
|
||||
path = m_relativeRootDirectory.getConcatenated(path);
|
||||
}
|
||||
|
||||
QString fileName;
|
||||
@@ -119,8 +119,8 @@ void QtLocationPicker::handleButtonPress()
|
||||
{
|
||||
if (!m_relativeRootDirectory.empty())
|
||||
{
|
||||
FilePath path(fileName.toStdString());
|
||||
FilePath relPath(path.relativeTo(m_relativeRootDirectory));
|
||||
const FilePath path(fileName.toStdString());
|
||||
const FilePath relPath = path.getRelativeTo(m_relativeRootDirectory);
|
||||
if (relPath.str().size() < path.str().size())
|
||||
{
|
||||
fileName = QString::fromStdString(relPath.str());
|
||||
|
||||
@@ -119,7 +119,7 @@ void QtContextMenu::copyFullPathActionTriggered()
|
||||
|
||||
void QtContextMenu::openContainingFolderActionTriggered()
|
||||
{
|
||||
FilePath dir = s_filePath.parentDirectory();
|
||||
FilePath dir = s_filePath.getParentDirectory();
|
||||
if (dir.exists())
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(("file:///" + dir.str()).c_str(), QUrl::TolerantMode));
|
||||
|
||||
@@ -250,7 +250,8 @@ void QtBookmarkView::showBookmarksClicked()
|
||||
void QtBookmarkView::setStyleSheet()
|
||||
{
|
||||
m_widget->setStyleSheet(utility::getStyleSheet(
|
||||
ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css"))).c_str());
|
||||
ResourcePaths::getGuiPath().concatenate(FilePath("bookmark_view/bookmark_view.css"))
|
||||
).c_str());
|
||||
}
|
||||
|
||||
void QtBookmarkView::refreshStyle()
|
||||
|
||||
@@ -285,7 +285,7 @@ void QtCodeView::setStyleSheet() const
|
||||
{
|
||||
utility::setWidgetBackgroundColor(m_widget, ColorScheme::getInstance()->getColor("code/background"));
|
||||
|
||||
std::string styleSheet = utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("code_view/code_view.css")));
|
||||
std::string styleSheet = utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("code_view/code_view.css")));
|
||||
|
||||
m_widget->setStyleSheet(styleSheet.c_str());
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ void QtGraphView::refreshView()
|
||||
|
||||
QtGraphicsView* view = getView();
|
||||
|
||||
std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("graph_view/graph_view.css")));
|
||||
std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("graph_view/graph_view.css")));
|
||||
view->setStyleSheet(css.c_str());
|
||||
view->setAppZoomFactor(GraphViewStyle::getZoomFactor());
|
||||
view->refreshStyle();
|
||||
|
||||
@@ -37,5 +37,5 @@ void QtRefreshView::refreshView()
|
||||
void QtRefreshView::setStyleSheet()
|
||||
{
|
||||
m_widget->setStyleSheet(utility::getStyleSheet(
|
||||
ResourcePaths::getGuiPath().concat(FilePath("refresh_view/refresh_view.css"))).c_str());
|
||||
ResourcePaths::getGuiPath().concatenate(FilePath("refresh_view/refresh_view.css"))).c_str());
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ void QtScreenSearchView::refreshView()
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_bar->setStyleSheet(
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(
|
||||
FilePath("screen_search_view/screen_search_view.css"))).c_str()
|
||||
);
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ void QtSearchView::setAutocompletionList(const std::vector<SearchMatch>& autocom
|
||||
|
||||
void QtSearchView::setStyleSheet()
|
||||
{
|
||||
std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("search_view/search_view.css")));
|
||||
std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("search_view/search_view.css")));
|
||||
|
||||
m_widget->setStyleSheet(css.c_str());
|
||||
|
||||
|
||||
@@ -65,6 +65,6 @@ void QtTabbedView::setStyleSheet()
|
||||
QtViewWidgetWrapper::getWidgetOfView(this), ColorScheme::getInstance()->getColor("tab/background"));
|
||||
|
||||
m_widget->setStyleSheet(
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("tabbed_view/tabbed_view.css"))).c_str()
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("tabbed_view/tabbed_view.css"))).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ void QtTooltipView::refreshView()
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_widget->setStyleSheet(
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("tooltip_view/tooltip_view.css"))).c_str()
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("tooltip_view/tooltip_view.css"))).c_str()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -69,5 +69,5 @@ void QtUndoRedoView::updateHistory(const std::vector<SearchMatch>& searchMatches
|
||||
void QtUndoRedoView::setStyleSheet()
|
||||
{
|
||||
m_widget->setStyleSheet(utility::getStyleSheet(
|
||||
ResourcePaths::getGuiPath().concat(FilePath("undoredo_view/undoredo_view.css"))).c_str());
|
||||
ResourcePaths::getGuiPath().concatenate(FilePath("undoredo_view/undoredo_view.css"))).c_str());
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ QSize QtAbout::sizeHint() const
|
||||
|
||||
void QtAbout::setupAbout()
|
||||
{
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("about/about.css"))).c_str());
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("about/about.css"))).c_str());
|
||||
|
||||
QVBoxLayout* windowLayout = new QVBoxLayout();
|
||||
windowLayout->setContentsMargins(10, 10, 10, 0);
|
||||
|
||||
@@ -24,8 +24,8 @@ QtBookmarkBrowser::~QtBookmarkBrowser()
|
||||
void QtBookmarkBrowser::setupBookmarkBrowser()
|
||||
{
|
||||
setStyleSheet((
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))) +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css")))
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("window/window.css"))) +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("bookmark_view/bookmark_view.css")))
|
||||
).c_str());
|
||||
|
||||
m_headerBackground = new QWidget(m_window);
|
||||
|
||||
@@ -106,8 +106,8 @@ void QtBookmarkCreator::setupBookmarkCreator()
|
||||
void QtBookmarkCreator::refreshStyle()
|
||||
{
|
||||
setStyleSheet((
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))) +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css")))
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("window/window.css"))) +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("bookmark_view/bookmark_view.css")))
|
||||
).c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -378,8 +378,8 @@ QBoxLayout* QtIndexingDialog::createLayout()
|
||||
);
|
||||
|
||||
setStyleSheet((
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))) +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("indexing_dialog/indexing_dialog.css")))
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("window/window.css"))) +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("indexing_dialog/indexing_dialog.css")))
|
||||
).c_str());
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
@@ -70,7 +70,7 @@ void QtKeyboardShortcuts::populateWindow(QWidget* widget)
|
||||
|
||||
widget->setLayout(layout);
|
||||
|
||||
widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("keyboard_shortcuts/keyboard_shortcuts.css"))).c_str());
|
||||
widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("keyboard_shortcuts/keyboard_shortcuts.css"))).c_str());
|
||||
}
|
||||
|
||||
void QtKeyboardShortcuts::windowReady()
|
||||
|
||||
@@ -134,7 +134,7 @@ void QtLicenseWindow::populateWindow(QWidget* widget)
|
||||
void QtLicenseWindow::windowReady()
|
||||
{
|
||||
m_content->setStyleSheet(m_content->styleSheet() +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("license/license.css"))).c_str());
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("license/license.css"))).c_str());
|
||||
|
||||
addLogo();
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ QtMainWindow::QtMainWindow()
|
||||
{
|
||||
// can only be done once, because resetting the style on the QCoreApplication causes crash
|
||||
app->setStyleSheet(
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("scrollbar.css"))).c_str());
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("scrollbar.css"))).c_str());
|
||||
}
|
||||
|
||||
m_recentProjectAction = new QAction*[ApplicationSettings::getInstance()->getMaxRecentProjectsCount()];
|
||||
@@ -379,7 +379,7 @@ void QtMainWindow::setContentEnabled(bool enabled)
|
||||
|
||||
void QtMainWindow::refreshStyle()
|
||||
{
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("main.css"))).c_str());
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("main.css"))).c_str());
|
||||
}
|
||||
|
||||
void QtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
@@ -524,12 +524,12 @@ void QtMainWindow::enteredLicense()
|
||||
|
||||
void QtMainWindow::showDataFolder()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getUserDataPath().canonical().str()).c_str(), QUrl::TolerantMode));
|
||||
QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getUserDataPath().makeCanonical().str()).c_str(), QUrl::TolerantMode));
|
||||
}
|
||||
|
||||
void QtMainWindow::showLogFolder()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getLogPath().canonical().str()).c_str(), QUrl::TolerantMode));
|
||||
QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getLogPath().makeCanonical().str()).c_str(), QUrl::TolerantMode));
|
||||
}
|
||||
|
||||
void QtMainWindow::showStartScreen()
|
||||
@@ -685,7 +685,9 @@ void QtMainWindow::resetWindowLayout()
|
||||
{
|
||||
FileSystem::remove(UserPaths::getWindowSettingsPath());
|
||||
FileSystem::copyFile(
|
||||
ResourcePaths::getFallbackPath().concat(FilePath("window_settings.ini")), UserPaths::getWindowSettingsPath());
|
||||
ResourcePaths::getFallbackPath().concatenate(FilePath("window_settings.ini")),
|
||||
UserPaths::getWindowSettingsPath()
|
||||
);
|
||||
loadDockWidgetLayout();
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ size_t i = 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("startscreen/startscreen.css"))).c_str());
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("startscreen/startscreen.css"))).c_str());
|
||||
}
|
||||
|
||||
void QtStartScreen::setupStartScreen()
|
||||
@@ -146,7 +146,7 @@ void QtStartScreen::setupStartScreen()
|
||||
License license;
|
||||
license.loadFromEncodedString(ApplicationSettings::getInstance()->getLicenseString(), AppPath::getAppPath());
|
||||
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("startscreen/startscreen.css"))).c_str());
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("startscreen/startscreen.css"))).c_str());
|
||||
addLogo();
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
|
||||
@@ -88,7 +88,7 @@ QSize QtWindow::sizeHint() const
|
||||
|
||||
void QtWindow::setup()
|
||||
{
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))).c_str());
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(FilePath("window/window.css"))).c_str());
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->setContentsMargins(10, 10, 10, 10);
|
||||
|
||||
@@ -74,7 +74,7 @@ void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::ve
|
||||
|
||||
if (m_projectSettings->getProjectFilePath().empty())
|
||||
{
|
||||
m_projectSettings->setProjectFilePath(filePath.withoutExtension().fileName(), filePath.parentDirectory());
|
||||
m_projectSettings->setProjectFilePath(filePath.withoutExtension().fileName(), filePath.getParentDirectory());
|
||||
}
|
||||
|
||||
if (!m_contentWidget)
|
||||
|
||||
@@ -61,7 +61,7 @@ void QtProjectWizzardContentCDBSource::load()
|
||||
|
||||
if (projectPath.exists())
|
||||
{
|
||||
path = path.relativeTo(projectPath);
|
||||
path.makeRelativeTo(projectPath);
|
||||
}
|
||||
|
||||
m_fileNames.push_back(path.str());
|
||||
|
||||
@@ -226,7 +226,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
|
||||
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
|
||||
|
||||
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
|
||||
const FilePath mavenProjectRoot = settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
const FilePath mavenProjectRoot = settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory();
|
||||
|
||||
std::vector<std::string> list;
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
@@ -270,7 +270,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
|
||||
{
|
||||
if (projectPath.exists())
|
||||
{
|
||||
path = path.relativeTo(projectPath);
|
||||
path.makeRelativeTo(projectPath);
|
||||
}
|
||||
|
||||
list.push_back(path.str());
|
||||
@@ -370,7 +370,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceGradle::getFileNames()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
|
||||
|
||||
const FilePath gradleProjectRoot = settings->getGradleProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
const FilePath gradleProjectRoot = settings->getGradleProjectFilePathExpandedAndAbsolute().getParentDirectory();
|
||||
|
||||
std::vector<std::string> list;
|
||||
|
||||
@@ -401,7 +401,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceGradle::getFileNames()
|
||||
{
|
||||
if (projectPath.exists())
|
||||
{
|
||||
path = path.relativeTo(projectPath);
|
||||
path.makeRelativeTo(projectPath);
|
||||
}
|
||||
|
||||
list.push_back(path.str());
|
||||
|
||||
@@ -305,7 +305,7 @@ void QtProjectWizzardContentPathsCDBHeader::load()
|
||||
{
|
||||
for (const FilePath& path : IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath))
|
||||
{
|
||||
sourcePaths.insert(path.parentDirectory());
|
||||
sourcePaths.insert(path.getParentDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ void QtProjectWizzardContentPathsCDBHeader::load()
|
||||
if (lastPath.empty() || !lastPath.contains(path)) // don't add subdirectories of already added paths
|
||||
{
|
||||
lastPath = path;
|
||||
rootPaths.push_back(path.relativeTo(projectPath));
|
||||
rootPaths.push_back(path.getRelativeTo(projectPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ std::vector<FilePath> CxxFrameworkPathDetector::getPaths() const
|
||||
{
|
||||
if (utility::isPostfix(" (framework directory)", path))
|
||||
{
|
||||
frameworkPaths.push_back(FilePath(utility::replace(path, " (framework directory)", "")).canonical());
|
||||
frameworkPaths.push_back(FilePath(utility::replace(path, " (framework directory)", "")).makeCanonical());
|
||||
}
|
||||
}
|
||||
return frameworkPaths;
|
||||
|
||||
@@ -22,7 +22,7 @@ std::vector<FilePath> CxxHeaderPathDetector::getPaths() const
|
||||
{
|
||||
if (!utility::isPostfix(" (framework directory)", path))
|
||||
{
|
||||
headerPaths.push_back(FilePath(path).canonical());
|
||||
headerPaths.push_back(FilePath(path).makeCanonical());
|
||||
}
|
||||
}
|
||||
return headerPaths;
|
||||
|
||||
@@ -23,7 +23,7 @@ CxxVs10To14HeaderPathDetector::~CxxVs10To14HeaderPathDetector()
|
||||
|
||||
std::vector<FilePath> CxxVs10To14HeaderPathDetector::getPaths() const
|
||||
{
|
||||
FilePath vsInstallPath = getVsInstallPathUsingRegistry();
|
||||
const FilePath vsInstallPath = getVsInstallPathUsingRegistry();
|
||||
|
||||
// vc++ headers
|
||||
std::vector<FilePath> headerSearchPaths;
|
||||
@@ -35,10 +35,10 @@ std::vector<FilePath> CxxVs10To14HeaderPathDetector::getPaths() const
|
||||
|
||||
for (size_t i = 0; i < subdirectories.size(); i++)
|
||||
{
|
||||
FilePath headerSearchPath = vsInstallPath.concat(FilePath(subdirectories[i]));
|
||||
FilePath headerSearchPath = vsInstallPath.getConcatenated(FilePath(subdirectories[i]));
|
||||
if (headerSearchPath.exists())
|
||||
{
|
||||
headerSearchPaths.push_back(headerSearchPath.canonical());
|
||||
headerSearchPaths.push_back(headerSearchPath.makeCanonical());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,16 +32,16 @@ std::vector<FilePath> CxxVs15HeaderPathDetector::getPaths() const
|
||||
const FilePath vsInstallPath(output);
|
||||
if (vsInstallPath.exists())
|
||||
{
|
||||
for (const FilePath& versionPath : FileSystem::getDirectSubDirectories(vsInstallPath.concat(FilePath("VC/Tools/MSVC"))))
|
||||
for (const FilePath& versionPath : FileSystem::getDirectSubDirectories(vsInstallPath.getConcatenated(FilePath("VC/Tools/MSVC"))))
|
||||
{
|
||||
if (versionPath.exists())
|
||||
{
|
||||
headerSearchPaths.push_back(versionPath.concat(FilePath("include")));
|
||||
headerSearchPaths.push_back(versionPath.concat(FilePath("atlmfc/include")));
|
||||
headerSearchPaths.push_back(versionPath.getConcatenated(FilePath("include")));
|
||||
headerSearchPaths.push_back(versionPath.getConcatenated(FilePath("atlmfc/include")));
|
||||
}
|
||||
}
|
||||
headerSearchPaths.push_back(vsInstallPath.concat(FilePath("VC/Auxiliary/VS/include")));
|
||||
headerSearchPaths.push_back(vsInstallPath.concat(FilePath("VC/Auxiliary/VS/UnitTest/include")));
|
||||
headerSearchPaths.push_back(vsInstallPath.getConcatenated(FilePath("VC/Auxiliary/VS/include")));
|
||||
headerSearchPaths.push_back(vsInstallPath.getConcatenated(FilePath("VC/Auxiliary/VS/UnitTest/include")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace utility
|
||||
|
||||
for (size_t i = 0; i < windowsSdkVersions.size(); i++)
|
||||
{
|
||||
FilePath sdkPath = getWindowsSdkRootPathUsingRegistry(architectureType, windowsSdkVersions[i]);
|
||||
const FilePath sdkPath = getWindowsSdkRootPathUsingRegistry(architectureType, windowsSdkVersions[i]);
|
||||
if (sdkPath.exists())
|
||||
{
|
||||
FilePath sdkIncludePath = sdkPath.concat(FilePath("include/"));
|
||||
const FilePath sdkIncludePath = sdkPath.getConcatenated(FilePath("include/"));
|
||||
if (sdkIncludePath.exists())
|
||||
{
|
||||
std::vector<std::string> subdirectories;
|
||||
@@ -55,7 +55,7 @@ namespace utility
|
||||
bool usingSubdirectories = false;
|
||||
for (size_t j = 0; j < subdirectories.size(); j++)
|
||||
{
|
||||
FilePath sdkSubdirectory = sdkIncludePath.concat(FilePath(subdirectories[j]));
|
||||
const FilePath sdkSubdirectory = sdkIncludePath.getConcatenated(FilePath(subdirectories[j]));
|
||||
if (sdkSubdirectory.exists())
|
||||
{
|
||||
headerSearchPaths.push_back(sdkSubdirectory);
|
||||
@@ -72,12 +72,12 @@ namespace utility
|
||||
}
|
||||
}
|
||||
{
|
||||
FilePath sdkPath = getWindowsSdkRootPathUsingRegistry(architectureType, "v10.0");
|
||||
const FilePath sdkPath = getWindowsSdkRootPathUsingRegistry(architectureType, "v10.0");
|
||||
if (sdkPath.exists())
|
||||
{
|
||||
for (const FilePath& versionPath : FileSystem::getDirectSubDirectories(sdkPath.concat(FilePath("include/"))))
|
||||
for (const FilePath& versionPath : FileSystem::getDirectSubDirectories(sdkPath.getConcatenated(FilePath("include/"))))
|
||||
{
|
||||
const FilePath ucrtPath = versionPath.concat(FilePath("ucrt"));
|
||||
const FilePath ucrtPath = versionPath.getConcatenated(FilePath("ucrt"));
|
||||
if (ucrtPath.exists())
|
||||
{
|
||||
headerSearchPaths.push_back(ucrtPath);
|
||||
|
||||
@@ -52,15 +52,12 @@ FilePath JavaPathDetectorLinux::readLink(const FilePath& path) const
|
||||
|
||||
FilePath JavaPathDetectorLinux::getFilePathRelativeToJavaExecutable(FilePath& javaExecutablePath) const
|
||||
{
|
||||
FilePath p(javaExecutablePath.parentDirectory().str() + jvmLibPathRelativeToJavaExecutable);
|
||||
if ( p.exists() )
|
||||
FilePath p(javaExecutablePath.getParentDirectory().str() + jvmLibPathRelativeToJavaExecutable);
|
||||
if (p.exists())
|
||||
{
|
||||
return p.canonical();
|
||||
}
|
||||
else
|
||||
{
|
||||
return FilePath();
|
||||
return p.makeCanonical();
|
||||
}
|
||||
return FilePath();
|
||||
}
|
||||
|
||||
FilePath JavaPathDetectorLinux::getJavaInJavaHome() const
|
||||
|
||||
+2
-2
@@ -21,8 +21,8 @@ std::vector<FilePath> JreSystemLibraryPathDetector::getPaths() const
|
||||
std::vector<FilePath> paths;
|
||||
for (const FilePath& jrePath: m_javaPathDetector->getPaths())
|
||||
{
|
||||
const FilePath javaRoot = jrePath.parentDirectory().parentDirectory().parentDirectory();
|
||||
for (const FilePath& jarPath : FileSystem::getFilePathsFromDirectory(javaRoot.concat(FilePath("lib")), {".jar"}))
|
||||
const FilePath javaRoot = jrePath.getParentDirectory().getParentDirectory().getParentDirectory();
|
||||
for (const FilePath& jarPath : FileSystem::getFilePathsFromDirectory(javaRoot.getConcatenated(FilePath("lib")), {".jar"}))
|
||||
{
|
||||
paths.push_back(jarPath);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ bool utility::saveLicense(const License* license)
|
||||
|
||||
std::string appLocation = AppPath::getAppPath();
|
||||
appSettings->setLicenseString(license->getLicenseEncodedString(appLocation));
|
||||
appSettings->setLicenseCheck(license->hashLocation(FilePath(appLocation).absolute().str()));
|
||||
appSettings->setLicenseCheck(license->hashLocation(FilePath(appLocation).makeAbsolute().str()));
|
||||
appSettings->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ std::set<FilePath> SourceGroupJava::fetchRootDirectories()
|
||||
continue;
|
||||
}
|
||||
|
||||
FilePath rootPath = filePath.parentDirectory();
|
||||
FilePath rootPath = filePath.getParentDirectory();
|
||||
bool success = true;
|
||||
|
||||
const std::vector<std::string> packageNameParts = utility::splitToVector(packageName, ".");
|
||||
@@ -163,7 +163,7 @@ std::set<FilePath> SourceGroupJava::fetchRootDirectories()
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
rootPath = rootPath.parentDirectory();
|
||||
rootPath = rootPath.getParentDirectory();
|
||||
}
|
||||
|
||||
if (success)
|
||||
|
||||
@@ -73,7 +73,7 @@ std::vector<FilePath> SourceGroupJavaGradle::getAllSourcePaths() const
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Gradle\nFetching Source Directories");
|
||||
|
||||
const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().getParentDirectory();
|
||||
sourcePaths = utility::gradleGetAllSourceDirectories(projectRootPath, m_settings->getShouldIndexGradleTests());
|
||||
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
@@ -85,7 +85,7 @@ bool SourceGroupJavaGradle::prepareGradleData()
|
||||
{
|
||||
if (m_settings && m_settings->getGradleProjectFilePathExpandedAndAbsolute().exists())
|
||||
{
|
||||
const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().getParentDirectory();
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ std::vector<FilePath> SourceGroupJavaMaven::getAllSourcePaths() const
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nFetching Source Directories");
|
||||
|
||||
const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath());
|
||||
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory();
|
||||
sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_settings->getShouldIndexMavenTests());
|
||||
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
@@ -87,7 +87,7 @@ bool SourceGroupJavaMaven::prepareMavenData()
|
||||
if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists())
|
||||
{
|
||||
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
|
||||
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory();
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nGenerating Source Files");
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace
|
||||
if (getenv("JAVA_HOME") == nullptr)
|
||||
{
|
||||
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
|
||||
const FilePath javaHomePath = javaPath.parentDirectory().parentDirectory().parentDirectory();
|
||||
const FilePath javaHomePath = javaPath.getParentDirectory().getParentDirectory().getParentDirectory();
|
||||
|
||||
LOG_WARNING("Environment variable \"JAVA_HOME\" not found on system. Setting value to \"" + javaHomePath.str() + "\" for this process.");
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace
|
||||
FilePath path(fetchedDirectory);
|
||||
if (!toAppend.empty())
|
||||
{
|
||||
path = path.concat(toAppend);
|
||||
path.concatenate(toAppend);
|
||||
}
|
||||
pathList.push_back(path);
|
||||
LOG_INFO("Found directory \"" + path.str() + "\".");
|
||||
@@ -51,7 +51,7 @@ namespace
|
||||
if (getenv("JAVA_HOME") == nullptr)
|
||||
{
|
||||
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
|
||||
const FilePath javaHomePath = javaPath.parentDirectory().parentDirectory().parentDirectory();
|
||||
const FilePath javaHomePath = javaPath.getParentDirectory().getParentDirectory().getParentDirectory();
|
||||
|
||||
LOG_WARNING("Environment variable \"JAVA_HOME\" not found on system. Setting value to \"" + javaHomePath.str() + "\" for this process.");
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class CxxIndexSampleProjectsTestSuite : public CxxTest::TestSuite
|
||||
public:
|
||||
static const bool s_updateExpectedOutput = false;
|
||||
|
||||
void test_index_box2d_project()
|
||||
void _test_index_box2d_project()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
processSourceFile("Box2D", FilePath("Box2D/Collision/b2BroadPhase.cpp"));
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_index_bullet3_project()
|
||||
void _test_index_bullet3_project()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
processSourceFile("Bullet3", FilePath("Bullet3Collision/BroadPhaseCollision/b3DynamicBvh.cpp"));
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
private:
|
||||
void processSourceFile(const std::string& projectName, const FilePath& sourceFilePath)
|
||||
{
|
||||
const FilePath projectDataRoot = FilePath("data/CxxIndexSampleProjectsTestSuite/" + projectName).absolute();
|
||||
const FilePath projectDataRoot = FilePath("data/CxxIndexSampleProjectsTestSuite/" + projectName).makeAbsolute();
|
||||
const FilePath projectDataSrcRoot = projectDataRoot.concat(FilePath("src"));
|
||||
const FilePath projectDataExpectedOutputRoot = projectDataRoot.concat(FilePath("expected_output"));
|
||||
|
||||
|
||||
@@ -7,38 +7,38 @@ class FilePathTestSuite : public CxxTest::TestSuite
|
||||
public:
|
||||
void test_file_path_gets_created_empty()
|
||||
{
|
||||
FilePath path;
|
||||
const FilePath path;
|
||||
|
||||
TS_ASSERT_EQUALS(path.str(), "");
|
||||
}
|
||||
|
||||
void test_file_path_gets_created_with_char_array()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/main.cpp");
|
||||
const FilePath path("data/FilePathTestSuite/main.cpp");
|
||||
|
||||
TS_ASSERT_EQUALS(path.str(), "data/FilePathTestSuite/main.cpp");
|
||||
}
|
||||
|
||||
void test_file_path_gets_created_with_string()
|
||||
{
|
||||
std::string str("data/FilePathTestSuite/main.cpp");
|
||||
FilePath path(str);
|
||||
const std::string str("data/FilePathTestSuite/main.cpp");
|
||||
const FilePath path(str);
|
||||
|
||||
TS_ASSERT_EQUALS(path.str(), str);
|
||||
}
|
||||
|
||||
void test_file_path_gets_created_other_file_path()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/main.cpp");
|
||||
FilePath path2(path);
|
||||
const FilePath path("data/FilePathTestSuite/main.cpp");
|
||||
const FilePath path2(path);
|
||||
|
||||
TS_ASSERT_EQUALS(path, path2);
|
||||
}
|
||||
|
||||
void test_file_path_empty()
|
||||
{
|
||||
FilePath path1("data/FilePathTestSuite/a.cpp");
|
||||
FilePath path2;
|
||||
const FilePath path1("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath path2;
|
||||
|
||||
TS_ASSERT(!path1.empty());
|
||||
TS_ASSERT(path2.empty());
|
||||
@@ -46,91 +46,91 @@ public:
|
||||
|
||||
void test_file_path_exists()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath path("data/FilePathTestSuite/a.cpp");
|
||||
|
||||
TS_ASSERT(path.exists());
|
||||
}
|
||||
|
||||
void test_file_path_not_exists()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/a.h");
|
||||
const FilePath path("data/FilePathTestSuite/a.h");
|
||||
|
||||
TS_ASSERT(!path.exists());
|
||||
}
|
||||
|
||||
void test_file_path_is_directory()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath path("data/FilePathTestSuite/a.cpp");
|
||||
|
||||
TS_ASSERT(!path.isDirectory());
|
||||
TS_ASSERT(path.parentDirectory().isDirectory());
|
||||
TS_ASSERT(path.getParentDirectory().isDirectory());
|
||||
}
|
||||
|
||||
void test_empty_file_path_has_empty_parent_directory()
|
||||
{
|
||||
FilePath path;
|
||||
const FilePath path;
|
||||
|
||||
TS_ASSERT(path.empty());
|
||||
TS_ASSERT(path.parentDirectory().empty());
|
||||
TS_ASSERT(path.getParentDirectory().empty());
|
||||
}
|
||||
|
||||
void test_file_path_is_absolute()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath path("data/FilePathTestSuite/a.cpp");
|
||||
|
||||
TS_ASSERT(!path.isAbsolute());
|
||||
TS_ASSERT(path.absolute().isAbsolute());
|
||||
TS_ASSERT(path.getAbsolute().isAbsolute());
|
||||
}
|
||||
|
||||
void test_file_path_parent_directory()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath path("data/FilePathTestSuite/a.cpp");
|
||||
|
||||
TS_ASSERT(path.parentDirectory().str() == "data/FilePathTestSuite");
|
||||
TS_ASSERT(path.parentDirectory().parentDirectory().str() == "data");
|
||||
TS_ASSERT(path.getParentDirectory().str() == "data/FilePathTestSuite");
|
||||
TS_ASSERT(path.getParentDirectory().getParentDirectory().str() == "data");
|
||||
}
|
||||
|
||||
void test_file_path_relative_to_other_path()
|
||||
{
|
||||
FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
FilePath pathB("data/FilePathTestSuite/test/c.h");
|
||||
const FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath pathB("data/FilePathTestSuite/test/c.h");
|
||||
|
||||
TS_ASSERT_EQUALS(pathA.relativeTo(pathB).str(), "../a.cpp");
|
||||
TS_ASSERT_EQUALS(pathB.relativeTo(pathA).str(), "test/c.h");
|
||||
TS_ASSERT_EQUALS(pathA.getRelativeTo(pathB).str(), "../a.cpp");
|
||||
TS_ASSERT_EQUALS(pathB.getRelativeTo(pathA).str(), "test/c.h");
|
||||
}
|
||||
|
||||
void test_file_path_relative_to_other_directory()
|
||||
{
|
||||
FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
FilePath pathB("data/FilePathTestSuite/test");
|
||||
const FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath pathB("data/FilePathTestSuite/test");
|
||||
|
||||
TS_ASSERT_EQUALS(pathA.relativeTo(pathB).str(), "../a.cpp");
|
||||
TS_ASSERT_EQUALS(pathA.getRelativeTo(pathB).str(), "../a.cpp");
|
||||
}
|
||||
|
||||
void test_file_path_relative_to_same_directory()
|
||||
{
|
||||
FilePath pathA("data/FilePathTestSuite/test");
|
||||
const FilePath pathA("data/FilePathTestSuite/test");
|
||||
|
||||
TS_ASSERT_EQUALS(pathA.relativeTo(pathA).str(), "./");
|
||||
TS_ASSERT_EQUALS(pathA.getRelativeTo(pathA).str(), "./");
|
||||
}
|
||||
|
||||
void test_file_path_file_name()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/abc.h");
|
||||
const FilePath path("data/FilePathTestSuite/abc.h");
|
||||
|
||||
TS_ASSERT_EQUALS(path.fileName(), "abc.h");
|
||||
}
|
||||
|
||||
void test_file_path_extension()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/a.h");
|
||||
const FilePath path("data/FilePathTestSuite/a.h");
|
||||
|
||||
TS_ASSERT_EQUALS(path.extension(), ".h");
|
||||
}
|
||||
|
||||
void test_file_path_without_extension()
|
||||
{
|
||||
FilePath path("data/FilePathTestSuite/a.h");
|
||||
const FilePath path("data/FilePathTestSuite/a.h");
|
||||
|
||||
TS_ASSERT_EQUALS(path.withoutExtension(), FilePath("data/FilePathTestSuite/a"));
|
||||
}
|
||||
@@ -149,42 +149,42 @@ public:
|
||||
|
||||
void test_file_path_equals_file_with_different_relative_paths()
|
||||
{
|
||||
FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
FilePath pathA2("data/../data/FilePathTestSuite/./a.cpp");
|
||||
const FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath pathA2("data/../data/FilePathTestSuite/./a.cpp");
|
||||
|
||||
TS_ASSERT_EQUALS(pathA, pathA2);
|
||||
}
|
||||
|
||||
void test_file_path_equals_relative_and_absolute_paths()
|
||||
{
|
||||
FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
FilePath pathA2(pathA.absolute());
|
||||
const FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath pathA2 = pathA.getAbsolute();
|
||||
|
||||
TS_ASSERT_EQUALS(pathA, pathA2);
|
||||
}
|
||||
|
||||
void test_file_path_equals_absolute_and_canonical_paths()
|
||||
{
|
||||
FilePath path("data/../data/FilePathTestSuite/./a.cpp");
|
||||
const FilePath path("data/../data/FilePathTestSuite/./a.cpp");
|
||||
|
||||
TS_ASSERT_EQUALS(path.absolute(), path.canonical());
|
||||
TS_ASSERT_EQUALS(path.getAbsolute(), path.getCanonical());
|
||||
}
|
||||
|
||||
void test_file_path_canonical_removes_symlinks()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
FilePath pathA("data/FilePathTestSuite/parent/target/d.cpp");
|
||||
FilePath pathB("data/FilePathTestSuite/target/d.cpp");
|
||||
const FilePath pathA("data/FilePathTestSuite/parent/target/d.cpp");
|
||||
const FilePath pathB("data/FilePathTestSuite/target/d.cpp");
|
||||
|
||||
TS_ASSERT_EQUALS(pathB.absolute(), pathA.canonical());
|
||||
TS_ASSERT_EQUALS(pathB.getAbsolute(), pathA.getCanonical());
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_file_path_compares_paths_with_posix_and_windows_format()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
FilePath pathB("data/FilePathTestSuite/b.cc");
|
||||
FilePath pathB2("data\\FilePathTestSuite\\b.cc");
|
||||
const FilePath pathB("data/FilePathTestSuite/b.cc");
|
||||
const FilePath pathB2("data\\FilePathTestSuite\\b.cc");
|
||||
|
||||
TS_ASSERT_EQUALS(pathB, pathB2);
|
||||
#endif
|
||||
@@ -192,24 +192,24 @@ public:
|
||||
|
||||
void test_file_path_differs_for_different_existing_files()
|
||||
{
|
||||
FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
FilePath pathB("data/FilePathTestSuite/b.cc");
|
||||
const FilePath pathA("data/FilePathTestSuite/a.cpp");
|
||||
const FilePath pathB("data/FilePathTestSuite/b.cc");
|
||||
|
||||
TS_ASSERT_DIFFERS(pathA, pathB);
|
||||
}
|
||||
|
||||
void test_file_path_differs_for_different_nonexisting_files()
|
||||
{
|
||||
FilePath pathA("data/FilePathTestSuite/a.h");
|
||||
FilePath pathB("data/FilePathTestSuite/b.c");
|
||||
const FilePath pathA("data/FilePathTestSuite/a.h");
|
||||
const FilePath pathB("data/FilePathTestSuite/b.c");
|
||||
|
||||
TS_ASSERT_DIFFERS(pathA, pathB);
|
||||
}
|
||||
|
||||
void test_file_path_differs_for_existing_and_nonexisting_files()
|
||||
{
|
||||
FilePath pathA("data/FilePathTestSuite/a.h");
|
||||
FilePath pathB("data/FilePathTestSuite/b.cc");
|
||||
const FilePath pathA("data/FilePathTestSuite/a.h");
|
||||
const FilePath pathB("data/FilePathTestSuite/b.cc");
|
||||
|
||||
TS_ASSERT_DIFFERS(pathA, pathB);
|
||||
}
|
||||
|
||||
@@ -121,18 +121,6 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_filesystem_finds_existing_files()
|
||||
{
|
||||
TS_ASSERT(FileSystem::exists(FilePath("data/FileSystemTestSuite")));
|
||||
TS_ASSERT(FileSystem::exists(FilePath("data/FileSystemTestSuite/tictactoe.h")));
|
||||
}
|
||||
|
||||
void test_filesystem_does_not_find_non_existing_files()
|
||||
{
|
||||
TS_ASSERT(!FileSystem::exists(FilePath("data/FileSystemTestSuite/foo")));
|
||||
TS_ASSERT(!FileSystem::exists(FilePath("data/FileSystemTestSuite/blabla.h")));
|
||||
}
|
||||
|
||||
void test_filesystem_extracts_filename()
|
||||
{
|
||||
TS_ASSERT_EQUALS(FileSystem::fileName("data/FileSystemTestSuite/tictactoe.h"), "tictactoe.h");
|
||||
|
||||
@@ -38,13 +38,13 @@ public:
|
||||
const bool updateExpectedOutput = false;
|
||||
|
||||
const std::vector<FilePath>& classpath = {
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/lib/guava-21.0.jar").absolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/lib/javaparser-core-3.3.0.jar").absolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/lib/javaslang-2.0.3.jar").absolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/lib/javassist-3.19.0-GA.jar").absolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/src/java-symbol-solver-core").absolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/src/java-symbol-solver-logic").absolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/src/java-symbol-solver-model").absolute()
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/lib/guava-21.0.jar").makeAbsolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/lib/javaparser-core-3.3.0.jar").makeAbsolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/lib/javaslang-2.0.3.jar").makeAbsolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/lib/javassist-3.19.0-GA.jar").makeAbsolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/src/java-symbol-solver-core").makeAbsolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/src/java-symbol-solver-logic").makeAbsolute(),
|
||||
FilePath("data/JavaIndexSampleProjectsTestSuite/JavaSymbolSolver060/src/java-symbol-solver-model").makeAbsolute()
|
||||
};
|
||||
|
||||
processSourceFile("JavaSymbolSolver060", FilePath("java-symbol-solver-core/com/github/javaparser/symbolsolver/SourceFileInfoExtractor.java"), classpath, updateExpectedOutput);
|
||||
@@ -218,12 +218,12 @@ private:
|
||||
void processSourceFile(const std::string& projectName, const FilePath& sourceFilePath, const std::vector<FilePath>& classpath, const bool updateExpectedOutput)
|
||||
{
|
||||
const FilePath projectDataRoot = FilePath("data/JavaIndexSampleProjectsTestSuite/" + projectName);
|
||||
const FilePath projectDataSrcRoot = projectDataRoot.concat(FilePath("src"));
|
||||
const FilePath projectDataExpectedOutputRoot = projectDataRoot.concat(FilePath("expected_output"));
|
||||
const FilePath projectDataSrcRoot = projectDataRoot.getConcatenated(FilePath("src"));
|
||||
const FilePath projectDataExpectedOutputRoot = projectDataRoot.getConcatenated(FilePath("expected_output"));
|
||||
|
||||
std::shared_ptr<TextAccess> output = parseCode(projectDataSrcRoot.concat(sourceFilePath), projectDataSrcRoot, classpath);
|
||||
std::shared_ptr<TextAccess> output = parseCode(projectDataSrcRoot.getConcatenated(sourceFilePath), projectDataSrcRoot, classpath);
|
||||
|
||||
FilePath expectedOutputFilePath = projectDataExpectedOutputRoot.concat(FilePath(utility::replace(sourceFilePath.withoutExtension().str() + ".txt", "/", "_")));
|
||||
const FilePath expectedOutputFilePath = projectDataExpectedOutputRoot.getConcatenated(FilePath(utility::replace(sourceFilePath.withoutExtension().str() + ".txt", "/", "_")));
|
||||
if (updateExpectedOutput || !expectedOutputFilePath.exists())
|
||||
{
|
||||
std::ofstream expectedOutputFile;
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
size_t bookmarkCount = 4;
|
||||
int result = -1;
|
||||
{
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
SqliteBookmarkStorage storage(databasePath);
|
||||
storage.setup();
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
result = storage.getAllBookmarks().size();
|
||||
}
|
||||
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(result, bookmarkCount);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
size_t bookmarkCount = 4;
|
||||
int result = -1;
|
||||
{
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
SqliteBookmarkStorage storage(databasePath);
|
||||
storage.setup();
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
result = storage.getAllBookmarkedNodes().size();
|
||||
}
|
||||
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(result, bookmarkCount);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
FilePath databasePath("data/SQLiteTestSuite/bookmarkTest.sqlite");
|
||||
int result = -1;
|
||||
{
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
SqliteBookmarkStorage storage(databasePath);
|
||||
storage.setup();
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
result = storage.getAllBookmarkedNodes().size();
|
||||
}
|
||||
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(result, 0);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
|
||||
StorageBookmark storageBookmark;
|
||||
{
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
SqliteBookmarkStorage storage(databasePath);
|
||||
storage.setup();
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
storageBookmark = storage.getAllBookmarks().front();
|
||||
}
|
||||
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(updatedName, storageBookmark.name);
|
||||
TS_ASSERT_EQUALS(updatedComment, storageBookmark.comment);
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
storage.commitTransaction();
|
||||
nodeCount = storage.getNodeCount();
|
||||
}
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(1, nodeCount);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
storage.commitTransaction();
|
||||
nodeCount = storage.getNodeCount();
|
||||
}
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(0, nodeCount);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
storage.commitTransaction();
|
||||
edgeCount = storage.getEdgeCount();
|
||||
}
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(1, edgeCount);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
storage.commitTransaction();
|
||||
edgeCount = storage.getEdgeCount();
|
||||
}
|
||||
boost::filesystem::remove(databasePath.path());
|
||||
FileSystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(0, edgeCount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user