File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
javascript/ql/lib/semmle/javascript Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -516,16 +516,37 @@ class MemberDeclaration extends @property, Documentable {
516
516
*/
517
517
predicate hasPublicKeyword ( ) { has_public_keyword ( this ) }
518
518
519
+ /**
520
+ * Holds if this member is considered private.
521
+ *
522
+ * This may occur in two cases:
523
+ * - it is a TypeScript member annotated with the `private` keyword, or
524
+ * - the member has a private name, such as `#foo`, referring to a private field in the class
525
+ */
526
+ predicate isPrivate ( ) { this .hasPrivateKeyword ( ) or this .hasPrivateFieldName ( ) }
527
+
519
528
/**
520
529
* Holds if this is a TypeScript member annotated with the `private` keyword.
521
530
*/
522
- predicate isPrivate ( ) { has_private_keyword ( this ) }
531
+ predicate hasPrivateKeyword ( ) { has_private_keyword ( this ) }
523
532
524
533
/**
525
534
* Holds if this is a TypeScript member annotated with the `protected` keyword.
526
535
*/
527
536
predicate isProtected ( ) { has_protected_keyword ( this ) }
528
537
538
+ /**
539
+ * Holds if the member has a private name, such as `#foo`, referring to a private field in the class.
540
+ *
541
+ * For example:
542
+ * ```js
543
+ * class Foo {
544
+ * #method() {}
545
+ * }
546
+ * ```
547
+ */
548
+ predicate hasPrivateFieldName ( ) { this .getNameExpr ( ) .( Label ) .getName ( ) .charAt ( 0 ) = "#" }
549
+
529
550
/**
530
551
* Gets the expression specifying the name of this member,
531
552
* or nothing if this is a call signature.
You can’t perform that action at this time.
0 commit comments