How to stop Eclipse from moving comments to a line after annotations?

I set some annotations for the class and comments on the same line as the annotations, such as:

@SampleAnnotation // sample comment
@AnotherAnnotation // another comment
public class SampleClass { }

However, every time I format a file, my comment on one line ends up moving to the next line . Not only is this undesirable because it moves my comment, but even worse it puts the comment in a confusing place. The above sample becomes:

@SampleAnnotation
// sample comment
@AnotherAnnotation
// another comment
public class SampleClass { }

How to stop Eclipse from moving these comments after formatting? Or, how do I get Eclipse to move comments to the line above rather than the line below? Thanks.

+4
source share
1

Eclipse, . :

// @formatter:off
@SampleAnnotation // sample comment
@AnotherAnnotation // another comment
// @formatter:on
public class SampleClass { }

, Eclipse off/on:

  • WindowsPreferences.
  • JavaCode StyleFormatter.
  • Edit. Java -> Code Style -> Formatter -> Edit
  • , Off/On Tags.
  • , Enable Off/On tags . Off / On Tags → Enable Off / On tags
    • , Profile name.
  • OK. , OK , .
0

Source: https://habr.com/ru/post/1627332/


All Articles