Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

Quesiton if anyone is expert with "Eclipse"

Thread view: 
Atreju - 12 Dec 2007 23:26 GMT
I'd like to make a macro or binding so when I hit CTRL+ENTER it should
place a ; then go to new line

There is a section in the preferences that says:

Automatically insert at correct position
...and it has checkboxes for Semicolons and Braces.
However, I haven't discovered what these checkboxes accomplish because
when I finish a line and hit ENTER, it did NOT place a semicolon
there.

Explanations/suggestions would be welcome, thanks.
I want either that it should just put a semi-colon every time I hit
ENTER, or perhaps even better would be that it does that UNLESS I
press CTRL+ENTER in which case it skips it.

Any thoughts?
Owen Jacobson - 12 Dec 2007 23:45 GMT
> I'd like to make a macro or binding so when I hit CTRL+ENTER it should
> place a ; then go to new line
[quoted text clipped - 13 lines]
>
> Any thoughts?

'tis better to understand the distinction between lines and statements
yourself; there are far too many places where a semicolon at the end
of the line will be subtly (or not so subtly) incorrect.  Consider:

for (int i = 0; i < 10; ++i);
{;
 /* some code */;
};

which is, admittedly, a ludicrous extreme -- but it's not immediately
obvious why the /* some code */ part always runs exactly once unless
you're explicitly looking for this kind of bug.  This is not the only
example, either.

You're going to have to come to terms with Java as its own language at
some point.  It's not VB, it's not *like* VB, and trying to pretend
that it's VB will not end well.

-o
(Ctrl-enter isn't even any fewer keystrokes, either -- if you can
train yourself to hit ctrl on only the correct lines, then you can
train yourself to hit semicolon just as well.)
Atreju - 13 Dec 2007 16:24 GMT
--SNIP--

>'tis better to understand the distinction between lines and statements
>yourself; there are far too many places where a semicolon at the end
[quoted text clipped - 4 lines]
>  /* some code */;
>};

Yes, but in that example, first of all, the initial { as I've seen
would be at the end of the first line. Regardless of that, the IDE in
theory could be designed to have exceptions: in this example, don't
put a ; after a {, or a }, or a */ all of these are very obvious
decisions.

I presume you could come up with examples where there is not such an
obvious choice of appropriateness for a ;, but maybe not. I don't
know.

>which is, admittedly, a ludicrous extreme -- but it's not immediately
>obvious why the /* some code */ part always runs exactly once unless
[quoted text clipped - 4 lines]
>some point.  It's not VB, it's not *like* VB, and trying to pretend
>that it's VB will not end well.

I'm not trying to get it to be like VB - you misunderstand me. I'm
only aspiring to have an IDE be more intuitive than it is. The things
I like about VB are what they are, and I leave that out of the
discussion. What I DO compare is the capabilities of the IDE software
- which only has a lateral relationship with the language itself. I
have discovered that the Eclipse software has a not-too-shabby version
of 'intellisense' as it is called in Visual Studio. But there are lots
of things that it lacks. I'm not criticizing in an offensive way,
rather just proposing new features that would improve it (or trying to
find out if they already exist and I cannot find them).

I'm no great fan of Micro$oft products, I have a plethora of
complaints about the designs behind most of their products, OSes,
games, etc. However, there are a precious few things that are
extremely impressive to me, and I acknowledge and respect them. One is
DirectX, for its own reasons, another is the Visual Studio IDE. It is
powerful, intuitive, and allows for some vital advantages: faster and
easier development. There are no downsides to that.

Given your example, though, and also that I'll take it for granted
(I'm only deferring to seniority in experience here) that there ARE
times where it would not be appropriate to put a ; at the end of the
line, can you explain what those checkboxes in the options are for
then? It specifically has a section where it has the option to
'automatically put where appropriate' a ;, and {
What exactly do those optional features mean?

>-o
>(Ctrl-enter isn't even any fewer keystrokes, either -- if you can
>train yourself to hit ctrl on only the correct lines, then you can
>train yourself to hit semicolon just as well.)

ENTER is easier for me to hit on my keyboard ;) You're correct that I
must train myself to end a line with ; when appropriate, I agree, and
I'm doing so. However, there's nothing retrogressive about wanting an
IDE to do more for me :)

Thank for the reply, I appreciate your point of view and advice.

Dan
Lew - 13 Dec 2007 17:01 GMT
Owen Jacobson wrote:
>> 'tis better to understand the distinction between lines and statements
>> yourself; there are far too many places where a semicolon at the end
[quoted text clipped - 4 lines]
>>  /* some code */;
>> };

> Yes, but in that example, first of all, the initial { as I've seen
> would be at the end of the first line. Regardless of that, the IDE in

Only by convention, and many people prefer to put an opening brace on its own
line.  Besides, that has nothing to do with Owen's point.

> theory could be designed to have exceptions: in this example, don't
> put a ; after a {, or a }, or a */ all of these are very obvious
> decisions.

Obvious, but not illegal.  You can put semicolons there if you want.

And what's wrong with it after a "*/" comment closer?

> I presume you could come up with examples where there is not such an
> obvious choice of appropriateness for a ;, but maybe not. I don't
> know.

"Appropriateness" is for the human; the compiler has different criteria.

> Given your example, though, and also that I'll take it for granted
> (I'm only deferring to seniority in experience here) that there ARE
[quoted text clipped - 3 lines]
> 'automatically put where appropriate' a ;, and {
> What exactly do those optional features mean?

Personally I find putting an opening brace for a block on its own line to be
appropriate, and I configure the IDE accordingly.

The problem is that the IDE cannot be as smart as you are.  It will do things
the way you want *most* of the time, appropriately configured, but you will
never get it to replace your own effort.

>> (Ctrl-enter isn't even any fewer keystrokes, either -- if you can
>> train yourself to hit ctrl on only the correct lines, then you can
[quoted text clipped - 4 lines]
> I'm doing so. However, there's nothing retrogressive about wanting an
> IDE to do more for me :)

You also have to train yourself to type "public" where appropriate, "static"
where appropriate, "class" where appropriate, parentheses where appropriate,
dots where appropriate, "%" symbols where appropriate, ...

It's called "learning the language".

Signature

Lew

Mark Clements - 14 Dec 2007 18:56 GMT
> Owen Jacobson wrote:
>>> 'tis better to understand the distinction between lines and statements
[quoted text clipped - 15 lines]
>> put a ; after a {, or a }, or a */ all of these are very obvious
>> decisions.

You can use a plugin such as PMD to flag when you are breaking a
pre-defined (albeit customizable) set of best-practise rules.

Mark
Hendrik Maryns - 13 Dec 2007 10:43 GMT
Atreju schreef:
> I'd like to make a macro or binding so when I hit CTRL+ENTER it should
> place a ; then go to new line
[quoted text clipped - 13 lines]
>
> Any thoughts?

If you type ‘;’, it will (most often[*]) be inserted in the right place.
Then hitting enter gives you a new line.  2 keystrokes, just like
Ctrl+Enter.

H.

[*] sometimes, if you’re in String literals, it won’t
Signature

Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.