Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
test updated for renaming symbols and PR cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kugesan1105 committed Aug 30, 2024
1 parent 89096c2 commit 0f49312
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
10 changes: 0 additions & 10 deletions jaclang/compiler/passes/main/fuse_typeinfo_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,6 @@ def exit_atom_trailer(self, node: ast.AtomTrailer) -> None:
"""Adding symbol links to AtomTrailer right nodes."""
# This will fix adding the symbol links to nodes in atom trailer
# self.x.z = 5 # will add symbol links to both x and z
for i in range(1, len(node.as_attr_list)):
left = node.as_attr_list[i - 1]
right = node.as_attr_list[i]
# assert isinstance(left, ast.NameAtom)
# assert isinstance(right, ast.NameAtom)
if left.type_sym_tab and not isinstance(
right, ast.IndexSlice
): # TODO check why IndexSlice produce an issue
right.name_spec.sym = left.type_sym_tab.lookup(right.sym_name)

# This function originally used `as_attr_list` in AtomTrailer
# but an issue happened when doing stuff like fool_me().CONST_VALUE2
Expand All @@ -524,7 +515,6 @@ def exit_atom_trailer(self, node: ast.AtomTrailer) -> None:
iteration_count += 1
if iteration_count > 50:
break
# print(1234,'atom_trailer_unwind',atom_trailer_unwind)
for i in range(1, len(atom_trailer_unwind)):
left = atom_trailer_unwind[i - 1]
right = atom_trailer_unwind[i]
Expand Down
1 change: 0 additions & 1 deletion jaclang/compiler/passes/main/pyjac_ast_link_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def exit_ability_def(self, node: ast.AbilityDef) -> None:
jac_node=node.signature.return_type,
py_nodes=node.parent.signature.return_type.gen.py_ast,
)
"""Enter ability definition."""

if isinstance(node.decl_link, ast.Ability) and isinstance(
node.target, ast.ArchRefChain
Expand Down
9 changes: 2 additions & 7 deletions jaclang/langserve/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from jaclang.compiler.passes import Pass
from jaclang.compiler.passes.main.schedules import py_code_gen_typed
from jaclang.compiler.passes.tool import FuseCommentsPass, JacFormatPass
from jaclang.compiler.symtable import Symbol
from jaclang.langserve.sem_manager import SemTokManager
from jaclang.langserve.utils import (
add_unique_text_edit,
Expand Down Expand Up @@ -429,14 +428,10 @@ def rename_symbol(
if index1 is None:
return None
node_selected = self.modules[file_path].sem_manager.static_sem_tokens[index1][3]
if (
node_selected
and node_selected.sym
and isinstance(node_selected.sym.decl.sym, Symbol)
):
if node_selected and node_selected.sym:
changes: dict[str, list[lspt.TextEdit]] = {}
for node in [
*node_selected.sym.decl.sym.uses,
*node_selected.sym.uses,
node_selected.sym.defn[0],
]:
key = uris.from_fs_path(node.loc.mod_path)
Expand Down
5 changes: 4 additions & 1 deletion jaclang/langserve/tests/fixtures/rename.jac
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ can foo;


obj out{
has cnt :int;
can bar;
can baz;
}
Expand All @@ -23,5 +24,7 @@ obj out{

with entry{
foo();
out().bar();
new = out();
new.cnt;
out(1).bar();
}
28 changes: 16 additions & 12 deletions jaclang/langserve/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,18 +540,22 @@ def test_rename_uses(self) -> None:
lsp.deep_check(circle_file)
# fmt: off
test_cases = [
(0, 7, "func", "24:4-24:7", "0:4-0:7", "4:5-4:8",),
(4, 6, "func", "24:4-24:7", "0:4-0:7", "4:5-4:8",),
(24, 7, "func", "24:4-24:7", "0:4-0:7", "4:5-4:8",),
(10, 10, "canBar", "10:8-10:11", "15:13-15:16", ), # until merge fool me
(15, 15, "ubar", "15:13-15:16", "10:8-10:11" ), # until merge fool me
# (10, 10, "canBar", "10:8-10:11", "14:13-14:16", "21....",), # True
# (14, 15, "ubar", "14:13-14:16", "10:8-10:11", "21......" ), # True
(9, 7, "result", "9:4-9:7", "25:4-25:7", "15:5-15:8", "15:5-15:8",),
(15, 7, "result", "9:4-9:7", "25:4-25:7", "15:5-15:8",),
(25, 7, "result", "9:4-9:7", "25:4-25:7", "15:5-15:8",),
(25, 7, "result", "9:4-9:7", "25:4-25:7", "15:5-15:8",),
(25, 7, "result", "9:4-9:7", "25:4-25:7", "15:5-15:8",),
(0, 7, "func", "25:4-25:7", "0:4-0:7", "4:5-4:8",),
(4, 6, "func", "25:4-25:7", "0:4-0:7", "4:5-4:8",),
(25, 7, "func", "25:4-25:7", "0:4-0:7", "4:5-4:8",),
(10, 10, "canBar", "27:8-27:11", "10:8-10:11"),
(27, 9, "canBar", "27:8-27:11", "10:8-10:11"),
(9, 6, "canBar", "26:10-26:13", "28:4-28:7", "16:5-16:8", "9:4-9:7"),
(26, 11, "canBar", "26:10-26:13", "28:4-28:7", "16:5-16:8", "9:4-9:7"),
(16, 7, "canBar", "26:10-26:13", "28:4-28:7", "16:5-16:8", "9:4-9:7"),
(28, 6, "canBar", "26:10-26:13", "28:4-28:7", "16:5-16:8", "9:4-9:7"),
(11, 10, "canBar", "11:8-11:11", "16:13-16:16", "28:11-28:14"),
(16, 14, "canBar", "11:8-11:11", "16:13-16:16", "28:11-28:14"),
(28, 13, "canBar", "11:8-11:11", "16:13-16:16", "28:11-28:14"),
(12, 10, "canBaz", "12:8-12:11", "20:13-20:16"),
(20, 14, "canBaz", "12:8-12:11", "20:13-20:16"),
(26, 6, "count", "27:4-27:7", "26:4-26:7"),
(27, 5, "count", "27:4-27:7", "26:4-26:7"),
]
# fmt: on
for tup in test_cases:
Expand Down

0 comments on commit 0f49312

Please sign in to comment.