Structural search context question

Hi,

I'm trying to do a structural search replace to change annotations. I have getters like

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    public Integer getId() {
        return this.id;
    }


which I want to replace with

    @Id
    @SequenceGenerator(name = "fooIdGenerator", sequenceName = "foo_id_seq")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fooIdGenerator")
    @Column(name = "id")
    public Integer getId() {
        return this.id;
    }


where foo is the class name.

I tried the following search template and replacement text, and set MethodName as the target of the search. But IDEA tells me that the replacement text is a well formed expression and the search template is not an expression.

search template:

class $CLASS$ {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    $ReturnType$ $MethodName$();
}



replacement text:


    @Id
    @SequenceGenerator(name = "$CLASS$IdGenerator", sequenceName = "$CLASS$_id_seq")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "$CLASS$IdGenerator")
    @Column(name = "id")
    $ReturnType$ $MethodName$();
}



Any help would be appreciated.

Regards,
Emerson
1 comment
Comment actions Permalink

Method replacement is not currently supported by SSR

On 11/11/2012 2:16 PM, mers wrote:

Hi,

>

I'm trying to do a structural search replace to change annotations. I have getters like

>

     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     @Column(name = "id")
     public Integer getId() {
         return this.id;
     }

>

which I want to replace with

>

     @Id
     @SequenceGenerator(name = "fooIdGenerator", sequenceName = "foo_id_seq")
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fooIdGenerator")
     @Column(name = "id")
     public Integer getId() {
         return this.id;
     }

>

where foo is the class name.

>

I tried the following search template and replacement text, and set MethodName as the target of the search. But IDEA tells me that the replacement text is a well formed expression and the search template is not an expression.

>

search template:

>

class $CLASS$ {

>

     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     @Column(name = "id")
     $ReturnType$ $MethodName$();
}

>

replacement text:

>

     @Id
     @SequenceGenerator(name = "$CLASS$IdGenerator", sequenceName = "$CLASS$_id_seq")
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "$CLASS$IdGenerator")
     @Column(name = "id")
     $ReturnType$ $MethodName$();
}

>

Any help would be appreciated.

>

Regards,
Emerson

>

---
Original message URL: http://devnet.jetbrains.net/message/5471480#5471480

>

0

Please sign in to leave a comment.