Skip to content

Commit

Permalink
replace EnumDef with FlagDef
Browse files Browse the repository at this point in the history
  • Loading branch information
z80dev committed Aug 8, 2024
1 parent 1ee9b66 commit de9763e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions vyper_lsp/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AST:
ast_data_folded = None
ast_data_unfolded = None

custom_type_node_types = (nodes.StructDef, nodes.EnumDef)
custom_type_node_types = (nodes.StructDef, nodes.FlagDef)

@classmethod
def from_node(cls, node: VyperNode):
Expand Down Expand Up @@ -67,7 +67,7 @@ def get_top_level_nodes(self, *args, **kwargs):
return self.best_ast.get_children(*args, **kwargs)

def get_enums(self) -> List[str]:
return [node.name for node in self.get_descendants(nodes.EnumDef)]
return [node.name for node in self.get_descendants(nodes.FlagDef)]

def get_structs(self) -> List[str]:
return [node.name for node in self.get_descendants(nodes.StructDef)]
Expand Down Expand Up @@ -153,7 +153,7 @@ def get_attributes_for_symbol(self, symbol: str):

if isinstance(node, nodes.StructDef):
return self.get_struct_fields(symbol)
elif isinstance(node, nodes.EnumDef):
elif isinstance(node, nodes.FlagDef):
return self.get_enum_variants(symbol)

return []
Expand Down Expand Up @@ -186,7 +186,7 @@ def find_type_declaration_node_for_name(self, symbol: str):
for node in self.get_descendants(searchable_types):
if node.name == symbol:
return node
if isinstance(node, nodes.EnumDef):
if isinstance(node, nodes.FlagDef):
for variant in node.get_children(nodes.Expr):
if variant.value.id == symbol:
return variant
Expand Down
4 changes: 2 additions & 2 deletions vyper_lsp/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import List, Optional

from pygls.workspace import Document
from vyper.ast import EnumDef, FunctionDef, VyperNode
from vyper.ast import FlagDef, FunctionDef, VyperNode
from vyper_lsp.ast import AST
from vyper_lsp.utils import (
get_expression_at_cursor,
Expand Down Expand Up @@ -98,7 +98,7 @@ def finalize(refs):
if self._is_state_var_decl(og_line, word):
return finalize(self.ast.find_nodes_referencing_state_variable(word))

if isinstance(top_level_node, EnumDef):
if isinstance(top_level_node, FlagDef):
return finalize(
self.ast.find_nodes_referencing_enum_variant(top_level_node.name, word)
)
Expand Down

0 comments on commit de9763e

Please sign in to comment.