MCPcopy Create free account
hub / github.com/KDE/kdevelop / attributeForType

Method attributeForType

kdevplatform/language/highlighting/codehighlighting.cpp:75–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75KTextEditor::Attribute::Ptr CodeHighlighting::attributeForType(CodeHighlightingType type,
76 CodeHighlightingContext context,
77 const QColor& color) const
78{
79 QMutexLocker lock(&m_dataMutex);
80 KTextEditor::Attribute::Ptr a;
81 switch (context) {
82 case CodeHighlightingContext::Definition:
83 a = m_definitionAttributes[type];
84 break;
85
86 case CodeHighlightingContext::Declaration:
87 a = m_declarationAttributes[type];
88 break;
89
90 case CodeHighlightingContext::Reference:
91 a = m_referenceAttributes[type];
92 break;
93 }
94
95 if (!a || color.isValid()) {
96 a = KTextEditor::Attribute::Ptr(new KTextEditor::Attribute(*ColorCache::self()->defaultColors()->attribute(
97 type)));
98
99 if (context == CodeHighlightingContext::Definition || context == CodeHighlightingContext::Declaration) {
100 if (ICore::self()->languageController()->completionSettings()->boldDeclarations()) {
101 a->setFontBold();
102 }
103 }
104
105 if (color.isValid()) {
106 a->setForeground(color);
107// a->setBackground(QColor(mix(0xffffff-color, backgroundColor(), 255-backgroundTinting)));
108 } else {
109 switch (context) {
110 case CodeHighlightingContext::Definition:
111 m_definitionAttributes.insert(type, a);
112 break;
113 case CodeHighlightingContext::Declaration:
114 m_declarationAttributes.insert(type, a);
115 break;
116 case CodeHighlightingContext::Reference:
117 m_referenceAttributes.insert(type, a);
118 break;
119 }
120 }
121 }
122
123 return a;
124}
125
126ColorMap emptyColorMap()
127{

Callers 2

highlightDeclarationMethod · 0.80
highlightUseMethod · 0.80

Calls 7

attributeMethod · 0.80
defaultColorsMethod · 0.80
boldDeclarationsMethod · 0.80
completionSettingsMethod · 0.80
languageControllerMethod · 0.80
isValidMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected