forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.1'
Change-Id: Ie96fa53a88bcd06fa688a579c1d84aaf6f5e905f
This commit is contained in:
@@ -34,15 +34,22 @@
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
const int SORT_LIMIT = 30000;
|
||||
|
||||
ClangAssistProposalModel::ClangAssistProposalModel(
|
||||
ClangBackEnd::CompletionCorrection neededCorrection)
|
||||
: m_neededCorrection(neededCorrection)
|
||||
{
|
||||
}
|
||||
|
||||
bool ClangAssistProposalModel::containsDuplicates() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClangAssistProposalModel::isSortable(const QString &/*prefix*/) const
|
||||
{
|
||||
return true;
|
||||
return m_currentItems.size() <= SORT_LIMIT;
|
||||
}
|
||||
|
||||
void ClangAssistProposalModel::sort(const QString &/*prefix*/)
|
||||
|
||||
@@ -39,6 +39,8 @@ class ClangAssistProposalModel : public TextEditor::GenericProposalModel
|
||||
public:
|
||||
ClangAssistProposalModel(ClangBackEnd::CompletionCorrection neededCorrection);
|
||||
|
||||
bool containsDuplicates() const override;
|
||||
|
||||
bool isSortable(const QString &prefix) const override;
|
||||
void sort(const QString &prefix) override;
|
||||
|
||||
|
||||
@@ -91,8 +91,6 @@ QList<AssistProposalItemInterface *> toAssistProposalItems(const CodeCompletions
|
||||
item->addOverload(codeCompletion);
|
||||
} else {
|
||||
item = new ClangAssistProposalItem;
|
||||
QString detail = CompletionChunksToTextConverter::convertToToolTipWithHtml(codeCompletion.chunks());
|
||||
|
||||
items.insert(name, item);
|
||||
|
||||
item->setText(name);
|
||||
@@ -138,7 +136,8 @@ using namespace CPlusPlus;
|
||||
using namespace TextEditor;
|
||||
|
||||
ClangCompletionAssistProcessor::ClangCompletionAssistProcessor()
|
||||
: m_completionOperator(T_EOF_SYMBOL)
|
||||
: CppCompletionAssistProcessor(100)
|
||||
, m_completionOperator(T_EOF_SYMBOL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -345,10 +345,7 @@ void ClangDiagnosticManager::addClangTextMarks(
|
||||
const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics)
|
||||
{
|
||||
for (const ClangBackEnd::DiagnosticContainer &diagnostic : diagnostics) {
|
||||
auto textMark = new ClangTextMark(filePath(),
|
||||
diagnostic.location().line(),
|
||||
diagnostic.severity());
|
||||
textMark->setToolTip(diagnostic.text());
|
||||
auto textMark = new ClangTextMark(filePath(), diagnostic);
|
||||
m_clangTextMarks.push_back(textMark);
|
||||
m_textDocument->addMark(textMark);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
void addChildrenToLayout(const QString &mainFilePath,
|
||||
const QVector<ClangBackEnd::DiagnosticContainer>::const_iterator first,
|
||||
const QVector<ClangBackEnd::DiagnosticContainer>::const_iterator last,
|
||||
QBoxLayout &boxLayout)
|
||||
QLayout &boxLayout)
|
||||
{
|
||||
for (auto it = first; it != last; ++it)
|
||||
boxLayout.addWidget(createDiagnosticLabel(*it, mainFilePath, IndentDiagnostic));
|
||||
@@ -194,7 +194,7 @@ void addChildrenToLayout(const QString &mainFilePath,
|
||||
|
||||
void setupChildDiagnostics(const QString &mainFilePath,
|
||||
const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
||||
QBoxLayout &boxLayout)
|
||||
QLayout &boxLayout)
|
||||
{
|
||||
if (diagnostics.size() <= 10) {
|
||||
addChildrenToLayout(mainFilePath, diagnostics.begin(), diagnostics.end(), boxLayout);
|
||||
@@ -214,22 +214,13 @@ void setupChildDiagnostics(const QString &mainFilePath,
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
ClangDiagnosticToolTipWidget::ClangDiagnosticToolTipWidget(
|
||||
const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
||||
QWidget *parent)
|
||||
: Utils::FakeToolTip(parent)
|
||||
void addToolTipToLayout(const ClangBackEnd::DiagnosticContainer &diagnostic, QLayout *target)
|
||||
{
|
||||
auto *mainLayout = createLayout<QVBoxLayout>();
|
||||
// Set up header and text row for main diagnostic
|
||||
target->addWidget(new MainDiagnosticWidget(diagnostic));
|
||||
|
||||
foreach (const auto &diagnostic, diagnostics) {
|
||||
// Set up header and text row for main diagnostic
|
||||
mainLayout->addWidget(new MainDiagnosticWidget(diagnostic));
|
||||
|
||||
// Set up child rows for notes
|
||||
setupChildDiagnostics(diagnostic.location().filePath(), diagnostic.children(), *mainLayout);
|
||||
}
|
||||
|
||||
setLayout(mainLayout);
|
||||
// Set up child rows for notes
|
||||
setupChildDiagnostics(diagnostic.location().filePath(), diagnostic.children(), *target);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -27,19 +27,14 @@
|
||||
|
||||
#include <clangbackendipc/diagnosticcontainer.h>
|
||||
|
||||
#include <utils/faketooltip.h>
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
class ClangDiagnosticToolTipWidget : public Utils::FakeToolTip
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ClangDiagnosticToolTipWidget(
|
||||
const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
||||
QWidget *parent = 0);
|
||||
};
|
||||
void addToolTipToLayout(const ClangBackEnd::DiagnosticContainer &diagnostic, QLayout *target);
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -35,7 +35,8 @@ ClangEditorDocumentParser::ClangEditorDocumentParser(const QString &filePath)
|
||||
setConfiguration(config);
|
||||
}
|
||||
|
||||
void ClangEditorDocumentParser::updateHelper(const CppTools::WorkingCopy &)
|
||||
void ClangEditorDocumentParser::updateHelper(const QFutureInterface<void> &,
|
||||
const CppTools::WorkingCopy &)
|
||||
{
|
||||
State state_ = state();
|
||||
state_.projectPart = determineProjectPart(filePath(), configuration(), state_);
|
||||
|
||||
@@ -37,7 +37,8 @@ public:
|
||||
ClangEditorDocumentParser(const QString &filePath);
|
||||
|
||||
private:
|
||||
void updateHelper(const CppTools::WorkingCopy &) override;
|
||||
void updateHelper(const QFutureInterface<void> &future,
|
||||
const CppTools::WorkingCopy &) override;
|
||||
};
|
||||
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
#include <cplusplus/CppDocument.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/tooltip/tooltip.h>
|
||||
#include <utils/runextensions.h>
|
||||
|
||||
#include <QTextBlock>
|
||||
@@ -244,16 +243,12 @@ bool ClangEditorDocumentProcessor::hasDiagnosticsAt(uint line, uint column) cons
|
||||
return m_diagnosticManager.hasDiagnosticsAt(line, column);
|
||||
}
|
||||
|
||||
void ClangEditorDocumentProcessor::showDiagnosticTooltip(const QPoint &point,
|
||||
QWidget *parent,
|
||||
uint line,
|
||||
uint column) const
|
||||
void ClangEditorDocumentProcessor::addDiagnosticToolTipToLayout(uint line,
|
||||
uint column,
|
||||
QLayout *target) const
|
||||
{
|
||||
const QVector<ClangBackEnd::DiagnosticContainer> diagnostics
|
||||
= m_diagnosticManager.diagnosticsAt(line, column);
|
||||
auto *tooltipWidget = new ClangDiagnosticToolTipWidget(diagnostics, parent);
|
||||
|
||||
::Utils::ToolTip::show(point, tooltipWidget, parent);
|
||||
foreach (const auto &diagnostic, m_diagnosticManager.diagnosticsAt(line, column))
|
||||
addToolTipToLayout(diagnostic, target);
|
||||
}
|
||||
|
||||
ClangBackEnd::FileContainer ClangEditorDocumentProcessor::fileContainerWithArguments() const
|
||||
|
||||
@@ -76,10 +76,7 @@ public:
|
||||
extraRefactoringOperations(const TextEditor::AssistInterface &assistInterface) override;
|
||||
|
||||
bool hasDiagnosticsAt(uint line, uint column) const override;
|
||||
void showDiagnosticTooltip(const QPoint &point,
|
||||
QWidget *parent,
|
||||
uint line,
|
||||
uint column) const override;
|
||||
void addDiagnosticToolTipToLayout(uint line, uint column, QLayout *target) const override;
|
||||
|
||||
ClangBackEnd::FileContainer fileContainerWithArguments() const;
|
||||
|
||||
|
||||
@@ -26,10 +26,12 @@
|
||||
#include "clangtextmark.h"
|
||||
|
||||
#include "clangconstants.h"
|
||||
#include "clangdiagnostictooltipwidget.h"
|
||||
|
||||
#include <utils/icon.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
#include <QLayout>
|
||||
#include <QString>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
@@ -57,11 +59,13 @@ Core::Id cartegoryForSeverity(ClangBackEnd::DiagnosticSeverity severity)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
ClangTextMark::ClangTextMark(const QString &fileName, int lineNumber, ClangBackEnd::DiagnosticSeverity severity)
|
||||
: TextEditor::TextMark(fileName, lineNumber, cartegoryForSeverity(severity))
|
||||
|
||||
ClangTextMark::ClangTextMark(const QString &fileName, const ClangBackEnd::DiagnosticContainer &diagnostic)
|
||||
: TextEditor::TextMark(fileName, int(diagnostic.location().line()), cartegoryForSeverity(diagnostic.severity())),
|
||||
m_diagnostic(diagnostic)
|
||||
{
|
||||
setPriority(TextEditor::TextMark::HighPriority);
|
||||
setIcon(severity);
|
||||
setIcon(diagnostic.severity());
|
||||
}
|
||||
|
||||
void ClangTextMark::setIcon(ClangBackEnd::DiagnosticSeverity severity)
|
||||
@@ -79,5 +83,10 @@ void ClangTextMark::setIcon(ClangBackEnd::DiagnosticSeverity severity)
|
||||
TextMark::setIcon(errorIcon);
|
||||
}
|
||||
|
||||
void ClangTextMark::addToToolTipLayout(QLayout *target)
|
||||
{
|
||||
Internal::addToolTipToLayout(m_diagnostic, target);
|
||||
}
|
||||
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <clangbackendipc_global.h>
|
||||
#include <clangbackendipc/diagnosticcontainer.h>
|
||||
|
||||
#include <texteditor/textmark.h>
|
||||
|
||||
@@ -34,10 +35,13 @@ namespace ClangCodeModel {
|
||||
class ClangTextMark : public TextEditor::TextMark
|
||||
{
|
||||
public:
|
||||
ClangTextMark(const QString &fileName, int lineNumber, ClangBackEnd::DiagnosticSeverity severity);
|
||||
ClangTextMark(const QString &fileName, const ClangBackEnd::DiagnosticContainer &diagnostic);
|
||||
|
||||
private:
|
||||
void addToToolTipLayout(QLayout *target);
|
||||
void setIcon(ClangBackEnd::DiagnosticSeverity severity);
|
||||
|
||||
ClangBackEnd::DiagnosticContainer m_diagnostic;
|
||||
};
|
||||
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
Reference in New Issue
Block a user