+ let minus_or_comment_nocpp = function
+ T2(_,Min adj,_) -> true
+ | x -> is_minusable_comment_nocpp x in
+
+ let common_adj (index1,adj1) (index2,adj2) =
+ adj1 = adj2 (* same adjacency info *) &&
+ (* non-empty intersection of witness trees *)
+ not ((Common.inter_set index1 index2) = []) in
+
+ let rec adjust_around_minus = function
+ [] -> []
+ | (T2(Parser_c.TCommentNewline c,_b,_i) as x)::
+ (((T2(_,Min adj,_))::_) as rest) ->
+ (* an initial newline, as in a replaced statement *)
+ let (between_minus,rest) = Common.span minus_or_comment rest in
+ (match rest with
+ [] -> (set_minus_comment adj x) ::
+ (List.map (set_minus_comment adj) between_minus)
+ | T2(_,Ctx,_)::_ when is_newline (List.hd(List.rev between_minus)) ->
+ (set_minus_comment adj x)::(adjust_within_minus between_minus) @
+ (adjust_around_minus rest)
+ | _ ->
+ x :: (adjust_within_minus between_minus) @
+ (adjust_around_minus rest))
+ | ((T2(_,Min adj,_))::_) as rest ->
+ (* no initial newline, as in a replaced expression *)
+ let (between_minus,rest) = Common.span minus_or_comment rest in
+ (match rest with
+ [] ->
+ (List.map (set_minus_comment adj) between_minus)
+ | _ ->
+ (adjust_within_minus between_minus) @
+ (adjust_around_minus rest))
+ | x::xs -> x::adjust_around_minus xs
+ and adjust_within_minus = function
+ [] -> []
+ | (T2(_,Min adj1,_) as t1)::xs ->
+ let (between_minus,rest) = Common.span is_minusable_comment xs in
+ (match rest with
+ [] ->
+ (* keep last newline *)
+ let (drop,keep) =
+ try
+ let (drop,nl,keep) =
+ Common.split_when is_newline between_minus in
+ (drop, nl :: keep)
+ with Not_found -> (between_minus,[]) in
+ t1 ::
+ List.map (set_minus_comment_or_plus adj1) drop @
+ keep
+ | (T2(_,Min adj2,_) as t2)::rest when common_adj adj1 adj2 ->
+ t1::
+ List.map (set_minus_comment_or_plus adj1) between_minus @
+ adjust_within_minus (t2::rest)
+ | x::xs ->
+ t1::(between_minus @ adjust_within_minus (x::xs)))
+ | _ -> failwith "only minus and space possible" in
+
+ (* new idea: collects regions not containing non-space context code
+ if two adjacent adjacent minus tokens satisfy common_adj then delete
+ all spaces, comments etc between them
+ if two adjacent minus tokens do not satisfy common_adj only delete
+ the spaces between them if there are no comments, etc.
+ if the region contain no plus code and is both preceded and followed
+ by a newline, delete the initial newline. *)
+
+ let rec adjust_around_minus = function