From 7fe65851d99465d8bd9506ba53d8772381666111 Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Wed, 30 Jan 2019 13:59:30 +0100 Subject: Clang: Extend ClangTool and CommandLineBuilder We now support source file and not only header files and the file path is now automatically added to the end. This removes quite some clutter. Change-Id: I74eabd262e6c7e5f4d523e3a3cd194bd3efe1ef3 Reviewed-by: Ivan Donchevskii --- src/tools/clangrefactoringbackend/source/symbolindexer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/tools/clangrefactoringbackend/source/symbolindexer.cpp') diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index 2ee454eadb..d3d0f4a505 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -107,6 +107,7 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart) using Builder = CommandLineBuilder; Builder commandLineBuilder{projectPart, projectPart.toolChainArguments, + InputFileType::Source, {}, {}, optionalProjectPartPch @@ -181,8 +182,8 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId, auto pchPath = optionalProjectPartPch ? optionalProjectPartPch.value().pchPath : FilePath{}; - CommandLineBuilder builder{ - artefact, artefact.toolChainArguments, {}, {}, pchPath}; + CommandLineBuilder + builder{artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath}; auto indexing = [projectPartId = artefact.projectPartId, arguments=builder.commandLine, filePathId, this]( SymbolsCollectorInterface &symbolsCollector) { -- cgit v1.2.1 From 97ec6b9ad2bb6859516928db0f98b740d8f72590 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 7 Feb 2019 12:20:51 +0100 Subject: ClangRefactoring: Don't update the database if something went wrong We can get an compile error. In that case we should not update the database. In the future we should have a mechanism to report about the database state. Task-number: QTCREATORBUG-21949 Change-Id: I203346d536b007171f7bf255047409431c44a85a Reviewed-by: Ivan Donchevskii --- .../source/symbolindexer.cpp | 57 +++++++++++++--------- 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'src/tools/clangrefactoringbackend/source/symbolindexer.cpp') diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index d3d0f4a505..2b4e90cf5a 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -117,27 +117,32 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart) std::vector symbolIndexerTask; symbolIndexerTask.reserve(projectPart.sourcePathIds.size()); for (FilePathId sourcePathId : projectPart.sourcePathIds) { - auto indexing = [projectPartId, arguments = commandLineBuilder.commandLine, sourcePathId, this]( - SymbolsCollectorInterface &symbolsCollector) { + auto indexing = [projectPartId, + arguments = commandLineBuilder.commandLine, + sourcePathId, + this](SymbolsCollectorInterface &symbolsCollector) { symbolsCollector.setFile(sourcePathId, arguments); - symbolsCollector.collectSymbols(); + bool success = symbolsCollector.collectSymbols(); - Sqlite::ImmediateTransaction transaction{m_transactionInterface}; + if (success) { + Sqlite::ImmediateTransaction transaction{m_transactionInterface}; - m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(), - symbolsCollector.sourceLocations()); + m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(), + symbolsCollector.sourceLocations()); - m_symbolStorage.updateProjectPartSources(projectPartId, symbolsCollector.sourceFiles()); + m_symbolStorage.updateProjectPartSources(projectPartId, + symbolsCollector.sourceFiles()); - m_buildDependencyStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros()); + m_buildDependencyStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros()); - m_buildDependencyStorage.insertFileStatuses(symbolsCollector.fileStatuses()); + m_buildDependencyStorage.insertFileStatuses(symbolsCollector.fileStatuses()); - m_buildDependencyStorage.insertOrUpdateSourceDependencies( - symbolsCollector.sourceDependencies()); + m_buildDependencyStorage.insertOrUpdateSourceDependencies( + symbolsCollector.sourceDependencies()); - transaction.commit(); + transaction.commit(); + } }; symbolIndexerTask.emplace_back(sourcePathId, projectPartId, std::move(indexing)); @@ -185,27 +190,31 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId, CommandLineBuilder builder{artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath}; - auto indexing = [projectPartId = artefact.projectPartId, arguments=builder.commandLine, filePathId, this]( - SymbolsCollectorInterface &symbolsCollector) { + auto indexing = [projectPartId = artefact.projectPartId, + arguments = builder.commandLine, + filePathId, + this](SymbolsCollectorInterface &symbolsCollector) { symbolsCollector.setFile(filePathId, arguments); - symbolsCollector.collectSymbols(); + bool success = symbolsCollector.collectSymbols(); - Sqlite::ImmediateTransaction transaction{m_transactionInterface}; + if (success) { + Sqlite::ImmediateTransaction transaction{m_transactionInterface}; - m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(), - symbolsCollector.sourceLocations()); + m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(), + symbolsCollector.sourceLocations()); - m_symbolStorage.updateProjectPartSources(projectPartId, symbolsCollector.sourceFiles()); + m_symbolStorage.updateProjectPartSources(projectPartId, symbolsCollector.sourceFiles()); - m_buildDependencyStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros()); + m_buildDependencyStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros()); - m_buildDependencyStorage.insertFileStatuses(symbolsCollector.fileStatuses()); + m_buildDependencyStorage.insertFileStatuses(symbolsCollector.fileStatuses()); - m_buildDependencyStorage.insertOrUpdateSourceDependencies( - symbolsCollector.sourceDependencies()); + m_buildDependencyStorage.insertOrUpdateSourceDependencies( + symbolsCollector.sourceDependencies()); - transaction.commit(); + transaction.commit(); + } }; symbolIndexerTask.emplace_back(filePathId, optionalArtefact->projectPartId, std::move(indexing)); -- cgit v1.2.1