forked from qt-creator/qt-creator
TextEditor: Implement highlighting of function definitions
This allows users to style function names at their definitions. Once set, the XML-style token "FunctionDefinition" will highlight all function definitions: the style option is a mixin to Function and Virtual Function. TEST=Default themes and locally hacked themes that lack Function, FunctionDefinition, Declaration-styling look as they did before this patch. Requires Clang. Task-number: QTCREATORBUG-16625 Change-Id: I49d8e401211bdf28ff74699feac16fe98f6d64ce Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -84,6 +84,10 @@ bool HighlightingMark::hasMainType(HighlightingType type) const
|
||||
return m_types.mainHighlightingType == type;
|
||||
}
|
||||
|
||||
unsigned HighlightingMark::mixinSize() const {
|
||||
return m_types.mixinHighlightingTypes.size();
|
||||
}
|
||||
|
||||
bool HighlightingMark::hasMixinType(HighlightingType type) const
|
||||
{
|
||||
auto found = std::find(m_types.mixinHighlightingTypes.begin(),
|
||||
@@ -93,6 +97,12 @@ bool HighlightingMark::hasMixinType(HighlightingType type) const
|
||||
return found != m_types.mixinHighlightingTypes.end();
|
||||
}
|
||||
|
||||
bool HighlightingMark::hasMixinTypeAt(uint position, HighlightingType type) const
|
||||
{
|
||||
return m_types.mixinHighlightingTypes.size() > position &&
|
||||
m_types.mixinHighlightingTypes.at(position) == type;
|
||||
}
|
||||
|
||||
bool HighlightingMark::hasOnlyType(HighlightingType type) const
|
||||
{
|
||||
return m_types.mixinHighlightingTypes.size() == 0 && hasMainType(type);
|
||||
@@ -191,17 +201,22 @@ void HighlightingMark::fieldKind(const Cursor &)
|
||||
m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument);
|
||||
}
|
||||
|
||||
bool HighlightingMark::isDefinition() const
|
||||
{
|
||||
return m_originalCursor.isDefinition();
|
||||
}
|
||||
|
||||
bool HighlightingMark::isVirtualMethodDeclarationOrDefinition(const Cursor &cursor) const
|
||||
{
|
||||
return cursor.isVirtualMethod()
|
||||
&& (m_originalCursor.isDeclaration() || m_originalCursor.isDefinition());
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool isNotFinalFunction(const Cursor &cursor)
|
||||
{
|
||||
return !cursor.hasFinalFunctionAttribute();
|
||||
}
|
||||
|
||||
}
|
||||
bool HighlightingMark::isRealDynamicCall(const Cursor &cursor) const
|
||||
{
|
||||
@@ -285,6 +300,9 @@ void HighlightingMark::functionKind(const Cursor &cursor, Recursion recursion)
|
||||
m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument);
|
||||
|
||||
addExtraTypeIfFirstPass(HighlightingType::Declaration, recursion);
|
||||
|
||||
if (isDefinition())
|
||||
addExtraTypeIfFirstPass(HighlightingType::FunctionDefinition, recursion);
|
||||
}
|
||||
|
||||
void HighlightingMark::identifierKind(const Cursor &cursor, Recursion recursion)
|
||||
|
||||
@@ -53,7 +53,9 @@ public:
|
||||
|
||||
bool hasInvalidMainType() const;
|
||||
bool hasMainType(HighlightingType type) const;
|
||||
unsigned mixinSize() const;
|
||||
bool hasMixinType(HighlightingType type) const;
|
||||
bool hasMixinTypeAt(uint, HighlightingType type) const;
|
||||
bool hasOnlyType(HighlightingType type) const;
|
||||
bool hasFunctionArguments() const;
|
||||
|
||||
@@ -66,6 +68,7 @@ private:
|
||||
void variableKind(const Cursor &cursor);
|
||||
void fieldKind(const Cursor &cursor);
|
||||
bool isVirtualMethodDeclarationOrDefinition(const Cursor &cursor) const;
|
||||
bool isDefinition() const;
|
||||
void functionKind(const Cursor &cursor, Recursion recursion);
|
||||
void memberReferenceKind(const Cursor &cursor);
|
||||
HighlightingType punctuationKind(const Cursor &cursor);
|
||||
|
||||
Reference in New Issue
Block a user