@@ -8,13 +8,16 @@ import javascript
88 */
99class NamespaceDefinition extends Stmt , @namespacedefinition, AST:: ValueNode {
1010 /**
11+ * DEPRECATED: Use `getIdentifier()` instead.
12+ *
1113 * Gets the identifier naming the namespace.
1214 */
13- Identifier getId ( ) {
14- result = this .( NamespaceDeclaration ) .getId ( )
15- or
16- result = this .( EnumDeclaration ) .getIdentifier ( )
17- }
15+ deprecated Identifier getId ( ) { result = getIdentifier ( ) }
16+
17+ /**
18+ * Gets the identifier naming the namespace.
19+ */
20+ Identifier getIdentifier ( ) { none ( ) } // Overridden in subtypes.
1821
1922 /**
2023 * Gets unqualified name of the namespace being defined.
@@ -29,7 +32,7 @@ class NamespaceDefinition extends Stmt, @namespacedefinition, AST::ValueNode {
2932 * Gets the local namespace name induced by this namespace.
3033 */
3134 LocalNamespaceName getLocalNamespaceName ( ) {
32- result = getId ( ) .( LocalNamespaceDecl ) .getLocalNamespaceName ( )
35+ result = getIdentifier ( ) .( LocalNamespaceDecl ) .getLocalNamespaceName ( )
3336 }
3437
3538 /**
@@ -55,10 +58,10 @@ class NamespaceDefinition extends Stmt, @namespacedefinition, AST::ValueNode {
5558 */
5659class NamespaceDeclaration extends NamespaceDefinition , StmtContainer , @namespacedeclaration {
5760 /** Gets the name of this namespace. */
58- override Identifier getId ( ) { result = getChildExpr ( - 1 ) }
61+ override Identifier getIdentifier ( ) { result = getChildExpr ( - 1 ) }
5962
6063 /** Gets the name of this namespace as a string. */
61- override string getName ( ) { result = getId ( ) .getName ( ) }
64+ override string getName ( ) { result = getIdentifier ( ) .getName ( ) }
6265
6366 /** Gets the `i`th statement in this namespace. */
6467 Stmt getStmt ( int i ) {
@@ -83,7 +86,7 @@ class NamespaceDeclaration extends NamespaceDefinition, StmtContainer, @namespac
8386 predicate isInstantiated ( ) { isInstantiated ( this ) }
8487
8588 override ControlFlowNode getFirstControlFlowNode ( ) {
86- if hasDeclareKeyword ( this ) then result = this else result = getId ( )
89+ if hasDeclareKeyword ( this ) then result = this else result = getIdentifier ( )
8790 }
8891}
8992
@@ -178,13 +181,20 @@ class GlobalAugmentationDeclaration extends Stmt, StmtContainer, @globalaugmenta
178181
179182/** A TypeScript "import-equals" declaration. */
180183class ImportEqualsDeclaration extends Stmt , @importequalsdeclaration {
184+ /**
185+ * DEPRECATED: Use `getIdentifier()` instead.
186+ *
187+ * Gets the name under which the imported entity is imported.
188+ */
189+ deprecated Identifier getId ( ) { result = getIdentifier ( ) }
190+
181191 /** Gets the name under which the imported entity is imported. */
182- Identifier getId ( ) { result = getChildExpr ( 0 ) }
192+ Identifier getIdentifier ( ) { result = getChildExpr ( 0 ) }
183193
184194 /** Gets the expression specifying the imported module or entity. */
185195 Expr getImportedEntity ( ) { result = getChildExpr ( 1 ) }
186196
187- override ControlFlowNode getFirstControlFlowNode ( ) { result = getId ( ) }
197+ override ControlFlowNode getFirstControlFlowNode ( ) { result = getIdentifier ( ) }
188198}
189199
190200/**
@@ -348,7 +358,7 @@ class TypeDecl extends Identifier, TypeRef, LexicalDecl {
348358 this = any ( ClassOrInterface ci ) .getIdentifier ( ) or
349359 this = any ( TypeParameter tp ) .getIdentifier ( ) or
350360 this = any ( ImportSpecifier im ) .getLocal ( ) or
351- this = any ( ImportEqualsDeclaration im ) .getId ( ) or
361+ this = any ( ImportEqualsDeclaration im ) .getIdentifier ( ) or
352362 this = any ( TypeAliasDeclaration td ) .getIdentifier ( ) or
353363 this = any ( EnumDeclaration ed ) .getIdentifier ( ) or
354364 this = any ( EnumMember member ) .getIdentifier ( )
@@ -1226,8 +1236,8 @@ abstract class NamespaceRef extends ASTNode { }
12261236 */
12271237class LocalNamespaceDecl extends VarDecl , NamespaceRef {
12281238 LocalNamespaceDecl ( ) {
1229- any ( NamespaceDeclaration nd ) .getId ( ) = this or
1230- any ( ImportEqualsDeclaration im ) .getId ( ) = this or
1239+ any ( NamespaceDeclaration nd ) .getIdentifier ( ) = this or
1240+ any ( ImportEqualsDeclaration im ) .getIdentifier ( ) = this or
12311241 any ( ImportSpecifier im ) .getLocal ( ) = this or
12321242 any ( EnumDeclaration ed ) .getIdentifier ( ) = this
12331243 }
@@ -1325,7 +1335,7 @@ class ImportVarTypeAccess extends VarTypeAccess, ImportTypeExpr, @importvartypea
13251335 */
13261336class EnumDeclaration extends NamespaceDefinition , @enumdeclaration, AST:: ValueNode {
13271337 /** Gets the name of this enum, such as `E` in `enum E { A, B }`. */
1328- Identifier getIdentifier ( ) { result = getChildExpr ( 0 ) }
1338+ override Identifier getIdentifier ( ) { result = getChildExpr ( 0 ) }
13291339
13301340 /** Gets the name of this enum as a string. */
13311341 override string getName ( ) { result = getIdentifier ( ) .getName ( ) }
0 commit comments