Skip to content

Commit

Permalink
refactor: get rid of SessionBuffer.data_per_severity (#2286)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl authored Jun 18, 2023
1 parent e5a9eb7 commit a074944
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 109 deletions.
5 changes: 4 additions & 1 deletion plugin/core/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
from .url import parse_uri
from .url import unparse_uri
from .version import __version__
from .views import DiagnosticSeverityData
from .views import extract_variables
from .views import get_storage_path
from .views import get_uri_and_range_from_location
Expand Down Expand Up @@ -539,7 +540,9 @@ def has_capability_async(self, capability_path: str) -> bool:
def shutdown_async(self) -> None:
...

def present_diagnostics_async(self, is_view_visible: bool) -> None:
def present_diagnostics_async(
self, is_view_visible: bool, data_per_severity: Dict[Tuple[int, bool], DiagnosticSeverityData]
) -> None:
...

def on_request_started_async(self, request_id: int, request: Request) -> None:
Expand Down
13 changes: 13 additions & 0 deletions plugin/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,19 @@
}


class DiagnosticSeverityData:

__slots__ = ('regions', 'regions_with_tag', 'annotations', 'scope', 'icon')

def __init__(self, severity: int) -> None:
self.regions = [] # type: List[sublime.Region]
self.regions_with_tag = {} # type: Dict[int, List[sublime.Region]]
self.annotations = [] # type: List[str]
_, _, self.scope, self.icon, _, _ = DIAGNOSTIC_SEVERITY[severity - 1]
if userprefs().diagnostics_gutter_marker != "sign":
self.icon = "" if severity == DiagnosticSeverity.Hint else userprefs().diagnostics_gutter_marker


class InvalidUriSchemeException(Exception):
def __init__(self, uri: str) -> None:
self.uri = uri
Expand Down
Loading

0 comments on commit a074944

Please sign in to comment.