File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4747 "invalidselectstarexpansion" ,
4848 "noselectstar" ,
4949 "nomissingaudits" ,
50+ "nomissingowner" ,
5051 ],
5152 ),
5253)
Original file line number Diff line number Diff line change @@ -421,12 +421,25 @@ def _diagnostic_to_lsp_diagnostic(
421421 def _diagnostics_to_lsp_diagnostics (
422422 diagnostics : t .List [AnnotatedRuleViolation ],
423423 ) -> t .List [types .Diagnostic ]:
424- lsp_diagnostics : t .List [types .Diagnostic ] = []
424+ """
425+ Converts a list of AnnotatedRuleViolations to a list of LSP diagnostics. It will remove duplicates based on the message and range.
426+ """
427+ # Use a set to track unique diagnostics based on their message and range
428+ lsp_diagnostics = {}
425429 for diagnostic in diagnostics :
426430 lsp_diagnostic = SQLMeshLanguageServer ._diagnostic_to_lsp_diagnostic (diagnostic )
427431 if lsp_diagnostic is not None :
428- lsp_diagnostics .append (lsp_diagnostic )
429- return lsp_diagnostics
432+ # Create a unique key combining message and range
433+ diagnostic_key = (
434+ lsp_diagnostic .message ,
435+ lsp_diagnostic .range .start .line ,
436+ lsp_diagnostic .range .start .character ,
437+ lsp_diagnostic .range .end .line ,
438+ lsp_diagnostic .range .end .character ,
439+ )
440+ if diagnostic_key not in lsp_diagnostics :
441+ lsp_diagnostics [diagnostic_key ] = lsp_diagnostic
442+ return list (lsp_diagnostics .values ())
430443
431444 @staticmethod
432445 def _uri_to_path (uri : str ) -> Path :
You can’t perform that action at this time.
0 commit comments