Skip to content

Commit

Permalink
🐛 Fix (un)export_directive
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Oct 28, 2023
1 parent 8da40b3 commit 302a139
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/autotools_language_server/finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_option(uni: UNI) -> str:
option = ""
if parent := uni.node.parent:
if children := getattr(parent.parent, "children", None):
if len(children) > 0:
if parent.parent == "include_directive" and len(children) > 0:
option = children[0].type
return option

Expand Down Expand Up @@ -124,7 +124,12 @@ def __init__(self, node: Node) -> None:
self.is_define = self.is_function_define
# https://github.com/alemuller/tree-sitter-make/issues/8
self.name = UNI.node2text(node).split(",")[0]
elif parent.type == "variable_reference":
elif node.type == "word" and (
parent.type == "variable_reference"
or parent.parent is not None
and parent.parent.type
in {"export_directive", "unexport_directive"}
):
self.is_define = self.is_variable_define
elif parent.type == "prerequisites":
self.is_define = self.is_target_define
Expand Down Expand Up @@ -263,7 +268,14 @@ def is_variable_reference(self, uni: UNI) -> bool:
if parent is None:
return False
return (
parent.type == "variable_reference" and uni.get_text() == self.name
uni.get_text() == self.name
and node.type == "word"
and (
parent.type == "variable_reference"
or parent.parent is not None
and parent.parent.type
in {"export_directive", "unexport_directive"}
)
)

def is_target_reference(self, uni: UNI) -> bool:
Expand Down
3 changes: 3 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ include common.mk
include fake.mk
-include fake.mk

export KBUILD_EXTMOD
export abs_objtree := $(CURDIR)
unexport KBUILD_EXTMOD
define f
@echo $(1)
endef
Expand Down

0 comments on commit 302a139

Please sign in to comment.