-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gazelle): support imports within declare-module expressions (#3449)
Support import/export within `declare module`. --- ### Type of change - Bug fix (change which fixes an issue) ### Test plan - Covered by existing test cases - New test cases added GitOrigin-RevId: 2635bf37a3d4a5f20e9c312570b522351e97f231
- Loading branch information
1 parent
eb34aba
commit 5d2c14e
Showing
8 changed files
with
109 additions
and
29 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
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,32 @@ | ||
package treesitter | ||
|
||
import sitter "github.com/smacker/go-tree-sitter" | ||
|
||
func GetNodeChildByTypePath(node *sitter.Node, childPath ...string) *sitter.Node { | ||
for _, childType := range childPath { | ||
node = GetNodeChildByType(node, childType) | ||
if node == nil { | ||
return nil | ||
} | ||
} | ||
|
||
return node | ||
} | ||
|
||
func GetNodeChildByType(node *sitter.Node, childType string) *sitter.Node { | ||
// TODO: assert only one child of type? | ||
|
||
for i := 0; i < int(node.NamedChildCount()); i++ { | ||
child := node.NamedChild(i) | ||
if child.Type() == childType { | ||
return child | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func GetNodeStringField(node *sitter.Node, name string) *sitter.Node { | ||
// TODO: assert its a string field, assert only one child | ||
return node.ChildByFieldName(name).NamedChild(0) | ||
} |
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
Empty file.
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,10 @@ | ||
load("@aspect_rules_ts//ts:defs.bzl", "ts_project") | ||
|
||
ts_project( | ||
name = "import", | ||
srcs = [ | ||
"lib.d.ts", | ||
"other.ts", | ||
], | ||
deps = ["//lib"], | ||
) |
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,3 @@ | ||
declare module 'lib-imports' { | ||
export * from 'lib-lib'; | ||
} |
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 @@ | ||
// Just to ensure generation until https://github.com/aspect-build/silo/pull/3438 |