mirror of
https://github.com/github/codeql.git
synced 2026-01-08 04:00:26 +01:00
TS: Support declare modifier for fields
This commit is contained in:
@@ -17,9 +17,10 @@ public class DeclarationFlags {
|
||||
public static final int protected_ = 1 << 6;
|
||||
public static final int optional = 1 << 7;
|
||||
public static final int definiteAssignmentAssertion = 1 << 8;
|
||||
public static final int declareKeyword = 1 << 9;
|
||||
|
||||
public static final int none = 0;
|
||||
public static final int numberOfFlags = 9;
|
||||
public static final int numberOfFlags = 10;
|
||||
|
||||
public static final List<String> names =
|
||||
Arrays.asList(
|
||||
@@ -31,7 +32,8 @@ public class DeclarationFlags {
|
||||
"private",
|
||||
"protected",
|
||||
"optional",
|
||||
"definiteAssignmentAssertion");
|
||||
"definiteAssignmentAssertion",
|
||||
"declare");
|
||||
|
||||
public static final List<String> relationNames =
|
||||
Arrays.asList(
|
||||
@@ -43,7 +45,8 @@ public class DeclarationFlags {
|
||||
"hasPrivateKeyword",
|
||||
"hasProtectedKeyword",
|
||||
"isOptionalMember",
|
||||
"hasDefiniteAssignmentAssertion");
|
||||
"hasDefiniteAssignmentAssertion",
|
||||
"hasDeclareKeyword");
|
||||
|
||||
public static boolean isComputed(int flags) {
|
||||
return (flags & computed) != 0;
|
||||
@@ -81,6 +84,10 @@ public class DeclarationFlags {
|
||||
return (flags & definiteAssignmentAssertion) != 0;
|
||||
}
|
||||
|
||||
public static boolean hasDeclareKeyword(int flags) {
|
||||
return (flags & declareKeyword) != 0;
|
||||
}
|
||||
|
||||
/** Returns a mask with the computed bit set to the value of <tt>enable</tt>. */
|
||||
public static int getComputed(boolean enable) {
|
||||
return enable ? computed : 0;
|
||||
@@ -128,6 +135,11 @@ public class DeclarationFlags {
|
||||
return enable ? definiteAssignmentAssertion : 0;
|
||||
}
|
||||
|
||||
/** Returns a mask with the declare keyword bit set to the value of <tt>enable</tt>. */
|
||||
public static int getDeclareKeyword(boolean enable) {
|
||||
return enable ? declareKeyword : 0;
|
||||
}
|
||||
|
||||
/** Returns true if the <tt>n</tt>th bit is set in <tt>flags</tt>. */
|
||||
public static boolean hasNthFlag(int flags, int n) {
|
||||
return (flags & (1 << n)) != 0;
|
||||
|
||||
@@ -75,6 +75,11 @@ public abstract class MemberDefinition<V extends Expression> extends Node {
|
||||
return DeclarationFlags.isReadonly(flags);
|
||||
}
|
||||
|
||||
/** Returns true if this has the <tt>declare</tt> modifier. */
|
||||
public boolean hasDeclareKeyword() {
|
||||
return DeclarationFlags.hasDeclareKeyword(flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expression denoting the name of the member, or {@code null} if this is a
|
||||
* call/construct signature.
|
||||
|
||||
@@ -1410,6 +1410,10 @@ public class ASTExtractor {
|
||||
}
|
||||
}
|
||||
|
||||
if (nd.hasDeclareKeyword()) {
|
||||
trapwriter.addTuple("hasDeclareKeyword", methkey);
|
||||
}
|
||||
|
||||
return methkey;
|
||||
}
|
||||
|
||||
|
||||
@@ -2009,6 +2009,9 @@ public class TypeScriptASTConverter {
|
||||
if (node.get("exclamationToken") != null) {
|
||||
flags |= DeclarationFlags.definiteAssignmentAssertion;
|
||||
}
|
||||
if (hasModifier(node, "DeclareKeyword")) {
|
||||
flags |= DeclarationFlags.declareKeyword;
|
||||
}
|
||||
FieldDefinition fieldDefinition =
|
||||
new FieldDefinition(
|
||||
loc,
|
||||
|
||||
Reference in New Issue
Block a user