-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve suggestion of internal fns & state
- Loading branch information
Showing
4 changed files
with
61 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import pytest | ||
|
||
from vyper_lsp.ast import AST | ||
|
||
|
||
@pytest.fixture | ||
def ast(): | ||
return AST() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from pygls.lsp.types import CompletionContext, CompletionParams, Position | ||
from pygls.workspace import Document | ||
|
||
from vyper_lsp.analyzer.AstAnalyzer import AstAnalyzer | ||
|
||
|
||
def test_completion(ast): | ||
src = """ | ||
@internal | ||
def foo(): | ||
return | ||
@external | ||
def bar(): | ||
self.foo() | ||
""" | ||
ast.build_ast(src) | ||
|
||
src += """ | ||
@external | ||
def baz(): | ||
self. | ||
""" | ||
|
||
doc = Document(uri="examples/Foo.vy", source=src) | ||
pos = Position(line=11, character=7) | ||
context = CompletionContext(trigger_character=".", trigger_kind=2) | ||
params = CompletionParams( | ||
text_document={"uri": doc.uri, "source": src}, position=pos, context=context | ||
) | ||
|
||
analyzer = AstAnalyzer(ast) | ||
completions = analyzer.get_completions_in_doc(doc, params) | ||
assert len(completions.items) == 1 | ||
assert "foo" in [c.label for c in completions.items] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters