Coccinelle release 1.0.0-rc3
[bpt/coccinelle.git] / parsing_cocci / insert_plus.ml
index e19ab82..74854aa 100644 (file)
@@ -529,7 +529,7 @@ let collect_plus_nodes root =
 
   let toplevel r k e =
     match Ast0.unwrap e with
-      Ast0.DECL(s) -> r.VT0.combiner_rec_statement s
+      Ast0.NONDECL(s) -> r.VT0.combiner_rec_statement s
     | Ast0.CODE(sdots) -> r.VT0.combiner_rec_statement_dots sdots
     | _ -> do_nothing mk_code r k e in
 
@@ -781,14 +781,19 @@ let init thing info =
      Ast0.left_offset = info.Ast0.pos_info.Ast0.offset;
      Ast0.right_offset = info.Ast0.pos_info.Ast0.offset})
 
+let it2c = function Ast.ONE -> "one" | Ast.MANY -> "many"
+
 let attachbefore (infop,c,p) = function
     Ast0.MINUS(replacements) ->
       let (repl,ti) = !replacements in
-      let (bef,ti) =
-       match repl with
-         [] -> init p infop
-       | repl -> insert p infop repl ti in
-      replacements := (bef,ti)
+      (match repl with
+       Ast.NOREPLACEMENT ->
+         let (bef,ti) = init p infop in
+         replacements := (Ast.REPLACEMENT(bef,c),ti)
+      | Ast.REPLACEMENT(repl,it) ->
+         let it = Ast.lub_count it c in
+         let (bef,ti) = insert p infop repl ti in
+         replacements := (Ast.REPLACEMENT(bef,it),ti))
   | Ast0.CONTEXT(neighbors) ->
       let (repl,ti1,ti2) = !neighbors in
       (match repl with
@@ -812,11 +817,14 @@ let attachbefore (infop,c,p) = function
 let attachafter (infop,c,p) = function
     Ast0.MINUS(replacements) ->
        let (repl,ti) = !replacements in
-       let (aft,ti) =
-       match repl with
-         [] -> init p infop
-       | repl -> insert p infop repl ti in
-       replacements := (aft,ti)
+       (match repl with
+       Ast.NOREPLACEMENT ->
+         let (aft,ti) = init p infop in
+         replacements := (Ast.REPLACEMENT(aft,c),ti)
+      | Ast.REPLACEMENT(repl,it) ->
+         let it = Ast.lub_count it c in
+         let (aft,ti) = insert p infop repl ti in
+         replacements := (Ast.REPLACEMENT(aft,it),ti))
   | Ast0.CONTEXT(neighbors) ->
       let (repl,ti1,ti2) = !neighbors in
       (match repl with
@@ -963,11 +971,14 @@ let merge_one : (minus_join_point * Ast0.info * 'a) list *
   Printf.printf "minus code\n";
   List.iter
     (function (_,info,_) ->
-      Printf.printf "start %d end %d real_start %d real_end %d\n"
+      Printf.printf
+       "start %d end %d real_start %d real_end %d attachable start %b attachable end %b\n"
        info.Ast0.pos_info.Ast0.logical_start
        info.Ast0.pos_info.Ast0.logical_end
        info.Ast0.pos_info.Ast0.line_start
-       info.Ast0.pos_info.Ast0.line_end)
+       info.Ast0.pos_info.Ast0.line_end
+       info.Ast0.attachable_start
+       info.Ast0.attachable_end)
     m;
   Printf.printf "plus code\n";
   List.iter