[ANN] StringEditorPlugin: v1.1
version 1.1
new: multi-segment string are supported (see illustration below)
fix: auto-resize problem on non MacOS X
known issue: there still are some auto-resize problems with some rare
combinations of "\n\t\n"
(source available at
http://www.intellij.org/twiki/bin/view/Main/StringEditorPlugin)
multi-segment support:
-
Attachment(s):
StringEditorPluginV1-1.png
Please sign in to leave a comment.
Hi Alain,
This version (1.1) works a bit more reliable on my system (#3136/Win2K).
The first release would often leave rendering artifacts.
Some quick comments for now:
1) I think the multi-expression editor would be much more useful when
implemented as a single textarea, instead of the current multi-field
solution. This would also enable Copy/Cut/Paste for multi-expression
string literals. (For example to paste a SQL query in some external
analyzer tool)
You could try to walk the PSI forwards and backwards and only include
elements of the pattern: "literal" + "literal" + "literal" + ...
Then, present all the collected lines in one single editor, potentially
having multiple lines of content.
2) I understand that including nonliteral expressions presents a
challenge. One idea is to invert the syntax:
String foo = "prefix" + i + "suffix";
would become (inside the editor area):
prefix " + i + " suffix
I agree that looks a bit strange, but with some highlighting syntax for
the nonliteral (" + i + ") part, I believe this will be a much more
natural editing mode, especially when editing multiple lines (see #1).
An extension of this idea is to customize the string editor and prevent
modification or deletion of the non-literal interleaved expression parts.
3) Editing multiline strings triggers reformat/indentation:
String query =
"select r.ot_id, r.oti_name, r.oti_open_path\n" +
"from tidx_recursive r\n" +
"where r.rpvc < ?";
Invoking the string editor, and closing it (Esc) without making a change
will cause the statement to be reformatted as a result:
String query =
"select r.ot_id, r.oti_name, r.oti_open_path\n" +
"from tidx_recursive r\n" +
"where r.rpvc < ?";
4) Positioning of the editor window could be smarter. If the default
position (beneath and to the right of expression) would cause the editor
window to be (partially) off-screen, try a location above the expression
etc.
5) Unrelated, but a nice formatting intention would be to reformat this:
String s = "line 1\nline 2\nline 3\n";
to:
String s = "line 1\n" +
"line 2\n" +
"line 3\n";
A bit like the inverse of "Join Concatenated String Literals".
Regards,
-tt
Alain Ravet wrote:
Taras
planned.
Only a bit? What problems are you still experiencing (except for the
mentioned "\n\t\n" ones)?
That's another design direction, that I don't want to follow: the
current implementation (separate fields, for separate literal expressions),
- is good enough (for me, at least)
- is simple, and clean (to code, and to use),
- allows for quick navigation, and smart caret positioning.
- doesn't let the user enter any invalid text
There are constraints/limitations I guess, but none that bothers me.
I wrote it to make my life easier in cases exactly like :
http://www.intellij.org/twiki/pub/Main/StringEditorPlugin/StringEditorPluginV1-1.png
If it hurts you too much, the code is available, and readable.
See:
http://www.intellij.org/twiki/bin/view/Main/StringEditorPlugin
You're lazy
Press .
:)
Alain
Any chance of a version for Idea 4.5.x?
Alain Ravet wrote:
Glen
I just changed the "since-build" value to 2234, for a quick test on my
Mac, but IDEA v4.5 doesn't seem to cohabitate very well with the current
EAP installation. Could you test the attached jar on you machine?
Alain
Attachment(s):
stringEditorPluginV1-1-v45.jar
Hello Alain,
Do you planed implement String search? I mean for searching in String constants
and string values.
For example, if i fix some bug in application, but i not know this application
- it just support with bug fixing, i can navigate and exam code by source
only with strings search: i look on visual problem, find some 'string' and
try to find this string in project usage. I may find it by "Find in Path"
but it will not work with splited strings: "my" + " title".
So, will be nice to have ability to find splited strings and StringBuffer
usages.
Thanks!
--
Alexey Efimov, Java Developer
Tops BI
http://www.topsbi.ru
Alexey
If you mean "String constants expansion", yes, it's planned:
static String s = "test" ;
...
String a = "un" + s + "deux"; =>]]> by default, the StringEditor looks like
un
s
deux
stringExpansion (planned)
1xclick on 's'
=>
un
test
deux
2xclick on 's'
=> all the vars are expanded
If it's not what you meant, could you provide another example?
Alain
Hello Alain,
I mean about search engine. Not a editor enchancement. So, for example, somethere
in project i have:
String s =
"my " +
"string";
In "blank box" case of searching this string, i search for "my string" string.
Becouse, i can see this string in UI by visual look and i don't know how
this string presented in source code.
As i guess, you use PSI for detect strings literals. So, you can use the
same 'string detection' in implementation search that about i talk.
Then i try find "my string" string literal, by using your detect engine,
i found:
"my " + "string" and "my string". Now i can found only "my string".
Thanks!
--
Alexey Efimov, Java Developer
Tops BI
http://www.topsbi.ru
Alexey Efimov wrote:
> I mean about search engine...
> Then i try find "my string" string literal, by using your detect
engine, i found:
> "my " + "string" and "my string". Now i can found only "my string".
My little plugin is just an editor, an input facilitator,
and your request rather looks like a request for StructuralSearch
improvement, don't you think?
Alain
Hello Alain,
AR> My little plugin is just an editor, an input facilitator,
AR> and your request rather looks like a request for StructuralSearch
AR> improvement, don't you think?
Hmm, i think that this request for separate plugin :))
Thank you in any case :)
--
Alexey Efimov, Java Developer
Tops BI
http://www.topsbi.ru
Alain Ravet wrote:
>> Any chance of a version for Idea 4.5.x?
Just tried it but it seems not to load. I checked idea.log but couldn't
see any error messages.
Actually probing a bit further I noticed you packed it wrong so I
repacked but then got this error:
2005-01-13 17:43:48,593 ERROR -
lication.impl.LaterInvocatorEx -
java.lang.NoSuchFieldError: STRING_LITERAL
at
com.ravet.ideaplugins.stringEditor.util.U$Psi_.isStringLiteralToken(U.java:48)
at
com.ravet.ideaplugins.stringEditor.StringEditorAction.isAvailable(StringEditorAction.java:26)
at com.intellij.codeInsight.f.a.m.d(m.java:116)
at com.intellij.codeInsight.f.a.m.c(m.java:51)
at com.intellij.codeInsight.f.a.e$3.run(e$3.java:2)
at com.intellij.openapi.o.b.d$b_.run(d$b_.java:2)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at com.intellij.ide.t.b(t.java:46)
at com.intellij.ide.t.a(t.java:13)
at com.intellij.ide.t.dispatchEvent(t.java:57)
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)
-- Glen
Glen Stampoultzis wrote:
>> Glen
>>
>>> Any chance of a version for Idea 4.5.x?
>>
>>
>>
>>
>>
>> I just changed the "since-build" value to 2234, for a quick test on my
>> Mac, but IDEA v4.5 doesn't seem to cohabitate very well with the
>> current EAP installation. Could you test the attached jar on you machine?
>>
>> Alain
>>
>>
Glen,
This one should work fine. Could you test it (use it), before I send it to the repository?
TIA
Alain
Attachment(s):
stringEditorPlugin_4-5.jar
Alain Ravet wrote:
>This one ...
>
The attachment doesn't show up in the newsgroup.
You can find it here:
http://www.intellij.net/forums/thread.jsp?forum=18&thread=121329&tstart=0&trange=100#3439042
Alain
Alain Ravet wrote:
>
>
Could a 4.5 user test this version?
If it works fine, as I think it should, I'll publish it in the
repository, next to the Irida version.
TIA
Alain
Hello Alain,
>> The attachment doesn't show up in the newsgroup.
>> You can find it here:
>> http://www.intellij.net/forums/thread.jsp?forum=18&thread=121329&tsta
>> rt=0&trange=100#3439042
>>
Works find for me on version 2250.
Another feature request though: could you make the popup, and the contained
text fields resizable?
Regards,
-tt
Working for me. Thanks very much. I really like it. (Sorry to be a bit slow in getting back to you).
Alain Ravet wrote:
>
>
The version for 4.5 has just been uploaded to the plugin repository. Its
version number is 1.1b (1.1 = Irida version).
Alain