forked from qt-creator/qt-creator
CppEditor: Render forward decls less prominently in outline
Fixes: QTCREATORBUG-312 Change-Id: I9bb77add24737881eeee008620941b55118ee0e5 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -62,6 +62,7 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/itemviews.h>
|
#include <utils/itemviews.h>
|
||||||
#include <utils/runextensions.h>
|
#include <utils/runextensions.h>
|
||||||
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -135,9 +136,16 @@ class ClangdOutlineItem : public LanguageClientOutlineItem
|
|||||||
private:
|
private:
|
||||||
QVariant data(int column, int role) const override
|
QVariant data(int column, int role) const override
|
||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole) {
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
return ClangdClient::displayNameFromDocumentSymbol(
|
return ClangdClient::displayNameFromDocumentSymbol(
|
||||||
static_cast<SymbolKind>(type()), name(), detail());
|
static_cast<SymbolKind>(type()), name(), detail());
|
||||||
|
case Qt::ForegroundRole:
|
||||||
|
if ((detail().endsWith("class") || detail().endsWith("struct"))
|
||||||
|
&& range().end() == selectionRange().end()) {
|
||||||
|
return creatorTheme()->color(Theme::TextColorDisabled);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return LanguageClientOutlineItem::data(column, role);
|
return LanguageClientOutlineItem::data(column, role);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <utils/linecolumn.h>
|
#include <utils/linecolumn.h>
|
||||||
#include <utils/link.h>
|
#include <utils/link.h>
|
||||||
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@@ -103,6 +104,24 @@ public:
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case Qt::ForegroundRole: {
|
||||||
|
const auto isFwdDecl = [&] {
|
||||||
|
const FullySpecifiedType type = symbol->type();
|
||||||
|
if (type->asForwardClassDeclarationType())
|
||||||
|
return true;
|
||||||
|
if (const Template * const tmpl = type->asTemplateType())
|
||||||
|
return tmpl->declaration() && tmpl->declaration()->asForwardClassDeclaration();
|
||||||
|
if (type->asObjCForwardClassDeclarationType())
|
||||||
|
return true;
|
||||||
|
if (type->asObjCForwardProtocolDeclarationType())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
if (isFwdDecl())
|
||||||
|
return Utils::creatorTheme()->color(Utils::Theme::TextColorDisabled);
|
||||||
|
return TreeItem::data(column, role);
|
||||||
|
}
|
||||||
|
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
return Icons::iconForSymbol(symbol);
|
return Icons::iconForSymbol(symbol);
|
||||||
|
|
||||||
|
|||||||
@@ -404,6 +404,7 @@ LanguageClientOutlineItem::LanguageClientOutlineItem(Client *client, const Docum
|
|||||||
, m_name(info.name())
|
, m_name(info.name())
|
||||||
, m_detail(info.detail().value_or(QString()))
|
, m_detail(info.detail().value_or(QString()))
|
||||||
, m_range(info.range())
|
, m_range(info.range())
|
||||||
|
, m_selectionRange(info.selectionRange())
|
||||||
, m_type(info.kind())
|
, m_type(info.kind())
|
||||||
{
|
{
|
||||||
const QList<LanguageServerProtocol::DocumentSymbol> children = sortedSymbols(
|
const QList<LanguageServerProtocol::DocumentSymbol> children = sortedSymbols(
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
LanguageClientOutlineItem(Client *client, const LanguageServerProtocol::DocumentSymbol &info);
|
LanguageClientOutlineItem(Client *client, const LanguageServerProtocol::DocumentSymbol &info);
|
||||||
|
|
||||||
LanguageServerProtocol::Range range() const { return m_range; }
|
LanguageServerProtocol::Range range() const { return m_range; }
|
||||||
|
LanguageServerProtocol::Range selectionRange() const { return m_selectionRange; }
|
||||||
LanguageServerProtocol::Position pos() const { return m_range.start(); }
|
LanguageServerProtocol::Position pos() const { return m_range.start(); }
|
||||||
bool contains(const LanguageServerProtocol::Position &pos) const {
|
bool contains(const LanguageServerProtocol::Position &pos) const {
|
||||||
return m_range.contains(pos);
|
return m_range.contains(pos);
|
||||||
@@ -46,6 +47,7 @@ private:
|
|||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_detail;
|
QString m_detail;
|
||||||
LanguageServerProtocol::Range m_range;
|
LanguageServerProtocol::Range m_range;
|
||||||
|
LanguageServerProtocol::Range m_selectionRange;
|
||||||
int m_type = -1;
|
int m_type = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user