Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CLS bugs bundle #25165

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tools/chapel-py/src/chapel/lsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion tools/chapel-py/src/method-tables/core-methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*>,
const char* name = chpl::ErrorBase::getTypeName(node->type());
return name ? std::optional(name) : std::nullopt;
jabraham17 marked this conversation as resolved.
Show resolved Hide resolved
)
jabraham17 marked this conversation as resolved.
Show resolved Hide resolved
CLASS_END(Error)

CLASS_BEGIN(ErrorManager)
Expand Down
6 changes: 6 additions & 0 deletions tools/chpl-language-server/src/chpl-language-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
Loading