@@ -7,21 +7,34 @@ pub type ID = int
77pub type AstNode = bindings.Node[bindings.NodeType]
88
99pub interface PsiElement {
10- node AstNode // base node from Tree Sitter
11- containing_file & PsiFile // file where the element is located
12- stub_id StubId
13- get_stub () ? & StubBase
14- stub_list () & StubList
10+ // node returns the base node from Tree Sitter.
11+ // In stub-based elements, this might be a zero-value node.
12+ node () AstNode
13+ // element_type returns the specific type of the element.
1514 element_type () bindings.NodeType
16- node () AstNode // return base node from Tree Sitter
17- containing_file () & PsiFile // return file where the element is located
18- is_equal (other PsiElement) bool // return true if the element is equal to the other element
19- // find_element_at returns the leaf node at the specified position relative to the start of the node.
20- // If the node is not found, none is returned.
21- find_element_at (offset u32 ) ? PsiElement
22- // find_reference_at returns the reference node at the specified position relative to the start of the node.
23- // If the node is not found, none is returned.
24- find_reference_at (offset u32 ) ? PsiElement
15+ // containing_file returns the file where the element is located.
16+ // Returns none if the element is synthetic or the file context is lost.
17+ containing_file () ? & PsiFile
18+ // is_equal returns true if the element represents the same underlying node/stub as other.
19+ is_equal (other PsiElement) bool
20+
21+ // return the slot id of the stub, or non_stubbed_element if the element is not stub-based
22+ stub_id () StubId
23+ // return the stub associated with the element, or none if the element is not stub-based
24+ get_stub () ? & StubBase
25+ // stub_list return the stub list associated with the element, or none if the element is not stub-based
26+ stub_list () ? & StubList
27+
28+ // text_range returns the range of the node in the source file.
29+ text_range () TextRange
30+ // text_length returns the length of the node's text.
31+ text_length () int
32+ // get_text returns the text of the node.
33+ get_text () string
34+ // text_matches returns true if the text of the node matches the specified value.
35+ // This method is more efficient than `get_text() == value`.
36+ text_matches (value string ) bool
37+
2538 // parent returns the parent node.
2639 // If the node is the root, none is returned.
2740 parent () ? PsiElement
@@ -35,17 +48,15 @@ pub interface PsiElement {
3548 // parent_of_any_type returns the parent node with one of the specified types.
3649 // If no such node exists, none is returned.
3750 parent_of_any_type (types ...bindings.NodeType) ? PsiElement
38- // inside returns true if the node is inside a node with the specified type.
39- inside (typ bindings.NodeType) bool
40- // is_parent_of returns true if the passed node is a child of the given node.
41- is_parent_of (element PsiElement) bool
42- // sibling_of_type_backward returns the previous node at the same nesting level with the specified type.
43- // If no such node exists, none is returned.
44- sibling_of_type_backward (typ bindings.NodeType) ? PsiElement
4551 // parent_of_type_or_self returns the parent node with the specified type, or the
4652 // node itself if its type matches the specified one.
4753 // If no such node exists, none is returned.
4854 parent_of_type_or_self (typ bindings.NodeType) ? PsiElement
55+ // is_parent_of returns true if the passed node is a child of the given node.
56+ is_parent_of (element PsiElement) bool
57+ // inside returns true if the node is inside a node with the specified type.
58+ inside (typ bindings.NodeType) bool
59+
4960 // children returns all child nodes.
5061 children () []PsiElement
5162 // named_children returns child nodes except unknown nodes.
@@ -62,6 +73,7 @@ pub interface PsiElement {
6273 // last_child_or_stub returns the last child node or stub.
6374 // If the node has no children or stub, none is returned.
6475 last_child_or_stub () ? PsiElement
76+
6577 // next_sibling returns the next node at the same nesting level.
6678 // If the node is the last child node, none is returned.
6779 next_sibling () ? PsiElement
@@ -77,11 +89,19 @@ pub interface PsiElement {
7789 // prev_sibling_or_stub returns the previous node at the same nesting level or stub.
7890 // If the node is the first child node or stub, none is returned.
7991 prev_sibling_or_stub () ? PsiElement
92+ // sibling_of_type_backward returns the previous node at the same nesting level with the specified type.
93+ // If no such node exists, none is returned.
94+ sibling_of_type_backward (typ bindings.NodeType) ? PsiElement
95+
96+ // find_element_at returns the leaf node at the specified position relative to the start of the node.
97+ // If the node is not found, none is returned.
98+ find_element_at (offset u32 ) ? PsiElement
99+ // find_reference_at returns the reference node at the specified position relative to the start of the node.
100+ // If the node is not found, none is returned.
101+ find_reference_at (offset u32 ) ? PsiElement
80102 // find_child_by_type returns the first child node with the specified type.
81103 // If no such node is found, none is returned.
82104 find_child_by_type (typ bindings.NodeType) ? PsiElement
83- // has_child_of_type returns true if the node has a child with the specified type.
84- has_child_of_type (typ bindings.NodeType) bool
85105 // find_child_by_type_or_stub returns the first child node with the specified type or stub.
86106 // If no such node is found, none is returned.
87107 find_child_by_type_or_stub (typ bindings.NodeType) ? PsiElement
@@ -94,18 +114,12 @@ pub interface PsiElement {
94114 // find_children_by_type_or_stub returns all child nodes with the specified type or stub.
95115 // If no such nodes are found, an empty array is returned.
96116 find_children_by_type_or_stub (typ bindings.NodeType) []PsiElement
97- // get_text returns the text of the node.
98- get_text () string
99- // text_matches returns true if the text of the node matches the specified value.
100- // This method is more efficient than `get_text() == value`.
101- text_matches (value string ) bool
117+ // has_child_of_type returns true if the node has a child with the specified type.
118+ has_child_of_type (typ bindings.NodeType) bool
119+
102120 // accept passes the element to the passed visitor.
103121 accept (visitor PsiElementVisitor)
104122 // accept_mut passes the element to the passed visitor.
105123 // Unlike `accept()`, this method uses a visitor that can mutate its state.
106124 accept_mut (mut visitor MutablePsiElementVisitor)
107- // text_range returns the range of the node in the source file.
108- text_range () TextRange
109- // text_length returns the length of the node's text.
110- text_length () int
111125}
0 commit comments