forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.9'
Change-Id: I0d3db14e583628b906d7fdeb800e004d98e52632
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
ClangCurrentDocumentFilter::ClangCurrentDocumentFilter()
|
||||
{
|
||||
@@ -108,7 +109,6 @@ QList<Core::LocatorFilterEntry> ClangCurrentDocumentFilter::matchesFor(
|
||||
if (!regexp.isValid())
|
||||
return goodEntries;
|
||||
|
||||
using Internal::ClangEditorDocumentProcessor;
|
||||
ClangEditorDocumentProcessor *processor = ClangEditorDocumentProcessor::get(m_currentPath);
|
||||
if (!processor)
|
||||
return goodEntries;
|
||||
@@ -170,4 +170,5 @@ void ClangCurrentDocumentFilter::onCurrentEditorChanged(Core::IEditor *newCurren
|
||||
reset();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Core { class IEditor; }
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class ClangCurrentDocumentFilter : public Core::ILocatorFilter
|
||||
{
|
||||
@@ -53,4 +54,5 @@ private:
|
||||
QString m_currentPath;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
|
||||
using namespace ClangCodeModel;
|
||||
using Internal::ClangDiagnosticWidget;
|
||||
using Internal::ClangFixItOperation;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -87,7 +88,7 @@ void openEditorAt(const ClangBackEnd::DiagnosticContainer &diagnostic)
|
||||
|
||||
void applyFixit(const ClangBackEnd::DiagnosticContainer &diagnostic)
|
||||
{
|
||||
ClangCodeModel::ClangFixItOperation operation(Utf8String(), diagnostic.fixIts);
|
||||
ClangFixItOperation operation(Utf8String(), diagnostic.fixIts);
|
||||
|
||||
operation.perform();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "clangeditordocumentparser.h"
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
ClangEditorDocumentParser::ClangEditorDocumentParser(const QString &filePath)
|
||||
: BaseEditorDocumentParser(filePath)
|
||||
@@ -46,4 +47,5 @@ void ClangEditorDocumentParser::updateImpl(const QFutureInterface<void> &,
|
||||
setState(state_);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <cpptools/baseeditordocumentparser.h>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class ClangEditorDocumentParser : public CppTools::BaseEditorDocumentParser
|
||||
{
|
||||
@@ -41,4 +42,5 @@ private:
|
||||
const UpdateParams &updateParams) override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QTextDocument>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
using FileToFixits = QMap<QString, QVector<ClangBackEnd::FixItContainer>>;
|
||||
using FileToFixitsIterator = QMapIterator<QString, QVector<ClangBackEnd::FixItContainer>>;
|
||||
@@ -50,7 +51,7 @@ int ClangFixItOperation::priority() const
|
||||
return 10;
|
||||
}
|
||||
|
||||
QString ClangCodeModel::ClangFixItOperation::description() const
|
||||
QString ClangFixItOperation::description() const
|
||||
{
|
||||
return QStringLiteral("Apply Fix: ") + fixItText.toString();
|
||||
}
|
||||
@@ -120,5 +121,5 @@ Utils::ChangeSet ClangFixItOperation::toChangeSet(
|
||||
return changeSet;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
|
||||
@@ -34,13 +34,13 @@
|
||||
#include <QVector>
|
||||
#include <QSharedPointer>
|
||||
|
||||
namespace TextEditor
|
||||
{
|
||||
namespace TextEditor {
|
||||
class RefactoringChanges;
|
||||
class RefactoringFile;
|
||||
}
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class ClangFixItOperation : public TextEditor::QuickFixOperation
|
||||
{
|
||||
@@ -67,4 +67,5 @@ private:
|
||||
QVector<ClangBackEnd::FixItContainer> fixItContainers;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -72,6 +72,7 @@ bool hasFixItAt(const QVector<ClangBackEnd::FixItContainer> &fixits,
|
||||
} // anonymous namespace
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
ClangFixItOperationsExtractor::ClangFixItOperationsExtractor(
|
||||
const QVector<DiagnosticContainer> &diagnosticContainers)
|
||||
@@ -114,4 +115,5 @@ void ClangFixItOperationsExtractor::extractFromDiagnostic(
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <clangsupport/diagnosticcontainer.h>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class ClangFixItOperationsExtractor
|
||||
{
|
||||
@@ -50,4 +51,5 @@ private:
|
||||
TextEditor::QuickFixOperations operations;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -144,6 +144,7 @@ TextEditor::HighlightingResult toHighlightingResult(
|
||||
} // anonymous
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
HighlightingResultReporter::HighlightingResultReporter(
|
||||
const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos)
|
||||
@@ -219,4 +220,5 @@ QFuture<TextEditor::HighlightingResult> HighlightingResultReporter::start()
|
||||
return future;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <clangsupport/tokeninfocontainer.h>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class HighlightingResultReporter:
|
||||
public QObject,
|
||||
@@ -67,4 +68,5 @@ private:
|
||||
unsigned m_flushLine = 0;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <cplusplus/Token.h>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
bool ClangPreprocessorAssistProposalItem::prematurelyApplies(const QChar &typedCharacter) const
|
||||
{
|
||||
@@ -156,4 +157,5 @@ bool ClangPreprocessorAssistProposalItem::isInclude() const
|
||||
|| m_completionOperator == CPlusPlus::T_ANGLE_STRING_LITERAL;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QString>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class ClangPreprocessorAssistProposalItem final : public TextEditor::AssistProposalItemInterface
|
||||
{
|
||||
@@ -68,4 +69,5 @@ private:
|
||||
mutable QChar m_typedCharacter;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -30,13 +30,14 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||
CppTools::ProjectPart *,
|
||||
RenameCallback &&renameSymbolsCallback)
|
||||
{
|
||||
Internal::ClangEditorDocumentProcessor *processor = Internal::ClangEditorDocumentProcessor::get(
|
||||
data.filePath().toString());
|
||||
ClangEditorDocumentProcessor *processor = ClangEditorDocumentProcessor::get(
|
||||
data.filePath().toString());
|
||||
const int startRevision = data.cursor().document()->revision();
|
||||
|
||||
using ClangBackEnd::SourceLocationsContainer;
|
||||
@@ -79,4 +80,5 @@ void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||
m_watcher->setFuture(cursorFuture);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -36,6 +36,7 @@ class RefactoringServerInterface;
|
||||
}
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class RefactoringEngine : public CppTools::RefactoringEngineInterface
|
||||
{
|
||||
@@ -60,4 +61,5 @@ private:
|
||||
std::unique_ptr<FutureCursorWatcher> m_watcher;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangRefactoring
|
||||
|
||||
@@ -48,9 +48,12 @@
|
||||
#include <QLayout>
|
||||
#include <QString>
|
||||
|
||||
using namespace CppTools;
|
||||
using namespace ClangCodeModel::Internal;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -75,9 +78,6 @@ static Core::Id categoryForSeverity(ClangBackEnd::DiagnosticSeverity severity)
|
||||
|
||||
ProjectExplorer::Project *projectForCurrentEditor()
|
||||
{
|
||||
using namespace CppTools;
|
||||
using namespace ClangCodeModel::Internal;
|
||||
|
||||
const QString filePath = Utils::currentCppEditorDocumentFilePath();
|
||||
if (filePath.isEmpty())
|
||||
return nullptr;
|
||||
@@ -90,35 +90,80 @@ ProjectExplorer::Project *projectForCurrentEditor()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void disableDiagnosticInConfig(CppTools::ClangDiagnosticConfig &config,
|
||||
enum class DiagnosticType { Clang, Tidy, Clazy };
|
||||
DiagnosticType diagnosticType(const ClangBackEnd::DiagnosticContainer &diagnostic)
|
||||
|
||||
{
|
||||
if (!diagnostic.disableOption.isEmpty())
|
||||
return DiagnosticType::Clang;
|
||||
|
||||
const Utils::DiagnosticTextInfo textInfo(diagnostic.text);
|
||||
if (Utils::DiagnosticTextInfo::isClazyOption(textInfo.option()))
|
||||
return DiagnosticType::Clazy;
|
||||
return DiagnosticType::Tidy;
|
||||
}
|
||||
|
||||
void disableDiagnosticInConfig(ClangDiagnosticConfig &config,
|
||||
const ClangBackEnd::DiagnosticContainer &diagnostic)
|
||||
{
|
||||
// Clang check
|
||||
if (!diagnostic.disableOption.isEmpty()) {
|
||||
config.setClangOptions(config.clangOptions() + QStringList(diagnostic.disableOption));
|
||||
return;
|
||||
}
|
||||
|
||||
// Clazy check
|
||||
using namespace ClangCodeModel::Utils;
|
||||
DiagnosticTextInfo textInfo(diagnostic.text);
|
||||
if (DiagnosticTextInfo::isClazyOption(textInfo.option())) {
|
||||
|
||||
switch (diagnosticType(diagnostic)) {
|
||||
case DiagnosticType::Clang:
|
||||
config.setClangOptions(config.clangOptions() + QStringList(diagnostic.disableOption));
|
||||
break;
|
||||
case DiagnosticType::Tidy:
|
||||
config.setClangTidyChecks(config.clangTidyChecks() + QString(",-")
|
||||
+ DiagnosticTextInfo(diagnostic.text).option());
|
||||
break;
|
||||
case DiagnosticType::Clazy: {
|
||||
const DiagnosticTextInfo textInfo(diagnostic.text);
|
||||
const QString checkName = DiagnosticTextInfo::clazyCheckName(textInfo.option());
|
||||
QStringList newChecks = config.clazyChecks().split(',');
|
||||
newChecks.removeOne(checkName);
|
||||
config.setClazyChecks(newChecks.join(','));
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tidy check
|
||||
config.setClangTidyChecks(config.clangTidyChecks() + QString(",-") + textInfo.option());
|
||||
ClangDiagnosticConfig diagnosticConfig(ClangProjectSettings &projectSettings,
|
||||
CppCodeModelSettings &globalSettings)
|
||||
{
|
||||
ProjectExplorer::Project *project = projectForCurrentEditor();
|
||||
QTC_ASSERT(project, return {});
|
||||
|
||||
// Get config id
|
||||
Core::Id currentConfigId = projectSettings.warningConfigId();
|
||||
if (projectSettings.useGlobalConfig())
|
||||
currentConfigId = globalSettings.clangDiagnosticConfigId();
|
||||
|
||||
// Get config
|
||||
ClangDiagnosticConfigsModel configsModel(globalSettings.clangCustomDiagnosticConfigs());
|
||||
QTC_ASSERT(configsModel.hasConfigWithId(currentConfigId), return {});
|
||||
return configsModel.configWithId(currentConfigId);
|
||||
}
|
||||
|
||||
bool isDiagnosticConfigChangable(ProjectExplorer::Project *project,
|
||||
const ClangBackEnd::DiagnosticContainer &diagnostic)
|
||||
{
|
||||
if (!project)
|
||||
return false;
|
||||
|
||||
ClangProjectSettings &projectSettings = ClangModelManagerSupport::instance()->projectSettings(
|
||||
project);
|
||||
const QSharedPointer<CppCodeModelSettings> globalSettings = codeModelSettings();
|
||||
const ClangDiagnosticConfig config = diagnosticConfig(projectSettings, *globalSettings);
|
||||
|
||||
if (config.clangTidyMode() == ClangDiagnosticConfig::TidyMode::File
|
||||
&& diagnosticType(diagnostic) == DiagnosticType::Tidy) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void disableDiagnosticInCurrentProjectConfig(const ClangBackEnd::DiagnosticContainer &diagnostic)
|
||||
{
|
||||
using namespace CppTools;
|
||||
using namespace ClangCodeModel::Internal;
|
||||
|
||||
ProjectExplorer::Project *project = projectForCurrentEditor();
|
||||
QTC_ASSERT(project, return );
|
||||
|
||||
@@ -127,15 +172,9 @@ void disableDiagnosticInCurrentProjectConfig(const ClangBackEnd::DiagnosticConta
|
||||
project);
|
||||
const QSharedPointer<CppCodeModelSettings> globalSettings = codeModelSettings();
|
||||
|
||||
// Get config id
|
||||
Core::Id currentConfigId = projectSettings.warningConfigId();
|
||||
if (projectSettings.useGlobalConfig())
|
||||
currentConfigId = globalSettings->clangDiagnosticConfigId();
|
||||
|
||||
// Get config
|
||||
ClangDiagnosticConfig config = diagnosticConfig(projectSettings, *globalSettings);
|
||||
ClangDiagnosticConfigsModel configsModel(globalSettings->clangCustomDiagnosticConfigs());
|
||||
QTC_ASSERT(configsModel.hasConfigWithId(currentConfigId), return );
|
||||
ClangDiagnosticConfig config = configsModel.configWithId(currentConfigId);
|
||||
|
||||
// Create copy if needed
|
||||
if (config.isReadOnly()) {
|
||||
@@ -197,7 +236,6 @@ ClangTextMark::ClangTextMark(const FileName &fileName,
|
||||
QAction *action = new QAction();
|
||||
action->setIcon(QIcon::fromTheme("edit-copy", ::Utils::Icons::COPY.icon()));
|
||||
QObject::connect(action, &QAction::triggered, [diagnostic]() {
|
||||
using namespace ClangCodeModel::Internal;
|
||||
const QString text = ClangDiagnosticWidget::createText({diagnostic},
|
||||
ClangDiagnosticWidget::InfoBar);
|
||||
QApplication::clipboard()->setText(text, QClipboard::Clipboard);
|
||||
@@ -205,7 +243,8 @@ ClangTextMark::ClangTextMark(const FileName &fileName,
|
||||
actions << action;
|
||||
|
||||
// Remove diagnostic warning action
|
||||
if (projectForCurrentEditor()) {
|
||||
ProjectExplorer::Project *project = projectForCurrentEditor();
|
||||
if (project && isDiagnosticConfigChangable(project, diagnostic)) {
|
||||
action = new QAction();
|
||||
action->setIcon(::Utils::Icons::BROKEN.icon());
|
||||
QObject::connect(action, &QAction::triggered, [diagnostic]() {
|
||||
@@ -228,8 +267,6 @@ void ClangTextMark::updateIcon(bool valid)
|
||||
|
||||
bool ClangTextMark::addToolTipContent(QLayout *target) const
|
||||
{
|
||||
using Internal::ClangDiagnosticWidget;
|
||||
|
||||
QWidget *widget = ClangDiagnosticWidget::createWidget({m_diagnostic},
|
||||
ClangDiagnosticWidget::ToolTip);
|
||||
target->addWidget(widget);
|
||||
@@ -243,5 +280,6 @@ void ClangTextMark::removedFromEditor()
|
||||
m_removedFromEditorHandler(this);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <functional>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class ClangTextMark : public TextEditor::TextMark
|
||||
{
|
||||
@@ -56,4 +57,5 @@ private:
|
||||
RemovedFromEditorHandler m_removedFromEditorHandler;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
Reference in New Issue
Block a user