struct search bug 2226

search:
String $name$ = "$string$";

replacement:
VSegAttribute $name$ = new VSegAttribute("$string$");

occurance in java source:
String ID_SPEED = "Speed";

IDEA#2226 result:
VSegAttribute ID_SPEED = new VSegAttribute(""

correct result would be
new VSegAttribute("Speed");

-> or is there some switch I got wrong ?! I used all
defaults.

5 comments
Comment actions Permalink

Hi,

Thank you for the reporting of the bug, as workaround I suggest to place
quotes inside text constraints:
search:
String $name$ = $string$;
replacement
VSegAttribute $name$ = new VSegAttribute($string$);

Michael Damberger wrote:

search:
String $name$ = "$string$";

replacement:
VSegAttribute $name$ = new VSegAttribute("$string$");

occurance in java source:
String ID_SPEED = "Speed";

IDEA#2226 result:
VSegAttribute ID_SPEED = new VSegAttribute(""

correct result would be
new VSegAttribute("Speed");

-> or is there some switch I got wrong ?! I used all
defaults.



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Well it stays a big annoyance if you want to replace "$string$" with "Some prefix $string$".

I tried with $QUOT$$string$$QUOT$ and defined $QUOT$ as \", but the \ is marked in red. What kind of regexp engine is this. Normally I can escape a " with \. I also tried to define $string$ as [^\"], but again no escaping.

Is this bug in the tracker?

0
Comment actions Permalink

Hi,
- \" is correct and correct hilighting of regular expressions will be in
future.
- So you want replace constant or constant fragment with another string?

Robert F. Beeger wrote:

Well it stays a big annoyance if you want to replace "$string$" with "Some prefix $string$".

I tried with $QUOT$$string$$QUOT$ and defined $QUOT$ as \", but the \ is marked in red. What kind of regexp engine is this. Normally I can escape a " with \. I also tried to define $string$ as [^\"], but again no escaping.

Is this bug in the tracker?



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Yes I want to replace things like

with


I'm currently porting an old project that used JDK 1.3 and an old version of our framework to JDK 1.4 and a new version of our framework.

We are doing very much "design by contract" and have replaced our Contract subframework with the usage of assertions for JDK 1.4.
Strutural Replace would take away a ton of tedious work if it worked, but sadly it doesn't.

I tried
Search template :

Replacement template :


if neither $EXP$ nor $DESC$ are defined specifically, $DESC$ contains the quotes when inserted in the replacement template.
Defining $DESC$ as [^\"]* doesn't change anything.

If I change the search template to

;
and define $QUOT$ as \", pressing Find doesn't do anything. In the log I see the following error:
2004-08-10 19:34:36,343 ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(288,391),button=1,modifiers=Button1,clickCount=1] on dialog0
2004-08-10 19:34:36,343 ERROR - com.intellij.ide.IdeEventQueue - IntelliJ IDEA 4.5 Build #2233
2004-08-10 19:34:36,343 ERROR - com.intellij.ide.IdeEventQueue - JDK: 1.4.2_04
2004-08-10 19:34:36,343 ERROR - com.intellij.ide.IdeEventQueue - VM: Java HotSpot(TM) Client VM
2004-08-10 19:34:36,343 ERROR - com.intellij.ide.IdeEventQueue - Vendor: Sun Microsystems Inc.
2004-08-10 19:34:36,343 ERROR - com.intellij.ide.IdeEventQueue - OS: Windows XP
2004-08-10 19:34:36,343 ERROR - com.intellij.ide.IdeEventQueue - Last Action: EditorPaste
2004-08-10 19:34:36,343 ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(288,391),button=1,modifiers=Button1,clickCount=1] on dialog0
java.lang.ClassCastException
at com.intellij.structuralsearch.b.a.o$e_.visitReferenceExpression(o$e_.java:103)
at com.intellij.psi.f.e.g.a.bj.accept(bj.java:37)
at com.intellij.psi.f.e.g.d.acceptChildren(d.java:38)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:38)
at com.intellij.structuralsearch.b.a.o$e_.visitElement(o$e_.java:269)
at com.intellij.psi.JavaElementVisitor.visitExpressionList(JavaElementVisitor.java:141)
at com.intellij.psi.f.e.g.a.r.accept(r.java:34)
at com.intellij.psi.f.e.g.d.acceptChildren(d.java:38)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:38)
at com.intellij.structuralsearch.b.a.o$e_.visitElement(o$e_.java:269)
at com.intellij.psi.JavaElementVisitor.visitExpression(JavaElementVisitor.java:137)
at com.intellij.psi.JavaElementVisitor.visitMethodCallExpression(JavaElementVisitor.java:221)
at com.intellij.structuralsearch.b.a.o$e_.visitMethodCallExpression(o$e_.java:99)
at com.intellij.psi.f.e.g.a.bc.accept(bc.java:12)
at com.intellij.psi.f.e.g.d.acceptChildren(d.java:38)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:38)
at com.intellij.structuralsearch.b.a.o$e_.visitElement(o$e_.java:269)
at com.intellij.psi.JavaElementVisitor.visitStatement(JavaElementVisitor.java:295)
at com.intellij.psi.JavaElementVisitor.visitExpressionStatement(JavaElementVisitor.java:149)
at com.intellij.structuralsearch.b.a.o$e_.visitExpressionStatement(o$e_.java:284)
at com.intellij.psi.f.e.g.a.t.accept(t.java:15)
at com.intellij.structuralsearch.b.a.o$e_.visitCodeBlock(o$e_.java:27)
at com.intellij.psi.f.e.g.a.bv.accept(bv.java:1)
at com.intellij.structuralsearch.b.a.o$e_.a(o$e_.java:158)
at com.intellij.structuralsearch.b.a.o.a(o.java:172)
at com.intellij.structuralsearch.b.a.k.a(k.java:73)
at com.intellij.structuralsearch.a.c.c.doOKAction(c.java:4)
at com.intellij.structuralsearch.a.b.b.doOKAction(b.java:96)
at com.intellij.openapi.ui.DialogWrapper$OkAction.actionPerformed(DialogWrapper.java:806)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:232)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at com.intellij.ide.t.b(t.java:158)
at com.intellij.ide.t.a(t.java:100)
at com.intellij.ide.t.dispatchEvent(t.java:103)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)
at java.awt.Dialog$1.run(Dialog.java:540)
at java.awt.Dialog.show(Dialog.java:561)
at com.intellij.openapi.e.b.a$d_.show(a$d_.java:27)
at com.intellij.openapi.e.b.a.show(a.java:37)
at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:711)
at com.intellij.structuralsearch.a.c.c.show(c.java:185)
at com.intellij.structuralsearch.a.b.b.show(b.java:25)
at com.intellij.structuralsearch.a.d.actionPerformed(d.java:13)
at com.intellij.openapi.a.a.m$b_.actionPerformed(m$b_.java:8)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at com.intellij.openapi.a.a.m.fireActionPerformed(m.java:44)
at com.intellij.ui.a.a.h.doClick(h.java:146)
at com.intellij.ui.a.a.h.access$300(h.java:165)
at com.intellij.ui.a.a.h$a_.mouseReleased(h$a_.java:5)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at com.intellij.ide.t.b(t.java:158)
at com.intellij.ide.t.a(t.java:100)
at com.intellij.ide.t.dispatchEvent(t.java:103)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

0
Comment actions Permalink

Hi,

This should work in 4.5.1 as described in your quoting below, please,
post if the problem persists.

Robert F. Beeger wrote:

Yes I want to replace things like


with



I'm currently porting an old project that used JDK 1.3 and an old version of our framework to JDK 1.4 and a new version of our framework.

We are doing very much "design by contract" and have replaced our Contract subframework with the usage of assertions for JDK 1.4.
Strutural Replace would take away a ton of tedious work if it worked, but sadly it doesn't.

I tried
Search template :

 ]]>

Replacement template :


>

--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Please sign in to leave a comment.