Skip to content

Commit

Permalink
Fix missing diagnostics provided by language server
Browse files Browse the repository at this point in the history
Ref. eng/recordflux/RecordFlux#1483
  • Loading branch information
treiher committed Jan 22, 2024
1 parent cdba8e0 commit 98b5e97
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Pragma marking all generated files as Ada 2012 (eng/recordflux/RecordFlux#1509, AdaCore/RecordFlux#1293)

### Fixed

- Missing diagnostics provided by language server

## [0.17.0] - 2024-01-03

### Fixed
Expand Down
14 changes: 9 additions & 5 deletions rflx/ls/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

from rflx import __version__, error
from rflx.common import assert_never
from rflx.const import CACHE_PATH
from rflx.const import BUILTINS_PACKAGE, CACHE_PATH, INTERNAL_PACKAGE
from rflx.graph import create_message_graph, write_graph
from rflx.model import Message, Model, UncheckedModel
from rflx.model.cache import Cache
Expand All @@ -65,7 +65,11 @@


def to_lsp_location(location: Optional[error.Location]) -> Optional[Location]:
if location is None or location.source is None:
if (
location is None
or location.source is None
or location.source.name in [str(BUILTINS_PACKAGE), str(INTERNAL_PACKAGE)]
):
return None

source = location.source.absolute().as_uri()
Expand Down Expand Up @@ -259,7 +263,8 @@ def update_model_debounced(ls: RecordFluxLanguageServer, uri: str) -> None:


@debounce(1, keyed_by="uri")
def verify_debounced(ls: RecordFluxLanguageServer, uri: str) -> None:
def update_model_and_verify_debounced(ls: RecordFluxLanguageServer, uri: str) -> None:
ls.update(uri)
ls.thread_pool_executor.submit(lambda: ls.verify(uri))


Expand All @@ -275,8 +280,7 @@ async def did_open(ls: RecordFluxLanguageServer, params: DidOpenTextDocumentPara

@server.feature(TEXT_DOCUMENT_DID_SAVE)
async def did_save(ls: RecordFluxLanguageServer, params: DidSaveTextDocumentParams) -> None:
update_model_debounced(ls, params.text_document.uri)
verify_debounced(ls, params.text_document.uri)
update_model_and_verify_debounced(ls, params.text_document.uri)


@server.feature(TEXT_DOCUMENT_DID_CHANGE)
Expand Down
2 changes: 0 additions & 2 deletions rflx/specification/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,8 +1671,6 @@ def parse_string(
spec = SpecificationFile.create(error, unit.root, filename)
_check_for_duplicate_specifications(error, [*self._specifications.values(), spec])

error.propagate()

self._specifications[spec.package] = spec

_check_for_dependency_cycles(error, [spec], self._specifications)
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/specification/parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def test_parse_string_error() -> None:
match=(
r"^"
r'a/b.rflx:1:9: parser: error: file name does not match unit name "A",'
r' should be "a.rflx"'
r' should be "a.rflx"\n'
r"a/b.rflx:2:0: style: error: unexpected keyword indentation \(expected 3 or 6\)"
r" \[indentation\]"
r"$"
),
):
Expand Down

0 comments on commit 98b5e97

Please sign in to comment.