forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/10.0'
Conflicts: src/plugins/clangcodemodel/clangdlocatorfilters.cpp Change-Id: If91f26625ea9620fb9fdbf45705b32f37cb7f158
This commit is contained in:
@@ -27,6 +27,7 @@ QtcPlugin {
|
||||
"clangactivationsequenceprocessor.h",
|
||||
"clangcodemodelplugin.cpp",
|
||||
"clangcodemodelplugin.h",
|
||||
"clangcodemodeltr.h",
|
||||
"clangcompletioncontextanalyzer.cpp",
|
||||
"clangcompletioncontextanalyzer.h",
|
||||
"clangconstants.h",
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
: m_followSymbol(followSymbol) {}
|
||||
|
||||
void cancel() override { resetData(true); }
|
||||
bool running() override { return m_followSymbol; }
|
||||
bool running() override { return m_followSymbol && m_running; }
|
||||
void update();
|
||||
void finalize();
|
||||
void resetData(bool resetFollowSymbolData);
|
||||
@@ -51,10 +51,11 @@ private:
|
||||
return createProposal(false);
|
||||
}
|
||||
|
||||
IAssistProposal *createProposal(bool final) const;
|
||||
IAssistProposal *createProposal(bool final);
|
||||
VirtualFunctionProposalItem *createEntry(const QString &name, const Link &link) const;
|
||||
|
||||
QPointer<ClangdFollowSymbol> m_followSymbol;
|
||||
bool m_running = false;
|
||||
};
|
||||
|
||||
class ClangdFollowSymbol::VirtualFunctionAssistProvider : public IAssistProvider
|
||||
@@ -297,10 +298,10 @@ void ClangdFollowSymbol::VirtualFunctionAssistProcessor::resetData(bool resetFol
|
||||
m_followSymbol = nullptr;
|
||||
}
|
||||
|
||||
IAssistProposal *
|
||||
ClangdFollowSymbol::VirtualFunctionAssistProcessor::createProposal(bool final) const
|
||||
IAssistProposal *ClangdFollowSymbol::VirtualFunctionAssistProcessor::createProposal(bool final)
|
||||
{
|
||||
QTC_ASSERT(m_followSymbol, return nullptr);
|
||||
m_running = !final;
|
||||
|
||||
QList<AssistProposalItemInterface *> items;
|
||||
bool needsBaseDeclEntry = !m_followSymbol->d->defLinkNode.range()
|
||||
@@ -453,7 +454,7 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult(
|
||||
const QString &name, const QString &prefix, const MessageId &reqId) {
|
||||
qCDebug(clangdLog) << "handling symbol info reply"
|
||||
<< link.targetFilePath.toUserOutput() << link.targetLine;
|
||||
if (!sentinel)
|
||||
if (!sentinel || !virtualFuncAssistProcessor)
|
||||
return;
|
||||
if (!name.isEmpty())
|
||||
symbolsToDisplay.push_back({prefix + name, link});
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <set>
|
||||
#include <tuple>
|
||||
|
||||
using namespace LanguageClient;
|
||||
using namespace LanguageServerProtocol;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -42,7 +43,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class LspWorkspaceFilter : public LanguageClient::WorkspaceLocatorFilter
|
||||
class LspWorkspaceFilter : public WorkspaceLocatorFilter
|
||||
{
|
||||
public:
|
||||
LspWorkspaceFilter()
|
||||
@@ -71,7 +72,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class LspClassesFilter : public LanguageClient::WorkspaceClassLocatorFilter
|
||||
class LspClassesFilter : public WorkspaceClassLocatorFilter
|
||||
{
|
||||
public:
|
||||
LspClassesFilter() {
|
||||
@@ -98,7 +99,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class LspFunctionsFilter : public LanguageClient::WorkspaceMethodLocatorFilter
|
||||
class LspFunctionsFilter : public WorkspaceMethodLocatorFilter
|
||||
{
|
||||
public:
|
||||
LspFunctionsFilter()
|
||||
@@ -119,7 +120,7 @@ ClangGlobalSymbolFilter::ClangGlobalSymbolFilter()
|
||||
}
|
||||
|
||||
ClangGlobalSymbolFilter::ClangGlobalSymbolFilter(ILocatorFilter *cppFilter,
|
||||
ILocatorFilter *lspFilter)
|
||||
WorkspaceLocatorFilter *lspFilter)
|
||||
: m_cppFilter(cppFilter), m_lspFilter(lspFilter)
|
||||
{
|
||||
setId(CppEditor::Constants::LOCATOR_FILTER_ID);
|
||||
@@ -138,17 +139,13 @@ ClangGlobalSymbolFilter::~ClangGlobalSymbolFilter()
|
||||
void ClangGlobalSymbolFilter::prepareSearch(const QString &entry)
|
||||
{
|
||||
m_cppFilter->prepareSearch(entry);
|
||||
QList<LanguageClient::Client *> clients;
|
||||
QList<Client *> clients;
|
||||
for (ProjectExplorer::Project * const project : ProjectExplorer::SessionManager::projects()) {
|
||||
if (LanguageClient::Client * const client
|
||||
= ClangModelManagerSupport::clientForProject(project)) {
|
||||
if (Client * const client = ClangModelManagerSupport::clientForProject(project))
|
||||
clients << client;
|
||||
}
|
||||
}
|
||||
if (!clients.isEmpty()) {
|
||||
static_cast<LanguageClient::WorkspaceLocatorFilter *>(m_lspFilter)
|
||||
->prepareSearch(entry, clients);
|
||||
}
|
||||
if (!clients.isEmpty())
|
||||
m_lspFilter->prepareSearch(entry, clients);
|
||||
}
|
||||
|
||||
QList<Core::LocatorFilterEntry> ClangGlobalSymbolFilter::matchesFor(
|
||||
@@ -157,16 +154,16 @@ QList<Core::LocatorFilterEntry> ClangGlobalSymbolFilter::matchesFor(
|
||||
QList<Core::LocatorFilterEntry> matches = m_cppFilter->matchesFor(future, entry);
|
||||
const QList<Core::LocatorFilterEntry> lspMatches = m_lspFilter->matchesFor(future, entry);
|
||||
if (!lspMatches.isEmpty()) {
|
||||
std::set<std::tuple<Utils::FilePath, int, int>> locations;
|
||||
std::set<std::tuple<FilePath, int, int>> locations;
|
||||
for (const auto &entry : std::as_const(matches)) {
|
||||
const CppEditor::IndexItem::Ptr item
|
||||
= qvariant_cast<CppEditor::IndexItem::Ptr>(entry.internalData);
|
||||
locations.insert(std::make_tuple(item->filePath(), item->line(), item->column()));
|
||||
}
|
||||
for (const auto &entry : lspMatches) {
|
||||
if (!entry.internalData.canConvert<Utils::Link>())
|
||||
if (!entry.internalData.canConvert<Link>())
|
||||
continue;
|
||||
const auto link = qvariant_cast<Utils::Link>(entry.internalData);
|
||||
const auto link = qvariant_cast<Link>(entry.internalData);
|
||||
if (locations.find(std::make_tuple(link.targetFilePath, link.targetLine,
|
||||
link.targetColumn)) == locations.cend()) {
|
||||
matches << entry; // TODO: Insert sorted?
|
||||
@@ -207,7 +204,7 @@ ClangFunctionsFilter::ClangFunctionsFilter()
|
||||
setDefaultIncludedByDefault(false);
|
||||
}
|
||||
|
||||
class LspCurrentDocumentFilter : public LanguageClient::DocumentLocatorFilter
|
||||
class LspCurrentDocumentFilter : public DocumentLocatorFilter
|
||||
{
|
||||
public:
|
||||
LspCurrentDocumentFilter()
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include <coreplugin/locator/ilocatorfilter.h>
|
||||
|
||||
namespace LanguageClient { class WorkspaceLocatorFilter; }
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
@@ -12,7 +14,8 @@ class ClangGlobalSymbolFilter : public Core::ILocatorFilter
|
||||
{
|
||||
public:
|
||||
ClangGlobalSymbolFilter();
|
||||
ClangGlobalSymbolFilter(Core::ILocatorFilter *cppFilter, Core::ILocatorFilter *lspFilter);
|
||||
ClangGlobalSymbolFilter(Core::ILocatorFilter *cppFilter,
|
||||
LanguageClient::WorkspaceLocatorFilter *lspFilter);
|
||||
~ClangGlobalSymbolFilter() override;
|
||||
|
||||
private:
|
||||
@@ -23,7 +26,7 @@ private:
|
||||
int *selectionStart, int *selectionLength) const override;
|
||||
|
||||
Core::ILocatorFilter * const m_cppFilter;
|
||||
Core::ILocatorFilter * const m_lspFilter;
|
||||
LanguageClient::WorkspaceLocatorFilter * const m_lspFilter;
|
||||
};
|
||||
|
||||
class ClangClassesFilter : public ClangGlobalSymbolFilter
|
||||
|
||||
@@ -121,8 +121,7 @@ void disableDiagnosticInCurrentProjectConfig(const ClangDiagnostic &diagnostic)
|
||||
|
||||
// Create copy if needed
|
||||
if (config.isReadOnly()) {
|
||||
const QString name = QCoreApplication::translate("ClangDiagnosticConfig",
|
||||
"Project: %1 (based on %2)")
|
||||
const QString name = Tr::tr("Project: %1 (based on %2)")
|
||||
.arg(project->displayName(), config.displayName());
|
||||
config = ClangDiagnosticConfigsModel::createCustomConfig(config, name);
|
||||
}
|
||||
@@ -141,9 +140,7 @@ void disableDiagnosticInCurrentProjectConfig(const ClangDiagnostic &diagnostic)
|
||||
projectSettings.setDiagnosticConfigId(config.id());
|
||||
|
||||
// Notify the user about changed project specific settings
|
||||
const QString text
|
||||
= QCoreApplication::translate("ClangDiagnosticConfig",
|
||||
"Changes applied in Projects Mode > Clang Code Model");
|
||||
const QString text = Tr::tr("Changes applied in Projects Mode > Clang Code Model");
|
||||
FadingIndicator::showText(Core::ICore::mainWindow(),
|
||||
text,
|
||||
FadingIndicator::SmallText);
|
||||
@@ -192,7 +189,7 @@ ClangDiagnostic convertDiagnostic(const ClangdDiagnostic &src,
|
||||
line = match.captured(6).toInt(&ok);
|
||||
column = 0;
|
||||
}
|
||||
FilePath auxFilePath = FilePath::fromUserInput(match.captured(1));
|
||||
FilePath auxFilePath = mapper(FilePath::fromUserInput(match.captured(1)));
|
||||
if (auxFilePath.isRelativePath() && auxFilePath.fileName() == filePath.fileName())
|
||||
auxFilePath = filePath;
|
||||
aux.location = {auxFilePath, line, column - 1};
|
||||
@@ -326,7 +323,7 @@ ClangdTextMark::ClangdTextMark(const FilePath &filePath,
|
||||
|
||||
bool ClangdTextMark::addToolTipContent(QLayout *target) const
|
||||
{
|
||||
const auto canApplyFixIt = [c = m_client, diag = m_lspDiagnostic, fp = fileName()] {
|
||||
const auto canApplyFixIt = [c = m_client, diag = m_lspDiagnostic, fp = filePath()] {
|
||||
return QTC_GUARD(c) && c->reachable() && c->hasDiagnostic(fp, diag);
|
||||
};
|
||||
const QString clientName = QTC_GUARD(m_client) ? m_client->name() : "clangd [unknown]";
|
||||
|
||||
@@ -154,15 +154,14 @@ GenerateCompilationDbResult generateCompilationDB(QList<ProjectInfo::ConstPtr> p
|
||||
FilePath clangIncludeDir)
|
||||
{
|
||||
QTC_ASSERT(!baseDir.isEmpty(), return GenerateCompilationDbResult(QString(),
|
||||
QCoreApplication::translate("ClangUtils", "Could not retrieve build directory.")));
|
||||
Tr::tr("Could not retrieve build directory.")));
|
||||
QTC_ASSERT(!projectInfoList.isEmpty(),
|
||||
return GenerateCompilationDbResult(QString(), "Could not retrieve project info."));
|
||||
QTC_CHECK(baseDir.ensureWritableDir());
|
||||
QFile compileCommandsFile(baseDir.pathAppended("compile_commands.json").toFSPathString());
|
||||
const bool fileOpened = compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
if (!fileOpened) {
|
||||
return GenerateCompilationDbResult(QString(),
|
||||
QCoreApplication::translate("ClangUtils", "Could not create \"%1\": %2")
|
||||
return GenerateCompilationDbResult(QString(), Tr::tr("Could not create \"%1\": %2")
|
||||
.arg(compileCommandsFile.fileName(), compileCommandsFile.errorString()));
|
||||
}
|
||||
compileCommandsFile.write("[");
|
||||
|
||||
Reference in New Issue
Block a user