Index: formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java,v retrieving revision 1.158 diff -u -r1.158 CodeFormatterVisitor.java --- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 12 May 2005 02:43:01 -0000 1.158 +++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 2 Jun 2005 14:02:49 -0000 @@ -311,6 +311,8 @@ if (currentField.declarationSourceStart == ((FieldDeclaration) previousMergedNode).declarationSourceStart) { // we create a multi field declaration mergedNodes.set(mergedNodes.size() - 1, new MultiFieldDeclaration(new FieldDeclaration[]{ (FieldDeclaration)previousMergedNode, currentField})); + } else { + mergedNodes.add(currentNode); } } else { mergedNodes.add(currentNode); Index: formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java,v retrieving revision 1.48 diff -u -r1.48 DefaultCodeFormatter.java --- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java 28 Mar 2005 21:15:56 -0000 1.48 +++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java 2 Jun 2005 14:02:49 -0000 @@ -333,21 +333,25 @@ } ProbingScanner.setSource((char[]) null); + // probe for expression Expression expression = this.codeSnippetParsingUtil.parseExpression(source.toCharArray(), getDefaultCompilerOptions(), true); if (expression != null) { return internalFormatExpression(source, indentationLevel, lineSeparator, expression, offset, length); } - ASTNode[] bodyDeclarations = this.codeSnippetParsingUtil.parseClassBodyDeclarations(source.toCharArray(), getDefaultCompilerOptions(), true); - if (bodyDeclarations != null) { - return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, offset, length); - } - + // probe for statements ConstructorDeclaration constructorDeclaration = this.codeSnippetParsingUtil.parseStatements(source.toCharArray(), getDefaultCompilerOptions(), true); if (constructorDeclaration.statements != null) { return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, offset, length); } + // probe for body declarations (fields, methods, constructors) + ASTNode[] bodyDeclarations = this.codeSnippetParsingUtil.parseClassBodyDeclarations(source.toCharArray(), getDefaultCompilerOptions(), true); + if (bodyDeclarations != null) { + return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, offset, length); + } + + // this has to be a compilation unit return formatCompilationUnit(source, indentationLevel, lineSeparator, offset, length); } }