Skip to content

Commit

Permalink
depend on pygls >= 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
perrinjerome committed Oct 4, 2023
1 parent fd530ed commit ee352be
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion server/buildoutls/bench/slapos.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async def test_open_and_diagnostic(
ls = LanguageServer(name='zc.buildout.languageserver',
version='dev',
loop=asyncio.new_event_loop())
ls.lsp.workspace = workspace
ls.lsp.workspace = workspace # type: ignore

async def open_and_get_diagnostics() -> List[Diagnostic]:
diags: List[Diagnostic] = []
Expand Down
6 changes: 3 additions & 3 deletions server/buildoutls/buildout.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ async def getTemplate(
uri_path.relative_to(
pathlib.Path(self.uri[len('file://'):]).parent)))

document = ls.workspace.get_document(uri)
document = ls.workspace.get_text_document(uri)
if not os.path.exists(document.path):
return None

Expand Down Expand Up @@ -969,7 +969,7 @@ async def parse(
logger.warning('Error parsing from uri %s', uri, exc_info=True)
fp = io.StringIO('')
else:
document = ls.workspace.get_document(uri)
document = ls.workspace.get_text_document(uri)
try:
fp = io.StringIO(document.source)
except IOError:
Expand Down Expand Up @@ -1312,7 +1312,7 @@ async def open(
For buildout, it is a wrapper over _open which uses language server's workspace
"""
document = ls.workspace.get_document(uri)
document = ls.workspace.get_text_document(uri)
logger.debug("open %s", uri)
if not force_open_as_buildout_profile:
# First, try to read as a template, because buildout profiles can be templates.
Expand Down
2 changes: 1 addition & 1 deletion server/buildoutls/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async def lsp_completion(
params: CompletionParams,
) -> Optional[List[CompletionItem]]:
items: List[CompletionItem] = []
doc = ls.workspace.get_document(params.text_document.uri)
doc = ls.workspace.get_text_document(params.text_document.uri)

def getSectionReferenceCompletionTextEdit(
doc: Document,
Expand Down
6 changes: 3 additions & 3 deletions server/buildoutls/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self):

server = FakeServer()

def get_document(uri) -> Document:
def get_text_document(uri) -> Document:
parsed_uri = urllib.parse.urlparse(uri)
assert parsed_uri.scheme == "file"
assert parsed_uri.path[0] == '/'
Expand All @@ -67,7 +67,7 @@ def get_document(uri) -> Document:
document.path = os.path.join(root_path, parsed_uri.path[1:])
return document

server.workspace.get_document = mock.Mock(side_effect=get_document)
server.workspace.get_text_document = mock.Mock(side_effect=get_text_document)

def os_path_exists(path: str) -> bool:
if path.startswith('/'):
Expand All @@ -89,7 +89,7 @@ def clearCaches() -> None:
server.publish_diagnostics.reset_mock()
server.show_message.reset_mock()
server.show_message_log.reset_mock()
server.workspace.get_document.reset_mock()
server.workspace.get_text_document.reset_mock()

clearCaches()

Expand Down
26 changes: 13 additions & 13 deletions server/buildoutls/tests/test_buildout_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ async def test_open_extends_cache(server: LanguageServer):
)
# check the cache is effective, the same file is included twice,
# but we load it only once.
assert server.workspace.get_document.call_count == 4 # type: ignore
assert server.workspace.get_text_document.call_count == 4 # type: ignore


async def test_open_extends_cache_clear(server: LanguageServer):
Expand All @@ -693,10 +693,10 @@ async def test_open_extends_cache_clear(server: LanguageServer):
assert 'option' in symbol.referenced_section

clearCache('file:///extended/extended.cfg')
original_get_document = server.workspace.get_document
original_get_text_document = server.workspace.get_text_document

def getModifiedDocument(uri: str):
doc = original_get_document(uri)
doc = original_get_text_document(uri)
if uri == 'file:///extended/extended.cfg':
doc._source = textwrap.dedent('''\
[extended_option]
Expand All @@ -706,7 +706,7 @@ def getModifiedDocument(uri: str):

with mock.patch.object(
server.workspace,
'get_document',
'get_text_document',
side_effect=getModifiedDocument,
):
parsed = await open(
Expand All @@ -724,9 +724,9 @@ def getModifiedDocument(uri: str):
async def test_open_resolved_cache_clear(server: LanguageServer):
with mock.patch.object(
server.workspace,
'get_document',
wraps=server.workspace.get_document,
) as get_document_initial:
'get_text_document',
wraps=server.workspace.get_text_document,
) as get_text_document_initial:
parsed = await open(
ls=server,
uri='file:///extended/two_levels.cfg',
Expand All @@ -737,15 +737,15 @@ async def test_open_resolved_cache_clear(server: LanguageServer):
assert symbol.referenced_section is not None
assert 'option' in symbol.referenced_section
assert mock.call(
'file:///extended/extended.cfg') in get_document_initial.mock_calls
'file:///extended/extended.cfg') in get_text_document_initial.mock_calls

clearCache('file:///extended/two_levels.cfg')

with mock.patch.object(
server.workspace,
'get_document',
wraps=server.workspace.get_document,
) as get_document_after_clear_cache:
'get_text_document',
wraps=server.workspace.get_text_document,
) as get_text_document_after_clear_cache:
parsed = await open(
ls=server,
uri='file:///extended/two_levels.cfg',
Expand All @@ -756,9 +756,9 @@ async def test_open_resolved_cache_clear(server: LanguageServer):
assert symbol.referenced_section is not None
assert 'option' in symbol.referenced_section
assert mock.call('file:///extended/two_levels.cfg'
) in get_document_after_clear_cache.mock_calls
) in get_text_document_after_clear_cache.mock_calls
assert mock.call('file:///extended/extended.cfg'
) not in get_document_after_clear_cache.mock_calls
) not in get_text_document_after_clear_cache.mock_calls


async def test_open_macro(server: LanguageServer):
Expand Down
6 changes: 3 additions & 3 deletions server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ async-timeout==4.0.3
attrs==23.1.0
cachetools==5.3.1
cattrs==23.1.2
charset-normalizer==3.2.0
charset-normalizer==3.3.0
exceptiongroup==1.1.3
frozenlist==1.4.0
idna==3.4
lsprotocol==2023.0.0b1
multidict==6.0.4
packaging==23.1
pygls==1.0.2
packaging==23.2
pygls==1.1.0
typeguard==3.0.2
typing-extensions==4.8.0
wheel==0.41.2
Expand Down
2 changes: 1 addition & 1 deletion server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'aiohttp',
'cachetools',
'packaging',
'pygls >= 1.0',
'pygls >= 1.1.0',
'typing-extensions',
'zc.buildout',
],
Expand Down
18 changes: 8 additions & 10 deletions server/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,31 @@
aiohttp==3.8.5
aioresponses==0.7.4
aiosignal==1.3.1
astroid==2.15.6
astroid==3.0.0
async-timeout==4.0.3
attrs==23.1.0
cachetools==5.3.1
cattrs==23.1.2
charset-normalizer==3.2.0
coverage[toml]==7.3.1
charset-normalizer==3.3.0
coverage[toml]==7.3.2
dill==0.3.7
exceptiongroup==1.1.3
frozenlist==1.4.0
idna==3.4
importlib-metadata==6.8.0
iniconfig==2.0.0
isort==5.12.0
lazy-object-proxy==1.9.0
lsprotocol==2023.0.0b1
mccabe==0.7.0
multidict==6.0.4
mypy==1.5.1
mypy-extensions==1.0.0
packaging==23.1
platformdirs==3.10.0
packaging==23.2
platformdirs==3.11.0
pluggy==1.3.0
py-cpuinfo==9.0.0
pygls==1.0.2
pylint==2.17.5
pygls==1.1.0
pylint==3.0.0
pytest==7.4.2
pytest-asyncio==0.21.1
pytest-benchmark==4.0.0
Expand All @@ -45,8 +44,7 @@ types-setuptools==68.2.0.0
types-toml==0.10.8.7
typing-extensions==4.8.0
wheel==0.41.2
wrapt==1.15.0
yapf==0.40.1
yapf==0.40.2
yarl==1.9.2
# zc-buildout==3.0.1
zipp==3.17.0
Expand Down

0 comments on commit ee352be

Please sign in to comment.