Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » code sorting [Java](support for code sorting (by @category or 'sections'/'regions') in Java)
code sorting [Java] [message #1771903] Thu, 31 August 2017 20:49 Go to next message
N247S - is currently offline N247S -Friend
Messages: 1
Registered: August 2017
Junior Member
Recently I was diving into the posibilities to sort / acces medium to large sized Java files, which made me wonder about a few things.

The main thing(s) I am looking for is/are:

  • Grouping of code (by either physical groups, or labels)
  • (optional)Hiding/folding/(hyper)linking of specified code groups
  • (optional)Sorting of code (by their group id/type, mainly at automatic import/override, or at formatting)

I realize not all of the above is achievable, but I hope I missed something which enables the above features in an easy (and hopefully clean) way.


My research:

1. Regions/sections

This has been (and may still be) a big topic/issue with eclipse. for most IDE's there is support for 'custom code regions'
(One bugzilla report I found dating back to 2004). Unfortunatly this kind of mechanism is still not implemented, besides there also doesn't seem to be any plugins anymore which provides this (coffee-bytes has been gone for quit a while now).

The last comment on the bugzilla report I mentioned is from 2011, so I was curious if there is any intention (by the eclipse/jdt developers, or by any plugin developers) to provide this mechanism for any of the newer (and future) versions of eclipse?


2. @Category

Now I know about the @Category documentation tag in eclipse. It enables grouping in some way, though its quit timeconsuming (e.g. adding documentation & tags to every single element), and besides its not really desinged to be used as such. It doesn't enable hiding/folding or sorting. Also its rather anoying that overriden methods don't inherit their parent category labels, which makes sence if its used as implementation specific labels, and not as method specific labels (which is what I am looking for).


3. Dirty workarounds

A commonly used 'dirty-workaround' is the use of a dummy method. when placed at the right place it can function as region/section header, separator and as region/section anchor. The down side (besides being 'dirty') is that it doesn't allow hiding/folding, although its IDE independent (which is usually not the case with other IDE code regions/sections support).



If anyone has any suggestions, or idea's I would love to hear them.
Thanks for your time!
Re: code sorting [Java] [message #1772328 is a reply to message #1771903] Fri, 08 September 2017 06:37 Go to previous message
Eclipse UserFriend
Sorting Array List :

import java.util.Scanner;

class Sorting {
public static void main(String []args) {
int n, c, d, swap;
Scanner in = new Scanner(System.in);

System.out.println("Input number of integers to sort");
n = in.nextInt();

int array[] = new int[n];

System.out.println("Enter " + n + " integers");

for (c = 0; c < n; c++)
array[c] = in.nextInt();

for (c = 0; c < ( n - 1 ); c++) {
for (d = 0; d < n - c - 1; d++) {
if (array[d] > array[d+1]) /* For descending order use < */
{
swap = array[d];
array[d] = array[d+1];
array[d+1] = swap;
}
}
}

System.out.println("Sorted list of numbers");

for (c = 0; c < n; c++)
System.out.println(array[c]);
}
}
Previous Topic:Hibernate - Eclipse Null pointer exception
Next Topic:Java Problem: No enclosing instance of type CompositeFileTree is available due to some intermediate
Goto Forum:
  


Current Time: Tue Dec 12 18:10:48 GMT 2017

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

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