Skip to content

Commit

Permalink
Rename ast.ml -> flow_ast.ml
Browse files Browse the repository at this point in the history
Summary: Rename `ast.ml` to `flow_ast.ml` so not to conflict with other `ast.ml` files

Reviewed By: panagosg7

Differential Revision: D9444051

fbshipit-source-id: 5fa6da0a76d9e4b1c2b970b9d3888351518802a1
  • Loading branch information
pieterv authored and facebook-github-bot committed Aug 23, 2018
1 parent 7360702 commit cdc62a9
Show file tree
Hide file tree
Showing 118 changed files with 646 additions and 545 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ flow.odocl: $(shell find . -name "*.ml" -o -name "*.mli")
done
# For some reason these two AST files cause ocamldoc to get stuck
cat deps \
| grep -v "src/parser/ast.ml" \
| grep -v "src/parser/flow_ast.ml" \
| sed "s/\.ml$$//" > $@
rm -f deps last_deps temp_deps

Expand Down
2 changes: 2 additions & 0 deletions src/commands/astCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

(***********************************************************************)
(* flow ast command *)
(***********************************************************************)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/lspCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type open_file_info = {
(* o_open_doc is guaranteed to be up-to-date with respect to the editor *)
o_open_doc: Lsp.TextDocumentItem.t;
(* o_ast, if present, is guaranteed to be up-to-date. It gets computed lazily. *)
o_ast: (Loc.t, Loc.t) Ast.program option;
o_ast: (Loc.t, Loc.t) Flow_ast.program option;
(* o_live_diagnostics, if present, is guaranteed to be up-to-date, and to only contain
* parse errors, and to be a better source of truth about the parse errors
* in this file than what the flow server has told us. It also gets computed lazily. *)
Expand Down Expand Up @@ -853,7 +853,7 @@ let error_to_lsp
* or it's an unopened file in which case we'll retrieve parse results but
* won't store them. *)
let parse_and_cache flowconfig_name (state: state) (uri: string)
: state * (Loc.t, Loc.t) Ast.program * PublishDiagnostics.diagnostic list option =
: state * (Loc.t, Loc.t) Flow_ast.program * PublishDiagnostics.diagnostic list option =
(* part of parsing is producing parse errors, if so desired *)
let liveSyntaxErrors = let open Initialize in match state with
| Connected cenv -> cenv.c_ienv.i_initialize_params.initializationOptions.liveSyntaxErrors
Expand Down
2 changes: 1 addition & 1 deletion src/common/docblock.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type jsx_pragma =
* when interpreting JSX syntax. Otherwise, the usual rules of JSX are
* followed: children are varargs after a props argument.
*)
| Jsx_pragma of (string * (Loc.t, Loc.t) Ast.Expression.t)
| Jsx_pragma of (string * (Loc.t, Loc.t) Flow_ast.Expression.t)

(**
* Alternate mode for interpreting JSX syntax. The element name is treated
Expand Down
2 changes: 2 additions & 0 deletions src/common/flow_lsp_conversions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

let flow_completion_to_lsp
(item: ServerProt.Response.complete_autocomplete_result)
: Lsp.Completion.completionItem =
Expand Down
2 changes: 1 addition & 1 deletion src/common/options.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type jsx_mode =
* when interpreting JSX syntax. Otherwise, the usual rules of JSX are
* followed: children are varargs after a props argument.
*)
| Jsx_pragma of (string * (Loc.t, Loc.t) Ast.Expression.t)
| Jsx_pragma of (string * (Loc.t, Loc.t) Flow_ast.Expression.t)

(**
* Alternate mode for interpreting JSX syntax. The element name is treated
Expand Down
2 changes: 2 additions & 0 deletions src/common/reason.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

(* This module defines a general notion of trace, which is used in modules
Type_inference_js and Flow_js to record how the typechecker reasons about
code, systematically collecting, simplifying, and solving constraints. This
Expand Down
4 changes: 2 additions & 2 deletions src/common/reason.mli
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ val json_of_loc_props: ?strip_root:Path.t option -> Loc.t -> (string * Hh_json.j

val locationless_reason: reason_desc -> reason

val func_reason: (Loc.t, Loc.t) Ast.Function.t -> Loc.t -> reason
val func_reason: (Loc.t, Loc.t) Flow_ast.Function.t -> Loc.t -> reason

val is_internal_name: string -> bool
val internal_name: string -> string
Expand Down Expand Up @@ -243,7 +243,7 @@ val do_patch: string list -> (int * int * string) list -> string

module ReasonMap : MyMap.S with type key = reason

val mk_expression_reason: (Loc.t, Loc.t) Ast.Expression.t -> reason
val mk_expression_reason: (Loc.t, Loc.t) Flow_ast.Expression.t -> reason

val unknown_elem_empty_array_desc: reason_desc
val inferred_union_elem_array_desc: reason_desc
Expand Down
4 changes: 3 additions & 1 deletion src/common/ty/ty_serializer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

open Core_result
open Ty
module T = Ast.Type
module T = Flow_ast.Type

let mapM f ts = all (List.map f ts)

Expand Down
2 changes: 1 addition & 1 deletion src/common/ty/ty_serializer.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
* LICENSE file in the root directory of this source tree.
*)

val type_ : Ty.t -> ((Loc.t, Loc.t) Ast.Type.t, string) Core_result.t
val type_ : Ty.t -> ((Loc.t, Loc.t) Flow_ast.Type.t, string) Core_result.t
6 changes: 3 additions & 3 deletions src/parser/ast_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*)

open Ast
open Flow_ast

type binding = Loc.t * string
type ident = Loc.t * string
Expand Down Expand Up @@ -42,14 +42,14 @@ let rec bindings_of_pattern =
failwith "expression pattern"

let bindings_of_variable_declarations =
let open Ast.Statement.VariableDeclaration in
let open Flow_ast.Statement.VariableDeclaration in
List.fold_left (fun acc -> function
| _, { Declarator.id = (_, pattern); _ } ->
bindings_of_pattern acc pattern
) []

let partition_directives statements =
let open Ast.Statement in
let open Flow_ast.Statement in
let rec helper directives = function
| ((_, Expression { Expression.directive = Some _; _ }) as directive)::rest ->
helper (directive::directives) rest
Expand Down
12 changes: 6 additions & 6 deletions src/parser/ast_utils.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ type source = Loc.t * string

val bindings_of_pattern:
binding list ->
(Loc.t, Loc.t) Ast.Pattern.t' ->
(Loc.t, Loc.t) Flow_ast.Pattern.t' ->
binding list

val bindings_of_variable_declarations:
(Loc.t, Loc.t) Ast.Statement.VariableDeclaration.Declarator.t list ->
(Loc.t, Loc.t) Flow_ast.Statement.VariableDeclaration.Declarator.t list ->
binding list

val partition_directives:
(Loc.t, Loc.t) Ast.Statement.t list ->
(Loc.t, Loc.t) Ast.Statement.t list * (Loc.t, Loc.t) Ast.Statement.t list
(Loc.t, Loc.t) Flow_ast.Statement.t list ->
(Loc.t, Loc.t) Flow_ast.Statement.t list * (Loc.t, Loc.t) Flow_ast.Statement.t list

val negate_number_literal:
float * string ->
float * string

val loc_of_expression:
('a, 'a) Ast.Expression.t -> 'a
('a, 'a) Flow_ast.Expression.t -> 'a

val loc_of_statement:
('a, 'a) Ast.Statement.t -> 'a
('a, 'a) Flow_ast.Statement.t -> 'a
4 changes: 3 additions & 1 deletion src/parser/declaration_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

open Token
open Parser_common
open Parser_env
open Ast
open Flow_ast
module Error = Parse_error
module SSet = Set.Make(String)

Expand Down
1 change: 1 addition & 0 deletions src/parser/estree_translator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

module type Config = sig
val include_locs: bool
Expand Down
4 changes: 3 additions & 1 deletion src/parser/expression_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

open Token
open Parser_env
open Ast
open Flow_ast
module Error = Parse_error
open Parser_common

Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion src/parser/jsx_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

open Token
open Parser_env
open Ast
open Flow_ast
module Error = Parse_error

module JSX (Parse: Parser_common.PARSER) = struct
Expand Down
2 changes: 1 addition & 1 deletion src/parser/lex_result.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type t = {
lex_token: Token.t;
lex_loc: Loc.t;
lex_errors: (Loc.t * Parse_error.t) list;
lex_comments: Loc.t Ast.Comment.t list;
lex_comments: Loc.t Flow_ast.Comment.t list;
}

let token result = result.lex_token
Expand Down
6 changes: 3 additions & 3 deletions src/parser/lexer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ let mk_comment
(start: Loc.position) (_end: Loc.position)
(buf: Buffer.t)
(multiline: bool)
: Loc.t Ast.Comment.t =
let open Ast.Comment in
: Loc.t Flow_ast.Comment.t =
let open Flow_ast.Comment in
let loc = { Loc.source = Lex_env.source env; start; _end } in
let s = Buffer.contents buf in
let c = if multiline then Block s else Line s in
Expand Down Expand Up @@ -383,7 +383,7 @@ type jsx_text_mode =

type result =
| Token of Lex_env.t * Token.t
| Comment of Lex_env.t * Loc.t Ast.Comment.t
| Comment of Lex_env.t * Loc.t Flow_ast.Comment.t
| Continue of Lex_env.t

let rec comment env buf lexbuf =
Expand Down
4 changes: 3 additions & 1 deletion src/parser/object_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

open Token
open Parser_env
open Ast
open Flow_ast
module Error = Parse_error
module SSet = Set.Make(String)

Expand Down
6 changes: 3 additions & 3 deletions src/parser/parser_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*)

open Parser_env
open Ast
open Flow_ast
module Error = Parse_error

type pattern_errors = {
Expand Down Expand Up @@ -131,9 +131,9 @@ let identifier_name env =
* https://tc39.github.io/ecma262/#sec-islabelledfunction
*)
let rec is_labelled_function = function
| _, Ast.Statement.Labeled { Ast.Statement.Labeled.body; _ } ->
| _, Flow_ast.Statement.Labeled { Flow_ast.Statement.Labeled.body; _ } ->
begin match body with
| _, Ast.Statement.FunctionDeclaration _ -> true
| _, Flow_ast.Statement.FunctionDeclaration _ -> true
| _ -> is_labelled_function body
end
| _ ->
Expand Down
4 changes: 2 additions & 2 deletions src/parser/parser_env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*)

open Ast
open Flow_ast
module Error = Parse_error
module SSet = Set.Make(String)

Expand Down Expand Up @@ -813,7 +813,7 @@ module Try = struct

type saved_state = {
saved_errors : (Loc.t * Error.t) list;
saved_comments : Loc.t Ast.Comment.t list;
saved_comments : Loc.t Flow_ast.Comment.t list;
saved_last_lex_result : Lex_result.t option;
saved_lex_mode_stack : Lex_mode.t list;
saved_lex_env : Lex_env.t;
Expand Down
6 changes: 3 additions & 3 deletions src/parser/parser_env.mli
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ val last_loc : env -> Loc.t option
val last_token : env -> Token.t option
val in_export : env -> bool
val labels : env -> SSet.t
val comments : env -> Loc.t Ast.Comment.t list
val comments : env -> Loc.t Flow_ast.Comment.t list
val in_loop : env -> bool
val in_switch : env -> bool
val in_formal_parameters : env -> bool
Expand Down Expand Up @@ -130,7 +130,7 @@ module Peek : sig
val token : env -> Token.t
val loc : env -> Loc.t
val errors : env -> (Loc.t * Parse_error.t) list
val comments : env -> Loc.t Ast.Comment.t list
val comments : env -> Loc.t Flow_ast.Comment.t list
val is_line_terminator : env -> bool
val is_implicit_semicolon : env -> bool
val is_identifier : env -> bool
Expand All @@ -142,7 +142,7 @@ module Peek : sig
val ith_token : i:int -> env -> Token.t
val ith_loc : i:int -> env -> Loc.t
val ith_errors : i:int -> env -> (Loc.t * Parse_error.t) list
val ith_comments : i:int -> env -> Loc.t Ast.Comment.t list
val ith_comments : i:int -> env -> Loc.t Flow_ast.Comment.t list
val ith_is_identifier : i:int -> env -> bool
val ith_is_identifier_name : i:int -> env -> bool
val ith_is_type_identifier : i:int -> env -> bool
Expand Down
2 changes: 2 additions & 0 deletions src/parser/parser_flow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

open Token
open Parser_env
module Error = Parse_error
Expand Down
4 changes: 2 additions & 2 deletions src/parser/pattern_cover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*)

open Ast
open Flow_ast
open Parser_common
open Parser_env

Expand Down Expand Up @@ -38,7 +38,7 @@ module Cover
then error_at env (fst expr, err);

(match expr with
| loc, Ast.Expression.Identifier (_, name)
| loc, Flow_ast.Expression.Identifier (_, name)
when is_restricted name ->
strict_error_at env (loc, Error.StrictLHSAssignment)
| _ -> ());
Expand Down
4 changes: 3 additions & 1 deletion src/parser/pattern_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

open Token
open Parser_common
open Parser_env
open Ast
open Flow_ast

module Pattern
(Parse: Parser_common.PARSER)
Expand Down
4 changes: 3 additions & 1 deletion src/parser/statement_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

open Token
open Parser_env
open Ast
open Flow_ast
module Error = Parse_error
module SSet = Set.Make(String)

Expand Down
2 changes: 2 additions & 0 deletions src/parser/test/run_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

module String_utils = struct
let spf = Printf.sprintf

Expand Down
4 changes: 3 additions & 1 deletion src/parser/type_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* LICENSE file in the root directory of this source tree.
*)

module Ast = Flow_ast

open Token
open Parser_env
open Ast
open Flow_ast
open Parser_common
module Error = Parse_error

Expand Down
Loading

0 comments on commit cdc62a9

Please sign in to comment.