Skip to content

Commit

Permalink
Allow users to turn off "Show instantiation" code lens (chapel-lang#2…
Browse files Browse the repository at this point in the history
…4613)

Adds a feature flag to CLS for "Show instantiation", so that users who
don't want/like the code lens can turn it off. The feature is still on
by default.

[Reviewed by @DanilaFe]
  • Loading branch information
jabraham17 authored Mar 26, 2024
2 parents 7b71685 + e0f2ce3 commit 5f045c5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/chpl-language-server/src/chpl-language-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ def add_bool_flag(name: str, dest: str, default: bool):
add_bool_flag("literal-arg-inlays", "literal_arg_inlays", True)
add_bool_flag("dead-code", "dead_code", True)
add_bool_flag("evaluate-expressions", "eval_expressions", True)
add_bool_flag("show-instantiations", "show_instantiations", True)
self.parser.add_argument("--end-markers", default="none")
self.parser.add_argument("--end-marker-threshold", type=int, default=10)

Expand Down Expand Up @@ -917,6 +918,7 @@ def __init__(self, config: CLSConfig):
self.param_inlays: bool = config.get("param_inlays")
self.dead_code: bool = config.get("dead_code")
self.eval_expressions: bool = config.get("eval_expressions")
self.show_instantiations: bool = config.get("show_instantiations")
self.end_markers: List[str] = config.get("end_markers")
self.end_marker_threshold: int = config.get("end_marker_threshold")
self.end_marker_patterns = self._get_end_marker_patterns()
Expand Down Expand Up @@ -1665,6 +1667,14 @@ async def document_highlight(

@server.feature(TEXT_DOCUMENT_CODE_LENS)
async def code_lens(ls: ChapelLanguageServer, params: CodeLensParams):

# return early if the resolver is not being used or the feature is disabled
if not ls.use_resolver:
return None

if not ls.show_instantiations:
return None

text_doc = ls.workspace.get_text_document(params.text_document.uri)

fi, _ = ls.get_file_info(text_doc.uri)
Expand Down

0 comments on commit 5f045c5

Please sign in to comment.