mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
fix the parser to allow lower-case module names
This commit is contained in:
BIN
ql/Cargo.lock
generated
BIN
ql/Cargo.lock
generated
Binary file not shown.
@@ -10,7 +10,7 @@ edition = "2018"
|
||||
flate2 = "1.0"
|
||||
node-types = { path = "../node-types" }
|
||||
tree-sitter = "0.19"
|
||||
tree-sitter-ql = { git = "https://github.com/erik-krogh/tree-sitter-ql.git", rev = "d8da4b8190a3c1f3fab293016bbbb60469e56ea3" }
|
||||
tree-sitter-ql = { git = "https://github.com/erik-krogh/tree-sitter-ql.git", rev = "343cc5873e20510586ade803659ef8ce153bd603" }
|
||||
clap = "2.33"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }
|
||||
|
||||
@@ -11,4 +11,4 @@ clap = "2.33"
|
||||
node-types = { path = "../node-types" }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }
|
||||
tree-sitter-ql = { git = "https://github.com/erik-krogh/tree-sitter-ql.git", rev = "d8da4b8190a3c1f3fab293016bbbb60469e56ea3" }
|
||||
tree-sitter-ql = { git = "https://github.com/erik-krogh/tree-sitter-ql.git", rev = "343cc5873e20510586ade803659ef8ce153bd603" }
|
||||
|
||||
@@ -699,7 +699,7 @@ class Module extends TModule, ModuleDeclaration {
|
||||
|
||||
override string getAPrimaryQlClass() { result = "Module" }
|
||||
|
||||
override string getName() { result = mod.getName().getValue() }
|
||||
override string getName() { result = mod.getName().getChild().getValue() }
|
||||
|
||||
/**
|
||||
* Gets a member of the module.
|
||||
@@ -1129,7 +1129,7 @@ class Import extends TImport, ModuleMember, ModuleRef {
|
||||
* import semmle.javascript.dataflow.Configuration as Flow
|
||||
* ```
|
||||
*/
|
||||
string importedAs() { result = imp.getChild(1).(QL::ModuleName).getValue() }
|
||||
string importedAs() { result = imp.getChild(1).(QL::ModuleName).getChild().getValue() }
|
||||
|
||||
/**
|
||||
* Gets the `i`th selected name from the imported module.
|
||||
@@ -2200,12 +2200,12 @@ class ModuleExpr extends TModuleExpr, ModuleRef {
|
||||
* is `Bar`.
|
||||
*/
|
||||
string getName() {
|
||||
result = me.getName().(QL::ModuleName).getValue()
|
||||
result = me.getName().(QL::SimpleId).getValue()
|
||||
or
|
||||
not exists(me.getName()) and result = me.getChild().(QL::ModuleName).getValue()
|
||||
not exists(me.getName()) and result = me.getChild().(QL::SimpleId).getValue()
|
||||
or
|
||||
exists(QL::ModuleInstantiation instantiation | instantiation.getParent() = me |
|
||||
result = instantiation.getName().getValue()
|
||||
result = instantiation.getName().getChild().getValue()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1023,10 +1023,16 @@ module QL {
|
||||
final override AstNode getAFieldOrChild() { ql_module_member_child(this, _, result) }
|
||||
}
|
||||
|
||||
/** A class representing `moduleName` tokens. */
|
||||
class ModuleName extends @ql_token_module_name, Token {
|
||||
/** A class representing `moduleName` nodes. */
|
||||
class ModuleName extends @ql_module_name, AstNode {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
final override string getAPrimaryQlClass() { result = "ModuleName" }
|
||||
|
||||
/** Gets the child of this node. */
|
||||
final SimpleId getChild() { ql_module_name_def(this, result) }
|
||||
|
||||
/** Gets a field or child node of this node. */
|
||||
final override AstNode getAFieldOrChild() { ql_module_name_def(this, result) }
|
||||
}
|
||||
|
||||
/** A class representing `moduleParam` nodes. */
|
||||
|
||||
@@ -529,7 +529,7 @@ ql_implication_def(
|
||||
int right: @ql_implication_right_type ref
|
||||
);
|
||||
|
||||
@ql_importDirective_child_type = @ql_import_module_expr | @ql_token_module_name
|
||||
@ql_importDirective_child_type = @ql_import_module_expr | @ql_module_name
|
||||
|
||||
#keyset[ql_import_directive, index]
|
||||
ql_import_directive_child(
|
||||
@@ -626,7 +626,7 @@ ql_module_child(
|
||||
|
||||
ql_module_def(
|
||||
unique int id: @ql_module,
|
||||
int name: @ql_token_module_name ref
|
||||
int name: @ql_module_name ref
|
||||
);
|
||||
|
||||
ql_module_alias_body_def(
|
||||
@@ -634,14 +634,14 @@ ql_module_alias_body_def(
|
||||
int child: @ql_module_expr ref
|
||||
);
|
||||
|
||||
@ql_moduleExpr_name_type = @ql_module_instantiation | @ql_token_module_name
|
||||
@ql_moduleExpr_name_type = @ql_module_instantiation | @ql_token_simple_id
|
||||
|
||||
ql_module_expr_name(
|
||||
unique int ql_module_expr: @ql_module_expr ref,
|
||||
unique int name: @ql_moduleExpr_name_type ref
|
||||
);
|
||||
|
||||
@ql_moduleExpr_child_type = @ql_module_expr | @ql_module_instantiation | @ql_token_module_name
|
||||
@ql_moduleExpr_child_type = @ql_module_expr | @ql_module_instantiation | @ql_token_simple_id
|
||||
|
||||
ql_module_expr_def(
|
||||
unique int id: @ql_module_expr,
|
||||
@@ -657,7 +657,7 @@ ql_module_instantiation_child(
|
||||
|
||||
ql_module_instantiation_def(
|
||||
unique int id: @ql_module_instantiation,
|
||||
int name: @ql_token_module_name ref
|
||||
int name: @ql_module_name ref
|
||||
);
|
||||
|
||||
@ql_moduleMember_child_type = @ql_annotation | @ql_classless_predicate | @ql_dataclass | @ql_datatype | @ql_import_directive | @ql_module | @ql_select | @ql_token_qldoc
|
||||
@@ -673,6 +673,11 @@ ql_module_member_def(
|
||||
unique int id: @ql_module_member
|
||||
);
|
||||
|
||||
ql_module_name_def(
|
||||
unique int id: @ql_module_name,
|
||||
int child: @ql_token_simple_id ref
|
||||
);
|
||||
|
||||
ql_module_param_def(
|
||||
unique int id: @ql_module_param,
|
||||
int parameter: @ql_token_simple_id ref,
|
||||
@@ -1086,27 +1091,26 @@ case @ql_token.kind of
|
||||
| 22 = @ql_token_integer
|
||||
| 23 = @ql_token_line_comment
|
||||
| 24 = @ql_token_literal_id
|
||||
| 25 = @ql_token_module_name
|
||||
| 26 = @ql_token_mulop
|
||||
| 27 = @ql_token_predicate
|
||||
| 28 = @ql_token_predicate_name
|
||||
| 29 = @ql_token_primitive_type
|
||||
| 30 = @ql_token_qldoc
|
||||
| 31 = @ql_token_quantifier
|
||||
| 32 = @ql_token_result
|
||||
| 33 = @ql_token_simple_id
|
||||
| 34 = @ql_token_special_id
|
||||
| 35 = @ql_token_string
|
||||
| 36 = @ql_token_super
|
||||
| 37 = @ql_token_this
|
||||
| 38 = @ql_token_true
|
||||
| 39 = @ql_token_underscore
|
||||
| 40 = @ql_token_unop
|
||||
| 41 = @ql_token_yaml_value
|
||||
| 25 = @ql_token_mulop
|
||||
| 26 = @ql_token_predicate
|
||||
| 27 = @ql_token_predicate_name
|
||||
| 28 = @ql_token_primitive_type
|
||||
| 29 = @ql_token_qldoc
|
||||
| 30 = @ql_token_quantifier
|
||||
| 31 = @ql_token_result
|
||||
| 32 = @ql_token_simple_id
|
||||
| 33 = @ql_token_special_id
|
||||
| 34 = @ql_token_string
|
||||
| 35 = @ql_token_super
|
||||
| 36 = @ql_token_this
|
||||
| 37 = @ql_token_true
|
||||
| 38 = @ql_token_underscore
|
||||
| 39 = @ql_token_unop
|
||||
| 40 = @ql_token_yaml_value
|
||||
;
|
||||
|
||||
|
||||
@ql_ast_node = @ql_add_expr | @ql_aggregate | @ql_annot_arg | @ql_annotation | @ql_arityless_predicate_expr | @ql_as_expr | @ql_as_exprs | @ql_body | @ql_bool | @ql_call_body | @ql_call_or_unqual_agg_expr | @ql_charpred | @ql_class_member | @ql_classless_predicate | @ql_comp_term | @ql_conjunction | @ql_dataclass | @ql_datatype | @ql_datatype_branch | @ql_datatype_branches | @ql_db_annotation | @ql_db_args_annotation | @ql_db_branch | @ql_db_case_decl | @ql_db_col_type | @ql_db_column | @ql_db_entry | @ql_db_repr_type | @ql_db_table | @ql_db_table_name | @ql_db_union_decl | @ql_disjunction | @ql_expr_aggregate_body | @ql_expr_annotation | @ql_field | @ql_full_aggregate_body | @ql_higher_order_term | @ql_if_term | @ql_implication | @ql_import_directive | @ql_import_module_expr | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_member_predicate | @ql_module | @ql_module_alias_body | @ql_module_expr | @ql_module_instantiation | @ql_module_member | @ql_module_param | @ql_mul_expr | @ql_negation | @ql_order_by | @ql_order_bys | @ql_par_expr | @ql_predicate_alias_body | @ql_predicate_expr | @ql_prefix_cast | @ql_ql | @ql_qual_module_expr | @ql_qualified_expr | @ql_qualified_rhs | @ql_quantified | @ql_range | @ql_select | @ql_set_literal | @ql_signature_expr | @ql_special_call | @ql_super_ref | @ql_token | @ql_type_alias_body | @ql_type_expr | @ql_type_union_body | @ql_unary_expr | @ql_unqual_agg_body | @ql_var_decl | @ql_var_name | @ql_variable | @ql_yaml_comment | @ql_yaml_entry | @ql_yaml_key | @ql_yaml_keyvaluepair | @ql_yaml_listitem
|
||||
@ql_ast_node = @ql_add_expr | @ql_aggregate | @ql_annot_arg | @ql_annotation | @ql_arityless_predicate_expr | @ql_as_expr | @ql_as_exprs | @ql_body | @ql_bool | @ql_call_body | @ql_call_or_unqual_agg_expr | @ql_charpred | @ql_class_member | @ql_classless_predicate | @ql_comp_term | @ql_conjunction | @ql_dataclass | @ql_datatype | @ql_datatype_branch | @ql_datatype_branches | @ql_db_annotation | @ql_db_args_annotation | @ql_db_branch | @ql_db_case_decl | @ql_db_col_type | @ql_db_column | @ql_db_entry | @ql_db_repr_type | @ql_db_table | @ql_db_table_name | @ql_db_union_decl | @ql_disjunction | @ql_expr_aggregate_body | @ql_expr_annotation | @ql_field | @ql_full_aggregate_body | @ql_higher_order_term | @ql_if_term | @ql_implication | @ql_import_directive | @ql_import_module_expr | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_member_predicate | @ql_module | @ql_module_alias_body | @ql_module_expr | @ql_module_instantiation | @ql_module_member | @ql_module_name | @ql_module_param | @ql_mul_expr | @ql_negation | @ql_order_by | @ql_order_bys | @ql_par_expr | @ql_predicate_alias_body | @ql_predicate_expr | @ql_prefix_cast | @ql_ql | @ql_qual_module_expr | @ql_qualified_expr | @ql_qualified_rhs | @ql_quantified | @ql_range | @ql_select | @ql_set_literal | @ql_signature_expr | @ql_special_call | @ql_super_ref | @ql_token | @ql_type_alias_body | @ql_type_expr | @ql_type_union_body | @ql_unary_expr | @ql_unqual_agg_body | @ql_var_decl | @ql_var_name | @ql_variable | @ql_yaml_comment | @ql_yaml_entry | @ql_yaml_key | @ql_yaml_keyvaluepair | @ql_yaml_listitem
|
||||
|
||||
@ql_ast_node_parent = @file | @ql_ast_node
|
||||
|
||||
|
||||
Reference in New Issue
Block a user