diff --git a/tools/chapel-py/src/chapel/lsp/__init__.py b/tools/chapel-py/src/chapel/lsp/__init__.py index 2f4f9f1453ff..64fb88f20b71 100644 --- a/tools/chapel-py/src/chapel/lsp/__init__.py +++ b/tools/chapel-py/src/chapel/lsp/__init__.py @@ -45,11 +45,16 @@ def error_to_diagnostic(error) -> Diagnostic: "warning": DiagnosticSeverity.Warning, } + type_ = error.type() + if type_ is not None: + message = "{}: [{}]: {}".format( + error.kind().capitalize(), type_, error.message() + ) + else: + message = "{}: {}".format(error.kind().capitalize(), error.message()) diagnostic = Diagnostic( range=location_to_range(error.location()), - message="{}: [{}]: {}".format( - error.kind().capitalize(), error.type(), error.message() - ), + message=message, severity=kind_to_severity[error.kind()], ) return diagnostic diff --git a/tools/chapel-py/src/method-tables/core-methods.h b/tools/chapel-py/src/method-tables/core-methods.h index 24e27b8cd2f7..f61edc8db86b 100644 --- a/tools/chapel-py/src/method-tables/core-methods.h +++ b/tools/chapel-py/src/method-tables/core-methods.h @@ -143,7 +143,10 @@ CLASS_BEGIN(Error) PLAIN_GETTER(Error, kind, "Retrieve the kind ('error', 'warning') of this type of error", const char*, return chpl::ErrorBase::getKindName(node->kind())) PLAIN_GETTER(Error, type, "Retrieve the unique name of this type of error", - const char*, return chpl::ErrorBase::getTypeName(node->type())) + std::optional, + const char* name = chpl::ErrorBase::getTypeName(node->type()); + return name ? std::optional(name) : std::nullopt; + ) CLASS_END(Error) CLASS_BEGIN(ErrorManager) diff --git a/tools/chpl-language-server/src/chpl-language-server.py b/tools/chpl-language-server/src/chpl-language-server.py index 32d310c74eab..aba5c43f14d3 100755 --- a/tools/chpl-language-server/src/chpl-language-server.py +++ b/tools/chpl-language-server/src/chpl-language-server.py @@ -258,6 +258,8 @@ def encode_deltas( to it: each line is encoded as a delta from the previous line, and each column is encoded as a delta from the previous column. + `tokens` must be sorted by line number, and then by column number within + Returns tokens with type token_type, and modifiers token_modifiers. """ @@ -688,6 +690,8 @@ def rebuild_index(self): self._collect_possibly_visible_decls(asts) if self.use_resolver: + # TODO: suppress resolution errors due to false-positives + # this should be removed once the resolver is finished with self.context.context.track_errors() as _: self._search_instantiations(asts) @@ -1853,6 +1857,8 @@ async def semantic_tokens_range( ls.get_dead_code_tokens(ast, fi.file_lines(), instantiation) ) + # sort tokens by line number, and then by column number + tokens.sort(key=lambda x: (x[0], x[1])) return SemanticTokens(data=encode_deltas(tokens, 0, 0)) @server.feature(TEXT_DOCUMENT_PREPARE_CALL_HIERARCHY)