forked from qt-creator/qt-creator
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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*/,
|
||||
|
||||
@@ -43,14 +43,12 @@ class IndexDataConsumer : public clang::index::IndexDataConsumer,
|
||||
public:
|
||||
IndexDataConsumer(SymbolEntries &symbolEntries,
|
||||
SourceLocationEntries &sourceLocationEntries,
|
||||
FileStatuses &fileStatuses,
|
||||
FilePathCachingInterface &filePathCache,
|
||||
SourcesManager &symbolSourcesManager,
|
||||
SourcesManager ¯oSourcesManager)
|
||||
: 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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user