forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/11.0'
Conflicts: cmake/QtCreatorIDEBranding.cmake qbs/modules/qtc/qtc.qbs Change-Id: If3ada34dcc764fa1d0cce04fd343fb5a02c2fbaa
This commit is contained in:
@@ -59,26 +59,6 @@ void ClangEditorDocumentProcessor::semanticRehighlight()
|
||||
BuiltinEditorDocumentProcessor::semanticRehighlight();
|
||||
}
|
||||
|
||||
bool ClangEditorDocumentProcessor::hasProjectPart() const
|
||||
{
|
||||
return !m_projectPart.isNull();
|
||||
}
|
||||
|
||||
CppEditor::ProjectPart::ConstPtr ClangEditorDocumentProcessor::projectPart() const
|
||||
{
|
||||
return m_projectPart;
|
||||
}
|
||||
|
||||
void ClangEditorDocumentProcessor::clearProjectPart()
|
||||
{
|
||||
m_projectPart.clear();
|
||||
}
|
||||
|
||||
::Utils::Id ClangEditorDocumentProcessor::diagnosticConfigId() const
|
||||
{
|
||||
return m_diagnosticConfigId;
|
||||
}
|
||||
|
||||
void ClangEditorDocumentProcessor::setParserConfig(
|
||||
const CppEditor::BaseEditorDocumentParser::Configuration &config)
|
||||
{
|
||||
|
||||
@@ -19,12 +19,6 @@ public:
|
||||
|
||||
void semanticRehighlight() override;
|
||||
|
||||
bool hasProjectPart() const;
|
||||
CppEditor::ProjectPart::ConstPtr projectPart() const;
|
||||
void clearProjectPart();
|
||||
|
||||
::Utils::Id diagnosticConfigId() const;
|
||||
|
||||
void setParserConfig(const CppEditor::BaseEditorDocumentParser::Configuration &config) override;
|
||||
CppEditor::BaseEditorDocumentParser::Configuration parserConfig();
|
||||
|
||||
@@ -37,8 +31,6 @@ signals:
|
||||
|
||||
private:
|
||||
TextEditor::TextDocument &m_document;
|
||||
CppEditor::ProjectPart::ConstPtr m_projectPart;
|
||||
::Utils::Id m_diagnosticConfigId;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -232,9 +232,7 @@ ClangModelManagerSupport::ClangModelManagerSupport()
|
||||
connect(modelManager, &CppModelManager::abstractEditorSupportRemoved,
|
||||
this, &ClangModelManagerSupport::onAbstractEditorSupportRemoved);
|
||||
connect(modelManager, &CppModelManager::projectPartsUpdated,
|
||||
this, &ClangModelManagerSupport::onProjectPartsUpdated);
|
||||
connect(modelManager, &CppModelManager::projectPartsRemoved,
|
||||
this, &ClangModelManagerSupport::onProjectPartsRemoved);
|
||||
this, &ClangModelManagerSupport::updateLanguageClient);
|
||||
connect(modelManager, &CppModelManager::fallbackProjectPartUpdated, this, [this] {
|
||||
if (sessionModeEnabled())
|
||||
return;
|
||||
@@ -861,37 +859,6 @@ void ClangModelManagerSupport::onTextMarkContextMenuRequested(TextEditor::TextEd
|
||||
}
|
||||
}
|
||||
|
||||
using ClangEditorDocumentProcessors = QVector<ClangEditorDocumentProcessor *>;
|
||||
static ClangEditorDocumentProcessors clangProcessors()
|
||||
{
|
||||
ClangEditorDocumentProcessors result;
|
||||
for (const CppEditorDocumentHandle *editorDocument : cppModelManager()->cppEditorDocuments())
|
||||
result.append(qobject_cast<ClangEditorDocumentProcessor *>(editorDocument->processor()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ClangModelManagerSupport::onProjectPartsUpdated(Project *project)
|
||||
{
|
||||
QTC_ASSERT(project, return);
|
||||
|
||||
updateLanguageClient(project);
|
||||
|
||||
QStringList projectPartIds;
|
||||
const ProjectInfo::ConstPtr projectInfo = cppModelManager()->projectInfo(project);
|
||||
QTC_ASSERT(projectInfo, return);
|
||||
|
||||
for (const ProjectPart::ConstPtr &projectPart : projectInfo->projectParts())
|
||||
projectPartIds.append(projectPart->id());
|
||||
onProjectPartsRemoved(projectPartIds);
|
||||
}
|
||||
|
||||
void ClangModelManagerSupport::onProjectPartsRemoved(const QStringList &projectPartIds)
|
||||
{
|
||||
if (!projectPartIds.isEmpty())
|
||||
reinitializeBackendDocuments(projectPartIds);
|
||||
}
|
||||
|
||||
void ClangModelManagerSupport::onClangdSettingsChanged()
|
||||
{
|
||||
const bool sessionMode = sessionModeEnabled();
|
||||
@@ -940,21 +907,4 @@ void ClangModelManagerSupport::onClangdSettingsChanged()
|
||||
}
|
||||
}
|
||||
|
||||
static ClangEditorDocumentProcessors
|
||||
clangProcessorsWithProjectParts(const QStringList &projectPartIds)
|
||||
{
|
||||
return ::Utils::filtered(clangProcessors(), [projectPartIds](ClangEditorDocumentProcessor *p) {
|
||||
return p->hasProjectPart() && projectPartIds.contains(p->projectPart()->id());
|
||||
});
|
||||
}
|
||||
|
||||
void ClangModelManagerSupport::reinitializeBackendDocuments(const QStringList &projectPartIds)
|
||||
{
|
||||
const ClangEditorDocumentProcessors processors = clangProcessorsWithProjectParts(projectPartIds);
|
||||
for (ClangEditorDocumentProcessor *processor : processors) {
|
||||
processor->clearProjectPart();
|
||||
processor->run();
|
||||
}
|
||||
}
|
||||
|
||||
} // ClangCodeModel::Internal
|
||||
|
||||
@@ -81,12 +81,8 @@ private:
|
||||
int lineNumber,
|
||||
QMenu *menu);
|
||||
|
||||
void onProjectPartsUpdated(ProjectExplorer::Project *project);
|
||||
void onProjectPartsRemoved(const QStringList &projectPartIds);
|
||||
void onClangdSettingsChanged();
|
||||
|
||||
void reinitializeBackendDocuments(const QStringList &projectPartIds);
|
||||
|
||||
void connectTextDocumentToTranslationUnit(TextEditor::TextDocument *textDocument);
|
||||
void connectToWidgetsMarkContextMenuRequested(QWidget *editorWidget);
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "clangconstants.h"
|
||||
#include "clangdclient.h"
|
||||
#include "clangdiagnostictooltipwidget.h"
|
||||
#include "clangeditordocumentprocessor.h"
|
||||
#include "clangutils.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -49,46 +48,15 @@ Project *projectForCurrentEditor()
|
||||
if (filePath.isEmpty())
|
||||
return nullptr;
|
||||
|
||||
if (auto processor = ClangEditorDocumentProcessor::get(filePath)) {
|
||||
if (ProjectPart::ConstPtr projectPart = processor->projectPart())
|
||||
return projectForProjectPart(*projectPart);
|
||||
}
|
||||
if (ProjectPart::ConstPtr projectPart = projectPartForFile(filePath))
|
||||
return projectForProjectPart(*projectPart);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
enum class DiagnosticType { Clang, Tidy, Clazy };
|
||||
DiagnosticType diagnosticType(const ClangDiagnostic &diagnostic)
|
||||
|
||||
{
|
||||
if (!diagnostic.disableOption.isEmpty())
|
||||
return DiagnosticType::Clang;
|
||||
|
||||
const DiagnosticTextInfo textInfo(diagnostic.text);
|
||||
if (DiagnosticTextInfo::isClazyOption(textInfo.option()))
|
||||
return DiagnosticType::Clazy;
|
||||
return DiagnosticType::Tidy;
|
||||
}
|
||||
|
||||
void disableDiagnosticInConfig(ClangDiagnosticConfig &config, const ClangDiagnostic &diagnostic)
|
||||
{
|
||||
switch (diagnosticType(diagnostic)) {
|
||||
case DiagnosticType::Clang:
|
||||
config.setClangOptions(config.clangOptions() + QStringList(diagnostic.disableOption));
|
||||
break;
|
||||
case DiagnosticType::Tidy:
|
||||
config.setChecks(ClangToolType::Tidy, config.checks(ClangToolType::Tidy) + QString(",-")
|
||||
+ DiagnosticTextInfo(diagnostic.text).option());
|
||||
break;
|
||||
case DiagnosticType::Clazy: {
|
||||
const DiagnosticTextInfo textInfo(diagnostic.text);
|
||||
const QString checkName = DiagnosticTextInfo::clazyCheckName(textInfo.option());
|
||||
QStringList newChecks = config.checks(ClangToolType::Clazy).split(',');
|
||||
newChecks.removeOne(checkName);
|
||||
config.setChecks(ClangToolType::Clazy, newChecks.join(','));
|
||||
break;
|
||||
}
|
||||
}
|
||||
config.setClangOptions(config.clangOptions() + QStringList(diagnostic.disableOption));
|
||||
}
|
||||
|
||||
ClangDiagnosticConfig diagnosticConfig()
|
||||
@@ -210,8 +178,10 @@ ClangDiagnostic convertDiagnostic(const ClangdDiagnostic &src,
|
||||
target.severity = convertSeverity(*src.severity());
|
||||
const Diagnostic::Code code = src.code().value_or(Diagnostic::Code());
|
||||
const QString * const codeString = std::get_if<QString>(&code);
|
||||
if (codeString && codeString->startsWith("-W"))
|
||||
if (codeString && codeString->startsWith("-W")) {
|
||||
target.enableOption = *codeString;
|
||||
target.disableOption = "-Wno-" + codeString->mid(2);
|
||||
}
|
||||
for (const CodeAction &codeAction : src.codeActions().value_or(QList<CodeAction>())) {
|
||||
const std::optional<WorkspaceEdit> edit = codeAction.edit();
|
||||
if (!edit)
|
||||
@@ -304,15 +274,17 @@ ClangdTextMark::ClangdTextMark(TextEditor::TextDocument *doc,
|
||||
actions << action;
|
||||
|
||||
// Remove diagnostic warning action
|
||||
Project *project = projectForCurrentEditor();
|
||||
if (project && isDiagnosticConfigChangable(project)) {
|
||||
action = new QAction();
|
||||
action->setIcon(Icons::BROKEN.icon());
|
||||
action->setToolTip(Tr::tr("Disable Diagnostic in Current Project"));
|
||||
QObject::connect(action, &QAction::triggered, [diag] {
|
||||
disableDiagnosticInCurrentProjectConfig(diag);
|
||||
});
|
||||
actions << action;
|
||||
if (!diag.disableOption.isEmpty()) {
|
||||
if (Project * const project = projectForCurrentEditor();
|
||||
project && isDiagnosticConfigChangable(project)) {
|
||||
action = new QAction();
|
||||
action->setIcon(Icons::BROKEN.icon());
|
||||
action->setToolTip(Tr::tr("Disable Diagnostic in Current Project"));
|
||||
QObject::connect(action, &QAction::triggered, [diag] {
|
||||
disableDiagnosticInCurrentProjectConfig(diag);
|
||||
});
|
||||
actions << action;
|
||||
}
|
||||
}
|
||||
return actions;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user