Skip to content

Commit d3f1972

Browse files
authored
Merge pull request #4153 from erik-krogh/snake_case_pr
JS: rename dbscheme predicates to consistently use snake_case in dbscheme
2 parents 3493c93 + 8ada928 commit d3f1972

File tree

278 files changed

+11983
-9203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+11983
-9203
lines changed

javascript/extractor/src/com/semmle/js/ast/DeclarationFlags.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ public class DeclarationFlags {
3737

3838
public static final List<String> relationNames =
3939
Arrays.asList(
40-
"isComputed",
41-
"isAbstractMember",
42-
"isStatic",
43-
"hasReadonlyKeyword",
44-
"hasPublicKeyword",
45-
"hasPrivateKeyword",
46-
"hasProtectedKeyword",
47-
"isOptionalMember",
48-
"hasDefiniteAssignmentAssertion",
49-
"hasDeclareKeyword");
40+
"is_computed",
41+
"is_abstract_member",
42+
"is_static",
43+
"has_readonly_keyword",
44+
"has_public_keyword",
45+
"has_private_keyword",
46+
"has_protected_keyword",
47+
"is_optional_member",
48+
"has_definite_assignment_assertion",
49+
"has_declare_keyword");
5050

5151
public static boolean isComputed(int flags) {
5252
return (flags & computed) != 0;

javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ protected Label visit(SourceElement nd, int kind, String tostring, Context c) {
404404
if (nd.hasLoc()) locationManager.emitNodeLocation(nd, lbl);
405405
Statement enclosingStmt = contextManager.getCurrentStatement();
406406
if (enclosingStmt != null)
407-
trapwriter.addTuple("enclosingStmt", lbl, trapwriter.localID(enclosingStmt));
408-
trapwriter.addTuple("exprContainers", lbl, contextManager.getCurrentContainerKey());
407+
trapwriter.addTuple("enclosing_stmt", lbl, trapwriter.localID(enclosingStmt));
408+
trapwriter.addTuple("expr_containers", lbl, contextManager.getCurrentContainerKey());
409409
return lbl;
410410
}
411411

@@ -416,7 +416,7 @@ public Label visit(Statement nd, Context c) {
416416
String tostring = lexicalExtractor.mkToString(nd);
417417
trapwriter.addTuple("stmts", lbl, kind, c.parent, c.childIndex, tostring);
418418
locationManager.emitNodeLocation(nd, lbl);
419-
trapwriter.addTuple("stmtContainers", lbl, contextManager.getCurrentContainerKey());
419+
trapwriter.addTuple("stmt_containers", lbl, contextManager.getCurrentContainerKey());
420420
contextManager.setCurrentStatement(nd);
421421
return lbl;
422422
}
@@ -691,16 +691,16 @@ public Label visit(Program nd, Context c) {
691691
scopeManager.enterScope(3, moduleScopeKey, toplevelLabel);
692692
scopeManager.addVariables(
693693
sourceType.getPredefinedLocals(platform, locationManager.getSourceFileExtension()));
694-
trapwriter.addTuple("isModule", toplevelLabel);
694+
trapwriter.addTuple("is_module", toplevelLabel);
695695
}
696696

697697
// Emit the specific source type.
698698
switch (sourceType) {
699699
case CLOSURE_MODULE:
700-
trapwriter.addTuple("isClosureModule", toplevelLabel);
700+
trapwriter.addTuple("is_closure_module", toplevelLabel);
701701
break;
702702
case MODULE:
703-
trapwriter.addTuple("isES2015Module", toplevelLabel);
703+
trapwriter.addTuple("is_es2015_module", toplevelLabel);
704704
break;
705705
default:
706706
break;
@@ -810,7 +810,7 @@ public Label visit(UpdateExpression nd, Context c) {
810810
public Label visit(YieldExpression nd, Context c) {
811811
Label key = super.visit(nd, c);
812812
visit(nd.getArgument(), key, 0);
813-
if (nd.isDelegating()) trapwriter.addTuple("isDelegating", key);
813+
if (nd.isDelegating()) trapwriter.addTuple("is_delegating", key);
814814
return key;
815815
}
816816

@@ -822,7 +822,7 @@ public Label visit(YieldExpression nd, Context c) {
822822
public Label visit(VariableDeclaration nd, Context c) {
823823
Label key = super.visit(nd, c);
824824
if (nd.hasDeclareKeyword()) {
825-
trapwriter.addTuple("hasDeclareKeyword", key);
825+
trapwriter.addTuple("has_declare_keyword", key);
826826
}
827827
visitAll(nd.getDeclarations(), key);
828828
return key;
@@ -881,17 +881,17 @@ public Label visit(BlockStatement nd, Context c) {
881881
public Label visit(FunctionDeclaration nd, Context c) {
882882
Label key = super.visit(nd, c);
883883
if (nd.hasDeclareKeyword()) {
884-
trapwriter.addTuple("hasDeclareKeyword", key);
884+
trapwriter.addTuple("has_declare_keyword", key);
885885
}
886886
extractFunction(nd, key);
887887
emitStaticType(nd, key);
888888
return key;
889889
}
890890

891891
private void extractFunctionAttributes(IFunction nd, Label key) {
892-
if (nd.isGenerator()) trapwriter.addTuple("isGenerator", key);
893-
if (nd.hasRest()) trapwriter.addTuple("hasRestParameter", key);
894-
if (nd.isAsync()) trapwriter.addTuple("isAsync", key);
892+
if (nd.isGenerator()) trapwriter.addTuple("is_generator", key);
893+
if (nd.hasRest()) trapwriter.addTuple("has_rest_parameter", key);
894+
if (nd.isAsync()) trapwriter.addTuple("is_async", key);
895895
}
896896

897897
@Override
@@ -939,7 +939,7 @@ private void extractFunction(IFunction nd, Label key) {
939939

940940
// Extract optional parameters
941941
if (nd.getOptionalParameterIndices().contains(i)) {
942-
trapwriter.addTuple("isOptionalParameterDeclaration", paramKey);
942+
trapwriter.addTuple("is_optional_parameter_declaration", paramKey);
943943
}
944944
++i;
945945
}
@@ -948,7 +948,7 @@ private void extractFunction(IFunction nd, Label key) {
948948
if (!(nd instanceof ArrowFunctionExpression)) {
949949
if (!scopeManager.declaredInCurrentScope("arguments"))
950950
scopeManager.addVariables("arguments");
951-
trapwriter.addTuple("isArgumentsObject", scopeManager.getVarKey("arguments"));
951+
trapwriter.addTuple("is_arguments_object", scopeManager.getVarKey("arguments"));
952952
}
953953

954954
// add return type at index -3
@@ -1084,15 +1084,15 @@ public Label visit(EnhancedForStatement nd, Context c) {
10841084
contextManager.leaveLoopStmt();
10851085
if (!lexicals.isEmpty()) scopeManager.leaveScope();
10861086
if (nd instanceof ForOfStatement && ((ForOfStatement) nd).isAwait())
1087-
trapwriter.addTuple("isForAwaitOf", key);
1087+
trapwriter.addTuple("is_for_await_of", key);
10881088
return key;
10891089
}
10901090

10911091
@Override
10921092
public Label visit(ArrayExpression nd, Context c) {
10931093
Label key = super.visit(nd, c);
10941094
visitAll(nd.getElements(), key, IdContext.varBind, 0);
1095-
trapwriter.addTuple("arraySize", key, nd.getElements().size());
1095+
trapwriter.addTuple("array_size", key, nd.getElements().size());
10961096
return key;
10971097
}
10981098

@@ -1102,7 +1102,7 @@ public Label visit(ArrayPattern nd, Context c) {
11021102
visitAll(nd.getElements(), key, c.idcontext, 0);
11031103
visit(nd.getRest(), key, -1, c.idcontext);
11041104
visitAll(nd.getDefaults(), key, IdContext.varBind, -2, -1);
1105-
trapwriter.addTuple("arraySize", key, nd.getElements().size());
1105+
trapwriter.addTuple("array_size", key, nd.getElements().size());
11061106
return key;
11071107
}
11081108

@@ -1132,8 +1132,8 @@ public Label visit(Property nd, Context c) {
11321132
visit(nd.getKey(), propkey, 0, nd.isComputed() ? IdContext.varBind : IdContext.label);
11331133
visit(nd.getValue(), propkey, 1, c.idcontext);
11341134
visit(nd.getDefaultValue(), propkey, 2, IdContext.varBind);
1135-
if (nd.isComputed()) trapwriter.addTuple("isComputed", propkey);
1136-
if (nd.isMethod()) trapwriter.addTuple("isMethod", propkey);
1135+
if (nd.isComputed()) trapwriter.addTuple("is_computed", propkey);
1136+
if (nd.isMethod()) trapwriter.addTuple("is_method", propkey);
11371137
return propkey;
11381138
}
11391139

@@ -1222,7 +1222,7 @@ public Label visit(JumpStatement nd, Context c) {
12221222
Label key = super.visit(nd, c);
12231223
visit(nd.getLabel(), key, 0, IdContext.label);
12241224
Label targetKey = trapwriter.localID(contextManager.getTarget(nd));
1225-
trapwriter.addTuple("jumpTargets", key, targetKey);
1225+
trapwriter.addTuple("jump_targets", key, targetKey);
12261226
return key;
12271227
}
12281228

@@ -1284,10 +1284,10 @@ public Label visit(TemplateElement nd, Context c) {
12841284
public Label visit(ClassDeclaration nd, Context c) {
12851285
Label lbl = super.visit(nd, c);
12861286
if (nd.hasDeclareKeyword()) {
1287-
trapwriter.addTuple("hasDeclareKeyword", lbl);
1287+
trapwriter.addTuple("has_declare_keyword", lbl);
12881288
}
12891289
if (nd.hasAbstractKeyword()) {
1290-
trapwriter.addTuple("isAbstractClass", lbl);
1290+
trapwriter.addTuple("is_abstract_class", lbl);
12911291
}
12921292
return visit(nd.getClassDef(), lbl, nd, false);
12931293
}
@@ -1361,7 +1361,7 @@ public Label visit(NamespaceDeclaration nd, Context c) {
13611361
nd.isInstantiated() ? IdContext.varAndNamespaceDecl : IdContext.namespaceDecl;
13621362
visit(nd.getName(), lbl, -1, context);
13631363
if (nd.hasDeclareKeyword()) {
1364-
trapwriter.addTuple("hasDeclareKeyword", lbl);
1364+
trapwriter.addTuple("has_declare_keyword", lbl);
13651365
}
13661366
DeclaredNames hoistedVars =
13671367
scopeManager.collectDeclaredNames(nd.getBody(), isStrict, false, DeclKind.none);
@@ -1375,7 +1375,7 @@ public Label visit(NamespaceDeclaration nd, Context c) {
13751375
contextManager.leaveContainer();
13761376
scopeManager.leaveScope();
13771377
if (nd.isInstantiated()) {
1378-
trapwriter.addTuple("isInstantiated", lbl);
1378+
trapwriter.addTuple("is_instantiated", lbl);
13791379
}
13801380
return lbl;
13811381
}
@@ -1520,7 +1520,7 @@ public Label visit(MemberDefinition<?> nd, Context c) {
15201520
if (ctor != null) contextManager.leaveContainer();
15211521

15221522
if (nd instanceof MethodDefinition && !nd.isCallSignature() && !nd.isIndexSignature())
1523-
trapwriter.addTuple("isMethod", methkey);
1523+
trapwriter.addTuple("is_method", methkey);
15241524
// Emit tuples for isStatic, isAbstract, isComputed, etc
15251525
for (int i = 0; i < DeclarationFlags.numberOfFlags; ++i) {
15261526
if (DeclarationFlags.hasNthFlag(nd.getFlags(), i)) {
@@ -1539,7 +1539,7 @@ public Label visit(MemberDefinition<?> nd, Context c) {
15391539
}
15401540

15411541
if (nd.hasDeclareKeyword()) {
1542-
trapwriter.addTuple("hasDeclareKeyword", methkey);
1542+
trapwriter.addTuple("has_declare_keyword", methkey);
15431543
}
15441544

15451545
return methkey;
@@ -1575,7 +1575,7 @@ public Label visit(ExportNamedDeclaration nd, Context c) {
15751575
IdContext.export;
15761576
visitAll(nd.getSpecifiers(), lbl, childContext, 0);
15771577
if (nd.hasTypeKeyword()) {
1578-
trapwriter.addTuple("hasTypeKeyword", lbl);
1578+
trapwriter.addTuple("has_type_keyword", lbl);
15791579
}
15801580
return lbl;
15811581
}
@@ -1596,7 +1596,7 @@ public Label visit(ImportDeclaration nd, Context c) {
15961596
visitAll(nd.getSpecifiers(), lbl, childContext, 0);
15971597
emitNodeSymbol(nd, lbl);
15981598
if (nd.hasTypeKeyword()) {
1599-
trapwriter.addTuple("hasTypeKeyword", lbl);
1599+
trapwriter.addTuple("has_type_keyword", lbl);
16001600
}
16011601
return lbl;
16021602
}
@@ -1866,7 +1866,7 @@ public Label visit(PredicateTypeExpr nd, Context c) {
18661866
visit(nd.getExpression(), key, 0, IdContext.varInTypeBind);
18671867
visit(nd.getTypeExpr(), key, 1, IdContext.typeBind);
18681868
if (nd.hasAssertsKeyword()) {
1869-
trapwriter.addTuple("hasAssertsKeyword", key);
1869+
trapwriter.addTuple("has_asserts_keyword", key);
18701870
}
18711871
return key;
18721872
}
@@ -1944,10 +1944,10 @@ public Label visit(EnumDeclaration nd, Context c) {
19441944
visitAll(nd.getMembers(), key, IdContext.varAndTypeDecl, 1, 1);
19451945
scopeManager.leaveScope();
19461946
if (nd.isConst()) {
1947-
trapwriter.addTuple("isConstEnum", key);
1947+
trapwriter.addTuple("is_const_enum", key);
19481948
}
19491949
if (nd.hasDeclareKeyword()) {
1950-
trapwriter.addTuple("hasDeclareKeyword", key);
1950+
trapwriter.addTuple("has_declare_keyword", key);
19511951
}
19521952
emitNodeSymbol(nd, key);
19531953
return key;
@@ -1968,7 +1968,7 @@ public Label visit(EnumMember nd, Context c) {
19681968
@Override
19691969
public Label visit(ExternalModuleDeclaration nd, Context c) {
19701970
Label key = super.visit(nd, c);
1971-
trapwriter.addTuple("hasDeclareKeyword", key);
1971+
trapwriter.addTuple("has_declare_keyword", key);
19721972
visit(nd.getName(), key, -1, IdContext.label);
19731973
DeclaredNames hoistedVars =
19741974
scopeManager.collectDeclaredNames(nd.getBody(), isStrict, false, DeclKind.none);
@@ -2013,7 +2013,7 @@ public Label visit(GlobalAugmentationDeclaration nd, Context c) {
20132013
// The fake scope does not exist at the QL level, as it is indistinguishable
20142014
// from the global scope.
20152015
Label key = super.visit(nd, c);
2016-
trapwriter.addTuple("hasDeclareKeyword", key);
2016+
trapwriter.addTuple("has_declare_keyword", key);
20172017
DeclaredNames hoistedVars =
20182018
scopeManager.collectDeclaredNames(nd.getBody(), isStrict, false, DeclKind.none);
20192019
DeclaredNames lexicalVars =

javascript/extractor/src/com/semmle/js/extractor/ExprKinds.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ public Integer visit(ComprehensionBlock nd, Void q) {
261261

262262
@Override
263263
public Integer visit(MetaProperty nd, Void c) {
264-
if (nd.getMeta().getName().equals("new")) return 82; // @newtargetexpr
265-
if (nd.getMeta().getName().equals("import")) return 115; // @importmetaexpr
266-
return 93; // @functionsentexpr
264+
if (nd.getMeta().getName().equals("new")) return 82; // @newtarget_expr
265+
if (nd.getMeta().getName().equals("import")) return 115; // @import_meta_expr
266+
return 93; // @function_sent_expr
267267
}
268268

269269
@Override

javascript/extractor/src/com/semmle/js/extractor/JSExtractor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ public Pair<Label, LoCInfo> extract(
130130
if (!config.isTolerateParseErrors()) throw parseError;
131131
Label key = trapwriter.freshLabel();
132132
String errorLine = textualExtractor.getLine(parseError.getPosition().getLine());
133-
trapwriter.addTuple("jsParseErrors", key, toplevelLabel, "Error: " + parseError, errorLine);
133+
trapwriter.addTuple("js_parse_errors", key, toplevelLabel, "Error: " + parseError, errorLine);
134134
locationManager.emitErrorLocation(
135135
key, parseError.getPosition(), textualExtractor.getNumLines());
136136
lexicalExtractor.extractLines(source, toplevelLabel);
137137
}
138138

139-
if (config.isExterns()) textualExtractor.getTrapwriter().addTuple("isExterns", toplevelLabel);
139+
if (config.isExterns()) textualExtractor.getTrapwriter().addTuple("is_externs", toplevelLabel);
140140
if (platform == Platform.NODE && sourceType == SourceType.COMMONJS_MODULE)
141-
textualExtractor.getTrapwriter().addTuple("isNodejs", toplevelLabel);
141+
textualExtractor.getTrapwriter().addTuple("is_nodejs", toplevelLabel);
142142

143143
textualExtractor.getMetrics().stopPhase(ExtractionPhase.JSExtractor_extract);
144144

0 commit comments

Comments
 (0)