Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

changed minds / corrected some details of comment and pattern indenta…

…tion
  • Loading branch information...
commit b8e665f06f8412f66558fe826e66b724f9aa933f 1 parent 0e92fb0
@pszilagyi pszilagyi authored
View
30 tests/failing-output/js-args.ml
@@ -9,14 +9,40 @@ let should_check_can_sell_and_marking regulatory_regime =
| `foo
-> some_function
argument
+(* pszilagyi: The above typically occurs in a multi-pattern match clause, so the
+ clause expression is on a line by itself. This is the more typical way a
+ long single-pattern match clause would be written: *)
+let should_check_can_sell_and_marking regulatory_regime =
+ match z with
+ | `foo ->
+ some_function
+ argument
-(* CR pszilagyi: What would you say about this one: *)
-let f = fun x -> ghi
+let f = fun x ->
+ ghi
x
+(* uncommon *)
let x =
try x with a -> b
| c -> d
+let x =
+ try x
+ with a -> b
+ | c -> d
+(* common *)
+let x =
+ try x with
+ | a -> b
+ | c -> d
+let x = try x with
+| a -> b
+| c -> d
+let x =
+ try x
+ with
+ | a -> b
+ | c -> d
let z =
some_function
View
22 tests/passing/js-comment.ml.ref → tests/failing-output/js-comment.ml
@@ -53,13 +53,33 @@ type t= {
-(* Don't reindent inside comments, whether code or formatted text. *)
+(* Now that we have support for {v v} and {[ ]}, reindent inside comments,
+ unless they are explicitly delimited as code or pre-formatted text. These
+ three all end up flattened to the same level. *)
(*
type t = {
(* This is a comment *)
a: int;
}
*)
+(*
+ type t = {
+ (* This is a comment *)
+ a: int;
+ }
+*)
+(*
+ type t = {
+ (* This is a comment *)
+ a: int;
+ }
+*)
+
+
+
+(* Possible to-do warning: Star-prefixed lines are allowed and indented a little
+ less, to line up with the star in the opening comment parenthesis. Maybe we
+ don't care enough about them to worry about it, though. *)
View
0  tests/passing/js-pattern.ml → tests/failing-output/js-pattern.ml
File renamed without changes
View
30 tests/failing/js-args.ml
@@ -9,14 +9,40 @@ let should_check_can_sell_and_marking regulatory_regime =
| `foo
-> some_function
argument
+(* pszilagyi: The above typically occurs in a multi-pattern match clause, so the
+ clause expression is on a line by itself. This is the more typical way a
+ long single-pattern match clause would be written: *)
+let should_check_can_sell_and_marking regulatory_regime =
+ match z with
+ | `foo ->
+ some_function
+ argument
-(* CR pszilagyi: What would you say about this one: *)
-let f = fun x -> ghi
+let f = fun x ->
+ ghi
x
+(* uncommon *)
let x =
try x with a -> b
| c -> d
+let x =
+ try x
+ with a -> b
+ | c -> d
+(* common *)
+let x =
+ try x with
+ | a -> b
+ | c -> d
+let x = try x with
+ | a -> b
+ | c -> d
+let x =
+ try x
+ with
+ | a -> b
+ | c -> d
let z =
some_function
View
22 tests/passing/js-comment.ml → tests/failing/js-comment.ml
@@ -53,13 +53,33 @@ type t= {
-(* Don't reindent inside comments, whether code or formatted text. *)
+(* Now that we have support for {v v} and {[ ]}, reindent inside comments,
+ unless they are explicitly delimited as code or pre-formatted text. These
+ three all end up flattened to the same level. *)
(*
type t = {
(* This is a comment *)
a: int;
}
*)
+(*
+ type t = {
+ (* This is a comment *)
+ a: int;
+ }
+*)
+(*
+ type t = {
+ (* This is a comment *)
+ a: int;
+ }
+*)
+
+
+
+(* Possible to-do warning: Star-prefixed lines are allowed and indented a little
+ less, to line up with the star in the opening comment parenthesis. Maybe we
+ don't care enough about them to worry about it, though. *)
View
0  tests/passing/js-comment.ml.opts → tests/failing/js-comment.ml.opts
File renamed without changes
View
110 tests/failing/js-comment.ml.ref
@@ -0,0 +1,110 @@
+(* ocp-indent is not going to be confused by comment-embedded tokens. *)
+
+
+
+type t = {
+ (* This is a comment *)
+ a: int;
+}
+
+type t = {
+ (* This is a comment : with a colon. *)
+ a: int;
+}
+
+type t = {
+ a: int;
+ (* with the : second field *)
+ b: int;
+}
+
+type t = {
+ a: int;
+ b: int;
+ (* and : the third... *)
+ c: int;
+}
+
+
+
+(* colon in CR comment messes Tuareg up *)
+type cfg = {
+ foo : int; (* CR mburns: float? *)
+ bar : string;
+}
+
+(* To be more precise about the Tuareg bug, it is the fact that the colon in the comment
+ is the first or second colon after the start of the record definition. If the comment
+ occurs after the first 2 fields in the record everything is fine.
+
+ For example, this is OK: *)
+type t= {
+ foo : int;
+ bar : string; (* CR mburns: float? *)
+ baz : string;
+}
+
+(* but Tuareg messes this up *)
+type t= {
+ foo : int;
+ (* CR mburns: float? *)
+ bar : string;
+}
+
+
+
+(* Now that we have support for {v v} and {[ ]}, reindent inside comments,
+ unless they are explicitly delimited as code or pre-formatted text. These
+ three all end up flattened to the same level. *)
+(*
+ type t = {
+ (* This is a comment *)
+ a: int;
+ }
+*)
+(*
+ type t = {
+ (* This is a comment *)
+ a: int;
+ }
+*)
+(*
+ type t = {
+ (* This is a comment *)
+ a: int;
+ }
+*)
+
+
+
+(* Possible to-do warning: Star-prefixed lines are allowed and indented a little
+ less, to line up with the star in the opening comment parenthesis. Maybe we
+ don't care enough about them to worry about it, though. *)
+
+
+
+(** Doc comment text should be aligned with the first line, so indented more
+ than otherwise. *)
+
+(* We're now using some ocamldoc block syntax to control indentation, and sweeks
+ and the rest of us have been relying on it, in and out of doc comments.
+
+ {[
+ let code =
+ should be reindented like code
+ so as to work also with vim
+ ]}
+
+ {v g
+ This is totally verbatim text and shouldn't be reindented. Maybe you don't
+ need to special-case this, since you will not be reindenting comments. It
+ probably doesn't matter what the indentation of the first line of a
+verbatim block is. But how will this be done in vim?
+ xx
+ yy
+ zz
+ c v}
+
+ Does this even confront ocp-indent? I think, when reindenting whole files,
+ source code blocks do confront ocp-indent.
+*)
View
32 tests/failing/js-pattern.ml
@@ -0,0 +1,32 @@
+let f = function
+ | _ -> 0
+;;
+
+let f x = match x with
+ | _ -> 0
+;;
+
+let f =
+ function
+ | _ -> 0
+;;
+
+let f x =
+ match x with
+ | _ -> 0
+;;
+
+let f x =
+ begin match x with
+ | _ -> 0
+ end
+;;
+
+let check_price t = function
+ | { Exec.
+ trade_at_settlement = (None | Some false);
+ } -> ()
+
+let check_price t = function
+ | simpler -> ()
+ | other -> ()
View
0  tests/passing/js-pattern.ml.opts → tests/failing/js-pattern.ml.opts
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.