IAsyncJob::AsyncPrepareResult UpdateAnnotationsJob::prepareAsyncRun() { const JobRequest jobRequest = context().jobRequest; QTC_ASSERT(isExpectedJobRequestType(jobRequest), return AsyncPrepareResult()); QTC_ASSERT(acquireDocument(), return AsyncPrepareResult()); const TranslationUnit translationUnit = *m_translationUnit; const TranslationUnitUpdateInput updateInput = createUpdateInput(m_pinnedDocument); setRunner([translationUnit, updateInput]() { TIME_SCOPE_DURATION("UpdateAnnotationsJobRunner"); // Update UpdateAnnotationsJob::AsyncResult asyncResult; asyncResult.updateResult = translationUnit.update(updateInput); // Collect translationUnit.extractAnnotations(asyncResult.firstHeaderErrorDiagnostic, asyncResult.diagnostics, asyncResult.tokenInfos, asyncResult.skippedSourceRanges); asyncResult.unresolvedFilePaths.unite( unresolvedFilePaths({asyncResult.firstHeaderErrorDiagnostic})); asyncResult.unresolvedFilePaths.unite(unresolvedFilePaths(asyncResult.diagnostics)); return asyncResult; }); return AsyncPrepareResult{translationUnit.id()}; }
void ClangIpcServer::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) { TIME_SCOPE_DURATION("ClangIpcServer::registerProjectPartsForCodeCompletion"); try { projects.createOrUpdate(command.projectContainers()); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::registerProjectPartsForCodeCompletion:" << exception.what(); } }
void ClangIpcServer::registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::registerProjectPartsForEditor"); try { projects.createOrUpdate(message.projectContainers()); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::registerProjectPartsForEditor:" << exception.what(); } }
bool ConnectionClient::connectToServer() { TIME_SCOPE_DURATION("ConnectionClient::connectToServer"); startProcess(); resetProcessAliveTimer(); const bool isConnected = connectToLocalSocket(); return isConnected; }
void ConnectionClient::startProcess() { TIME_SCOPE_DURATION("ConnectionClient::startProcess"); if (!isProcessIsRunning()) { connectProcessFinished(); connectStandardOutputAndError(); process()->start(processPath(), {connectionName()}); process()->waitForStarted(); resetProcessAliveTimer(); } }
void ClangCodeModelServer::registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) { TIME_SCOPE_DURATION("ClangCodeModelServer::registerProjectPartsForEditor"); try { projects.createOrUpdate(message.projectContainers()); translationUnits.setTranslationUnitsDirtyIfProjectPartChanged(); sendDocumentAnnotationsTimer.start(0); } catch (const std::exception &exception) { qWarning() << "Error in ClangCodeModelServer::registerProjectPartsForEditor:" << exception.what(); } }
void ClangIpcServer::updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::updateVisibleTranslationUnits"); try { translationUnits.setUsedByCurrentEditor(message.currentEditorFilePath()); translationUnits.setVisibleInEditors(message.visibleEditorFilePaths()); sendDocumentAnnotationsTimer.start(0); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::updateVisibleTranslationUnits:" << exception.what(); } }
void ClangIpcServer::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) { TIME_SCOPE_DURATION("ClangIpcServer::unregisterProjectPartsForCodeCompletion"); try { projects.remove(command.projectPartIds()); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistCommand(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::unregisterProjectPartsForCodeCompletion:" << exception.what(); } }
void ClangIpcServer::unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::unregisterProjectPartsForEditor"); try { projects.remove(message.projectPartIds()); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::unregisterProjectPartsForEditor:" << exception.what(); } }
IAsyncJob::AsyncPrepareResult UpdateExtraDocumentAnnotationsJob::prepareAsyncRun() { const JobRequest jobRequest = context().jobRequest; QTC_ASSERT(acquireDocument(), return AsyncPrepareResult()); const TranslationUnit translationUnit = *m_translationUnit; setRunner([translationUnit]() { TIME_SCOPE_DURATION("UpdateExtraDocumentAnnotationsJobRunner"); return translationUnit.fullTokenInfos().toTokenInfoContainers(); }); return AsyncPrepareResult{translationUnit.id()}; }
void ClangIpcServer::registerTranslationUnitsForCodeCompletion(const ClangBackEnd::RegisterTranslationUnitForCodeCompletionCommand &command) { TIME_SCOPE_DURATION("ClangIpcServer::registerTranslationUnitsForCodeCompletion"); try { translationUnits.createOrUpdate(command.fileContainers()); unsavedFiles.createOrUpdate(command.fileContainers()); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistCommand(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::registerTranslationUnitsForCodeCompletion:" << exception.what(); } }
void ClangIpcServer::registerTranslationUnitsForEditor(const ClangBackEnd::RegisterTranslationUnitForEditorMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::registerTranslationUnitsForEditor"); try { translationUnits.create(message.fileContainers()); unsavedFiles.createOrUpdate(message.fileContainers()); sendDiagnosticsTimer.start(0); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::registerTranslationUnitsForEditor:" << exception.what(); } }
void ClangIpcServer::registerUnsavedFilesForEditor(const RegisterUnsavedFilesForEditorMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::registerUnsavedFilesForEditor"); try { unsavedFiles.createOrUpdate(message.fileContainers()); translationUnits.updateTranslationUnitsWithChangedDependencies(message.fileContainers()); sendDocumentAnnotationsTimer.start(delayedDocumentAnnotationsTimerInterval()); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::registerUnsavedFilesForEditor:" << exception.what(); } }
void ClangIpcServer::unregisterUnsavedFilesForEditor(const UnregisterUnsavedFilesForEditorMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::unregisterUnsavedFilesForEditor"); try { unsavedFiles.remove(message.fileContainers()); translationUnits.updateTranslationUnitsWithChangedDependencies(message.fileContainers()); } catch (const TranslationUnitDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::unregisterUnsavedFilesForEditor:" << exception.what(); } }
void ClangCodeModelServer::unregisterTranslationUnitsForEditor(const ClangBackEnd::UnregisterTranslationUnitsForEditorMessage &message) { TIME_SCOPE_DURATION("ClangCodeModelServer::unregisterTranslationUnitsForEditor"); try { translationUnits.remove(message.fileContainers()); unsavedFiles.remove(message.fileContainers()); } catch (const TranslationUnitDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangCodeModelServer::unregisterTranslationUnitsForEditor:" << exception.what(); } }
void ConnectionClient::finishProcess() { TIME_SCOPE_DURATION("ConnectionClient::finishProcess"); processAliveTimer.stop(); disconnectProcessFinished(); endProcess(); disconnectFromServer(); terminateProcess(); killProcess(); process_.reset(); serverProxy_.resetCounter(); }
void ClangIpcServer::registerTranslationUnitsForEditor(const ClangBackEnd::RegisterTranslationUnitForEditorMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::registerTranslationUnitsForEditor"); try { auto createdTranslationUnits = translationUnits.create(message.fileContainers()); unsavedFiles.createOrUpdate(message.fileContainers()); translationUnits.setUsedByCurrentEditor(message.currentEditorFilePath()); translationUnits.setVisibleInEditors(message.visibleEditorFilePaths()); startDocumentAnnotations(); reparseVisibleDocuments(createdTranslationUnits); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::registerTranslationUnitsForEditor:" << exception.what(); } }
void ClangIpcServer::requestDiagnostics(const RequestDiagnosticsMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::requestDiagnostics"); try { auto translationUnit = translationUnits.translationUnit(message.file().filePath(), message.file().projectPartId()); client()->diagnosticsChanged(DiagnosticsChangedMessage(translationUnit.fileContainer(), translationUnit.mainFileDiagnostics())); } catch (const TranslationUnitDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::requestDiagnostics:" << exception.what(); } }
void ClangIpcServer::completeCode(const ClangBackEnd::CompleteCodeMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::completeCode"); try { CodeCompleter codeCompleter(translationUnits.translationUnit(message.filePath(), message.projectPartId())); const auto codeCompletions = codeCompleter.complete(message.line(), message.column()); client()->codeCompleted(CodeCompletedMessage(codeCompletions, message.ticketNumber())); } catch (const TranslationUnitDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::completeCode:" << exception.what(); } }
void ClangIpcServer::requestHighlighting(const RequestHighlightingMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::requestHighlighting"); try { auto translationUnit = translationUnits.translationUnit(message.fileContainer().filePath(), message.fileContainer().projectPartId()); client()->highlightingChanged(HighlightingChangedMessage(translationUnit.fileContainer(), translationUnit.highlightingInformations().toHighlightingMarksContainers(), translationUnit.skippedSourceRanges().toSourceRangeContainers())); } catch (const TranslationUnitDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::requestHighlighting:" << exception.what(); } }
void ClangIpcServer::updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message) { TIME_SCOPE_DURATION("ClangIpcServer::updateTranslationUnitsForEditor"); try { const auto newerFileContainers = translationUnits.newerFileContainers(message.fileContainers()); if (newerFileContainers.size() > 0) { translationUnits.update(newerFileContainers); unsavedFiles.createOrUpdate(newerFileContainers); sendDocumentAnnotationsTimer.start(delayedDocumentAnnotationsTimerInterval()); } } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const TranslationUnitDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const std::exception &exception) { qWarning() << "Error in ClangIpcServer::updateTranslationUnitsForEditor:" << exception.what(); } }
void ClangCodeModelServer::requestDocumentAnnotations(const RequestDocumentAnnotationsMessage &message) { TIME_SCOPE_DURATION("ClangCodeModelServer::requestDocumentAnnotations"); try { auto translationUnit = translationUnits.translationUnit(message.fileContainer().filePath(), message.fileContainer().projectPartId()); client()->documentAnnotationsChanged(DocumentAnnotationsChangedMessage(translationUnit.fileContainer(), translationUnit.mainFileDiagnostics(), translationUnit.highlightingMarks().toHighlightingMarksContainers(), translationUnit.skippedSourceRanges().toSourceRangeContainers())); } catch (const TranslationUnitDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); } catch (const std::exception &exception) { qWarning() << "Error in ClangCodeModelServer::requestDocumentAnnotations:" << exception.what(); } }