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.text.tests/src/org/eclipse/jdt/text/tests/JavaHeuristicScannerTest.java
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.text.tests;
import java.util.Hashtable;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
import org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner;
import org.eclipse.jdt.internal.ui.text.JavaIndenter;
/**
 * SmartSemicolonAutoEditStrategyTest
 * @since 3.0
 */
public class JavaHeuristicScannerTest extends TestCase {