Skip to content

Commit

Permalink
Use snake_case everywhere
Browse files Browse the repository at this point in the history
Summary:
Currently, we're using a mixture of snake_case, lowerCamelCase, and dash-case in different situations. It's probably best to use only a single one of those styles, so as to avoid confusing the consumers of the API.

I chose snake_case because it already has precedence, given the JSON output of the full-fidelity parser, and it's also usable for identifiers in code (unlike dash-case in Hack or Flow).

Differential Revision: D7717960

fbshipit-source-id: 4c5a5b75d1267d75980ccdafbfe6cace1c371f8c
  • Loading branch information
Waleed Khan authored and hhvm-bot committed Apr 25, 2018
1 parent 404e15d commit 2eb299d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions hphp/hack/src/server/cstSearchService.ml
Expand Up @@ -202,15 +202,15 @@ let compile_pattern (json: Hh_json.json): (pattern, string) Core_result.t =
in

let rec compile_pattern ~json ~keytrace : (pattern, string) Core_result.t =
get_string "patternType" (json, keytrace)
get_string "pattern_type" (json, keytrace)

>>= fun (pattern_type, pattern_type_keytrace) ->
match pattern_type with
| "node-pattern" ->
| "node_pattern" ->
compile_node_pattern ~json ~keytrace
| "match-pattern" ->
| "match_pattern" ->
compile_match_pattern ~json ~keytrace
| "descendant-pattern" ->
| "descendant_pattern" ->
compile_descendant_pattern ~json ~keytrace
| pattern_type ->
error_at_keytrace ~keytrace:pattern_type_keytrace
Expand Down Expand Up @@ -279,7 +279,7 @@ let compile_pattern (json: Hh_json.json): (pattern, string) Core_result.t =
}

and compile_match_pattern ~json ~keytrace =
get_string "matchName" (json, keytrace)
get_string "match_name" (json, keytrace)
>>| fun (match_name, _match_name_keytrace) ->
MatchPattern {
match_name = MatchName match_name;
Expand Down Expand Up @@ -308,12 +308,12 @@ let result_to_json (result: result option): Hh_json.json =
with MatchName match_name -> match_name
in
JSON_Object [
"matchName", JSON_String match_name;
"match_name", JSON_String match_name;
"node", Syntax.to_json matched_node.node;
])
in
JSON_Object [
"matchedNodes", JSON_Array matched_nodes;
"matched_nodes", JSON_Array matched_nodes;
]

let search
Expand Down
10 changes: 5 additions & 5 deletions hphp/hack/test/cst_search/basic_class.json
@@ -1,16 +1,16 @@
{
"patternType": "descendant-pattern",
"pattern_type": "descendant_pattern",
"pattern": {
"patternType": "node-pattern",
"pattern_type": "node_pattern",
"kind": "methodish_declaration",
"children": {
"methodish_function_decl_header": {
"patternType": "node-pattern",
"pattern_type": "node_pattern",
"kind": "function_declaration_header",
"children": {
"function_name": {
"patternType": "match-pattern",
"matchName": "function name"
"pattern_type": "match_pattern",
"match_name": "function name"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions hphp/hack/test/cst_search/basic_class.json.exp
@@ -1,7 +1,7 @@
{
"matchedNodes":[
"matched_nodes":[
{
"matchName":"function name",
"match_name":"function name",
"node":{
"kind":"token",
"token":{
Expand Down
8 changes: 4 additions & 4 deletions hphp/hack/test/cst_search/basic_class_no_match.json
@@ -1,13 +1,13 @@
{
"patternType": "descendant-pattern",
"pattern_type": "descendant_pattern",
"pattern": {
"patternType": "node-pattern",
"pattern_type": "node_pattern",
"kind": "methodish_declaration",
"children": {
"methodish_semicolon": {
"patternType": "descendant-pattern",
"pattern_type": "descendant_pattern",
"pattern": {
"patternType": "node-pattern",
"pattern_type": "node_pattern",
"kind": "methodish_declaration",
"children": {}
}
Expand Down
4 changes: 2 additions & 2 deletions hphp/hack/test/cst_search/error_non_existent_child_type.json
@@ -1,9 +1,9 @@
{
"patternType": "node-pattern",
"pattern_type": "node_pattern",
"kind": "methodish_declaration",
"children": {
"foo": {
"patternType": "match-pattern"
"pattern_type": "match_pattern"
}
}
}
2 changes: 1 addition & 1 deletion hphp/hack/test/cst_search/error_non_existent_kind.json
@@ -1,5 +1,5 @@
{
"patternType": "node-pattern",
"pattern_type": "node_pattern",
"kind": "foo",
"children": {}
}

0 comments on commit 2eb299d

Please sign in to comment.