ClangRefactoring: Remove file status collection

It is not needed anymore. If we need it again we can reintroduce it.

Change-Id: If8897ddb404daaf52b249ddd3763deb685c35fe5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2019-07-24 16:44:24 +02:00
parent cc78969bdb
commit 1e703a6901
11 changed files with 0 additions and 181 deletions

View File

@@ -32,7 +32,6 @@ SOURCES += \
$$PWD/collectsymbolsaction.cpp \
$$PWD/collectmacrossourcefilecallbacks.cpp \
$$PWD/symbolscollector.cpp \
$$PWD/filestatuspreprocessorcallbacks.cpp \
$$PWD/clangquerygatherer.cpp \
$$PWD/symbolindexing.cpp \
$$PWD/indexdataconsumer.cpp
@@ -51,7 +50,6 @@ HEADERS += \
$$PWD/symbolscollector.h \
$$PWD/symbolsvisitorbase.h \
$$PWD/indexdataconsumer.h \
$$PWD/filestatuspreprocessorcallbacks.h \
$$PWD/clangquerygatherer.h
}

View File

@@ -1,59 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 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.
**
****************************************************************************/
#include "filestatuspreprocessorcallbacks.h"
namespace ClangBackEnd {
void FileStatusPreprocessorCallbacks::FileChanged(clang::SourceLocation sourceLocation,
clang::PPCallbacks::FileChangeReason reason,
clang::SrcMgr::CharacteristicKind,
clang::FileID)
{
if (reason == clang::PPCallbacks::EnterFile) {
const clang::FileEntry *fileEntry = m_sourceManager->getFileEntryForID(
m_sourceManager->getFileID(sourceLocation));
if (fileEntry)
addFileStatus(fileEntry);
}
}
void FileStatusPreprocessorCallbacks::addFileStatus(const clang::FileEntry *fileEntry)
{
auto id = filePathId(fileEntry);
auto found = std::lower_bound(m_fileStatuses.begin(),
m_fileStatuses.end(),
id,
[](const auto &first, const auto &second) {
return first.filePathId < second;
});
if (found == m_fileStatuses.end() || found->filePathId != id) {
m_fileStatuses.emplace(found, id, fileEntry->getSize(), fileEntry->getModificationTime());
}
}
} // namespace ClangBackEnd

View File

@@ -1,59 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 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 "filestatus.h"
#include "symbolsvisitorbase.h"
#include <filepathid.h>
#include <clang/Lex/PPCallbacks.h>
namespace ClangBackEnd {
class FileStatusPreprocessorCallbacks final : public clang::PPCallbacks, public SymbolsVisitorBase
{
public:
FileStatusPreprocessorCallbacks(FileStatuses &fileStatuses,
const FilePathCachingInterface &filePathCache,
const clang::SourceManager *sourceManager,
FilePathIds &filePathIndices)
: SymbolsVisitorBase(filePathCache, sourceManager, filePathIndices)
, m_fileStatuses(fileStatuses)
{}
void FileChanged(clang::SourceLocation sourceLocation,
clang::PPCallbacks::FileChangeReason reason,
clang::SrcMgr::CharacteristicKind,
clang::FileID) override;
void addFileStatus(const clang::FileEntry *fileEntry);
private:
FileStatuses &m_fileStatuses;
};
} // namespace ClangBackEnd

View File

@@ -25,7 +25,6 @@
#include "indexdataconsumer.h"
#include "collectsymbolsaction.h"
#include "filestatuspreprocessorcallbacks.h"
#include <clang/AST/DeclVisitor.h>
#include <clang/Basic/SourceLocation.h>
@@ -119,12 +118,6 @@ bool IndexDataConsumer::isAlreadyParsed(clang::FileID fileId, SourcesManager &so
return sourcesManager.alreadyParsed(filePathId(fileEntry), fileEntry->getModificationTime());
}
void IndexDataConsumer::setPreprocessor(std::shared_ptr<clang::Preprocessor> preprocessor)
{
preprocessor->addPPCallbacks(std::make_unique<FileStatusPreprocessorCallbacks>(
m_fileStatuses, m_filePathCache, m_sourceManager, m_filePathIndices));
}
bool IndexDataConsumer::handleDeclOccurence(const clang::Decl *declaration,
clang::index::SymbolRoleSet symbolRoles,
llvm::ArrayRef<clang::index::SymbolRelation> /*symbolRelations*/,

View File

@@ -43,14 +43,12 @@ class IndexDataConsumer : public clang::index::IndexDataConsumer,
public:
IndexDataConsumer(SymbolEntries &symbolEntries,
SourceLocationEntries &sourceLocationEntries,
FileStatuses &fileStatuses,
FilePathCachingInterface &filePathCache,
SourcesManager &symbolSourcesManager,
SourcesManager &macroSourcesManager)
: SymbolsVisitorBase(filePathCache, nullptr, m_filePathIndices)
, m_symbolEntries(symbolEntries)
, m_sourceLocationEntries(sourceLocationEntries)
, m_fileStatuses(fileStatuses)
, m_symbolSourcesManager(symbolSourcesManager)
, m_macroSourcesManager(macroSourcesManager)
@@ -59,8 +57,6 @@ public:
IndexDataConsumer(const IndexDataConsumer &) = delete;
IndexDataConsumer &operator=(const IndexDataConsumer &) = delete;
void setPreprocessor(std::shared_ptr<clang::Preprocessor> preprocessor) override;
bool handleDeclOccurence(const clang::Decl *declaration,
clang::index::SymbolRoleSet symbolRoles,
llvm::ArrayRef<clang::index::SymbolRelation> symbolRelations,
@@ -82,7 +78,6 @@ private:
FilePathIds m_filePathIndices;
SymbolEntries &m_symbolEntries;
SourceLocationEntries &m_sourceLocationEntries;
FileStatuses &m_fileStatuses;
SourcesManager &m_symbolSourcesManager;
SourcesManager &m_macroSourcesManager;
};

View File

@@ -35,7 +35,6 @@ SymbolsCollector::SymbolsCollector(Sqlite::Database &database)
: m_filePathCache(database)
, m_indexDataConsumer(std::make_shared<IndexDataConsumer>(m_symbolEntries,
m_sourceLocationEntries,
m_fileStatuses,
m_filePathCache,
m_symbolSourcesManager,
m_macroSourcesManager))
@@ -63,7 +62,6 @@ void SymbolsCollector::clear()
{
m_symbolEntries.clear();
m_sourceLocationEntries.clear();
m_fileStatuses.clear();
m_clangTool = ClangTool();
}
@@ -150,11 +148,6 @@ const SourceLocationEntries &SymbolsCollector::sourceLocations() const
return m_sourceLocationEntries;
}
const FileStatuses &SymbolsCollector::fileStatuses() const
{
return m_fileStatuses;
}
bool SymbolsCollector::isUsed() const
{
return m_isUsed;

View File

@@ -58,7 +58,6 @@ public:
const SymbolEntries &symbols() const override;
const SourceLocationEntries &sourceLocations() const override;
const FileStatuses &fileStatuses() const override;
bool isUsed() const override;
void setIsUsed(bool isUsed) override;
@@ -70,7 +69,6 @@ private:
ClangTool m_clangTool;
SymbolEntries m_symbolEntries;
SourceLocationEntries m_sourceLocationEntries;
FileStatuses m_fileStatuses;
std::shared_ptr<IndexDataConsumer> m_indexDataConsumer;
CollectSymbolsAction m_collectSymbolsAction;
SourcesManager m_symbolSourcesManager;

View File

@@ -48,7 +48,6 @@ public:
virtual const SymbolEntries &symbols() const = 0;
virtual const SourceLocationEntries &sourceLocations() const = 0;
virtual const FileStatuses &fileStatuses() const = 0;
};
} // namespace ClangBackEnd

View File

@@ -74,9 +74,6 @@ public:
MOCK_CONST_METHOD0(usedMacros,
const ClangBackEnd::UsedMacros &());
MOCK_CONST_METHOD0(fileStatuses,
const ClangBackEnd::FileStatuses &());
MOCK_CONST_METHOD0(sourceDependencies,
const ClangBackEnd::SourceDependencies &());

View File

@@ -111,7 +111,6 @@ protected:
ON_CALL(mockCollector, sourceLocations()).WillByDefault(ReturnRef(sourceLocations));
ON_CALL(mockCollector, sourceFiles()).WillByDefault(ReturnRef(sourceFileIds));
ON_CALL(mockCollector, usedMacros()).WillByDefault(ReturnRef(usedMacros));
ON_CALL(mockCollector, fileStatuses()).WillByDefault(ReturnRef(fileStatus));
ON_CALL(mockCollector, sourceDependencies()).WillByDefault(ReturnRef(sourceDependencies));
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<FilePathId>()))
.WillByDefault(Return(artefact));
@@ -871,7 +870,6 @@ TEST_F(SymbolIndexer, UpdateProjectPartsFetchIncludedIndexingTimeStamps)
InSequence s;
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
EXPECT_CALL(mockCollector, fileStatuses()).WillRepeatedly(ReturnRef(fileStatuses1));
EXPECT_CALL(mockBuildDependenciesStorage,
insertOrUpdateIndexingTimeStampsWithoutTransaction(_, _));
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(_, _));
@@ -887,7 +885,6 @@ TEST_F(SymbolIndexer, UpdateProjectPartsIsBusyInStoringData)
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin())
.WillOnce(Throw(Sqlite::StatementIsBusy{""}));
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
EXPECT_CALL(mockCollector, fileStatuses()).WillRepeatedly(ReturnRef(fileStatuses1));
EXPECT_CALL(mockBuildDependenciesStorage,
insertOrUpdateIndexingTimeStampsWithoutTransaction(_, _));
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(_, _));

View File

@@ -295,16 +295,6 @@ TEST_F(SymbolsCollector, ClearSourceLocations)
ASSERT_THAT(collector.sourceLocations(), IsEmpty());
}
TEST_F(SymbolsCollector, ClearFileStatus)
{
collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector/main.cpp"), {"cc"});
collector.collectSymbols();
collector.clear();
ASSERT_THAT(collector.fileStatuses(), IsEmpty());
}
TEST_F(SymbolsCollector, DontCollectSymbolsAfterFilesAreCleared)
{
collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector/main.cpp"), {"cc"});
@@ -315,16 +305,6 @@ TEST_F(SymbolsCollector, DontCollectSymbolsAfterFilesAreCleared)
ASSERT_THAT(collector.symbols(), IsEmpty());
}
TEST_F(SymbolsCollector, DontCollectFileStatusAfterFilesAreCleared)
{
collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector/main.cpp"), {"cc"});
collector.clear();
collector.collectSymbols();
ASSERT_THAT(collector.fileStatuses(), IsEmpty());
}
TEST_F(SymbolsCollector, CollectMacroDefinitionSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector/defines.h");
@@ -457,19 +437,6 @@ TEST_F(SymbolsCollector, DISABLED_CollectMacroCompilerArgumentSymbols)
Contains(AllOf(HasSymbolName("COMPILER_ARGUMENT"), HasSymbolKind(SymbolKind::Macro))));
}
TEST_F(SymbolsCollector, CollectFileStatuses)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector/main.cpp");
collector.setFile(fileId, {"cc"});
collector.collectSymbols();
ASSERT_THAT(collector.fileStatuses(),
ElementsAre(fileStatus(TESTDATA_DIR "/symbolscollector/main.cpp"),
fileStatus(TESTDATA_DIR "/symbolscollector/header1.h"),
fileStatus(TESTDATA_DIR "/symbolscollector/header2.h")));
}
TEST_F(SymbolsCollector, IsClassSymbol)
{
collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector/symbolkind.cpp"), {"cc"});