forked from qt-creator/qt-creator
LanguageClient: render hint and info diagnostics differently
Currently hint and information diagnostics are rendered as warnings. Add and use a new color for those type of diagnostics. Fixes: QTCREATORBUG-31878 Change-Id: I2fdd01213b32bd5dc433b925a1a44c0db480f422 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -11,6 +11,7 @@ BadgeLabelTextColorChecked=Token_Text_Default
|
||||
BadgeLabelTextColorUnchecked=Token_Text_Default
|
||||
CodeModel_Error_TextMarkColor=error
|
||||
CodeModel_Warning_TextMarkColor=warning
|
||||
CodeModel_Info_TextMarkColor=info
|
||||
ComboBoxTextColor=Token_Text_Muted
|
||||
DockWidgetResizeHandleColor=Token_Stroke_Subtle
|
||||
EditorPlaceholderColor=Token_Background_Muted
|
||||
|
@@ -16,6 +16,7 @@ normalBackground=ff333333
|
||||
alternateBackground=ff515151
|
||||
error=ffd84044
|
||||
warning=ffe0b716
|
||||
info=ff1f75cc
|
||||
splitterColor=ff313131
|
||||
textColorLink=ff8ab4f8
|
||||
textColorLinkVisited=ffc58af9
|
||||
@@ -406,6 +407,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
||||
|
||||
CodeModel_Error_TextMarkColor=error
|
||||
CodeModel_Warning_TextMarkColor=warning
|
||||
CodeModel_Info_TextMarkColor=info
|
||||
|
||||
PaletteWindow=normalBackground
|
||||
PaletteWindowText=text
|
||||
|
@@ -10,6 +10,7 @@ textDisabled=88a0a0a0
|
||||
toolBarItem=ffdcdcdc
|
||||
error=ffdf4f4f
|
||||
warning=ffecbc1c
|
||||
info=ff4f8fff
|
||||
shadowBackground=ff232323
|
||||
splitterColor=ff151515
|
||||
qmlDesignerButtonColor=ff4c4e50
|
||||
@@ -399,6 +400,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
||||
|
||||
CodeModel_Error_TextMarkColor=error
|
||||
CodeModel_Warning_TextMarkColor=warning
|
||||
CodeModel_Info_TextMarkColor=info
|
||||
|
||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||
QmlDesigner_HighlightColor=ff46a2da
|
||||
|
@@ -20,6 +20,7 @@ stop_error=ffec7373
|
||||
run_success=ff52c23b
|
||||
error=ffdf4f4f
|
||||
warning=ffecbc1c
|
||||
info=ff4f9df8
|
||||
splitter=ffbdbebf
|
||||
qmlDesignerButtonColor=fff8f8f8
|
||||
textColorLink=ff007af4
|
||||
@@ -410,6 +411,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
||||
|
||||
CodeModel_Error_TextMarkColor=error
|
||||
CodeModel_Warning_TextMarkColor=warning
|
||||
CodeModel_Info_TextMarkColor=info
|
||||
|
||||
;new colors
|
||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||
|
@@ -19,6 +19,7 @@ normalBackground=ff262728
|
||||
alternateBackground=ff353637
|
||||
error=ffdf4f4f
|
||||
warning=ffecbc1c
|
||||
info=ff4f8fff
|
||||
splitter=ff474747
|
||||
textColorLink=ff007af4
|
||||
textColorLinkVisited=ffa57aff
|
||||
@@ -414,6 +415,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
||||
|
||||
CodeModel_Error_TextMarkColor=error
|
||||
CodeModel_Warning_TextMarkColor=warning
|
||||
CodeModel_Info_TextMarkColor=info
|
||||
|
||||
;Designer Main colors
|
||||
|
||||
|
@@ -20,6 +20,7 @@ normalBackground=ff2E2F30
|
||||
alternateBackground=ff353637
|
||||
error=ffdf4f4f
|
||||
warning=ffecbc1c
|
||||
info=ff4f8fff
|
||||
splitter=ff06080A
|
||||
textColorLink=ff007af4
|
||||
textColorLinkVisited=ffa57aff
|
||||
@@ -410,6 +411,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
||||
|
||||
CodeModel_Error_TextMarkColor=error
|
||||
CodeModel_Warning_TextMarkColor=warning
|
||||
CodeModel_Info_TextMarkColor=info
|
||||
|
||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||
QmlDesigner_HighlightColor=ff1d545c
|
||||
|
@@ -20,6 +20,7 @@ run_success=ff52c23b
|
||||
splitter=ffbdbebf
|
||||
error=ffdf4f4f
|
||||
warning=ffecbc1c
|
||||
info=ff4f8df0
|
||||
textColorLink=PaletteLink
|
||||
textColorLinkVisited=PaletteLinkVisited
|
||||
backgroundColorDisabled=PaletteWindowDisabled
|
||||
@@ -410,6 +411,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
||||
|
||||
CodeModel_Error_TextMarkColor=error
|
||||
CodeModel_Warning_TextMarkColor=warning
|
||||
CodeModel_Info_TextMarkColor=info
|
||||
|
||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||
QmlDesigner_HighlightColor=ff46a2da
|
||||
|
@@ -17,6 +17,7 @@ normalBackground=PaletteWindow
|
||||
alternateBackground=PaletteAlternateBase
|
||||
error=ffdf4f4f
|
||||
warning=ffecbc1c
|
||||
info=ff4f83f1
|
||||
splitter=ff313131
|
||||
textColorLink=PaletteLink
|
||||
textColorLinkVisited=PaletteLinkVisited
|
||||
@@ -407,6 +408,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
||||
|
||||
CodeModel_Error_TextMarkColor=error
|
||||
CodeModel_Warning_TextMarkColor=warning
|
||||
CodeModel_Info_TextMarkColor=info
|
||||
|
||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||
QmlDesigner_HighlightColor=ff46a2da
|
||||
|
@@ -171,6 +171,7 @@ public:
|
||||
|
||||
CodeModel_Error_TextMarkColor,
|
||||
CodeModel_Warning_TextMarkColor,
|
||||
CodeModel_Info_TextMarkColor,
|
||||
|
||||
/* Output panes */
|
||||
|
||||
|
@@ -39,13 +39,19 @@ public:
|
||||
{
|
||||
setLineAnnotation(diag.message());
|
||||
setToolTip(diag.message());
|
||||
const bool isError
|
||||
= diag.severity().value_or(DiagnosticSeverity::Hint) == DiagnosticSeverity::Error;
|
||||
setColor(isError ? Theme::CodeModel_Error_TextMarkColor
|
||||
: Theme::CodeModel_Warning_TextMarkColor);
|
||||
|
||||
setIcon(isError ? Icons::CODEMODEL_ERROR.icon()
|
||||
: Icons::CODEMODEL_WARNING.icon());
|
||||
switch (diag.severity().value_or(DiagnosticSeverity::Hint)) {
|
||||
case DiagnosticSeverity::Error:
|
||||
setColor(Theme::CodeModel_Error_TextMarkColor);
|
||||
setIcon(Icons::CODEMODEL_ERROR.icon());
|
||||
break;
|
||||
case DiagnosticSeverity::Warning:
|
||||
setColor(Theme::CodeModel_Warning_TextMarkColor);
|
||||
setIcon(Icons::CODEMODEL_WARNING.icon());
|
||||
break;
|
||||
default:
|
||||
setColor(Theme::CodeModel_Info_TextMarkColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -257,16 +263,23 @@ void DiagnosticManager::setForceCreateTasks(bool forceCreateTasks)
|
||||
QTextEdit::ExtraSelection DiagnosticManager::createDiagnosticSelection(
|
||||
const LanguageServerProtocol::Diagnostic &diagnostic, QTextDocument *textDocument) const
|
||||
{
|
||||
const DiagnosticSeverity severity = diagnostic.severity().value_or(DiagnosticSeverity::Warning);
|
||||
TextStyle style;
|
||||
if (severity == DiagnosticSeverity::Error)
|
||||
style = C_ERROR;
|
||||
else if (severity == DiagnosticSeverity::Warning)
|
||||
style = C_ERROR;
|
||||
else
|
||||
return {};
|
||||
|
||||
QTextCursor cursor(textDocument);
|
||||
cursor.setPosition(diagnostic.range().start().toPositionInDocument(textDocument));
|
||||
cursor.setPosition(diagnostic.range().end().toPositionInDocument(textDocument),
|
||||
QTextCursor::KeepAnchor);
|
||||
|
||||
const FontSettings &fontSettings = TextEditorSettings::fontSettings();
|
||||
const DiagnosticSeverity severity = diagnostic.severity().value_or(DiagnosticSeverity::Warning);
|
||||
const TextStyle style = severity == DiagnosticSeverity::Error ? C_ERROR : C_WARNING;
|
||||
const QTextCharFormat format = TextEditorSettings::fontSettings().toTextCharFormat(style);
|
||||
|
||||
return QTextEdit::ExtraSelection{cursor, fontSettings.toTextCharFormat(style)};
|
||||
return QTextEdit::ExtraSelection{cursor, format};
|
||||
}
|
||||
|
||||
void DiagnosticManager::setExtraSelectionsId(const Utils::Id &extraSelectionsId)
|
||||
|
Reference in New Issue
Block a user