File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535import com .semmle .ts .ast .InterfaceTypeExpr ;
3636import com .semmle .ts .ast .IntersectionTypeExpr ;
3737import com .semmle .ts .ast .IsTypeExpr ;
38- import com .semmle .ts .ast .KeyofTypeExpr ;
38+ import com .semmle .ts .ast .UnaryTypeExpr ;
3939import com .semmle .ts .ast .KeywordTypeExpr ;
4040import com .semmle .ts .ast .MappedTypeExpr ;
4141import com .semmle .ts .ast .NamespaceDeclaration ;
@@ -619,7 +619,7 @@ public R visit(TupleTypeExpr nd, C c) {
619619 }
620620
621621 @ Override
622- public R visit (KeyofTypeExpr nd , C c ) {
622+ public R visit (UnaryTypeExpr nd , C c ) {
623623 return visit ((TypeExpression ) nd , c );
624624 }
625625
Original file line number Diff line number Diff line change 3131import com .semmle .ts .ast .InterfaceTypeExpr ;
3232import com .semmle .ts .ast .IntersectionTypeExpr ;
3333import com .semmle .ts .ast .IsTypeExpr ;
34- import com .semmle .ts .ast .KeyofTypeExpr ;
34+ import com .semmle .ts .ast .UnaryTypeExpr ;
3535import com .semmle .ts .ast .KeywordTypeExpr ;
3636import com .semmle .ts .ast .MappedTypeExpr ;
3737import com .semmle .ts .ast .NamespaceDeclaration ;
@@ -700,8 +700,8 @@ public INode visit(TupleTypeExpr nd, Void c) {
700700 }
701701
702702 @ Override
703- public INode visit (KeyofTypeExpr nd , Void c ) {
704- return new KeyofTypeExpr (visit (nd .getLoc ()), copy (nd .getElementType ()));
703+ public INode visit (UnaryTypeExpr nd , Void c ) {
704+ return new UnaryTypeExpr (visit (nd .getLoc ()), nd . getKind ( ), copy (nd .getElementType ()));
705705 }
706706
707707 @ Override
Original file line number Diff line number Diff line change 3131import com .semmle .ts .ast .InterfaceTypeExpr ;
3232import com .semmle .ts .ast .IntersectionTypeExpr ;
3333import com .semmle .ts .ast .IsTypeExpr ;
34- import com .semmle .ts .ast .KeyofTypeExpr ;
34+ import com .semmle .ts .ast .UnaryTypeExpr ;
3535import com .semmle .ts .ast .KeywordTypeExpr ;
3636import com .semmle .ts .ast .MappedTypeExpr ;
3737import com .semmle .ts .ast .NamespaceDeclaration ;
@@ -250,7 +250,7 @@ public interface Visitor<C, R> {
250250
251251 public R visit (TupleTypeExpr nd , C c );
252252
253- public R visit (KeyofTypeExpr nd , C c );
253+ public R visit (UnaryTypeExpr nd , C c );
254254
255255 public R visit (GenericTypeExpr nd , C c );
256256
Original file line number Diff line number Diff line change 125125import com .semmle .ts .ast .InterfaceTypeExpr ;
126126import com .semmle .ts .ast .IntersectionTypeExpr ;
127127import com .semmle .ts .ast .IsTypeExpr ;
128- import com .semmle .ts .ast .KeyofTypeExpr ;
128+ import com .semmle .ts .ast .UnaryTypeExpr ;
129129import com .semmle .ts .ast .KeywordTypeExpr ;
130130import com .semmle .ts .ast .MappedTypeExpr ;
131131import com .semmle .ts .ast .NamespaceDeclaration ;
@@ -1672,7 +1672,7 @@ public Label visit(TupleTypeExpr nd, Context c) {
16721672 }
16731673
16741674 @ Override
1675- public Label visit (KeyofTypeExpr nd , Context c ) {
1675+ public Label visit (UnaryTypeExpr nd , Context c ) {
16761676 Label key = super .visit (nd , c );
16771677 visit (nd .getElementType (), key , 0 , IdContext .typeBind );
16781678 return key ;
Original file line number Diff line number Diff line change 1717import com .semmle .ts .ast .InterfaceTypeExpr ;
1818import com .semmle .ts .ast .IntersectionTypeExpr ;
1919import com .semmle .ts .ast .IsTypeExpr ;
20- import com .semmle .ts .ast .KeyofTypeExpr ;
20+ import com .semmle .ts .ast .UnaryTypeExpr ;
2121import com .semmle .ts .ast .KeywordTypeExpr ;
2222import com .semmle .ts .ast .MappedTypeExpr ;
2323import com .semmle .ts .ast .OptionalTypeExpr ;
@@ -126,7 +126,7 @@ public Integer visit(TupleTypeExpr nd, Void c) {
126126 }
127127
128128 @ Override
129- public Integer visit (KeyofTypeExpr nd , Void c ) {
129+ public Integer visit (UnaryTypeExpr nd , Void c ) {
130130 return keyofTypeExpr ;
131131 }
132132
Original file line number Diff line number Diff line change 126126import com .semmle .ts .ast .InterfaceTypeExpr ;
127127import com .semmle .ts .ast .IntersectionTypeExpr ;
128128import com .semmle .ts .ast .IsTypeExpr ;
129- import com .semmle .ts .ast .KeyofTypeExpr ;
129+ import com .semmle .ts .ast .UnaryTypeExpr ;
130130import com .semmle .ts .ast .KeywordTypeExpr ;
131131import com .semmle .ts .ast .MappedTypeExpr ;
132132import com .semmle .ts .ast .NamespaceDeclaration ;
@@ -2130,7 +2130,7 @@ private Node convertTypeOfExpression(JsonObject node, SourceLocation loc) throws
21302130 private Node convertTypeOperator (JsonObject node , SourceLocation loc ) throws ParseError {
21312131 String operator = syntaxKinds .get ("" + node .get ("operator" ).getAsInt ()).getAsString ();
21322132 if (operator .equals ("KeyOfKeyword" )) {
2133- return new KeyofTypeExpr (loc , convertChildAsType (node , "type" ));
2133+ return new UnaryTypeExpr (loc , UnaryTypeExpr . Kind . Keyof , convertChildAsType (node , "type" ));
21342134 }
21352135 if (operator .equals ("UniqueKeyword" )) {
21362136 return new KeywordTypeExpr (loc , "unique symbol" );
Original file line number Diff line number Diff line change 44import com .semmle .js .ast .Visitor ;
55
66/** A type of form <tt>keyof T</tt> where <tt>T</tt> is a type. */
7- public class KeyofTypeExpr extends TypeExpression {
7+ public class UnaryTypeExpr extends TypeExpression {
88 private final ITypeExpression elementType ;
9+ private final Kind kind ;
910
10- public KeyofTypeExpr (SourceLocation loc , ITypeExpression elementType ) {
11- super ("KeyofTypeExpr" , loc );
11+ public enum Kind {
12+ Keyof ,
13+ Readonly
14+ }
15+
16+ public UnaryTypeExpr (SourceLocation loc , Kind kind , ITypeExpression elementType ) {
17+ super ("UnaryTypeExpr" , loc );
18+ this .kind = kind ;
1219 this .elementType = elementType ;
1320 }
1421
1522 public ITypeExpression getElementType () {
1623 return elementType ;
1724 }
1825
26+ public Kind getKind () {
27+ return kind ;
28+ }
29+
1930 @ Override
2031 public <C , R > R accept (Visitor <C , R > v , C c ) {
2132 return v .visit (this , c );
You can’t perform that action at this time.
0 commit comments