forked from qt-creator/qt-creator
		
	Clang: Split symbol storage
We need UsedMacros and source related statements in the PCH manager too, so we have to split that class. Task-number: QTCREATORBUG-21289 Change-Id: Ie27d4b518b3d6d9174e93fcb243fdb55a09ddf51 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
		@@ -9,7 +9,6 @@ HEADERS += \
 | 
			
		||||
    $$PWD/symbolscollectorinterface.h \
 | 
			
		||||
    $$PWD/symbolstorageinterface.h \
 | 
			
		||||
    $$PWD/symbolstorage.h \
 | 
			
		||||
    $$PWD/storagesqlitestatementfactory.h \
 | 
			
		||||
    $$PWD/symbolindexing.h \
 | 
			
		||||
    $$PWD/symbolindexinginterface.h \
 | 
			
		||||
    $$PWD/collectmacrospreprocessorcallbacks.h \
 | 
			
		||||
 
 | 
			
		||||
@@ -1,237 +0,0 @@
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
**
 | 
			
		||||
** Copyright (C) 2017 The Qt Company Ltd.
 | 
			
		||||
** Contact: https://www.qt.io/licensing/
 | 
			
		||||
**
 | 
			
		||||
** This file is part of Qt Creator.
 | 
			
		||||
**
 | 
			
		||||
** Commercial License Usage
 | 
			
		||||
** Licensees holding valid commercial Qt licenses may use this file in
 | 
			
		||||
** accordance with the commercial license agreement provided with the
 | 
			
		||||
** Software or, alternatively, in accordance with the terms contained in
 | 
			
		||||
** a written agreement between you and The Qt Company. For licensing terms
 | 
			
		||||
** and conditions see https://www.qt.io/terms-conditions. For further
 | 
			
		||||
** information use the contact form at https://www.qt.io/contact-us.
 | 
			
		||||
**
 | 
			
		||||
** GNU General Public License Usage
 | 
			
		||||
** Alternatively, this file may be used under the terms of the GNU
 | 
			
		||||
** General Public License version 3 as published by the Free Software
 | 
			
		||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
 | 
			
		||||
** included in the packaging of this file. Please review the following
 | 
			
		||||
** information to ensure the GNU General Public License requirements will
 | 
			
		||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
 | 
			
		||||
**
 | 
			
		||||
****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <sqlitetransaction.h>
 | 
			
		||||
#include <sqlitetable.h>
 | 
			
		||||
 | 
			
		||||
namespace ClangBackEnd {
 | 
			
		||||
 | 
			
		||||
template<typename DatabaseType>
 | 
			
		||||
class StorageSqliteStatementFactory
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    using Database = DatabaseType;
 | 
			
		||||
    using ReadStatement = typename Database::ReadStatement;
 | 
			
		||||
    using WriteStatement = typename Database::WriteStatement;
 | 
			
		||||
 | 
			
		||||
    StorageSqliteStatementFactory(Database &database)
 | 
			
		||||
        : transaction(database),
 | 
			
		||||
          database(database)
 | 
			
		||||
    {
 | 
			
		||||
        transaction.commit();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Sqlite::Table createNewSymbolsTable() const
 | 
			
		||||
    {
 | 
			
		||||
        Sqlite::Table table;
 | 
			
		||||
        table.setName("newSymbols");
 | 
			
		||||
        table.setUseTemporaryTable(true);
 | 
			
		||||
        table.addColumn("temporarySymbolId", Sqlite::ColumnType::Integer, Sqlite::Contraint::PrimaryKey);
 | 
			
		||||
        const Sqlite::Column &symbolIdColumn = table.addColumn("symbolId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column &usrColumn = table.addColumn("usr", Sqlite::ColumnType::Text);
 | 
			
		||||
        const Sqlite::Column &symbolNameColumn = table.addColumn("symbolName", Sqlite::ColumnType::Text);
 | 
			
		||||
        table.addColumn("symbolKind", Sqlite::ColumnType::Integer);
 | 
			
		||||
        table.addIndex({usrColumn, symbolNameColumn});
 | 
			
		||||
        table.addIndex({symbolIdColumn});
 | 
			
		||||
 | 
			
		||||
        table.initialize(database);
 | 
			
		||||
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Sqlite::Table createNewLocationsTable() const
 | 
			
		||||
    {
 | 
			
		||||
        Sqlite::Table table;
 | 
			
		||||
        table.setName("newLocations");
 | 
			
		||||
        table.setUseTemporaryTable(true);
 | 
			
		||||
        table.addColumn("temporarySymbolId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        table.addColumn("symbolId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column &sourceIdColumn = table.addColumn("sourceId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column &lineColumn = table.addColumn("line", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column &columnColumn = table.addColumn("column", Sqlite::ColumnType::Integer);
 | 
			
		||||
        table.addColumn("locationKind", Sqlite::ColumnType::Integer);
 | 
			
		||||
        table.addUniqueIndex({sourceIdColumn, lineColumn, columnColumn});
 | 
			
		||||
 | 
			
		||||
        table.initialize(database);
 | 
			
		||||
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Sqlite::Table createNewUsedMacrosTable() const
 | 
			
		||||
    {
 | 
			
		||||
        Sqlite::Table table;
 | 
			
		||||
        table.setName("newUsedMacros");
 | 
			
		||||
        table.setUseTemporaryTable(true);
 | 
			
		||||
        const Sqlite::Column &sourceIdColumn = table.addColumn("sourceId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column ¯oNameColumn = table.addColumn("macroName", Sqlite::ColumnType::Text);
 | 
			
		||||
        table.addIndex({sourceIdColumn, macroNameColumn});
 | 
			
		||||
 | 
			
		||||
        table.initialize(database);
 | 
			
		||||
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Sqlite::Table createNewSourceDependenciesTable() const
 | 
			
		||||
    {
 | 
			
		||||
        Sqlite::Table table;
 | 
			
		||||
        table.setName("newSourceDependencies");
 | 
			
		||||
        table.setUseTemporaryTable(true);
 | 
			
		||||
        const Sqlite::Column &sourceIdColumn = table.addColumn("sourceId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column &dependencySourceIdColumn = table.addColumn("dependencySourceId", Sqlite::ColumnType::Text);
 | 
			
		||||
        table.addIndex({sourceIdColumn, dependencySourceIdColumn});
 | 
			
		||||
 | 
			
		||||
        table.initialize(database);
 | 
			
		||||
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    Sqlite::ImmediateNonThrowingDestructorTransaction transaction;
 | 
			
		||||
    Database &database;
 | 
			
		||||
    Sqlite::Table newSymbolsTablet{createNewSymbolsTable()};
 | 
			
		||||
    Sqlite::Table newLocationsTable{createNewLocationsTable()};
 | 
			
		||||
    Sqlite::Table newUsedMacroTable{createNewUsedMacrosTable()};
 | 
			
		||||
    Sqlite::Table newNewSourceDependenciesTable{createNewSourceDependenciesTable()};
 | 
			
		||||
    WriteStatement insertSymbolsToNewSymbolsStatement{
 | 
			
		||||
        "INSERT INTO newSymbols(temporarySymbolId, usr, symbolName, symbolKind) VALUES(?,?,?,?)",
 | 
			
		||||
        database};
 | 
			
		||||
    WriteStatement insertLocationsToNewLocationsStatement{
 | 
			
		||||
        "INSERT OR IGNORE INTO newLocations(temporarySymbolId, line, column, sourceId, locationKind) VALUES(?,?,?,?,?)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    ReadStatement selectNewSourceIdsStatement{
 | 
			
		||||
        "SELECT DISTINCT sourceId FROM newLocations WHERE NOT EXISTS (SELECT sourceId FROM sources WHERE newLocations.sourceId == sources.sourceId)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement addNewSymbolsToSymbolsStatement{
 | 
			
		||||
        "INSERT INTO symbols(usr, symbolName, symbolKind) "
 | 
			
		||||
        "SELECT usr, symbolName, symbolKind FROM newSymbols WHERE NOT EXISTS "
 | 
			
		||||
        "(SELECT usr FROM symbols WHERE symbols.usr == newSymbols.usr)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement syncNewSymbolsFromSymbolsStatement{
 | 
			
		||||
        "UPDATE newSymbols SET symbolId = (SELECT symbolId FROM symbols WHERE newSymbols.usr = symbols.usr)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement syncSymbolsIntoNewLocationsStatement{
 | 
			
		||||
        "UPDATE newLocations SET symbolId = (SELECT symbolId FROM newSymbols WHERE newSymbols.temporarySymbolId = newLocations.temporarySymbolId)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement deleteAllLocationsFromUpdatedFilesStatement{
 | 
			
		||||
        "DELETE FROM locations WHERE sourceId IN (SELECT DISTINCT sourceId FROM newLocations)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement insertNewLocationsInLocationsStatement{
 | 
			
		||||
        "INSERT INTO locations(symbolId, line, column, sourceId, locationKind) SELECT symbolId, line, column, sourceId, locationKind FROM newLocations",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement deleteNewSymbolsTableStatement{
 | 
			
		||||
        "DELETE FROM newSymbols",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement deleteNewLocationsTableStatement{
 | 
			
		||||
        "DELETE FROM newLocations",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement insertProjectPartStatement{
 | 
			
		||||
        "INSERT OR IGNORE INTO projectParts(projectPartName, compilerArguments, compilerMacros, includeSearchPaths) VALUES (?,?,?,?)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement updateProjectPartStatement{
 | 
			
		||||
        "UPDATE projectParts SET compilerArguments = ?, compilerMacros = ?, includeSearchPaths = ? WHERE projectPartName = ?",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    ReadStatement getProjectPartIdStatement{
 | 
			
		||||
        "SELECT projectPartId FROM projectParts WHERE projectPartName = ?",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement deleteAllProjectPartsSourcesWithProjectPartIdStatement{
 | 
			
		||||
        "DELETE FROM projectPartsSources WHERE projectPartId = ?",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement insertProjectPartSourcesStatement{
 | 
			
		||||
        "INSERT INTO projectPartsSources(projectPartId, sourceId) VALUES (?,?)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
   ReadStatement getCompileArgumentsForFileIdStatement{
 | 
			
		||||
        "SELECT compilerArguments FROM projectParts WHERE projectPartId = (SELECT projectPartId FROM projectPartsSources WHERE sourceId = ?)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
   WriteStatement insertIntoNewUsedMacrosStatement{
 | 
			
		||||
       "INSERT INTO newUsedMacros(sourceId, macroName) VALUES (?,?)",
 | 
			
		||||
       database
 | 
			
		||||
   };
 | 
			
		||||
   WriteStatement syncNewUsedMacrosStatement{
 | 
			
		||||
        "INSERT INTO usedMacros(sourceId, macroName) SELECT sourceId, macroName FROM newUsedMacros WHERE NOT EXISTS (SELECT sourceId FROM usedMacros WHERE usedMacros.sourceId == newUsedMacros.sourceId AND usedMacros.macroName == newUsedMacros.macroName)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
   WriteStatement deleteOutdatedUsedMacrosStatement{
 | 
			
		||||
        "DELETE FROM usedMacros WHERE sourceId IN (SELECT sourceId FROM newUsedMacros) AND NOT EXISTS (SELECT sourceId FROM newUsedMacros WHERE newUsedMacros.sourceId == usedMacros.sourceId AND newUsedMacros.macroName == usedMacros.macroName)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
   WriteStatement deleteNewUsedMacrosTableStatement{
 | 
			
		||||
        "DELETE FROM newUsedMacros",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
   WriteStatement insertFileStatuses{
 | 
			
		||||
        "INSERT OR REPLACE INTO fileStatuses(sourceId, size, lastModified, isInPrecompiledHeader) VALUES (?,?,?,?)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
   WriteStatement insertIntoNewSourceDependenciesStatement{
 | 
			
		||||
       "INSERT INTO newSourceDependencies(sourceId, dependencySourceId) VALUES (?,?)",
 | 
			
		||||
       database
 | 
			
		||||
   };
 | 
			
		||||
   WriteStatement syncNewSourceDependenciesStatement{
 | 
			
		||||
        "INSERT INTO sourceDependencies(sourceId, dependencySourceId) SELECT sourceId, dependencySourceId FROM newSourceDependencies WHERE NOT EXISTS (SELECT sourceId FROM sourceDependencies WHERE sourceDependencies.sourceId == newSourceDependencies.sourceId AND sourceDependencies.dependencySourceId == newSourceDependencies.dependencySourceId)",
 | 
			
		||||
        database
 | 
			
		||||
    };
 | 
			
		||||
   WriteStatement deleteOutdatedSourceDependenciesStatement{
 | 
			
		||||
       "DELETE FROM sourceDependencies WHERE sourceId IN (SELECT sourceId FROM newSourceDependencies) AND NOT EXISTS (SELECT sourceId FROM newSourceDependencies WHERE newSourceDependencies.sourceId == sourceDependencies.sourceId AND newSourceDependencies.dependencySourceId == sourceDependencies.dependencySourceId)",
 | 
			
		||||
       database
 | 
			
		||||
   };
 | 
			
		||||
   WriteStatement deleteNewSourceDependenciesStatement{
 | 
			
		||||
       "DELETE FROM newSourceDependencies",
 | 
			
		||||
       database
 | 
			
		||||
   };
 | 
			
		||||
   ReadStatement getProjectPartArtefactsBySourceId{
 | 
			
		||||
       "SELECT compilerArguments, compilerMacros, includeSearchPaths, projectPartId FROM projectParts WHERE projectPartId = (SELECT projectPartId FROM projectPartsSources WHERE sourceId = ?)",
 | 
			
		||||
       database
 | 
			
		||||
   };
 | 
			
		||||
   ReadStatement getProjectPartArtefactsByProjectPartName{
 | 
			
		||||
       "SELECT compilerArguments, compilerMacros, includeSearchPaths, projectPartId FROM projectParts WHERE projectPartName = ?",
 | 
			
		||||
       database
 | 
			
		||||
   };
 | 
			
		||||
   ReadStatement getLowestLastModifiedTimeOfDependencies{
 | 
			
		||||
       "WITH RECURSIVE sourceIds(sourceId) AS (VALUES(?) UNION SELECT dependencySourceId FROM sourceDependencies, sourceIds WHERE sourceDependencies.sourceId = sourceIds.sourceId) SELECT min(lastModified) FROM fileStatuses, sourceIds WHERE fileStatuses.sourceId = sourceIds.sourceId",
 | 
			
		||||
       database
 | 
			
		||||
   };
 | 
			
		||||
   ReadStatement getPrecompiledHeader{
 | 
			
		||||
       "SELECT pchPath, pchBuildTime FROM precompiledHeaders WHERE projectPartId = ?",
 | 
			
		||||
       database
 | 
			
		||||
   };
 | 
			
		||||
};
 | 
			
		||||
} // namespace ClangBackEnd
 | 
			
		||||
@@ -58,12 +58,14 @@ private:
 | 
			
		||||
 | 
			
		||||
SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQueue,
 | 
			
		||||
                             SymbolStorageInterface &symbolStorage,
 | 
			
		||||
                             UsedMacroAndSourceStorageInterface &usedMacroAndSourceStorage,
 | 
			
		||||
                             ClangPathWatcherInterface &pathWatcher,
 | 
			
		||||
                             FilePathCachingInterface &filePathCache,
 | 
			
		||||
                             FileStatusCache &fileStatusCache,
 | 
			
		||||
                             Sqlite::TransactionInterface &transactionInterface)
 | 
			
		||||
    : m_symbolIndexerTaskQueue(symbolIndexerTaskQueue),
 | 
			
		||||
      m_symbolStorage(symbolStorage),
 | 
			
		||||
      m_usedMacroAndSourceStorage(usedMacroAndSourceStorage),
 | 
			
		||||
      m_pathWatcher(pathWatcher),
 | 
			
		||||
      m_filePathCache(filePathCache),
 | 
			
		||||
      m_fileStatusCache(fileStatusCache),
 | 
			
		||||
@@ -115,11 +117,11 @@ void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart)
 | 
			
		||||
            m_symbolStorage.updateProjectPartSources(projectPartId,
 | 
			
		||||
                                                     symbolsCollector.sourceFiles());
 | 
			
		||||
 | 
			
		||||
            m_symbolStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros());
 | 
			
		||||
            m_usedMacroAndSourceStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros());
 | 
			
		||||
 | 
			
		||||
            m_symbolStorage.insertFileStatuses(symbolsCollector.fileStatuses());
 | 
			
		||||
            m_usedMacroAndSourceStorage.insertFileStatuses(symbolsCollector.fileStatuses());
 | 
			
		||||
 | 
			
		||||
            m_symbolStorage.insertOrUpdateSourceDependencies(symbolsCollector.sourceDependencies());
 | 
			
		||||
            m_usedMacroAndSourceStorage.insertOrUpdateSourceDependencies(symbolsCollector.sourceDependencies());
 | 
			
		||||
 | 
			
		||||
            transaction.commit();
 | 
			
		||||
        };
 | 
			
		||||
@@ -180,11 +182,11 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
 | 
			
		||||
 | 
			
		||||
            m_symbolStorage.updateProjectPartSources(projectPartId, symbolsCollector.sourceFiles());
 | 
			
		||||
 | 
			
		||||
            m_symbolStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros());
 | 
			
		||||
            m_usedMacroAndSourceStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros());
 | 
			
		||||
 | 
			
		||||
            m_symbolStorage.insertFileStatuses(symbolsCollector.fileStatuses());
 | 
			
		||||
            m_usedMacroAndSourceStorage.insertFileStatuses(symbolsCollector.fileStatuses());
 | 
			
		||||
 | 
			
		||||
            m_symbolStorage.insertOrUpdateSourceDependencies(symbolsCollector.sourceDependencies());
 | 
			
		||||
            m_usedMacroAndSourceStorage.insertOrUpdateSourceDependencies(symbolsCollector.sourceDependencies());
 | 
			
		||||
 | 
			
		||||
            transaction.commit();
 | 
			
		||||
        };
 | 
			
		||||
@@ -212,7 +214,7 @@ FilePathIds SymbolIndexer::filterChangedFiles(const V2::ProjectPartContainer &pr
 | 
			
		||||
    ids.reserve(projectPart.sourcePathIds.size());
 | 
			
		||||
 | 
			
		||||
    for (const FilePathId &sourceId : projectPart.sourcePathIds) {
 | 
			
		||||
        long long oldLastModified = m_symbolStorage.fetchLowestLastModifiedTime(sourceId);
 | 
			
		||||
        long long oldLastModified = m_usedMacroAndSourceStorage.fetchLowestLastModifiedTime(sourceId);
 | 
			
		||||
        long long currentLastModified =  m_fileStatusCache.lastModifiedTime(sourceId);
 | 
			
		||||
        if (oldLastModified < currentLastModified)
 | 
			
		||||
            ids.push_back(sourceId);
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@
 | 
			
		||||
#include "filestatuscache.h"
 | 
			
		||||
#include "symbolindexertaskqueueinterface.h"
 | 
			
		||||
#include "symbolstorageinterface.h"
 | 
			
		||||
#include "usedmacroandsourcestorageinterface.h"
 | 
			
		||||
#include "clangpathwatcher.h"
 | 
			
		||||
 | 
			
		||||
#include <projectpartcontainerv2.h>
 | 
			
		||||
@@ -42,6 +43,7 @@ class SymbolIndexer final : public ClangPathWatcherNotifier
 | 
			
		||||
public:
 | 
			
		||||
    SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQueue,
 | 
			
		||||
                  SymbolStorageInterface &symbolStorage,
 | 
			
		||||
                  UsedMacroAndSourceStorageInterface &usedMacroAndSourceStorage,
 | 
			
		||||
                  ClangPathWatcherInterface &pathWatcher,
 | 
			
		||||
                  FilePathCachingInterface &filePathCache,
 | 
			
		||||
                  FileStatusCache &fileStatusCache,
 | 
			
		||||
@@ -71,6 +73,7 @@ public:
 | 
			
		||||
private:
 | 
			
		||||
    SymbolIndexerTaskQueueInterface &m_symbolIndexerTaskQueue;
 | 
			
		||||
    SymbolStorageInterface &m_symbolStorage;
 | 
			
		||||
    UsedMacroAndSourceStorageInterface &m_usedMacroAndSourceStorage;
 | 
			
		||||
    ClangPathWatcherInterface &m_pathWatcher;
 | 
			
		||||
    FilePathCachingInterface &m_filePathCache;
 | 
			
		||||
    FileStatusCache &m_fileStatusCache;
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,6 @@
 | 
			
		||||
 | 
			
		||||
#include "symbolindexinginterface.h"
 | 
			
		||||
 | 
			
		||||
#include "storagesqlitestatementfactory.h"
 | 
			
		||||
#include "symbolindexer.h"
 | 
			
		||||
#include "symbolscollector.h"
 | 
			
		||||
#include "processormanager.h"
 | 
			
		||||
@@ -35,6 +34,8 @@
 | 
			
		||||
#include "taskscheduler.h"
 | 
			
		||||
#include "symbolstorage.h"
 | 
			
		||||
 | 
			
		||||
#include <usedmacroandsourcestorage.h>
 | 
			
		||||
 | 
			
		||||
#include <refactoringdatabaseinitializer.h>
 | 
			
		||||
#include <filepathcachingfwd.h>
 | 
			
		||||
 | 
			
		||||
@@ -73,13 +74,14 @@ private:
 | 
			
		||||
class SymbolIndexing final : public SymbolIndexingInterface
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    using StatementFactory = ClangBackEnd::StorageSqliteStatementFactory<Sqlite::Database>;
 | 
			
		||||
    using Storage = ClangBackEnd::SymbolStorage<StatementFactory>;
 | 
			
		||||
    using UsedMacroAndSourceStorage = ClangBackEnd::UsedMacroAndSourceStorage<Sqlite::Database>;
 | 
			
		||||
    using SymbolStorage = ClangBackEnd::SymbolStorage<Sqlite::Database>;
 | 
			
		||||
    SymbolIndexing(Sqlite::Database &database,
 | 
			
		||||
                   FilePathCachingInterface &filePathCache,
 | 
			
		||||
                   const GeneratedFiles &generatedFiles)
 | 
			
		||||
        : m_filePathCache(filePathCache),
 | 
			
		||||
          m_statementFactory(database),
 | 
			
		||||
          m_usedMacroAndSourceStorage(database),
 | 
			
		||||
          m_symbolStorage(database),
 | 
			
		||||
          m_collectorManger(generatedFiles, database),
 | 
			
		||||
          m_indexerScheduler(m_collectorManger, m_indexerQueue, std::thread::hardware_concurrency())
 | 
			
		||||
    {
 | 
			
		||||
@@ -109,8 +111,8 @@ public:
 | 
			
		||||
private:
 | 
			
		||||
    using SymbolIndexerTaskScheduler = TaskScheduler<SymbolsCollectorManager, SymbolIndexerTask::Callable>;
 | 
			
		||||
    FilePathCachingInterface &m_filePathCache;
 | 
			
		||||
    StatementFactory m_statementFactory;
 | 
			
		||||
    Storage m_symbolStorage{m_statementFactory};
 | 
			
		||||
    UsedMacroAndSourceStorage m_usedMacroAndSourceStorage;
 | 
			
		||||
    SymbolStorage m_symbolStorage;
 | 
			
		||||
    ClangPathWatcher<QFileSystemWatcher, QTimer> m_sourceWatcher{m_filePathCache};
 | 
			
		||||
    FileStatusCache m_fileStatusCache{m_filePathCache};
 | 
			
		||||
    SymbolsCollectorManager m_collectorManger;
 | 
			
		||||
@@ -118,10 +120,11 @@ private:
 | 
			
		||||
    SymbolIndexerTaskQueue m_indexerQueue{m_indexerScheduler};
 | 
			
		||||
    SymbolIndexer m_indexer{m_indexerQueue,
 | 
			
		||||
                            m_symbolStorage,
 | 
			
		||||
                            m_usedMacroAndSourceStorage,
 | 
			
		||||
                            m_sourceWatcher,
 | 
			
		||||
                            m_filePathCache,
 | 
			
		||||
                            m_fileStatusCache,
 | 
			
		||||
                            m_statementFactory.database};
 | 
			
		||||
                            m_symbolStorage.m_database};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace ClangBackEnd
 | 
			
		||||
 
 | 
			
		||||
@@ -27,9 +27,10 @@
 | 
			
		||||
 | 
			
		||||
#include "symbolstorageinterface.h"
 | 
			
		||||
 | 
			
		||||
#include <filepathcachingfwd.h>
 | 
			
		||||
#include <sqliteexception.h>
 | 
			
		||||
#include <sqlitetransaction.h>
 | 
			
		||||
#include <filepathcachingfwd.h>
 | 
			
		||||
#include <sqlitetable.h>
 | 
			
		||||
 | 
			
		||||
#include <QJsonArray>
 | 
			
		||||
#include <QJsonDocument>
 | 
			
		||||
@@ -37,17 +38,19 @@
 | 
			
		||||
 | 
			
		||||
namespace ClangBackEnd {
 | 
			
		||||
 | 
			
		||||
template <typename StatementFactory>
 | 
			
		||||
template <typename DatabaseType>
 | 
			
		||||
class SymbolStorage final : public SymbolStorageInterface
 | 
			
		||||
{
 | 
			
		||||
    using ReadStatement = typename StatementFactory::ReadStatement;
 | 
			
		||||
    using WriteStatement = typename StatementFactory::WriteStatement;
 | 
			
		||||
    using Database = typename StatementFactory::Database;
 | 
			
		||||
    using Database = DatabaseType;
 | 
			
		||||
    using ReadStatement = typename Database::ReadStatement;
 | 
			
		||||
    using WriteStatement = typename Database::WriteStatement;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    SymbolStorage(StatementFactory &statementFactory)
 | 
			
		||||
        : m_statementFactory(statementFactory)
 | 
			
		||||
    SymbolStorage(Database &database)
 | 
			
		||||
        : m_transaction(database),
 | 
			
		||||
          m_database(database)
 | 
			
		||||
    {
 | 
			
		||||
        m_transaction.commit();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void addSymbolsAndSourceLocations(const SymbolEntries &symbolEntries,
 | 
			
		||||
@@ -69,95 +72,54 @@ public:
 | 
			
		||||
                                   const CompilerMacros &compilerMacros,
 | 
			
		||||
                                   const Utils::SmallStringVector &includeSearchPaths) override
 | 
			
		||||
    {
 | 
			
		||||
        m_statementFactory.database.setLastInsertedRowId(-1);
 | 
			
		||||
        m_database.setLastInsertedRowId(-1);
 | 
			
		||||
 | 
			
		||||
        Utils::SmallString compilerArguementsAsJson = toJson(commandLineArguments);
 | 
			
		||||
        Utils::SmallString compilerMacrosAsJson = toJson(compilerMacros);
 | 
			
		||||
        Utils::SmallString includeSearchPathsAsJason = toJson(includeSearchPaths);
 | 
			
		||||
 | 
			
		||||
        WriteStatement &insertStatement = m_statementFactory.insertProjectPartStatement;
 | 
			
		||||
        WriteStatement &insertStatement = m_insertProjectPartStatement;
 | 
			
		||||
        insertStatement.write(projectPartName,
 | 
			
		||||
                              compilerArguementsAsJson,
 | 
			
		||||
                              compilerMacrosAsJson,
 | 
			
		||||
                              includeSearchPathsAsJason);
 | 
			
		||||
 | 
			
		||||
        if (m_statementFactory.database.lastInsertedRowId() == -1) {
 | 
			
		||||
            WriteStatement &updateStatement = m_statementFactory.updateProjectPartStatement;
 | 
			
		||||
        if (m_database.lastInsertedRowId() == -1) {
 | 
			
		||||
            WriteStatement &updateStatement = m_updateProjectPartStatement;
 | 
			
		||||
            updateStatement.write(compilerArguementsAsJson,
 | 
			
		||||
                                  compilerMacrosAsJson,
 | 
			
		||||
                                  includeSearchPathsAsJason,
 | 
			
		||||
                                  projectPartName);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return int(m_statementFactory.database.lastInsertedRowId());
 | 
			
		||||
        return int(m_database.lastInsertedRowId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(FilePathId sourceId) const override
 | 
			
		||||
    {
 | 
			
		||||
        ReadStatement &statement = m_statementFactory.getProjectPartArtefactsBySourceId;
 | 
			
		||||
        ReadStatement &statement = m_getProjectPartArtefactsBySourceId;
 | 
			
		||||
 | 
			
		||||
        return statement.template value<ProjectPartArtefact, 4>(sourceId.filePathId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(Utils::SmallStringView projectPartName) const override
 | 
			
		||||
    {
 | 
			
		||||
        ReadStatement &statement = m_statementFactory.getProjectPartArtefactsByProjectPartName;
 | 
			
		||||
        ReadStatement &statement = m_getProjectPartArtefactsByProjectPartName;
 | 
			
		||||
 | 
			
		||||
        return statement.template value<ProjectPartArtefact, 4>(projectPartName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    long long fetchLowestLastModifiedTime(FilePathId sourceId) const override
 | 
			
		||||
    {
 | 
			
		||||
        ReadStatement &statement = m_statementFactory.getLowestLastModifiedTimeOfDependencies;
 | 
			
		||||
 | 
			
		||||
        return statement.template value<long long>(sourceId.filePathId).value_or(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void insertOrUpdateUsedMacros(const UsedMacros &usedMacros) override
 | 
			
		||||
    {
 | 
			
		||||
        WriteStatement &insertStatement = m_statementFactory.insertIntoNewUsedMacrosStatement;
 | 
			
		||||
        for (const UsedMacro &usedMacro : usedMacros)
 | 
			
		||||
            insertStatement.write(usedMacro.filePathId.filePathId, usedMacro.macroName);
 | 
			
		||||
 | 
			
		||||
        m_statementFactory.syncNewUsedMacrosStatement.execute();
 | 
			
		||||
        m_statementFactory.deleteOutdatedUsedMacrosStatement.execute();
 | 
			
		||||
        m_statementFactory.deleteNewUsedMacrosTableStatement.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void insertOrUpdateSourceDependencies(const SourceDependencies &sourceDependencies) override
 | 
			
		||||
    {
 | 
			
		||||
        WriteStatement &insertStatement = m_statementFactory.insertIntoNewSourceDependenciesStatement;
 | 
			
		||||
        for (SourceDependency sourceDependency : sourceDependencies)
 | 
			
		||||
            insertStatement.write(sourceDependency.filePathId.filePathId,
 | 
			
		||||
                                  sourceDependency.dependencyFilePathId.filePathId);
 | 
			
		||||
 | 
			
		||||
        m_statementFactory.syncNewSourceDependenciesStatement.execute();
 | 
			
		||||
        m_statementFactory.deleteOutdatedSourceDependenciesStatement.execute();
 | 
			
		||||
        m_statementFactory.deleteNewSourceDependenciesStatement.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void updateProjectPartSources(int projectPartId,
 | 
			
		||||
                                  const FilePathIds &sourceFilePathIds) override
 | 
			
		||||
    {
 | 
			
		||||
        WriteStatement &deleteStatement = m_statementFactory.deleteAllProjectPartsSourcesWithProjectPartIdStatement;
 | 
			
		||||
        WriteStatement &deleteStatement = m_deleteAllProjectPartsSourcesWithProjectPartIdStatement;
 | 
			
		||||
        deleteStatement.write(projectPartId);
 | 
			
		||||
 | 
			
		||||
        WriteStatement &insertStatement = m_statementFactory.insertProjectPartSourcesStatement;
 | 
			
		||||
        WriteStatement &insertStatement = m_insertProjectPartSourcesStatement;
 | 
			
		||||
        for (const FilePathId &sourceFilePathId : sourceFilePathIds)
 | 
			
		||||
            insertStatement.write(projectPartId, sourceFilePathId.filePathId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void insertFileStatuses(const FileStatuses &fileStatuses)
 | 
			
		||||
    {
 | 
			
		||||
        WriteStatement &statement = m_statementFactory.insertFileStatuses;
 | 
			
		||||
 | 
			
		||||
        for (const FileStatus &fileStatus : fileStatuses)
 | 
			
		||||
            statement.write(fileStatus.filePathId.filePathId,
 | 
			
		||||
                            fileStatus.size,
 | 
			
		||||
                            fileStatus.lastModified,
 | 
			
		||||
                            fileStatus.isInPrecompiledHeader);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static Utils::SmallString toJson(const Utils::SmallStringVector &strings)
 | 
			
		||||
    {
 | 
			
		||||
        QJsonDocument document;
 | 
			
		||||
@@ -187,7 +149,7 @@ public:
 | 
			
		||||
 | 
			
		||||
    void fillTemporarySymbolsTable(const SymbolEntries &symbolEntries)
 | 
			
		||||
    {
 | 
			
		||||
        WriteStatement &statement = m_statementFactory.insertSymbolsToNewSymbolsStatement;
 | 
			
		||||
        WriteStatement &statement = m_insertSymbolsToNewSymbolsStatement;
 | 
			
		||||
 | 
			
		||||
        for (const auto &symbolEntry : symbolEntries) {
 | 
			
		||||
            statement.write(symbolEntry.first,
 | 
			
		||||
@@ -199,7 +161,7 @@ public:
 | 
			
		||||
 | 
			
		||||
    void fillTemporaryLocationsTable(const SourceLocationEntries &sourceLocations)
 | 
			
		||||
    {
 | 
			
		||||
        WriteStatement &statement = m_statementFactory.insertLocationsToNewLocationsStatement;
 | 
			
		||||
        WriteStatement &statement = m_insertLocationsToNewLocationsStatement;
 | 
			
		||||
 | 
			
		||||
        for (const auto &locationEntry : sourceLocations) {
 | 
			
		||||
            statement.write(locationEntry.symbolId,
 | 
			
		||||
@@ -212,42 +174,42 @@ public:
 | 
			
		||||
 | 
			
		||||
    void addNewSymbolsToSymbols()
 | 
			
		||||
    {
 | 
			
		||||
        m_statementFactory.addNewSymbolsToSymbolsStatement.execute();
 | 
			
		||||
        m_addNewSymbolsToSymbolsStatement.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void syncNewSymbolsFromSymbols()
 | 
			
		||||
    {
 | 
			
		||||
        m_statementFactory.syncNewSymbolsFromSymbolsStatement.execute();
 | 
			
		||||
        m_syncNewSymbolsFromSymbolsStatement.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void syncSymbolsIntoNewLocations()
 | 
			
		||||
    {
 | 
			
		||||
        m_statementFactory.syncSymbolsIntoNewLocationsStatement.execute();
 | 
			
		||||
        m_syncSymbolsIntoNewLocationsStatement.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deleteAllLocationsFromUpdatedFiles()
 | 
			
		||||
    {
 | 
			
		||||
        m_statementFactory.deleteAllLocationsFromUpdatedFilesStatement.execute();
 | 
			
		||||
        m_deleteAllLocationsFromUpdatedFilesStatement.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void insertNewLocationsInLocations()
 | 
			
		||||
    {
 | 
			
		||||
        m_statementFactory.insertNewLocationsInLocationsStatement.execute();
 | 
			
		||||
        m_insertNewLocationsInLocationsStatement.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deleteNewSymbolsTable()
 | 
			
		||||
    {
 | 
			
		||||
        m_statementFactory.deleteNewSymbolsTableStatement.execute();
 | 
			
		||||
        m_deleteNewSymbolsTableStatement.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deleteNewLocationsTable()
 | 
			
		||||
    {
 | 
			
		||||
        m_statementFactory.deleteNewLocationsTableStatement.execute();
 | 
			
		||||
        m_deleteNewLocationsTableStatement.execute();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Utils::optional<ProjectPartPch> fetchPrecompiledHeader(int projectPartId) const
 | 
			
		||||
    {
 | 
			
		||||
        return m_statementFactory.getPrecompiledHeader.template value<ProjectPartPch, 2>(projectPartId);
 | 
			
		||||
        return m_getPrecompiledHeader.template value<ProjectPartPch, 2>(projectPartId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SourceLocationEntries sourceLocations() const
 | 
			
		||||
@@ -255,8 +217,124 @@ public:
 | 
			
		||||
        return SourceLocationEntries();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    StatementFactory &m_statementFactory;
 | 
			
		||||
    Sqlite::Table createNewSymbolsTable() const
 | 
			
		||||
    {
 | 
			
		||||
        Sqlite::Table table;
 | 
			
		||||
        table.setName("newSymbols");
 | 
			
		||||
        table.setUseTemporaryTable(true);
 | 
			
		||||
        table.addColumn("temporarySymbolId", Sqlite::ColumnType::Integer, Sqlite::Contraint::PrimaryKey);
 | 
			
		||||
        const Sqlite::Column &symbolIdColumn = table.addColumn("symbolId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column &usrColumn = table.addColumn("usr", Sqlite::ColumnType::Text);
 | 
			
		||||
        const Sqlite::Column &symbolNameColumn = table.addColumn("symbolName", Sqlite::ColumnType::Text);
 | 
			
		||||
        table.addColumn("symbolKind", Sqlite::ColumnType::Integer);
 | 
			
		||||
        table.addIndex({usrColumn, symbolNameColumn});
 | 
			
		||||
        table.addIndex({symbolIdColumn});
 | 
			
		||||
 | 
			
		||||
        table.initialize(m_database);
 | 
			
		||||
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Sqlite::Table createNewLocationsTable() const
 | 
			
		||||
    {
 | 
			
		||||
        Sqlite::Table table;
 | 
			
		||||
        table.setName("newLocations");
 | 
			
		||||
        table.setUseTemporaryTable(true);
 | 
			
		||||
        table.addColumn("temporarySymbolId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        table.addColumn("symbolId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column &sourceIdColumn = table.addColumn("sourceId", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column &lineColumn = table.addColumn("line", Sqlite::ColumnType::Integer);
 | 
			
		||||
        const Sqlite::Column &columnColumn = table.addColumn("column", Sqlite::ColumnType::Integer);
 | 
			
		||||
        table.addColumn("locationKind", Sqlite::ColumnType::Integer);
 | 
			
		||||
        table.addUniqueIndex({sourceIdColumn, lineColumn, columnColumn});
 | 
			
		||||
 | 
			
		||||
        table.initialize(m_database);
 | 
			
		||||
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    Sqlite::ImmediateNonThrowingDestructorTransaction m_transaction;
 | 
			
		||||
    Database &m_database;
 | 
			
		||||
    Sqlite::Table newSymbolsTablet{createNewSymbolsTable()};
 | 
			
		||||
    Sqlite::Table newLocationsTable{createNewLocationsTable()};
 | 
			
		||||
    WriteStatement m_insertSymbolsToNewSymbolsStatement{
 | 
			
		||||
        "INSERT INTO newSymbols(temporarySymbolId, usr, symbolName, symbolKind) VALUES(?,?,?,?)",
 | 
			
		||||
        m_database};
 | 
			
		||||
    WriteStatement m_insertLocationsToNewLocationsStatement{
 | 
			
		||||
        "INSERT OR IGNORE INTO newLocations(temporarySymbolId, line, column, sourceId, locationKind) VALUES(?,?,?,?,?)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    ReadStatement m_selectNewSourceIdsStatement{
 | 
			
		||||
        "SELECT DISTINCT sourceId FROM newLocations WHERE NOT EXISTS (SELECT sourceId FROM sources WHERE newLocations.sourceId == sources.sourceId)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_addNewSymbolsToSymbolsStatement{
 | 
			
		||||
        "INSERT INTO symbols(usr, symbolName, symbolKind) "
 | 
			
		||||
        "SELECT usr, symbolName, symbolKind FROM newSymbols WHERE NOT EXISTS "
 | 
			
		||||
        "(SELECT usr FROM symbols WHERE symbols.usr == newSymbols.usr)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_syncNewSymbolsFromSymbolsStatement{
 | 
			
		||||
        "UPDATE newSymbols SET symbolId = (SELECT symbolId FROM symbols WHERE newSymbols.usr = symbols.usr)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_syncSymbolsIntoNewLocationsStatement{
 | 
			
		||||
        "UPDATE newLocations SET symbolId = (SELECT symbolId FROM newSymbols WHERE newSymbols.temporarySymbolId = newLocations.temporarySymbolId)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_deleteAllLocationsFromUpdatedFilesStatement{
 | 
			
		||||
        "DELETE FROM locations WHERE sourceId IN (SELECT DISTINCT sourceId FROM newLocations)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_insertNewLocationsInLocationsStatement{
 | 
			
		||||
        "INSERT INTO locations(symbolId, line, column, sourceId, locationKind) SELECT symbolId, line, column, sourceId, locationKind FROM newLocations",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_deleteNewSymbolsTableStatement{
 | 
			
		||||
        "DELETE FROM newSymbols",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_deleteNewLocationsTableStatement{
 | 
			
		||||
        "DELETE FROM newLocations",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_insertProjectPartStatement{
 | 
			
		||||
        "INSERT OR IGNORE INTO projectParts(projectPartName, compilerArguments, compilerMacros, includeSearchPaths) VALUES (?,?,?,?)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_updateProjectPartStatement{
 | 
			
		||||
        "UPDATE projectParts SET compilerArguments = ?, compilerMacros = ?, includeSearchPaths = ? WHERE projectPartName = ?",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    mutable ReadStatement m_getProjectPartIdStatement{
 | 
			
		||||
        "SELECT projectPartId FROM projectParts WHERE projectPartName = ?",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_deleteAllProjectPartsSourcesWithProjectPartIdStatement{
 | 
			
		||||
        "DELETE FROM projectPartsSources WHERE projectPartId = ?",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    WriteStatement m_insertProjectPartSourcesStatement{
 | 
			
		||||
        "INSERT INTO projectPartsSources(projectPartId, sourceId) VALUES (?,?)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    mutable ReadStatement m_getCompileArgumentsForFileIdStatement{
 | 
			
		||||
        "SELECT compilerArguments FROM projectParts WHERE projectPartId = (SELECT projectPartId FROM projectPartsSources WHERE sourceId = ?)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    mutable ReadStatement m_getProjectPartArtefactsBySourceId{
 | 
			
		||||
        "SELECT compilerArguments, compilerMacros, includeSearchPaths, projectPartId FROM projectParts WHERE projectPartId = (SELECT projectPartId FROM projectPartsSources WHERE sourceId = ?)",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    mutable ReadStatement m_getProjectPartArtefactsByProjectPartName{
 | 
			
		||||
        "SELECT compilerArguments, compilerMacros, includeSearchPaths, projectPartId FROM projectParts WHERE projectPartName = ?",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
    mutable ReadStatement m_getPrecompiledHeader{
 | 
			
		||||
        "SELECT pchPath, pchBuildTime FROM precompiledHeaders WHERE projectPartId = ?",
 | 
			
		||||
        m_database
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace ClangBackEnd
 | 
			
		||||
 
 | 
			
		||||
@@ -55,12 +55,8 @@ public:
 | 
			
		||||
                                          const Utils::SmallStringVector &includeSearchPaths) = 0;
 | 
			
		||||
    virtual void updateProjectPartSources(int projectPartId,
 | 
			
		||||
                                          const FilePathIds &sourceFilePathIds) = 0;
 | 
			
		||||
    virtual void insertOrUpdateUsedMacros(const UsedMacros &usedMacros) = 0;
 | 
			
		||||
    virtual void insertFileStatuses(const FileStatuses &fileStatuses) = 0;
 | 
			
		||||
    virtual void insertOrUpdateSourceDependencies(const SourceDependencies &sourceDependencies) = 0;
 | 
			
		||||
    virtual Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(FilePathId sourceId) const = 0;
 | 
			
		||||
    virtual Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(Utils::SmallStringView projectPartName) const = 0;
 | 
			
		||||
    virtual long long fetchLowestLastModifiedTime(FilePathId sourceId) const = 0;
 | 
			
		||||
    virtual Utils::optional<ProjectPartPch> fetchPrecompiledHeader(int projectPartId) const = 0;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user