Clang: Clean up exceptions

* Extract common stuff into the base class ClangException
* Remove unused exceptions TranslationUnitParseErrorException and
  TranslationUnitReparseErrorException
* Do not send error messages to the Qt Creator side. The messages were
  only generated when the backend crashed and while it was not yet fully
  re-initialized (e.g. do code completion right after crash where the
  document was not yet registered at the backend).

Change-Id: I91d98d5ef681ad487f7a2fd66f78fa7cd1e958df
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2016-09-09 15:18:25 +02:00
parent 26cb17bb65
commit cb0e730bb5
8 changed files with 73 additions and 385 deletions

View File

@@ -116,7 +116,7 @@ const Document &Documents::document(const Utf8String &filePath, const Utf8String
auto findIterator = findDocument(filePath, projectPartId);
if (findIterator == documents_.end())
throw DocumentDoesNotExistException(FileContainer(filePath, projectPartId));
throw DocumentDoesNotExistException(filePath, projectPartId);
return *findIterator;
}
@@ -279,16 +279,20 @@ void Documents::checkIfProjectPartsExists(const QVector<FileContainer> &fileCont
void Documents::checkIfDocumentsDoNotExist(const QVector<FileContainer> &fileContainers) const
{
for (const FileContainer &fileContainer : fileContainers) {
if (hasDocument(fileContainer))
throw DocumentAlreadyExistsException(fileContainer);
if (hasDocument(fileContainer)) {
throw DocumentAlreadyExistsException(fileContainer.filePath(),
fileContainer.projectPartId());
}
}
}
void Documents::checkIfDocumentsForFilePathsExist(const QVector<FileContainer> &fileContainers) const
{
for (const FileContainer &fileContainer : fileContainers) {
if (!hasDocumentWithFilePath(fileContainer.filePath()))
throw DocumentDoesNotExistException(fileContainer);
if (!hasDocumentWithFilePath(fileContainer.filePath())) {
throw DocumentDoesNotExistException(fileContainer.filePath(),
fileContainer.projectPartId());
}
}
}
@@ -302,8 +306,11 @@ void Documents::removeDocuments(const QVector<FileContainer> &fileContainers)
documents_.erase(removeBeginIterator, documents_.end());
if (!processedFileContainers.isEmpty())
throw DocumentDoesNotExistException(processedFileContainers.first());
if (!processedFileContainers.isEmpty()) {
const FileContainer fileContainer = processedFileContainers.first();
throw DocumentDoesNotExistException(fileContainer.filePath(),
fileContainer.projectPartId());
}
}
} // namespace ClangBackEnd