src: miscellaneous bug fixes for upcoming release
* only randomize parsing order of source files for multithreaded indexing * fixed overview not displayed when switching projects due to MessageScrollCode being dispatched * avoid adding duplicate TokenLocations that causes highlighting to break in QtCodeArea * clear all controllers when switching project * maximize unindexed file when clicking title instead of activating it
This commit is contained in:
@@ -53,7 +53,7 @@ TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
|
||||
TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
|
||||
TextAccess.cpp WARNING: Line numbers start with one, is 0
|
||||
TextAccess.cpp WARNING: Line numbers start with one, is 0
|
||||
TokenLocationCollection.cpp ERROR: Can't create TokenLocation with wrong boundaries.
|
||||
TokenLocationCollection.cpp ERROR: Can't create TokenLocation with wrong boundaries.
|
||||
TokenLocationCollection.cpp ERROR: TokenLocation has wrong boundaries: file.c 2:3 2:1
|
||||
TokenLocationCollection.cpp ERROR: TokenLocation has wrong boundaries: file.c 4:1 1:10
|
||||
SolutionParserVisualStudio.cpp INFO: Found 24 additional include paths
|
||||
SolutionParserVisualStudio.cpp INFO: Found 450 code files
|
||||
|
||||
@@ -116,6 +116,8 @@ void Application::createAndLoadProject(const FilePath& projectSettingsFilePath)
|
||||
|
||||
void Application::loadProject(const FilePath& projectSettingsFilePath)
|
||||
{
|
||||
m_componentManager->clearComponents();
|
||||
|
||||
bool reparse = false;
|
||||
|
||||
Project::ProjectState state = m_project->load(projectSettingsFilePath);
|
||||
|
||||
+5
-4
@@ -142,8 +142,6 @@ void Project::parseCode()
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
|
||||
|
||||
m_fileManager.fetchFilePaths(m_storage->getInfoOnAllFiles());
|
||||
std::set<FilePath> addedFilePaths = m_fileManager.getAddedFilePaths();
|
||||
std::set<FilePath> updatedFilePaths = m_fileManager.getUpdatedFilePaths();
|
||||
@@ -164,7 +162,10 @@ void Project::parseCode()
|
||||
filesToParse.insert(filesToParse.end(), addedFilePaths.begin(), addedFilePaths.end());
|
||||
filesToParse.insert(filesToParse.end(), updatedFilePaths.begin(), updatedFilePaths.end());
|
||||
|
||||
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(&m_fileManager);
|
||||
|
||||
int indexerThreadCount = ApplicationSettings::getInstance()->getIndexerThreadCount();
|
||||
|
||||
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(&m_fileManager, indexerThreadCount > 1);
|
||||
fileRegister->setFilePaths(filesToParse);
|
||||
|
||||
std::shared_ptr<TaskGroupParallel> taskParallel = std::make_shared<TaskGroupParallel>();
|
||||
@@ -177,7 +178,7 @@ void Project::parseCode()
|
||||
|
||||
std::shared_ptr<std::mutex> storageMutex = std::make_shared<std::mutex>();
|
||||
|
||||
for (int i = 0; i < ApplicationSettings::getInstance()->getIndexerThreadCount(); i++)
|
||||
for (int i = 0; i < indexerThreadCount; i++)
|
||||
{
|
||||
taskParallel->addTask(std::make_shared<TaskParseCxx>(
|
||||
m_storage.get(),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "component/controller/NetworkFactory.h"
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "component/view/CodeView.h"
|
||||
#include "component/view/CompositeView.h"
|
||||
#include "component/view/GraphView.h"
|
||||
@@ -51,6 +52,19 @@ void ComponentManager::setup(ViewLayout* viewLayout)
|
||||
m_components.push_back(featureComponent);
|
||||
}
|
||||
|
||||
void ComponentManager::clearComponents()
|
||||
{
|
||||
for (std::shared_ptr<Component> component : m_components)
|
||||
{
|
||||
Controller* controller = component->getController<Controller>();
|
||||
|
||||
if (controller)
|
||||
{
|
||||
controller->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentManager::refreshViews()
|
||||
{
|
||||
for (std::shared_ptr<Component> component : m_components)
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
|
||||
void setup(ViewLayout* viewLayout);
|
||||
|
||||
void clearComponents();
|
||||
void refreshViews();
|
||||
|
||||
private:
|
||||
|
||||
@@ -103,8 +103,12 @@ void CodeController::handleMessage(MessageActivateTokens* message)
|
||||
}
|
||||
|
||||
std::vector<Id> activeTokenIds = message->tokenIds;
|
||||
Id declarationId = 0; // 0 means that no token is found.
|
||||
if (!activeTokenIds.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Id declarationId = 0; // 0 means that no token is found.
|
||||
if (!message->isAggregation)
|
||||
{
|
||||
activeTokenIds = m_storageAccess->getActiveTokenIdsForId(activeTokenIds[0], &declarationId);
|
||||
@@ -306,6 +310,13 @@ CodeView* CodeController::getView()
|
||||
return Controller::getView<CodeView>();
|
||||
}
|
||||
|
||||
void CodeController::clear()
|
||||
{
|
||||
getView()->clear();
|
||||
|
||||
m_collection.reset();
|
||||
}
|
||||
|
||||
void CodeController::showContents(MessageBase* message)
|
||||
{
|
||||
if (!message->isReplayed())
|
||||
|
||||
@@ -61,6 +61,9 @@ private:
|
||||
virtual void handleMessage(MessageShowScope* message);
|
||||
|
||||
CodeView* getView();
|
||||
|
||||
virtual void clear();
|
||||
|
||||
void showContents(MessageBase* message);
|
||||
|
||||
std::vector<CodeSnippetParams> getSnippetsForActiveTokenLocations(
|
||||
|
||||
@@ -11,13 +11,14 @@ public:
|
||||
|
||||
void setComponent(Component* component);
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
protected:
|
||||
template <typename ViewType>
|
||||
ViewType* getView() const;
|
||||
ViewType* getView() const;
|
||||
|
||||
private:
|
||||
Component* m_component;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -25,8 +26,11 @@ template <typename ViewType>
|
||||
ViewType* Controller::getView() const
|
||||
{
|
||||
if (m_component)
|
||||
{
|
||||
return m_component->getView<ViewType>();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif // CONTROLLER_H
|
||||
|
||||
@@ -19,6 +19,10 @@ FeatureController::~FeatureController()
|
||||
{
|
||||
}
|
||||
|
||||
void FeatureController::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageActivateEdge* message)
|
||||
{
|
||||
if (message->isAggregation())
|
||||
@@ -61,9 +65,15 @@ void FeatureController::handleMessage(MessageActivateFile* message)
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageActivateTokens m(message, std::vector<Id>());
|
||||
m.unknownNames.push_back(message->filePath.fileName());
|
||||
m.dispatchImmediately();
|
||||
MessageChangeFileView msg(
|
||||
message->filePath,
|
||||
MessageChangeFileView::FILE_MAXIMIZED,
|
||||
true,
|
||||
true
|
||||
);
|
||||
msg.setIsReplayed(message->isReplayed());
|
||||
msg.setKeepContent(message->keepContent());
|
||||
msg.dispatchImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
FeatureController(StorageAccess* storageAccess);
|
||||
~FeatureController();
|
||||
|
||||
virtual void clear();
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageActivateEdge* message);
|
||||
virtual void handleMessage(MessageActivateFile* message);
|
||||
|
||||
@@ -186,6 +186,7 @@ void GraphController::clear()
|
||||
m_activeEdgeIds.clear();
|
||||
|
||||
m_graph.reset();
|
||||
|
||||
getView()->clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
|
||||
GraphView* getView() const;
|
||||
|
||||
void clear();
|
||||
virtual void clear();
|
||||
|
||||
void createDummyGraphForTokenIds(const std::vector<Id>& tokenIds, const std::shared_ptr<Graph> graph);
|
||||
std::shared_ptr<DummyNode> createDummyNodeTopDown(Node* node, Id parentId);
|
||||
|
||||
@@ -24,6 +24,10 @@ IDECommunicationController::~IDECommunicationController()
|
||||
{
|
||||
}
|
||||
|
||||
void IDECommunicationController::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void IDECommunicationController::handleIncomingMessage(const std::string& message)
|
||||
{
|
||||
if (m_enabled == false)
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
IDECommunicationController(StorageAccess* storageAccess);
|
||||
virtual ~IDECommunicationController();
|
||||
|
||||
virtual void clear();
|
||||
|
||||
void handleIncomingMessage(const std::string& message);
|
||||
|
||||
bool getEnabled() const;
|
||||
|
||||
@@ -13,6 +13,10 @@ RefreshController::~RefreshController()
|
||||
{
|
||||
}
|
||||
|
||||
void RefreshController::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void RefreshController::handleMessage(MessageAutoRefreshChanged* message)
|
||||
{
|
||||
m_autoRefreshEnabled = message->enabled;
|
||||
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
RefreshController();
|
||||
virtual ~RefreshController();
|
||||
|
||||
virtual void clear();
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageAutoRefreshChanged* message);
|
||||
virtual void handleMessage(MessageWindowFocus* message);
|
||||
|
||||
@@ -79,3 +79,8 @@ SearchView* SearchController::getView()
|
||||
{
|
||||
return Controller::getView<SearchView>();
|
||||
}
|
||||
|
||||
void SearchController::clear()
|
||||
{
|
||||
getView()->setMatches(std::vector<SearchMatch>());
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ private:
|
||||
|
||||
SearchView* getView();
|
||||
|
||||
virtual void clear();
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,12 @@ StatusBarView* StatusBarController::getView()
|
||||
return Controller::getView<StatusBarView>();
|
||||
}
|
||||
|
||||
void StatusBarController::clear()
|
||||
{
|
||||
getView()->setErrorCount(ErrorCountInfo());
|
||||
getView()->showMessage("", false, false);
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageClearErrorCount* message)
|
||||
{
|
||||
getView()->setErrorCount(ErrorCountInfo());
|
||||
|
||||
@@ -27,6 +27,8 @@ public:
|
||||
|
||||
StatusBarView* getView();
|
||||
|
||||
virtual void clear();
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageClearErrorCount* message);
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
|
||||
@@ -22,6 +22,15 @@ UndoRedoView* UndoRedoController::getView()
|
||||
return Controller::getView<UndoRedoView>();
|
||||
}
|
||||
|
||||
void UndoRedoController::clear()
|
||||
{
|
||||
m_list.clear();
|
||||
m_iterator = m_list.begin();
|
||||
|
||||
getView()->setUndoButtonEnabled(false);
|
||||
getView()->setRedoButtonEnabled(false);
|
||||
}
|
||||
|
||||
UndoRedoController::Command::Command(std::shared_ptr<MessageBase> message, Order order, bool replayLastOnly)
|
||||
: message(message)
|
||||
, order(order)
|
||||
@@ -143,11 +152,6 @@ void UndoRedoController::handleMessage(MessageGraphNodeMove* message)
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageLoadProject* message)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageRedo* message)
|
||||
{
|
||||
if (m_iterator == m_list.end())
|
||||
@@ -326,6 +330,11 @@ void UndoRedoController::replayCommands(std::list<Command>::iterator it)
|
||||
|
||||
void UndoRedoController::processCommand(Command command)
|
||||
{
|
||||
if (command.order != Command::ORDER_ACTIVATE && m_iterator == m_list.begin())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (command.order == Command::ORDER_ACTIVATE && command.message->keepContent())
|
||||
{
|
||||
command.order = Command::ORDER_ADAPT;
|
||||
@@ -369,15 +378,6 @@ void UndoRedoController::processCommand(Command command)
|
||||
}
|
||||
}
|
||||
|
||||
void UndoRedoController::clear()
|
||||
{
|
||||
m_list.clear();
|
||||
m_iterator = m_list.end();
|
||||
|
||||
getView()->setUndoButtonEnabled(false);
|
||||
getView()->setRedoButtonEnabled(false);
|
||||
}
|
||||
|
||||
bool UndoRedoController::sameMessageTypeAsLast(MessageBase* message) const
|
||||
{
|
||||
if (!m_list.size() || m_list.begin() == m_iterator)
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeExpand.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageRedo.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageScrollCode.h"
|
||||
@@ -41,7 +40,6 @@ class UndoRedoController
|
||||
, public MessageListener<MessageGraphNodeBundleSplit>
|
||||
, public MessageListener<MessageGraphNodeExpand>
|
||||
, public MessageListener<MessageGraphNodeMove>
|
||||
, public MessageListener<MessageLoadProject>
|
||||
, public MessageListener<MessageRedo>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageScrollCode>
|
||||
@@ -56,6 +54,8 @@ public:
|
||||
|
||||
UndoRedoView* getView();
|
||||
|
||||
virtual void clear();
|
||||
|
||||
private:
|
||||
struct Command
|
||||
{
|
||||
@@ -83,7 +83,6 @@ private:
|
||||
virtual void handleMessage(MessageGraphNodeBundleSplit* message);
|
||||
virtual void handleMessage(MessageGraphNodeExpand* message);
|
||||
virtual void handleMessage(MessageGraphNodeMove* message);
|
||||
virtual void handleMessage(MessageLoadProject* message);
|
||||
virtual void handleMessage(MessageRedo* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
virtual void handleMessage(MessageScrollCode* message);
|
||||
@@ -97,8 +96,6 @@ private:
|
||||
|
||||
void processCommand(Command command);
|
||||
|
||||
void clear();
|
||||
|
||||
bool sameMessageTypeAsLast(MessageBase* message) const;
|
||||
MessageBase* lastMessage() const;
|
||||
|
||||
|
||||
@@ -869,9 +869,7 @@ std::shared_ptr<TokenLocationCollection> PersistentStorage::getTokenLocationsFor
|
||||
for (Id fileId: fileIds)
|
||||
{
|
||||
StorageFile storageFile = m_sqliteStorage.getFileById(fileId);
|
||||
collection->addTokenLocationFileAsPlainCopy(
|
||||
m_sqliteStorage.getTokenLocationsForFile(storageFile.filePath).get()
|
||||
);
|
||||
collection->addTokenLocationFile(m_sqliteStorage.getTokenLocationsForFile(storageFile.filePath));
|
||||
}
|
||||
|
||||
std::vector<StorageSourceLocation> locations = m_sqliteStorage.getTokenLocationsForElementIds(nonFileIds);
|
||||
@@ -923,16 +921,14 @@ std::shared_ptr<TokenLocationCollection> PersistentStorage::getTokenLocationsFor
|
||||
|
||||
std::shared_ptr<TokenLocationFile> PersistentStorage::getTokenLocationsForFile(const std::string& filePath) const
|
||||
{
|
||||
std::shared_ptr<TokenLocationFile> locationFile = m_sqliteStorage.getTokenLocationsForFile(filePath);
|
||||
locationFile->isWholeCopy = true;
|
||||
return locationFile;
|
||||
return m_sqliteStorage.getTokenLocationsForFile(filePath);
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenLocationFile> PersistentStorage::getTokenLocationsForLinesInFile(
|
||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||
) const
|
||||
{
|
||||
return m_sqliteStorage.getTokenLocationsForFile(filePath)->getFilteredByLines(firstLineNumber, lastLineNumber);
|
||||
return getTokenLocationsForFile(filePath)->getFilteredByLines(firstLineNumber, lastLineNumber);
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> PersistentStorage::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
|
||||
|
||||
@@ -504,6 +504,8 @@ std::shared_ptr<TokenLocationFile> SqliteStorage::getTokenLocationsForFile(const
|
||||
loc->setType(intToLocationType(location.type));
|
||||
}
|
||||
|
||||
ret->isWholeCopy = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -661,7 +663,7 @@ void SqliteStorage::setupTables()
|
||||
);
|
||||
|
||||
// TODO: move to createIndexesForAnalysis() or prepareForAnalysis
|
||||
m_database.execDML( // used for checking for duplicates during code analysis
|
||||
m_database.execDML( // used for checking for duplicates during code analysis
|
||||
"CREATE INDEX IF NOT EXISTS edge_multipart_index ON edge(type, source_node_id, target_node_id);"
|
||||
);
|
||||
|
||||
|
||||
@@ -67,13 +67,21 @@ TokenLocation* TokenLocationCollection::addTokenLocation(
|
||||
{
|
||||
if (startLineNumber > endLineNumber || (startLineNumber == endLineNumber && startColumnNumber > endColumnNumber))
|
||||
{
|
||||
LOG_ERROR("Can't create TokenLocation with wrong boundaries.");
|
||||
LOG_ERROR_STREAM(<< "TokenLocation has wrong boundaries: "<< filePath.str() << " "
|
||||
<< startLineNumber << ":" << startColumnNumber << " "
|
||||
<< endLineNumber << ":" << endColumnNumber);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TokenLocation* location = findTokenLocationById(locationId);
|
||||
if (location)
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
TokenLocationFile* file = createTokenLocationFile(filePath);
|
||||
TokenLocation* location =
|
||||
file->addTokenLocation(locationId, tokenId, startLineNumber, startColumnNumber, endLineNumber, endColumnNumber);
|
||||
location = file->addTokenLocation(
|
||||
locationId, tokenId, startLineNumber, startColumnNumber, endLineNumber, endColumnNumber);
|
||||
|
||||
m_locations.emplace(location->getId(), location);
|
||||
return location;
|
||||
@@ -98,6 +106,37 @@ void TokenLocationCollection::removeTokenLocation(TokenLocation* location)
|
||||
}
|
||||
}
|
||||
|
||||
TokenLocationFile* TokenLocationCollection::addTokenLocationFile(std::shared_ptr<TokenLocationFile> locationFile)
|
||||
{
|
||||
TokenLocationFile* file = findTokenLocationFileByPath(locationFile->getFilePath());
|
||||
if (file)
|
||||
{
|
||||
LOG_ERROR("TokenLocationFile with same path already exists.");
|
||||
return file;
|
||||
}
|
||||
|
||||
m_files.emplace(locationFile->getFilePath(), locationFile);
|
||||
locationFile->forEachTokenLocation(
|
||||
[this, &file](TokenLocation* tokenLocation) -> void
|
||||
{
|
||||
m_locations.emplace(tokenLocation->getId(), tokenLocation);
|
||||
}
|
||||
);
|
||||
return locationFile.get();
|
||||
}
|
||||
|
||||
void TokenLocationCollection::removeTokenLocationFile(TokenLocationFile* file)
|
||||
{
|
||||
file->forEachTokenLocation(
|
||||
[&](TokenLocation* location)
|
||||
{
|
||||
m_locations.erase(location->getId());
|
||||
}
|
||||
);
|
||||
|
||||
m_files.erase(file->getFilePath());
|
||||
}
|
||||
|
||||
TokenLocation* TokenLocationCollection::findTokenLocationById(Id id) const
|
||||
{
|
||||
std::map<Id, TokenLocation*>::const_iterator it = m_locations.find(id);
|
||||
@@ -115,7 +154,8 @@ TokenLocationFile* TokenLocationCollection::findTokenLocationFileByPath(const Fi
|
||||
return getTokenLocationFileByPath(filePath).get();
|
||||
}
|
||||
|
||||
void TokenLocationCollection::forEachTokenLocationFile(std::function<void(std::shared_ptr<TokenLocationFile>)> func) const
|
||||
void TokenLocationCollection::forEachTokenLocationFile(
|
||||
std::function<void(std::shared_ptr<TokenLocationFile>)> func) const
|
||||
{
|
||||
for (const TokenLocationFilePairType& file : m_files)
|
||||
{
|
||||
@@ -139,18 +179,6 @@ void TokenLocationCollection::forEachTokenLocation(std::function<void(TokenLocat
|
||||
}
|
||||
}
|
||||
|
||||
void TokenLocationCollection::removeTokenLocationFile(TokenLocationFile* file)
|
||||
{
|
||||
file->forEachTokenLocation(
|
||||
[&](TokenLocation* location)
|
||||
{
|
||||
m_locations.erase(location->getId());
|
||||
}
|
||||
);
|
||||
|
||||
m_files.erase(file->getFilePath());
|
||||
}
|
||||
|
||||
TokenLocationFile* TokenLocationCollection::addTokenLocationFileAsPlainCopy(const TokenLocationFile* locationFile)
|
||||
{
|
||||
TokenLocationFile* file = createTokenLocationFile(locationFile->getFilePath());
|
||||
@@ -161,7 +189,6 @@ TokenLocationFile* TokenLocationCollection::addTokenLocationFileAsPlainCopy(cons
|
||||
m_locations.emplace(copy->getId(), copy);
|
||||
}
|
||||
);
|
||||
file->isWholeCopy = true;
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@ public:
|
||||
unsigned int endLineNumber, unsigned int endColumnNumber);
|
||||
void removeTokenLocation(TokenLocation* location);
|
||||
|
||||
TokenLocationFile* addTokenLocationFile(std::shared_ptr<TokenLocationFile> locationFile);
|
||||
void removeTokenLocationFile(TokenLocationFile* file);
|
||||
|
||||
TokenLocation* findTokenLocationById(Id id) const;
|
||||
TokenLocationFile* findTokenLocationFileByPath(const FilePath& filePath) const;
|
||||
|
||||
@@ -45,8 +48,6 @@ public:
|
||||
void forEachTokenLocationLine(std::function<void(TokenLocationLine*)> func) const;
|
||||
void forEachTokenLocation(std::function<void(TokenLocation*)> func) const;
|
||||
|
||||
void removeTokenLocationFile(TokenLocationFile* file);
|
||||
|
||||
TokenLocationFile* addTokenLocationFileAsPlainCopy(const TokenLocationFile* locationFile);
|
||||
TokenLocation* addTokenLocationAsPlainCopy(const TokenLocation* location);
|
||||
|
||||
|
||||
@@ -57,14 +57,41 @@ TokenLocation* TokenLocationFile::addTokenLocation(
|
||||
unsigned int endLineNumber, unsigned int endColumnNumber)
|
||||
{
|
||||
TokenLocationLine* line = createTokenLocationLine(startLineNumber);
|
||||
TokenLocation* start = line->addStartTokenLocation(locationId, tokenId, startColumnNumber);
|
||||
|
||||
if (startLineNumber != endLineNumber)
|
||||
// Check if a TokenLocation with the same start and end was already added.
|
||||
TokenLocation* start = nullptr;
|
||||
line->forEachStartTokenLocation(
|
||||
[&](TokenLocation* startLocation)
|
||||
{
|
||||
if (start)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TokenLocation* endLocation = startLocation->getEndTokenLocation();
|
||||
|
||||
if (startLocation->getTokenId() == tokenId &&
|
||||
startLocation->getColumnNumber() == startColumnNumber &&
|
||||
endLocation &&
|
||||
endLocation->getLineNumber() == endLineNumber &&
|
||||
endLocation->getColumnNumber() == endColumnNumber)
|
||||
{
|
||||
start = startLocation;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!start)
|
||||
{
|
||||
line = createTokenLocationLine(endLineNumber);
|
||||
}
|
||||
start = line->addStartTokenLocation(locationId, tokenId, startColumnNumber);
|
||||
|
||||
line->addEndTokenLocation(start, endColumnNumber);
|
||||
if (startLineNumber != endLineNumber)
|
||||
{
|
||||
line = createTokenLocationLine(endLineNumber);
|
||||
}
|
||||
|
||||
line->addEndTokenLocation(start, endColumnNumber);
|
||||
}
|
||||
|
||||
return start;
|
||||
}
|
||||
@@ -132,7 +159,7 @@ TokenLocation* TokenLocationFile::addTokenLocationAsPlainCopy(const TokenLocatio
|
||||
TokenLocationLine* line = createTokenLocationLine(lineNumber);
|
||||
|
||||
// Check whether this location was already added or if the other TokenLocation was added.
|
||||
TokenLocation* otherLocation = line->getTokenLocationByIdAndType(location->getId(), location->getType());
|
||||
TokenLocation* otherLocation = line->getTokenLocationById(location->getId());
|
||||
if (otherLocation)
|
||||
{
|
||||
if (otherLocation->isStartTokenLocation() == location->isStartTokenLocation())
|
||||
@@ -150,7 +177,7 @@ TokenLocation* TokenLocationFile::addTokenLocationAsPlainCopy(const TokenLocatio
|
||||
TokenLocationLine* otherLine = findTokenLocationLine(otherLineNumber);
|
||||
if (otherLine)
|
||||
{
|
||||
otherLocation = otherLine->getTokenLocationByIdAndType(location->getId(), location->getType());
|
||||
otherLocation = otherLine->getTokenLocationById(location->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,11 +71,11 @@ void TokenLocationLine::removeTokenLocation(TokenLocation* location)
|
||||
LOG_ERROR("TokenLocation can't be removed, it's not part of the TokenLocationLine.");
|
||||
}
|
||||
|
||||
TokenLocation* TokenLocationLine::getTokenLocationByIdAndType(Id id, LocationType type) const
|
||||
TokenLocation* TokenLocationLine::getTokenLocationById(Id id) const
|
||||
{
|
||||
for (const TokenLocationPairType& p : m_locations)
|
||||
{
|
||||
if (p.second->getId() == id && p.second->getType() == type)
|
||||
if (p.second->getId() == id)
|
||||
{
|
||||
return p.second.get();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include "data/location/LocationType.h"
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
@@ -36,7 +34,7 @@ public:
|
||||
TokenLocation* addEndTokenLocation(TokenLocation* start, unsigned int columnNumber);
|
||||
void removeTokenLocation(TokenLocation* location);
|
||||
|
||||
TokenLocation* getTokenLocationByIdAndType(Id id, LocationType type) const;
|
||||
TokenLocation* getTokenLocationById(Id id) const;
|
||||
|
||||
void forEachTokenLocation(std::function<void(TokenLocation*)> func) const;
|
||||
void forEachStartTokenLocation(std::function<void(TokenLocation*)> func) const;
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
|
||||
FileRegister::FileRegister(const FileManager* fileManager)
|
||||
FileRegister::FileRegister(const FileManager* fileManager, bool randomizeParseOrder)
|
||||
: m_fileManager(fileManager)
|
||||
, m_randomizeParseOrder(randomizeParseOrder)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -144,7 +145,14 @@ FilePath FileRegister::consumeSourceFile()
|
||||
|
||||
if (paths.size())
|
||||
{
|
||||
path = paths[rand() % paths.size()];
|
||||
if (m_randomizeParseOrder)
|
||||
{
|
||||
path = paths[rand() % paths.size()];
|
||||
}
|
||||
else
|
||||
{
|
||||
path = paths[0];
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_sourceFileMutex);
|
||||
m_sourceFilePaths[path] = STATE_PARSING;
|
||||
|
||||
@@ -17,7 +17,7 @@ class FileManager;
|
||||
class FileRegister
|
||||
{
|
||||
public:
|
||||
explicit FileRegister(const FileManager* fileManager);
|
||||
explicit FileRegister(const FileManager* fileManager, bool randomizeParseOrder);
|
||||
|
||||
void setFilePaths(const std::vector<FilePath>& filePaths);
|
||||
|
||||
@@ -49,6 +49,7 @@ private:
|
||||
};
|
||||
|
||||
const FileManager* m_fileManager;
|
||||
bool m_randomizeParseOrder;
|
||||
|
||||
mutable std::unordered_map<std::string, bool> m_projectFiles;
|
||||
mutable std::mutex m_projectFilesMutex;
|
||||
|
||||
@@ -405,19 +405,6 @@ void QtCodeFile::clickedTitleBar()
|
||||
void QtCodeFile::clickedTitle()
|
||||
{
|
||||
MessageActivateFile(m_filePath).dispatch();
|
||||
|
||||
// TODO: check if external file and maximize instead
|
||||
|
||||
// MessageChangeFileView msg(
|
||||
// message->filePath,
|
||||
// MessageChangeFileView::FILE_MAXIMIZED,
|
||||
// true,
|
||||
// false,
|
||||
// nullptr
|
||||
// );
|
||||
// msg.setIsReplayed(message->isReplayed());
|
||||
// msg.setKeepContent(message->keepContent());
|
||||
// msg.dispatch();
|
||||
}
|
||||
|
||||
void QtCodeFile::editProject()
|
||||
|
||||
@@ -2779,7 +2779,7 @@ public:
|
||||
void test_cxx_parser_parses_multiple_files()
|
||||
{
|
||||
TestFileManager fm;
|
||||
std::shared_ptr<FileRegister> fr = std::make_shared<FileRegister>(&fm);
|
||||
std::shared_ptr<FileRegister> fr = std::make_shared<FileRegister>(&fm, false);
|
||||
TestParserClient client;
|
||||
CxxParser parser(&client, fr);
|
||||
|
||||
@@ -3094,7 +3094,7 @@ private:
|
||||
m_args.languageStandard = "1z";
|
||||
|
||||
TestFileManager fm;
|
||||
std::shared_ptr<FileRegister> fr = std::make_shared<FileRegister>(&fm);
|
||||
std::shared_ptr<FileRegister> fr = std::make_shared<FileRegister>(&fm, false);
|
||||
std::shared_ptr<TestParserClient> client = std::make_shared<TestParserClient>();
|
||||
CxxParser parser(client.get(), fr);
|
||||
parser.parseFile("input.cc", TextAccess::createFromString(code), m_args);
|
||||
|
||||
Reference in New Issue
Block a user