File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 3232 incremental ,
3333 server_event ,
3434)
35+ from api import query
3536
3637LOG : logging .Logger = logging .getLogger (__name__ )
3738
@@ -502,6 +503,37 @@ def type_errors_to_diagnostics(
502503 return result
503504
504505
506+ # ** NEW **
507+ # Convert InvalidModel to Diagnostic object
508+ def invalid_model_to_diagnostic (
509+ invalid_model : query .InvalidModel ,
510+ ) -> lsp .Diagnostic :
511+ return lsp .Diagnostic (
512+ range = lsp .Range (
513+ start = lsp .Position (line = invalid_model .line , character = invalid_model .column ),
514+ end = lsp .Position (
515+ line = invalid_model .stop_line , character = invalid_model .stop_column
516+ ),
517+ ),
518+ message = invalid_model .full_error_message ,
519+ severity = lsp .DiagnosticSeverity .ERROR ,
520+ code = None ,
521+ source = "Pysa" ,
522+ )
523+
524+
525+ # ** NEW **
526+ # Convert list of InvalidModels to list of Diagnostics
527+ def invalid_models_to_diagnostics (
528+ invalid_models : Sequence [query .InvalidModel ],
529+ ) -> Dict [Path , List [lsp .Diagnostic ]]:
530+ result : Dict [Path , List [lsp .Diagnostic ]] = {}
531+ for model in invalid_models :
532+ result .setdefault (model .path , []).append (invalid_model_to_diagnostic (model ))
533+ # LOG.info(f"invalid_models_to_diagnostics(): result = {result}")
534+ return result
535+
536+
505537class PyreServerHandler (connection .BackgroundTask ):
506538 binary_location : str
507539 server_identifier : str
You can’t perform that action at this time.
0 commit comments