Commit a284d136 authored by Milian Wolff's avatar Milian Wolff
Browse files

Also remove Error Variable from list of configurable attributes

Instead just reuse dsError directly, I don't see any advantage
of having this as a separate editable entity. While at it, also
rename the highlighting type from ErrorVariable to just Error.
parent 4f56c0fa
......@@ -385,12 +385,8 @@ CodeHighlightingType CodeHighlightingInstance::typeForDeclaration(Declaration* d
*
* */
// if(ClassMemberDeclaration* classMember = dynamic_cast<ClassMemberDeclaration*>(dec))
// if(!Cpp::isAccessible(context, classMember))
// return ErrorVariableType;
if (!dec)
return CodeHighlightingType::ErrorVariable;
return CodeHighlightingType::Error;
auto type = CodeHighlightingType::LocalVariable;
if (dec->kind() == Declaration::Namespace)
......@@ -478,12 +474,11 @@ void CodeHighlightingInstance::highlightDeclaration(Declaration* declaration, co
void CodeHighlightingInstance::highlightUse(DUContext* context, int index, const QColor& color)
{
auto type = CodeHighlightingType::ErrorVariable;
Declaration* decl = context->topContext()->usedDeclarationForIndex(context->uses()[index].m_declarationIndex);
type = typeForDeclaration(decl, context);
auto type = typeForDeclaration(decl, context);
if (type != CodeHighlightingType::ErrorVariable
if (type != CodeHighlightingType::Error
|| ICore::self()->languageController()->completionSettings()->highlightSemanticProblems()) {
HighlightedRange h;
h.range = context->uses()[index].m_range;
......
......@@ -30,7 +30,7 @@ using ColorMap = QVector<KDevelop::Declaration*>;
class CodeHighlighting;
enum class CodeHighlightingType {
Unknown,
Error,
LocalClassMember,
LocalMemberFunction,
......@@ -41,7 +41,6 @@ enum class CodeHighlightingType {
NamespaceVariable,
GlobalVariable,
FunctionVariable,
ErrorVariable,
Class,
Namespace,
......
......@@ -72,10 +72,8 @@ CodeHighlightingType highlightingTypeFromName(const QString& name)
return CodeHighlightingType::Macro;
} else if (name == QLatin1String("Macro Function")) {
return CodeHighlightingType::MacroFunctionLike;
} else if (name == QLatin1String("Error Variable")) {
return CodeHighlightingType::ErrorVariable;
}
return CodeHighlightingType::Unknown;
return CodeHighlightingType::Error;
}
ColorCache::ColorCache(QObject* parent)
......@@ -263,10 +261,11 @@ bool ColorCache::updateColorsFromTheme(const KSyntaxHighlighting::Theme& theme)
bool anyAttrChanged = false;
for (const auto& format : formats) {
const auto type = highlightingTypeFromName(format.name());
const auto attr = m_defaultColors->attribute(type);
if (!attr) {
if (type == CodeHighlightingType::Error) {
continue;
}
const auto attr = m_defaultColors->attribute(type);
Q_ASSERT(attr);
auto forwardProperty = [&](auto formatGetter, auto attrProperty, auto attrSetter) {
auto formatProperty = (format.*formatGetter)(theme);
......
......@@ -33,13 +33,16 @@ KTextEditor::Attribute::Ptr ConfigurableHighlightingColors::attribute(CodeHighli
void ConfigurableHighlightingColors::reset(ColorCache* cache, KTextEditor::View* view)
{
m_attributes.clear();
auto createAttribute = [&](CodeHighlightingType type) {
KTextEditor::Attribute::Ptr a(new KTextEditor::Attribute);
m_attributes[type] = a;
return a;
};
auto addColor = [&](CodeHighlightingType type, QRgb color_) {
auto a = createAttribute(type);
auto color = QColor::fromRgb(color_);
KTextEditor::Attribute::Ptr a(new KTextEditor::Attribute);
a->setForeground(cache ? cache->blendGlobalColor(color) : color);
m_attributes[type] = a;
ifDebug(qCDebug(LANGUAGE) << #type << "color: " << #color_ << "->" << a->foreground().color().name());
return a;
};
// TODO: The set of colors doesn't work very well. Many colors simply too dark (even on the maximum "Global colorization intensity" they hardly distinguishable from grey) and look alike.
addColor(CodeHighlightingType::Class, 0x005912); // Dark green
......@@ -57,13 +60,12 @@ void ConfigurableHighlightingColors::reset(ColorCache* cache, KTextEditor::View*
addColor(CodeHighlightingType::NamespaceVariable, 0x9F3C5F); // Rose
addColor(CodeHighlightingType::GlobalVariable, 0x12762B); // Grass green
addColor(CodeHighlightingType::Namespace, 0x6B2840); // Dark rose
addColor(CodeHighlightingType::ErrorVariable, 0x8b0019); // Pure red
addColor(CodeHighlightingType::ForwardDeclaration, 0x5C5C5C); // Gray
addColor(CodeHighlightingType::Macro, 0xA41239);
addColor(CodeHighlightingType::MacroFunctionLike, 0x008080);
{
auto highlightUses = addColor(CodeHighlightingType::HighlightUses, 0xffffff);
auto highlightUses = createAttribute(CodeHighlightingType::HighlightUses);
highlightUses->setDefaultStyle(KTextEditor::dsNormal);
highlightUses->setForeground(highlightUses->selectedForeground());
highlightUses->setBackground(highlightUses->selectedBackground());
......@@ -73,5 +75,9 @@ void ConfigurableHighlightingColors::reset(ColorCache* cache, KTextEditor::View*
highlightUses->setBackground(QColor::fromRgb(searchHighlight));
}
}
{
auto error = createAttribute(CodeHighlightingType::Error);
error->setDefaultStyle(KTextEditor::dsError);
}
}
}
......@@ -34,7 +34,6 @@
<itemData name="Enumerator" defStyleNum="dsNormal" spellChecking="false" />
<itemData name="Macro" defStyleNum="dsPreprocessor" spellChecking="false" />
<itemData name="Macro Function" defStyleNum="dsPreprocessor" spellChecking="false" />
<itemData name="Error Variable" defStyleNum="dsError" spellChecking="false" />
</itemDatas>
</highlighting>
</language>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment