Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit f784152

Browse files
author
Hendrik van Antwerpen
committed
Support identifiers in asserts
1 parent c5b3053 commit f784152

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

languages/tree-sitter-stack-graphs-typescript/src/stack-graphs.tsg

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,7 @@ if none @is_async {
27322732
}
27332733

27342734

2735-
;; Variables
2735+
;; Variables / Identifiers
27362736

27372737
; x;
27382738

@@ -2742,6 +2742,8 @@ if none @is_async {
27422742
(for_in_statement ["var" "let" "const"]?@is_def left:(identifier)@name)
27432743
(assignment_expression left:(identifier)@name)
27442744
(augmented_assignment_expression left:(identifier)@name)
2745+
(asserts (identifier)@name)
2746+
(type_predicate name:(identifier)@name)
27452747
; FIXME type_query has its own restricted expression production
27462748
; we need to do this for every (identifier) inside a type query
27472749
; this cannot be expressed, so we manually unroll three levels here
@@ -2789,6 +2791,8 @@ if none @is_def {
27892791
(for_in_statement ["var" "let" "const"]?@is_def left:(identifier)@name)
27902792
(assignment_expression left:(identifier)@name)
27912793
(augmented_assignment_expression left:(identifier)@name)
2794+
(asserts (identifier)@name)
2795+
(type_predicate name:(identifier)@name)
27922796
; FIXME type_query has its own restricted expression production
27932797
(type_query (identifier)@name)
27942798
(type_query (member_expression object:(identifier)@name))
@@ -4972,9 +4976,6 @@ if none @is_acc {
49724976
)@asserts {
49734977
; propagate lexical scope
49744978
edge @type.lexical_scope -> @asserts.lexical_scope
4975-
4976-
; type is type of inner
4977-
edge @asserts.type -> @type.type
49784979
}
49794980

49804981

@@ -5119,9 +5120,8 @@ if none @is_acc {
51195120
(_)@type
51205121
)@type_pred {
51215122
; propagate lexical scope
5123+
edge @name.lexical_scope -> @type_pred.lexical_scope
51225124
edge @type.lexical_scope -> @type_pred.lexical_scope
5123-
5124-
; FIXME name is a expression reference
51255125
}
51265126

51275127

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function assert(
2+
condition: any,
3+
): asserts condition {
4+
// ^ defined: 2
5+
}
6+
7+
export {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function assertIsString(
2+
val: any
3+
): asserts val is string {
4+
// ^ defined: 2
5+
}
6+
7+
export {}

0 commit comments

Comments
 (0)