Skip to content

Commit

Permalink
Renames "." to "GUARD:MEMBER" and documents it
Browse files Browse the repository at this point in the history
  • Loading branch information
BekaValentine committed Jul 20, 2023
1 parent d4d2ca6 commit ff591b0
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions languages/tree-sitter-stack-graphs-javascript/src/stack-graphs.tsg
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ attribute node_symbol = node => symbol = (source-text node), source_n

;; By convention, this library of queries prefixes all guard nodes with "GUARD:"
;; to distinguish them from nodes that more directly correspond to aspects of
;; execution such as member lookup (labelled with ".") or variable lookup
;; execution such as member lookup (labelled with "GUARD:MEMBER") or variable lookup
;; (labelled with the variable name itself). The current names used for guard
;; nodes are

Expand All @@ -232,6 +232,7 @@ attribute node_symbol = node => symbol = (source-text node), source_n
;; during any normal traversals. By only ever popping, and never pushing, we can get
;; a connected subgraph that is never the less never traversed.
;; - `GUARD:LABEL` - used for the names of labels
;; - `GUARD:MEMBER` - used for the members/fields/properties of objects

; ## Inherited

Expand Down Expand Up @@ -687,7 +688,7 @@ inherit .return_or_yield
}
}
attr (@alias.pop) node_definition = @alias
attr (@alias.pop_dot) pop_symbol = "."
attr (@alias.pop_dot) pop_symbol = "GUARD:MEMBER"
edge @export_statement.exports -> @alias.pop
edge @alias.pop -> @alias.pop_dot
edge @alias.pop_dot -> @source.push_guard_exports
Expand Down Expand Up @@ -743,7 +744,7 @@ inherit .return_or_yield
edge @namespace_import.after_scope -> @namespace_import.before_scope

attr (@imported_as.pop) node_definition = @imported_as
attr (@imported_as.pop_dot) pop_symbol = "."
attr (@imported_as.pop_dot) pop_symbol = "GUARD:MEMBER"
edge @imported_as.pop -> @imported_as.pop_dot
edge @imported_as.pop_dot -> @namespace_import.source

Expand Down Expand Up @@ -896,7 +897,7 @@ inherit .return_or_yield
; edge @mod_name.push -> ROOT_NODE
;
; attr (@name) node_reference = @name
; attr (@name.push_dot) push_symbol = "."
; attr (@name.push_dot) push_symbol = "GUARD:MEMBER"
; edge @name.push_dot -> @mod_name.push
; edge @name -> @name.push_dot
;
Expand Down Expand Up @@ -1313,7 +1314,7 @@ inherit .return_or_yield
node @name.pop_dot
; augmentation for the method
attr (@name.pop) node_definition = @name
attr (@name.pop_dot) pop_symbol = "."
attr (@name.pop_dot) pop_symbol = "GUARD:MEMBER"
edge @method_def.after_scope -> @name.pop_dot
edge @name.pop_dot -> @name.pop
edge @name.pop -> @method_def.method_value
Expand Down Expand Up @@ -1388,7 +1389,7 @@ inherit .return_or_yield
node @property.pop_dot

attr (@property.pop) node_definition = @property
attr (@property.pop_dot) pop_symbol = "."
attr (@property.pop_dot) pop_symbol = "GUARD:MEMBER"
edge @field_def.after_scope -> @property.pop_dot
edge @property.pop_dot -> @property.pop
}
Expand Down Expand Up @@ -1787,7 +1788,7 @@ inherit .return_or_yield
edge @body.before_scope -> @object.after_scope
edge @with_stmt.after_scope -> @body.after_scope

attr (@with_stmt.push_dot) push_symbol = "."
attr (@with_stmt.push_dot) push_symbol = "GUARD:MEMBER"
edge @with_stmt.push_dot -> @object.value
edge @body.before_scope -> @with_stmt.push_dot
}
Expand Down Expand Up @@ -2133,7 +2134,7 @@ inherit .return_or_yield
(object)@object {

node @object.member_pop
attr (@object.member_pop) pop_symbol = "."
attr (@object.member_pop) pop_symbol = "GUARD:MEMBER"
edge @object.value -> @object.member_pop

}
Expand Down Expand Up @@ -2284,7 +2285,7 @@ inherit .return_or_yield
(array)@array_expr {

node @array_expr.element_pop_dot
attr (@array_expr.element_pop_dot) pop_symbol = "."
attr (@array_expr.element_pop_dot) pop_symbol = "GUARD:MEMBER"
edge @array_expr.value -> @array_expr.element_pop_dot

}
Expand Down Expand Up @@ -2674,7 +2675,7 @@ inherit .return_or_yield
edge @arguments.arg_scope -> @arguments.arg_scope_no_this

attr (@arguments.arg_arguments) symbol_definition = "arguments", source_node = @arguments
attr (@arguments.arg_arguments_dot) pop_symbol = "."
attr (@arguments.arg_arguments_dot) pop_symbol = "GUARD:MEMBER"
edge @arguments.arg_scope -> @arguments.arg_arguments
edge @arguments.arg_arguments -> @arguments.arg_arguments_dot
edge @arguments.arg_arguments_dot -> @arguments.arg_scope_no_this
Expand Down Expand Up @@ -2765,7 +2766,7 @@ inherit .return_or_yield
edge @member_expr.after_scope -> @object.after_scope

; value is a member projection on the value of the object ie. a push then push dot
attr (member_push) push_symbol = "."
attr (member_push) push_symbol = "GUARD:MEMBER"
attr (property_push) node_reference = @property
edge property_push -> member_push
edge @member_expr.value -> property_push
Expand All @@ -2788,7 +2789,7 @@ inherit .return_or_yield
edge @subscript_expr.after_scope -> @index.after_scope

; value is a subscript lookup, ie a push then push dot
attr (@subscript_expr.push_dot) push_symbol = "."
attr (@subscript_expr.push_dot) push_symbol = "GUARD:MEMBER"
edge @subscript_expr.push_dot -> @object.value

; this is done differently depending on what the index is
Expand Down Expand Up @@ -2985,7 +2986,7 @@ inherit .return_or_yield
attr (@this.drop) type = "drop_scopes"
edge @this.drop -> @this.pop
attr (@this.pop) pop_symbol = "this"
attr (@this.pop_dot) pop_symbol = "."
attr (@this.pop_dot) pop_symbol = "GUARD:MEMBER"
attr (@property.pop) node_definition = @property
edge @assignment_expr.after_scope -> @this.drop
edge @assignment_expr.after_scope -> @this.pop
Expand Down Expand Up @@ -3456,7 +3457,7 @@ inherit .return_or_yield
node @key.push_dot

; covalues flow in dotted
attr (@key.push_dot) push_symbol = "."
attr (@key.push_dot) push_symbol = "GUARD:MEMBER"
edge @value_pat.covalue -> @key.push
edge @key.push -> @key.push_dot
edge @key.push_dot -> @pair_pat.covalue
Expand Down Expand Up @@ -3518,7 +3519,7 @@ inherit .return_or_yield
edge @left_pat.after_scope -> @left_pat.before_scope

attr (@left_pat.push) node_reference = @left_pat
attr (@left_pat.push_dot) push_symbol = "."
attr (@left_pat.push_dot) push_symbol = "GUARD:MEMBER"
attr (@left_pat.pop) node_definition = @left_pat
edge @left_pat.pop -> @left_pat.push
edge @left_pat.push -> @left_pat.push_dot
Expand Down Expand Up @@ -3570,7 +3571,7 @@ inherit .return_or_yield
(array_pattern)@array_pat {
node @array_pat.element_index_push_dot
edge @array_pat.element_index_push_dot -> @array_pat.covalue
attr (@array_pat.element_index_push_dot) push_symbol = "."
attr (@array_pat.element_index_push_dot) push_symbol = "GUARD:MEMBER"
}

; array pattern elements
Expand Down Expand Up @@ -3706,7 +3707,7 @@ inherit .return_or_yield
node @property.pop
node @property.pop_dot
attr (@property.pop) node_definition = @property
attr (@property.pop_dot) pop_symbol = "."
attr (@property.pop_dot) pop_symbol = "GUARD:MEMBER"
edge @assignment_expr.exports -> @property.pop_dot
edge @property.pop_dot -> @property.pop
edge @property.pop -> @right.value
Expand Down

0 comments on commit ff591b0

Please sign in to comment.