View | Details | Raw Unified | Return to bug 98037 | Differences between
and this patch

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java (+2 lines)
Lines 311-316 Link Here
311
						if (currentField.declarationSourceStart == ((FieldDeclaration) previousMergedNode).declarationSourceStart) {
311
						if (currentField.declarationSourceStart == ((FieldDeclaration) previousMergedNode).declarationSourceStart) {
312
							// we create a multi field declaration
312
							// we create a multi field declaration
313
							mergedNodes.set(mergedNodes.size() - 1, new MultiFieldDeclaration(new FieldDeclaration[]{ (FieldDeclaration)previousMergedNode, currentField}));
313
							mergedNodes.set(mergedNodes.size() - 1, new MultiFieldDeclaration(new FieldDeclaration[]{ (FieldDeclaration)previousMergedNode, currentField}));
314
						} else {
315
							mergedNodes.add(currentNode);
314
						}
316
						}
315
					} else {
317
					} else {
316
						mergedNodes.add(currentNode);
318
						mergedNodes.add(currentNode);
(-)formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java (-5 / +9 lines)
Lines 333-353 Link Here
333
		}
333
		}
334
		ProbingScanner.setSource((char[]) null);
334
		ProbingScanner.setSource((char[]) null);
335
335
336
		// probe for expression
336
		Expression expression = this.codeSnippetParsingUtil.parseExpression(source.toCharArray(), getDefaultCompilerOptions(), true);
337
		Expression expression = this.codeSnippetParsingUtil.parseExpression(source.toCharArray(), getDefaultCompilerOptions(), true);
337
		if (expression != null) {
338
		if (expression != null) {
338
			return internalFormatExpression(source, indentationLevel, lineSeparator, expression, offset, length);
339
			return internalFormatExpression(source, indentationLevel, lineSeparator, expression, offset, length);
339
		}
340
		}
340
341
341
		ASTNode[] bodyDeclarations = this.codeSnippetParsingUtil.parseClassBodyDeclarations(source.toCharArray(), getDefaultCompilerOptions(), true);
342
		// probe for statements
342
		if (bodyDeclarations != null) {
343
			return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, offset, length);
344
		}
345
346
		ConstructorDeclaration constructorDeclaration = this.codeSnippetParsingUtil.parseStatements(source.toCharArray(), getDefaultCompilerOptions(), true);
343
		ConstructorDeclaration constructorDeclaration = this.codeSnippetParsingUtil.parseStatements(source.toCharArray(), getDefaultCompilerOptions(), true);
347
		if (constructorDeclaration.statements != null) {
344
		if (constructorDeclaration.statements != null) {
348
			return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, offset, length);
345
			return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, offset, length);
349
		}
346
		}
350
347
348
		// probe for body declarations (fields, methods, constructors)
349
		ASTNode[] bodyDeclarations = this.codeSnippetParsingUtil.parseClassBodyDeclarations(source.toCharArray(), getDefaultCompilerOptions(), true);
350
		if (bodyDeclarations != null) {
351
			return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, offset, length);
352
		}
353
354
		// this has to be a compilation unit
351
		return formatCompilationUnit(source, indentationLevel, lineSeparator, offset, length);
355
		return formatCompilationUnit(source, indentationLevel, lineSeparator, offset, length);
352
	}
356
	}
353
}
357
}

Return to bug 98037