Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Huge auto-indent after opening bracket + line feed
Huge auto-indent after opening bracket + line feed [message #219976] Fri, 02 December 2005 06:08 Go to next message
Eclipse UserFriend
Originally posted by: Alexander.Kriegisch.web.de

My coding style is such that I want to use indentation in multi-line
expressions surrounded by round or square brackets. The indentation
mechanism should work in a way analogous to curly brace indentation.
Currently, whenever I press [Return] after an opening bracket, the
following line is indented by multiple tab levels, not just one as
expected.

1. For example, I want my code to look like this (I am replacing each tab
by four dots because I assume the web interface for this newsgroup will
kill my leading spaces):

void foo()
{
....if
....(
........currentSquare.getY() == 7 ||
........board.isBlocked
........(
............newX = currentSquare.getX(),
............newY = currentSquare.getY() + 1
............)
....)
........return false;
}

2. What it does look like when manually pressing [Return] after each line,
though, is this:

void foo()
{
....if
....(
....................currentSquare.getY() == 7 ||
....................board.isBlocked
....................(
........................newX = currentSquare.getX(),
........................newY = currentSquare.getY() + 1)
........................)
........return false;
}

3. When applying auto-format (Ctrl-Shift-F), it looks still different:

void foo()
{
....if (currentSquare.getY() == 7
........|| board.isBlocked(
............newX = currentSquare.getX(), newY = currentSquare.getY() + 1))
........return false;
}

4. When applying auto-indent (Ctrl-I), there is yet another variant:

void foo()
{
....if (currentSquare.getY() == 7
....................|| board.isBlocked(
........................newX = currentSquare.getX(), newY =
currentSquare.getY() + 1))
........return false;
}


First of all, I don't understannd why #3 and #4 are different at all. I
assume auto-indent should just be a subset of auto-format. The latter
modifies line-wrapping and subsequently applies auto-indent. At least this
is what I expected. Obviously my assumption is wrong for Eclipse 3.1.

Secondly, I would like to know if there is a way to achieve
auto-indentation like in #1 in the editor as well as in the formatter
preferences. Do I have to extend any Eclipse classes myself or is it
possible to do this via parametrisation?

Thanks in advance
Re: Huge auto-indent after opening bracket + line feed [message #219984 is a reply to message #219976] Fri, 02 December 2005 06:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Alexander.Kriegisch.web.de

Sorry, guys. Example #1 was meant to look like this:

void foo()
{
....if
....(
........currentSquare.getY() == 7 ||
........board.isBlocked
........(
............newX = currentSquare.getX(),
............newY = currentSquare.getY() + 1
........)
....)
........return false;
}


I.e. the closing bracket after the 'newY' line is now de-dented by one
level compared to my original message.
Re: Huge auto-indent after opening bracket + line feed [message #219992 is a reply to message #219976] Fri, 02 December 2005 16:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse3.rizzoweb.com

Alexander Kriegisch wrote:
> My coding style is such that I want to use indentation in multi-line
> expressions surrounded by round or square brackets. The indentation
> mechanism should work in a way analogous to curly brace indentation.
> Currently, whenever I press [Return] after an opening bracket, the
> following line is indented by multiple tab levels, not just one as
> expected.
>
> 1. For example, I want my code to look like this (I am replacing each
> tab by four dots because I assume the web interface for this newsgroup
> will kill my leading spaces):
>
> void foo()
> {
> ...if
> ...(
> .......currentSquare.getY() == 7 ||
> .......board.isBlocked
> .......(
> ...........newX = currentSquare.getX(),
> ...........newY = currentSquare.getY() + 1
> ...........)
> ...)
> .......return false;
> }

I think the very unusual convention of putting the open parenthesis on a
separate line is confusing the smart-indent engine.
You might try to define your own code template for if statements. See
Preferences | Java | Editor | Templates

Then you can invoke your template via Content Assist (Ctrl+Space)

HTH,
Eric
Re: Huge auto-indent after opening bracket + line feed [message #220080 is a reply to message #219976] Tue, 06 December 2005 06:07 Go to previous message
Eclipse UserFriend
Originally posted by: daniel.megert.eclipse.org

Alexander Kriegisch wrote:

> My coding style is such that I want to use indentation in multi-line
> expressions surrounded by round or square brackets. The indentation
> mechanism should work in a way analogous to curly brace indentation.
> Currently, whenever I press [Return] after an opening bracket, the
> following line is indented by multiple tab levels, not just one as
> expected.

I suggest you file a bug report with steps to reproduce.

Dani

>
> 1. For example, I want my code to look like this (I am replacing each
> tab by four dots because I assume the web interface for this newsgroup
> will kill my leading spaces):
>
> void foo()
> {
> ...if
> ...(
> .......currentSquare.getY() == 7 ||
> .......board.isBlocked
> .......(
> ...........newX = currentSquare.getX(),
> ...........newY = currentSquare.getY() + 1
> ...........)
> ...)
> .......return false;
> }
>
> 2. What it does look like when manually pressing [Return] after each
> line, though, is this:
>
> void foo()
> {
> ...if
> ...(
> ...................currentSquare.getY() == 7 ||
> ...................board.isBlocked
> ...................(
> .......................newX = currentSquare.getX(),
> .......................newY = currentSquare.getY() + 1)
> .......................)
> .......return false;
> }
>
> 3. When applying auto-format (Ctrl-Shift-F), it looks still different:
>
> void foo()
> {
> ...if (currentSquare.getY() == 7
> .......|| board.isBlocked(
> ...........newX = currentSquare.getX(), newY = currentSquare.getY() + 1))
> .......return false;
> }
>
> 4. When applying auto-indent (Ctrl-I), there is yet another variant:
>
> void foo()
> {
> ...if (currentSquare.getY() == 7
> ...................|| board.isBlocked(
> .......................newX = currentSquare.getX(), newY =
> currentSquare.getY() + 1))
> .......return false;
> }
>
>
> First of all, I don't understannd why #3 and #4 are different at all.
> I assume auto-indent should just be a subset of auto-format. The
> latter modifies line-wrapping and subsequently applies auto-indent. At
> least this is what I expected. Obviously my assumption is wrong for
> Eclipse 3.1.
>
> Secondly, I would like to know if there is a way to achieve
> auto-indentation like in #1 in the editor as well as in the formatter
> preferences. Do I have to extend any Eclipse classes myself or is it
> possible to do this via parametrisation?
>
> Thanks in advance
>
Previous Topic:Project ClassLoader
Next Topic:doesn't find the extension point for "ParameterGuessingProposal"
Goto Forum:
  


Current Time: Sat Nov 08 05:07:07 EST 2025

Powered by FUDForum. Page generated in 0.04591 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top