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
|
BadgeLabelTextColorUnchecked=Token_Text_Default
|
||||||
CodeModel_Error_TextMarkColor=error
|
CodeModel_Error_TextMarkColor=error
|
||||||
CodeModel_Warning_TextMarkColor=warning
|
CodeModel_Warning_TextMarkColor=warning
|
||||||
|
CodeModel_Info_TextMarkColor=info
|
||||||
ComboBoxTextColor=Token_Text_Muted
|
ComboBoxTextColor=Token_Text_Muted
|
||||||
DockWidgetResizeHandleColor=Token_Stroke_Subtle
|
DockWidgetResizeHandleColor=Token_Stroke_Subtle
|
||||||
EditorPlaceholderColor=Token_Background_Muted
|
EditorPlaceholderColor=Token_Background_Muted
|
||||||
|
@@ -16,6 +16,7 @@ normalBackground=ff333333
|
|||||||
alternateBackground=ff515151
|
alternateBackground=ff515151
|
||||||
error=ffd84044
|
error=ffd84044
|
||||||
warning=ffe0b716
|
warning=ffe0b716
|
||||||
|
info=ff1f75cc
|
||||||
splitterColor=ff313131
|
splitterColor=ff313131
|
||||||
textColorLink=ff8ab4f8
|
textColorLink=ff8ab4f8
|
||||||
textColorLinkVisited=ffc58af9
|
textColorLinkVisited=ffc58af9
|
||||||
@@ -406,6 +407,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
|||||||
|
|
||||||
CodeModel_Error_TextMarkColor=error
|
CodeModel_Error_TextMarkColor=error
|
||||||
CodeModel_Warning_TextMarkColor=warning
|
CodeModel_Warning_TextMarkColor=warning
|
||||||
|
CodeModel_Info_TextMarkColor=info
|
||||||
|
|
||||||
PaletteWindow=normalBackground
|
PaletteWindow=normalBackground
|
||||||
PaletteWindowText=text
|
PaletteWindowText=text
|
||||||
|
@@ -10,6 +10,7 @@ textDisabled=88a0a0a0
|
|||||||
toolBarItem=ffdcdcdc
|
toolBarItem=ffdcdcdc
|
||||||
error=ffdf4f4f
|
error=ffdf4f4f
|
||||||
warning=ffecbc1c
|
warning=ffecbc1c
|
||||||
|
info=ff4f8fff
|
||||||
shadowBackground=ff232323
|
shadowBackground=ff232323
|
||||||
splitterColor=ff151515
|
splitterColor=ff151515
|
||||||
qmlDesignerButtonColor=ff4c4e50
|
qmlDesignerButtonColor=ff4c4e50
|
||||||
@@ -399,6 +400,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
|||||||
|
|
||||||
CodeModel_Error_TextMarkColor=error
|
CodeModel_Error_TextMarkColor=error
|
||||||
CodeModel_Warning_TextMarkColor=warning
|
CodeModel_Warning_TextMarkColor=warning
|
||||||
|
CodeModel_Info_TextMarkColor=info
|
||||||
|
|
||||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||||
QmlDesigner_HighlightColor=ff46a2da
|
QmlDesigner_HighlightColor=ff46a2da
|
||||||
|
@@ -20,6 +20,7 @@ stop_error=ffec7373
|
|||||||
run_success=ff52c23b
|
run_success=ff52c23b
|
||||||
error=ffdf4f4f
|
error=ffdf4f4f
|
||||||
warning=ffecbc1c
|
warning=ffecbc1c
|
||||||
|
info=ff4f9df8
|
||||||
splitter=ffbdbebf
|
splitter=ffbdbebf
|
||||||
qmlDesignerButtonColor=fff8f8f8
|
qmlDesignerButtonColor=fff8f8f8
|
||||||
textColorLink=ff007af4
|
textColorLink=ff007af4
|
||||||
@@ -410,6 +411,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
|||||||
|
|
||||||
CodeModel_Error_TextMarkColor=error
|
CodeModel_Error_TextMarkColor=error
|
||||||
CodeModel_Warning_TextMarkColor=warning
|
CodeModel_Warning_TextMarkColor=warning
|
||||||
|
CodeModel_Info_TextMarkColor=info
|
||||||
|
|
||||||
;new colors
|
;new colors
|
||||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||||
|
@@ -19,6 +19,7 @@ normalBackground=ff262728
|
|||||||
alternateBackground=ff353637
|
alternateBackground=ff353637
|
||||||
error=ffdf4f4f
|
error=ffdf4f4f
|
||||||
warning=ffecbc1c
|
warning=ffecbc1c
|
||||||
|
info=ff4f8fff
|
||||||
splitter=ff474747
|
splitter=ff474747
|
||||||
textColorLink=ff007af4
|
textColorLink=ff007af4
|
||||||
textColorLinkVisited=ffa57aff
|
textColorLinkVisited=ffa57aff
|
||||||
@@ -414,6 +415,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
|||||||
|
|
||||||
CodeModel_Error_TextMarkColor=error
|
CodeModel_Error_TextMarkColor=error
|
||||||
CodeModel_Warning_TextMarkColor=warning
|
CodeModel_Warning_TextMarkColor=warning
|
||||||
|
CodeModel_Info_TextMarkColor=info
|
||||||
|
|
||||||
;Designer Main colors
|
;Designer Main colors
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ normalBackground=ff2E2F30
|
|||||||
alternateBackground=ff353637
|
alternateBackground=ff353637
|
||||||
error=ffdf4f4f
|
error=ffdf4f4f
|
||||||
warning=ffecbc1c
|
warning=ffecbc1c
|
||||||
|
info=ff4f8fff
|
||||||
splitter=ff06080A
|
splitter=ff06080A
|
||||||
textColorLink=ff007af4
|
textColorLink=ff007af4
|
||||||
textColorLinkVisited=ffa57aff
|
textColorLinkVisited=ffa57aff
|
||||||
@@ -410,6 +411,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
|||||||
|
|
||||||
CodeModel_Error_TextMarkColor=error
|
CodeModel_Error_TextMarkColor=error
|
||||||
CodeModel_Warning_TextMarkColor=warning
|
CodeModel_Warning_TextMarkColor=warning
|
||||||
|
CodeModel_Info_TextMarkColor=info
|
||||||
|
|
||||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||||
QmlDesigner_HighlightColor=ff1d545c
|
QmlDesigner_HighlightColor=ff1d545c
|
||||||
|
@@ -20,6 +20,7 @@ run_success=ff52c23b
|
|||||||
splitter=ffbdbebf
|
splitter=ffbdbebf
|
||||||
error=ffdf4f4f
|
error=ffdf4f4f
|
||||||
warning=ffecbc1c
|
warning=ffecbc1c
|
||||||
|
info=ff4f8df0
|
||||||
textColorLink=PaletteLink
|
textColorLink=PaletteLink
|
||||||
textColorLinkVisited=PaletteLinkVisited
|
textColorLinkVisited=PaletteLinkVisited
|
||||||
backgroundColorDisabled=PaletteWindowDisabled
|
backgroundColorDisabled=PaletteWindowDisabled
|
||||||
@@ -410,6 +411,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
|||||||
|
|
||||||
CodeModel_Error_TextMarkColor=error
|
CodeModel_Error_TextMarkColor=error
|
||||||
CodeModel_Warning_TextMarkColor=warning
|
CodeModel_Warning_TextMarkColor=warning
|
||||||
|
CodeModel_Info_TextMarkColor=info
|
||||||
|
|
||||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||||
QmlDesigner_HighlightColor=ff46a2da
|
QmlDesigner_HighlightColor=ff46a2da
|
||||||
|
@@ -17,6 +17,7 @@ normalBackground=PaletteWindow
|
|||||||
alternateBackground=PaletteAlternateBase
|
alternateBackground=PaletteAlternateBase
|
||||||
error=ffdf4f4f
|
error=ffdf4f4f
|
||||||
warning=ffecbc1c
|
warning=ffecbc1c
|
||||||
|
info=ff4f83f1
|
||||||
splitter=ff313131
|
splitter=ff313131
|
||||||
textColorLink=PaletteLink
|
textColorLink=PaletteLink
|
||||||
textColorLinkVisited=PaletteLinkVisited
|
textColorLinkVisited=PaletteLinkVisited
|
||||||
@@ -407,6 +408,7 @@ ProjectExplorer_TaskWarn_TextMarkColor=warning
|
|||||||
|
|
||||||
CodeModel_Error_TextMarkColor=error
|
CodeModel_Error_TextMarkColor=error
|
||||||
CodeModel_Warning_TextMarkColor=warning
|
CodeModel_Warning_TextMarkColor=warning
|
||||||
|
CodeModel_Info_TextMarkColor=info
|
||||||
|
|
||||||
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
QmlDesigner_BackgroundColor=qmlDesignerButtonColor
|
||||||
QmlDesigner_HighlightColor=ff46a2da
|
QmlDesigner_HighlightColor=ff46a2da
|
||||||
|
@@ -171,6 +171,7 @@ public:
|
|||||||
|
|
||||||
CodeModel_Error_TextMarkColor,
|
CodeModel_Error_TextMarkColor,
|
||||||
CodeModel_Warning_TextMarkColor,
|
CodeModel_Warning_TextMarkColor,
|
||||||
|
CodeModel_Info_TextMarkColor,
|
||||||
|
|
||||||
/* Output panes */
|
/* Output panes */
|
||||||
|
|
||||||
|
@@ -39,13 +39,19 @@ public:
|
|||||||
{
|
{
|
||||||
setLineAnnotation(diag.message());
|
setLineAnnotation(diag.message());
|
||||||
setToolTip(diag.message());
|
setToolTip(diag.message());
|
||||||
const bool isError
|
switch (diag.severity().value_or(DiagnosticSeverity::Hint)) {
|
||||||
= diag.severity().value_or(DiagnosticSeverity::Hint) == DiagnosticSeverity::Error;
|
case DiagnosticSeverity::Error:
|
||||||
setColor(isError ? Theme::CodeModel_Error_TextMarkColor
|
setColor(Theme::CodeModel_Error_TextMarkColor);
|
||||||
: Theme::CodeModel_Warning_TextMarkColor);
|
setIcon(Icons::CODEMODEL_ERROR.icon());
|
||||||
|
break;
|
||||||
setIcon(isError ? Icons::CODEMODEL_ERROR.icon()
|
case DiagnosticSeverity::Warning:
|
||||||
: Icons::CODEMODEL_WARNING.icon());
|
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(
|
QTextEdit::ExtraSelection DiagnosticManager::createDiagnosticSelection(
|
||||||
const LanguageServerProtocol::Diagnostic &diagnostic, QTextDocument *textDocument) const
|
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);
|
QTextCursor cursor(textDocument);
|
||||||
cursor.setPosition(diagnostic.range().start().toPositionInDocument(textDocument));
|
cursor.setPosition(diagnostic.range().start().toPositionInDocument(textDocument));
|
||||||
cursor.setPosition(diagnostic.range().end().toPositionInDocument(textDocument),
|
cursor.setPosition(diagnostic.range().end().toPositionInDocument(textDocument),
|
||||||
QTextCursor::KeepAnchor);
|
QTextCursor::KeepAnchor);
|
||||||
|
|
||||||
const FontSettings &fontSettings = TextEditorSettings::fontSettings();
|
const QTextCharFormat format = TextEditorSettings::fontSettings().toTextCharFormat(style);
|
||||||
const DiagnosticSeverity severity = diagnostic.severity().value_or(DiagnosticSeverity::Warning);
|
|
||||||
const TextStyle style = severity == DiagnosticSeverity::Error ? C_ERROR : C_WARNING;
|
|
||||||
|
|
||||||
return QTextEdit::ExtraSelection{cursor, fontSettings.toTextCharFormat(style)};
|
return QTextEdit::ExtraSelection{cursor, format};
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticManager::setExtraSelectionsId(const Utils::Id &extraSelectionsId)
|
void DiagnosticManager::setExtraSelectionsId(const Utils::Id &extraSelectionsId)
|
||||||
|
Reference in New Issue
Block a user