Bug 104796 [formatter] Indentation BREAKS if a inline class is built inside a switch-case statement
If I try to create a new class inline from an interface for examle (actionListener, Runnable, etc...) it normally works right and the indentation (highlighting everything and hitting CTRL-I) works just right like // Runnable with correct indentation new Runnable() { public void run() { // Do nothing } }; If instead I try to do this inside a switch case statement, after the methods, the }; closing the class gets WRONG indentation and all the indentation after this gets bugges like this: // Runnable with bugged indentation due to case new Runnable() { public void run() { // Do nothing } }; // bug here Minimal test case provided: public class IndentationSwitchCaseBug { public static void IBreakIndentation() { // Runnable with correct indentation new Runnable() { public void run() { // Do nothing } }; int i = 5; switch (i) { case 0: // Indentation works right here break; case 1: // Runnable with bugged indentation due to case new Runnable() { public void run() { // Do nothing } }; // You can see the indentation gets bugged when a runnable // is used inside a switch-case statemente break; } } }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java
*         type variable or type name, <code>false</code> if not
	 * @since 3.1
	 */
	private boolean isGenericStarter(CharSequence identifier) {
		/* This heuristic allows any identifiers if they start with an upper
		 * case. This will fail when a comparison is made with constants:
		 *
		 * if (MAX > foo)
		 *
		 * will try to find the matching '<' which will never come
		 *
		 * Also, it will fail on lower case types and type variables
		 */
		int length= identifier.length();
		if (length > 0 && Character.isUpperCase(identifier.charAt(0))) {
			for (int i= 0; i < length; i++) {
				if (identifier.charAt(i) == '_')
					return false;
			}
			return true;
		}
		return false;
	}
	/**
	 * Handles the introduction of a new scope. The current token must be one out
	 * of <code>Symbols.TokenLPAREN</code>, <code>Symbols.TokenLBRACE</code>,
	 * and <code>Symbols.TokenLBRACKET</code>. Returns as the reference position
	 * either the token introducing the scope or - if available - the first
	 * java token after that.
	 *