@@ -24,21 +24,31 @@ import { CSSProperties, useEffect, useRef, useState } from "react";
24
24
import AutoSizer from "react-virtualized-auto-sizer" ;
25
25
26
26
function hasOp ( node : any ) : node is AST & { getOp ( ) : TokenKind } {
27
- return typeof node . getOp === "function" ;
27
+ return typeof node . getOp === "function" && node . getOp ( ) ;
28
28
}
29
29
30
- function hasIdentifier ( node : any ) : node is AST & { getIdentifier ( ) : string } {
31
- return typeof node . getIdentifier === "function" ;
30
+ function hasAccessOp ( node : any ) : node is AST & { getAccessOp ( ) : TokenKind } {
31
+ return typeof node . getAccessOp === "function" && node . getAccessOp ( ) ;
32
32
}
33
33
34
- function hasNamespaceName (
34
+ function hasAccessSpecifier (
35
35
node : any
36
- ) : node is AST & { getNamespaceName ( ) : string } {
37
- return typeof node . getNamespaceName === "function" ;
36
+ ) : node is AST & { getAccessSpecifier ( ) : TokenKind } {
37
+ return (
38
+ typeof node . getAccessSpecifier === "function" && node . getAccessSpecifier ( )
39
+ ) ;
40
+ }
41
+
42
+ function hasSpecifier ( node : any ) : node is AST & { getSpecifier ( ) : TokenKind } {
43
+ return typeof node . getSpecifier === "function" && node . getSpecifier ( ) ;
44
+ }
45
+
46
+ function hasIdentifier ( node : any ) : node is AST & { getIdentifier ( ) : string } {
47
+ return typeof node . getIdentifier === "function" && node . getIdentifier ( ) ;
38
48
}
39
49
40
50
function hasLiteral ( node : any ) : node is AST & { getLiteral ( ) : string } {
41
- return typeof node . getLiteral === "function" ;
51
+ return typeof node . getLiteral === "function" && node . getLiteral ( ) ;
42
52
}
43
53
44
54
interface SyntaxTreeProps {
@@ -68,10 +78,13 @@ export function SyntaxTree({ parser, cursorPosition }: SyntaxTreeProps) {
68
78
const kind = ASTKind [ node . getKind ( ) ] ;
69
79
70
80
let extra = "" ;
71
- if ( hasNamespaceName ( node ) ) extra += ` (${ node . getNamespaceName ( ) } )` ;
72
81
if ( hasIdentifier ( node ) ) extra += ` (${ node . getIdentifier ( ) } )` ;
73
82
if ( hasLiteral ( node ) ) extra += ` (${ node . getLiteral ( ) } )` ;
74
83
if ( hasOp ( node ) ) extra += ` (${ TokenKind [ node . getOp ( ) ] } )` ;
84
+ if ( hasAccessOp ( node ) ) extra += ` (${ TokenKind [ node . getAccessOp ( ) ] } )` ;
85
+ if ( hasSpecifier ( node ) ) extra += ` (${ TokenKind [ node . getSpecifier ( ) ] } )` ;
86
+ if ( hasAccessSpecifier ( node ) )
87
+ extra += ` (${ TokenKind [ node . getAccessSpecifier ( ) ] } )` ;
75
88
76
89
const description = `${ kind } ${ extra } ` ;
77
90
const handle = node . getHandle ( ) ;
0 commit comments