mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
lsp: Mark deprecation warnings
Some editors use different styling (e.g. strikethrough) for deprecation warnings.
This commit is contained in:
parent
94db929f74
commit
950b141d26
8 changed files with 23 additions and 5 deletions
|
@ -128,6 +128,10 @@ class CompileWarning(CompileError):
|
|||
color = Colors.YELLOW
|
||||
|
||||
|
||||
class DeprecatedWarning(CompileWarning):
|
||||
pass
|
||||
|
||||
|
||||
class UpgradeWarning(CompileWarning):
|
||||
category = "upgrade"
|
||||
color = Colors.PURPLE
|
||||
|
|
|
@ -33,6 +33,7 @@ from ..errors import (
|
|||
CodeAction,
|
||||
CompileError,
|
||||
CompileWarning,
|
||||
DeprecatedWarning,
|
||||
MultipleErrors,
|
||||
UpgradeWarning,
|
||||
)
|
||||
|
|
|
@ -99,7 +99,7 @@ class Property(AstNode):
|
|||
hints = []
|
||||
if self.gir_property.deprecated_doc:
|
||||
hints.append(self.gir_property.deprecated_doc)
|
||||
raise CompileWarning(
|
||||
raise DeprecatedWarning(
|
||||
f"{self.gir_property.signature} is deprecated",
|
||||
hints=hints,
|
||||
)
|
||||
|
|
|
@ -142,7 +142,7 @@ class Signal(AstNode):
|
|||
hints = []
|
||||
if self.gir_signal.deprecated_doc:
|
||||
hints.append(self.gir_signal.deprecated_doc)
|
||||
raise CompileWarning(
|
||||
raise DeprecatedWarning(
|
||||
f"{self.gir_signal.signature} is deprecated",
|
||||
hints=hints,
|
||||
)
|
||||
|
|
|
@ -63,7 +63,7 @@ class TypeName(AstNode):
|
|||
hints = []
|
||||
if self.gir_type.deprecated_doc:
|
||||
hints.append(self.gir_type.deprecated_doc)
|
||||
raise CompileWarning(
|
||||
raise DeprecatedWarning(
|
||||
f"{self.gir_type.full_name} is deprecated",
|
||||
hints=hints,
|
||||
)
|
||||
|
|
|
@ -391,6 +391,9 @@ class LanguageServer:
|
|||
else DiagnosticSeverity.Error,
|
||||
}
|
||||
|
||||
if isinstance(err, DeprecationWarning):
|
||||
result["tags"] = [DiagnosticTag.Deprecated]
|
||||
|
||||
if len(err.references) > 0:
|
||||
result["relatedInformation"] = [
|
||||
{
|
||||
|
|
|
@ -119,6 +119,11 @@ class DiagnosticSeverity(enum.IntEnum):
|
|||
Hint = 4
|
||||
|
||||
|
||||
class DiagnosticTag(enum.IntEnum):
|
||||
Unnecessary = 1
|
||||
Deprecated = 2
|
||||
|
||||
|
||||
@dataclass
|
||||
class SemanticToken:
|
||||
start: int
|
||||
|
|
|
@ -29,7 +29,12 @@ from gi.repository import Gtk
|
|||
|
||||
from blueprintcompiler import decompiler, parser, tokenizer, utils
|
||||
from blueprintcompiler.completions import complete
|
||||
from blueprintcompiler.errors import CompileError, MultipleErrors, PrintableError
|
||||
from blueprintcompiler.errors import (
|
||||
CompileError,
|
||||
DeprecatedWarning,
|
||||
MultipleErrors,
|
||||
PrintableError,
|
||||
)
|
||||
from blueprintcompiler.outputs.xml import XmlOutput
|
||||
from blueprintcompiler.tokenizer import Token, TokenType, tokenize
|
||||
|
||||
|
@ -59,7 +64,7 @@ class TestSamples(unittest.TestCase):
|
|||
warnings = [
|
||||
warning
|
||||
for warning in warnings
|
||||
if "is deprecated" not in warning.message
|
||||
if not isinstance(warning, DeprecatedWarning)
|
||||
]
|
||||
|
||||
if errors:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue