Quesiton if anyone is expert with "Eclipse"

A

Atreju

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?
 
O

Owen Jacobson

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?

'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.)
 
H

Hendrik Maryns

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

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?

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
--
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


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD4DBQFHYQzfe+7xMGD3itQRAiatAJ4/dd1Ydjt+V6BTW9kSLSQPABqi1ACY6Gsj
eGSkrHHKNtrLN3zw9wayLQ==
=sxoU
-----END PGP SIGNATURE-----
 
A

Atreju

On Wed, 12 Dec 2007 15:45:40 -0800 (PST), Owen Jacobson

--SNIP--
'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 */;
};

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
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.

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
 
L

Lew

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
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?

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.
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 :)

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".
 
M

Mark Clements

Lew said:
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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top