JS: Treat private-field methods as private

This commit is contained in:
Asger F
2024-01-15 13:00:39 +01:00
parent 057ee85cd0
commit 96f8a02a72

View File

@@ -516,16 +516,37 @@ class MemberDeclaration extends @property, Documentable {
*/
predicate hasPublicKeyword() { has_public_keyword(this) }
/**
* Holds if this member is considered private.
*
* This may occur in two cases:
* - it is a TypeScript member annotated with the `private` keyword, or
* - the member has a private name, such as `#foo`, referring to a private field in the class
*/
predicate isPrivate() { this.hasPrivateKeyword() or this.hasPrivateFieldName() }
/**
* Holds if this is a TypeScript member annotated with the `private` keyword.
*/
predicate isPrivate() { has_private_keyword(this) }
predicate hasPrivateKeyword() { has_private_keyword(this) }
/**
* Holds if this is a TypeScript member annotated with the `protected` keyword.
*/
predicate isProtected() { has_protected_keyword(this) }
/**
* Holds if the member has a private name, such as `#foo`, referring to a private field in the class.
*
* For example:
* ```js
* class Foo {
* #method() {}
* }
* ```
*/
predicate hasPrivateFieldName() { this.getNameExpr().(Label).getName().charAt(0) = "#" }
/**
* Gets the expression specifying the name of this member,
* or nothing if this is a call signature.