logic: fixed handling case insensitive filepath matches when activating a symbol via editor plugin
This commit is contained in:
@@ -84,10 +84,11 @@ void IDECommunicationController::handleSetActiveTokenMessage(
|
||||
{
|
||||
const unsigned int cursorColumn = message.column;
|
||||
|
||||
const FilePath filePath = message.filePath.getCanonical();
|
||||
const Id fileId = m_storageAccess->getNodeIdForFileNode(message.filePath.getCanonical());
|
||||
const FileInfo fileInfo = m_storageAccess->getFileInfoForFileId(fileId);
|
||||
const FilePath filePath = fileInfo.path;
|
||||
|
||||
if (FileSystem::getFileInfoForPath(filePath).lastWriteTime
|
||||
== m_storageAccess->getFileInfoForFilePath(filePath).lastWriteTime)
|
||||
if (FileSystem::getFileInfoForPath(filePath).lastWriteTime == fileInfo.lastWriteTime)
|
||||
{
|
||||
// file was not modified
|
||||
std::shared_ptr<SourceLocationFile> sourceLocationFile = m_storageAccess->getSourceLocationsForLinesInFile(
|
||||
@@ -110,7 +111,7 @@ void IDECommunicationController::handleSetActiveTokenMessage(
|
||||
}
|
||||
);
|
||||
|
||||
if (selectedLocationIds.size() > 0)
|
||||
if (!selectedLocationIds.empty())
|
||||
{
|
||||
MessageStatus(
|
||||
L"Activating source location from plug-in succeeded: " + filePath.wstr() + L", row: " +
|
||||
@@ -123,7 +124,6 @@ void IDECommunicationController::handleSetActiveTokenMessage(
|
||||
}
|
||||
}
|
||||
|
||||
Id fileId = m_storageAccess->getNodeIdForFileNode(filePath);
|
||||
if (fileId > 0)
|
||||
{
|
||||
MessageActivateFile(filePath, message.row).dispatchImmediately();
|
||||
|
||||
@@ -79,6 +79,8 @@ public:
|
||||
|
||||
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const = 0;
|
||||
|
||||
virtual FileInfo getFileInfoForFileId(Id id) const = 0;
|
||||
|
||||
virtual FileInfo getFileInfoForFilePath(const FilePath& filePath) const = 0;
|
||||
virtual std::vector<FileInfo> getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const = 0;
|
||||
|
||||
|
||||
@@ -303,6 +303,16 @@ std::shared_ptr<TextAccess> StorageAccessProxy::getFileContent(const FilePath& f
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FileInfo StorageAccessProxy::getFileInfoForFileId(Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getFileInfoForFileId(id);
|
||||
}
|
||||
|
||||
return FileInfo();
|
||||
}
|
||||
|
||||
FileInfo StorageAccessProxy::getFileInfoForFilePath(const FilePath& filePath) const
|
||||
{
|
||||
if (hasSubject())
|
||||
|
||||
@@ -63,6 +63,8 @@ public:
|
||||
virtual std::shared_ptr<SourceLocationFile> getCommentLocationsInFile(const FilePath& filePath) const override;
|
||||
|
||||
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const override;
|
||||
|
||||
virtual FileInfo getFileInfoForFileId(Id id) const override;
|
||||
|
||||
virtual FileInfo getFileInfoForFilePath(const FilePath& filePath) const override;
|
||||
virtual std::vector<FileInfo> getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const override;
|
||||
|
||||
@@ -295,6 +295,7 @@ void PersistentStorage::clearCaches()
|
||||
m_fileIndex.clear();
|
||||
|
||||
m_fileNodeIds.clear();
|
||||
m_lowerCasefileNodeIds.clear();
|
||||
m_fileNodePaths.clear();
|
||||
m_fileNodeComplete.clear();
|
||||
m_fileNodeIndexed.clear();
|
||||
@@ -429,7 +430,7 @@ void PersistentStorage::optimizeMemory()
|
||||
|
||||
Id PersistentStorage::getNodeIdForFileNode(const FilePath& filePath) const
|
||||
{
|
||||
return m_sqliteIndexStorage.getFileByPath(filePath.wstr()).id;
|
||||
return getFileNodeId(filePath);
|
||||
}
|
||||
|
||||
Id PersistentStorage::getNodeIdForNameHierarchy(const NameHierarchy& nameHierarchy) const
|
||||
@@ -1473,9 +1474,15 @@ std::shared_ptr<TextAccess> PersistentStorage::getFileContent(const FilePath& fi
|
||||
return m_sqliteIndexStorage.getFileContentByPath(filePath.wstr());
|
||||
}
|
||||
|
||||
FileInfo PersistentStorage::getFileInfoForFileId(Id id) const
|
||||
{
|
||||
StorageFile storageFile = m_sqliteIndexStorage.getFirstById<StorageFile>(id);
|
||||
return FileInfo(FilePath(storageFile.filePath), storageFile.modificationTime);
|
||||
}
|
||||
|
||||
FileInfo PersistentStorage::getFileInfoForFilePath(const FilePath& filePath) const
|
||||
{
|
||||
return FileInfo(filePath, m_sqliteIndexStorage.getFileByPath(filePath.wstr()).modificationTime);
|
||||
return getFileInfoForFileId(getFileNodeId(filePath));
|
||||
}
|
||||
|
||||
std::vector<FileInfo> PersistentStorage::getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const
|
||||
@@ -2064,11 +2071,19 @@ Id PersistentStorage::getFileNodeId(const FilePath& filePath) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::map<FilePath, Id>::const_iterator it = m_fileNodeIds.find(filePath);
|
||||
|
||||
if (it != m_fileNodeIds.end())
|
||||
{
|
||||
return it->second;
|
||||
std::map<FilePath, Id>::const_iterator it = m_fileNodeIds.find(filePath);
|
||||
if (it != m_fileNodeIds.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
{
|
||||
std::map<FilePath, Id>::const_iterator it = m_lowerCasefileNodeIds.find(filePath.getLowerCase());
|
||||
if (it != m_lowerCasefileNodeIds.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -2703,6 +2718,7 @@ void PersistentStorage::buildFilePathMaps()
|
||||
const FilePath path(file.filePath);
|
||||
|
||||
m_fileNodeIds.emplace(path, file.id);
|
||||
m_lowerCasefileNodeIds.emplace(path.getLowerCase(), file.id);
|
||||
m_fileNodePaths.emplace(file.id, path);
|
||||
m_fileNodeComplete.emplace(file.id, file.complete);
|
||||
m_fileNodeIndexed.emplace(file.id, file.indexed);
|
||||
|
||||
@@ -119,6 +119,8 @@ public:
|
||||
|
||||
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const override;
|
||||
|
||||
virtual FileInfo getFileInfoForFileId(Id id) const override;
|
||||
|
||||
virtual FileInfo getFileInfoForFilePath(const FilePath& filePath) const override;
|
||||
virtual std::vector<FileInfo> getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const override;
|
||||
|
||||
@@ -200,6 +202,7 @@ private:
|
||||
SqliteBookmarkStorage m_sqliteBookmarkStorage;
|
||||
|
||||
std::map<FilePath, Id> m_fileNodeIds;
|
||||
std::map<FilePath, Id> m_lowerCasefileNodeIds;
|
||||
std::map<Id, FilePath> m_fileNodePaths;
|
||||
std::map<Id, bool> m_fileNodeComplete;
|
||||
std::map<Id, bool> m_fileNodeIndexed;
|
||||
|
||||
@@ -337,6 +337,11 @@ FilePath FilePath::getConcatenated(const std::wstring& other) const
|
||||
return path;
|
||||
}
|
||||
|
||||
FilePath FilePath::getLowerCase() const
|
||||
{
|
||||
return FilePath(utility::toLowerCase(wstr()));
|
||||
}
|
||||
|
||||
bool FilePath::contains(const FilePath& other) const
|
||||
{
|
||||
if (!isDirectory())
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
FilePath getConcatenated(const FilePath& other) const;
|
||||
FilePath& concatenate(const std::wstring& other);
|
||||
FilePath getConcatenated(const std::wstring& other) const;
|
||||
FilePath getLowerCase() const;
|
||||
std::vector<FilePath> expandEnvironmentVariables() const;
|
||||
|
||||
bool contains(const FilePath& other) const;
|
||||
|
||||
Reference in New Issue
Block a user