Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter')
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/AbortFormatting.java31
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/BinaryExpressionFragmentBuilder.java480
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/CascadingMethodInvocationFragmentBuilder.java57
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/CodeFormatterVisitor.java4781
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/DefaultCodeFormatter.java420
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/DefaultCodeFormatterOptions.java2483
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/Location.java58
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/OptimizedReplaceEdit.java28
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/Scribe.java1807
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/align/Alignment.java417
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/align/AlignmentException.java55
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentFormatterUtil.java119
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentLine.java315
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentRange.java262
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentRegion.java573
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/HTMLEntity2JavaReader.java112
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IBorderAttributes.java26
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/ICommentAttributes.java65
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IHtmlTagDelimiters.java29
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IJavaDocTagConstants.java111
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/Java2HTMLEntityReader.java56
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/JavaDocLine.java52
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/JavaDocRegion.java363
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/MultiCommentLine.java409
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/MultiCommentRegion.java245
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/SingleCommentLine.java115
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/SubstitutionTextReader.java181
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/options.properties75
28 files changed, 0 insertions, 13725 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/AbortFormatting.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/AbortFormatting.java
deleted file mode 100644
index c3915b59..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/AbortFormatting.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter;
-
-/**
- * Unchecked exception wrapping invalid input checked exception which may occur
- * when scanning original formatted source.
- *
- * @since 2.1
- */
-public class AbortFormatting extends RuntimeException {
-
- Throwable nestedException;
- private static final long serialVersionUID = -5796507276311428526L; // backward compatible
-
- public AbortFormatting(String message) {
- super(message);
- }
- public AbortFormatting(Throwable nestedException) {
- super(nestedException.getMessage());
- this.nestedException = nestedException;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/BinaryExpressionFragmentBuilder.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/BinaryExpressionFragmentBuilder.java
deleted file mode 100644
index 691b69c1..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/BinaryExpressionFragmentBuilder.java
+++ /dev/null
@@ -1,480 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.wst.jsdt.internal.formatter;
-
-import java.util.ArrayList;
-
-import org.eclipse.wst.jsdt.internal.compiler.ASTVisitor;
-import org.eclipse.wst.jsdt.internal.compiler.ast.AND_AND_Expression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ASTNode;
-import org.eclipse.wst.jsdt.internal.compiler.ast.AllocationExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayAllocationExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayInitializer;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayQualifiedTypeReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayTypeReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Assignment;
-import org.eclipse.wst.jsdt.internal.compiler.ast.BinaryExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ClassLiteralAccess;
-import org.eclipse.wst.jsdt.internal.compiler.ast.CombinedBinaryExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.CompoundAssignment;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ConditionalExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.DoubleLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.EqualExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Expression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ExtendedStringLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.FalseLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.FieldReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.FunctionExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.InstanceOfExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.IntLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ListExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend;
-import org.eclipse.wst.jsdt.internal.compiler.ast.NullLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.OR_OR_Expression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ObjectLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.OperatorIds;
-import org.eclipse.wst.jsdt.internal.compiler.ast.PostfixExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.PrefixExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedAllocationExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedNameReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedThisReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.RegExLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.SingleNameReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.StringLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.StringLiteralConcatenation;
-import org.eclipse.wst.jsdt.internal.compiler.ast.SuperReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ThisReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.TrueLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.UnaryExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.UndefinedLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.wst.jsdt.internal.compiler.parser.TerminalTokens;
-
-class BinaryExpressionFragmentBuilder
- extends ASTVisitor {
-
- ArrayList fragmentsList;
- ArrayList operatorsList;
- private int realFragmentsSize;
-
- BinaryExpressionFragmentBuilder() {
- this.fragmentsList = new ArrayList();
- this.operatorsList = new ArrayList();
- this.realFragmentsSize = 0;
- }
-
- private final void addRealFragment(ASTNode node) {
- this.fragmentsList.add(node);
- this.realFragmentsSize++;
- }
-
- private final void addSmallFragment(ASTNode node) {
- this.fragmentsList.add(node);
- }
-
- private boolean buildFragments(Expression expression) {
- if (((expression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) != 0) {
- addRealFragment(expression);
- return false;
- } else {
- return true;
- }
- }
-
- public ASTNode[] fragments() {
- ASTNode[] fragments = new ASTNode[this.fragmentsList.size()];
- this.fragmentsList.toArray(fragments);
- return fragments;
- }
-
- public int[] operators() {
- int length = operatorsList.size();
- int[] tab = new int[length];
- for (int i = 0; i < length; i++) {
- tab[i] = ((Integer)operatorsList.get(i)).intValue();
- }
- return tab;
- }
-
- public int realFragmentsSize() {
- return this.realFragmentsSize;
- }
-
- public boolean visit(
- AllocationExpression allocationExpression,
- BlockScope scope) {
- this.addRealFragment(allocationExpression);
- return false;
- }
-
- public boolean visit(
- AND_AND_Expression and_and_Expression,
- BlockScope scope) {
-
- if (((and_and_Expression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) != 0) {
- addRealFragment(and_and_Expression);
- } else {
- and_and_Expression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNameAND_AND));
- and_and_Expression.right.traverse(this, scope);
- }
- return false;
- }
-
- public boolean visit(
- ArrayAllocationExpression arrayAllocationExpression,
- BlockScope scope) {
- this.addRealFragment(arrayAllocationExpression);
- return false;
- }
-
- public boolean visit(ArrayInitializer arrayInitializer, BlockScope scope) {
- this.addRealFragment(arrayInitializer);
- return false;
- }
-
- public boolean visit(
- ArrayQualifiedTypeReference arrayQualifiedTypeReference,
- BlockScope scope) {
- this.addRealFragment(arrayQualifiedTypeReference);
- return false;
- }
-
- public boolean visit(
- ArrayQualifiedTypeReference arrayQualifiedTypeReference,
- ClassScope scope) {
- this.addRealFragment(arrayQualifiedTypeReference);
- return false;
- }
-
- public boolean visit(ArrayReference arrayReference, BlockScope scope) {
- this.addRealFragment(arrayReference);
- return false;
- }
-
- public boolean visit(
- ArrayTypeReference arrayTypeReference,
- BlockScope scope) {
- this.addRealFragment(arrayTypeReference);
- return false;
- }
-
- public boolean visit(
- ArrayTypeReference arrayTypeReference,
- ClassScope scope) {
- this.addRealFragment(arrayTypeReference);
- return false;
- }
-
- public boolean visit(Assignment assignment, BlockScope scope) {
- this.addRealFragment(assignment);
- return false;
- }
-
- public boolean visit(BinaryExpression binaryExpression, BlockScope scope) {
- if (binaryExpression instanceof CombinedBinaryExpression) {
- CombinedBinaryExpression expression = (CombinedBinaryExpression) binaryExpression;
- if (expression.referencesTable != null) {
- return this.visit(expression, scope);
- }
- }
- final int numberOfParens = (binaryExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- this.addRealFragment(binaryExpression);
- } else {
- switch((binaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT) {
- case OperatorIds.PLUS :
- if (buildFragments(binaryExpression)) {
- binaryExpression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNamePLUS));
- binaryExpression.right.traverse(this, scope);
- }
- return false;
- case OperatorIds.MINUS :
- if (buildFragments(binaryExpression)) {
- binaryExpression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNameMINUS));
- binaryExpression.right.traverse(this, scope);
- }
- return false;
- case OperatorIds.MULTIPLY :
- if (buildFragments(binaryExpression)) {
- binaryExpression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNameMULTIPLY));
- binaryExpression.right.traverse(this, scope);
- }
- return false;
- case OperatorIds.REMAINDER :
- if (buildFragments(binaryExpression)) {
- binaryExpression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNameREMAINDER));
- binaryExpression.right.traverse(this, scope);
- }
- return false;
- case OperatorIds.XOR :
- if (buildFragments(binaryExpression)) {
- binaryExpression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNameXOR));
- binaryExpression.right.traverse(this, scope);
- }
- return false;
- case OperatorIds.DIVIDE :
- if (buildFragments(binaryExpression)) {
- binaryExpression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNameDIVIDE));
- binaryExpression.right.traverse(this, scope);
- }
- return false;
- case OperatorIds.OR :
- if (buildFragments(binaryExpression)) {
- binaryExpression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNameOR));
- binaryExpression.right.traverse(this, scope);
- }
- return false;
- case OperatorIds.AND :
- if (buildFragments(binaryExpression)) {
- binaryExpression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNameAND));
- binaryExpression.right.traverse(this, scope);
- }
- return false;
- default:
- this.addRealFragment(binaryExpression);
- }
- }
- return false;
- }
-
- public boolean visit(CombinedBinaryExpression combinedBinaryExpression, BlockScope scope) {
- // keep implementation in sync with BinaryExpression#resolveType
- if (combinedBinaryExpression.referencesTable == null) {
- this.addRealFragment(combinedBinaryExpression.left);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNamePLUS));
- this.addRealFragment(combinedBinaryExpression.right);
- return false;
- }
- BinaryExpression cursor = combinedBinaryExpression.referencesTable[0];
- if (cursor.left instanceof CombinedBinaryExpression) {
- this.visit((CombinedBinaryExpression) cursor.left, scope);
- } else {
- this.addRealFragment(cursor.left);
- }
- for (int i = 0, end = combinedBinaryExpression.arity; i < end; i ++) {
- this.operatorsList.add(new Integer(TerminalTokens.TokenNamePLUS));
- this.addRealFragment(combinedBinaryExpression.referencesTable[i].right);
- }
- this.operatorsList.add(new Integer(TerminalTokens.TokenNamePLUS));
- this.addRealFragment(combinedBinaryExpression.right);
- return false;
- }
-
- public boolean visit(
- ClassLiteralAccess classLiteralAccess,
- BlockScope scope) {
- this.addRealFragment(classLiteralAccess);
- return false;
- }
-
- public boolean visit(
- CompoundAssignment compoundAssignment,
- BlockScope scope) {
- this.addRealFragment(compoundAssignment);
- return false;
- }
-
- public boolean visit(
- ConditionalExpression conditionalExpression,
- BlockScope scope) {
- this.addRealFragment(conditionalExpression);
- return false;
- }
-
- public boolean visit(DoubleLiteral doubleLiteral, BlockScope scope) {
- this.addSmallFragment(doubleLiteral);
- return false;
- }
-
- public boolean visit(EqualExpression equalExpression, BlockScope scope) {
- this.addRealFragment(equalExpression);
- return false;
- }
-
- public boolean visit(
- ExtendedStringLiteral extendedStringLiteral,
- BlockScope scope) {
- this.addRealFragment(extendedStringLiteral);
- return false;
- }
-
- public boolean visit(FalseLiteral falseLiteral, BlockScope scope) {
- this.addSmallFragment(falseLiteral);
- return false;
- }
-
- public boolean visit(FieldReference fieldReference, BlockScope scope) {
- this.addRealFragment(fieldReference);
- return false;
- }
-
-
- public boolean visit(ObjectLiteral literal, BlockScope scope) {
- this.addRealFragment(literal);
- return false;
- }
-
- public boolean visit(UndefinedLiteral undefined, BlockScope scope) {
- this.addSmallFragment(undefined);
- return false;
- }
-
- public boolean visit(FunctionExpression functionExpression, BlockScope scope) {
- this.addRealFragment(functionExpression);
- return false;
- }
-
- public boolean visit(
- InstanceOfExpression instanceOfExpression,
- BlockScope scope) {
- this.addRealFragment(instanceOfExpression);
- return false;
- }
-
- public boolean visit(IntLiteral intLiteral, BlockScope scope) {
- this.addSmallFragment(intLiteral);
- return false;
- }
-
- public boolean visit(
- ListExpression listExpression,
- BlockScope scope) {
- this.addRealFragment(listExpression);
- return false;
- }
-
- public boolean visit(MessageSend messageSend, BlockScope scope) {
- this.addRealFragment(messageSend);
- return false;
- }
-
- public boolean visit(StringLiteralConcatenation stringLiteral, BlockScope scope) {
- if (((stringLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) != 0) {
- addRealFragment(stringLiteral);
- return false;
- } else {
- for (int i = 0, max = stringLiteral.counter; i < max; i++) {
- this.addRealFragment(stringLiteral.literals[i]);
- if (i < max - 1) {
- this.operatorsList.add(new Integer(TerminalTokens.TokenNamePLUS));
- }
- }
- return false;
- }
- }
-
- public boolean visit(NullLiteral nullLiteral, BlockScope scope) {
- this.addRealFragment(nullLiteral);
- return false;
- }
-
- public boolean visit(OR_OR_Expression or_or_Expression, BlockScope scope) {
- if (((or_or_Expression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) != 0) {
- addRealFragment(or_or_Expression);
- } else {
- or_or_Expression.left.traverse(this, scope);
- this.operatorsList.add(new Integer(TerminalTokens.TokenNameOR_OR));
- or_or_Expression.right.traverse(this, scope);
- }
- return false;
- }
-
- public boolean visit(
- PostfixExpression postfixExpression,
- BlockScope scope) {
- this.addRealFragment(postfixExpression);
- return false;
- }
-
- public boolean visit(PrefixExpression prefixExpression, BlockScope scope) {
- this.addRealFragment(prefixExpression);
- return false;
- }
-
- public boolean visit(RegExLiteral regexLiteral, BlockScope scope) {
- this.addSmallFragment(regexLiteral);
- return false;
- }
-
-
- public boolean visit(
- QualifiedAllocationExpression qualifiedAllocationExpression,
- BlockScope scope) {
- this.addRealFragment(qualifiedAllocationExpression);
- return false;
- }
- public boolean visit(
- QualifiedNameReference qualifiedNameReference,
- BlockScope scope) {
- this.addRealFragment(qualifiedNameReference);
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedThisReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- QualifiedThisReference qualifiedThisReference,
- BlockScope scope) {
- this.addRealFragment(qualifiedThisReference);
- return false;
- }
-
- public boolean visit(
- SingleNameReference singleNameReference,
- BlockScope scope) {
- this.addRealFragment(singleNameReference);
- return false;
- }
-
- public boolean visit(StringLiteral stringLiteral, BlockScope scope) {
- this.addRealFragment(stringLiteral);
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.SuperReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(SuperReference superReference, BlockScope scope) {
- this.addRealFragment(superReference);
- return false;
- }
-
- public boolean visit(ThisReference thisReference, BlockScope scope) {
- this.addRealFragment(thisReference);
- return false;
- }
-
- public boolean visit(TrueLiteral trueLiteral, BlockScope scope) {
- this.addSmallFragment(trueLiteral);
- return false;
- }
-
- public boolean visit(UnaryExpression unaryExpression, BlockScope scope) {
- this.addRealFragment(unaryExpression);
- return false;
- }
-
- public int size() {
- return this.fragmentsList.size();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/CascadingMethodInvocationFragmentBuilder.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/CascadingMethodInvocationFragmentBuilder.java
deleted file mode 100644
index 3e9383b4..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/CascadingMethodInvocationFragmentBuilder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter;
-
-import java.util.ArrayList;
-
-import org.eclipse.wst.jsdt.internal.compiler.ASTVisitor;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ASTNode;
-import org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope;
-
-class CascadingMethodInvocationFragmentBuilder
- extends ASTVisitor {
-
- ArrayList fragmentsList;
-
- CascadingMethodInvocationFragmentBuilder() {
- this.fragmentsList = new ArrayList();
- }
-
- public MessageSend[] fragments() {
- MessageSend[] fragments = new MessageSend[this.fragmentsList.size()];
- this.fragmentsList.toArray(fragments);
- return fragments;
- }
-
- public int size() {
- return this.fragmentsList.size();
- }
- /* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(MessageSend messageSend, BlockScope scope) {
- if ( messageSend.receiver==null || (messageSend.receiver.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT == 0) {
-
- if (messageSend.receiver!=null &&messageSend.receiver instanceof MessageSend) {
- this.fragmentsList.add(0, messageSend);
- messageSend.receiver.traverse(this, scope);
- return false;
- }
- this.fragmentsList.add(0, messageSend);
- this.fragmentsList.add(1, messageSend);
- } else {
- this.fragmentsList.add(0, messageSend);
- this.fragmentsList.add(1, messageSend);
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/CodeFormatterVisitor.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/CodeFormatterVisitor.java
deleted file mode 100644
index 38dab2eb..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/CodeFormatterVisitor.java
+++ /dev/null
@@ -1,4781 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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.wst.jsdt.internal.formatter;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.compiler.ASTVisitor;
-import org.eclipse.wst.jsdt.internal.compiler.ast.AND_AND_Expression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ASTNode;
-import org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.AbstractVariableDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.AllocationExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Argument;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayAllocationExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayInitializer;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayQualifiedTypeReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ArrayTypeReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Assignment;
-import org.eclipse.wst.jsdt.internal.compiler.ast.BinaryExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Block;
-import org.eclipse.wst.jsdt.internal.compiler.ast.BreakStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.CaseStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ClassLiteralAccess;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Clinit;
-import org.eclipse.wst.jsdt.internal.compiler.ast.CombinedBinaryExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.CompoundAssignment;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ConditionalExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ConstructorDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ContinueStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.DoStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.DoubleLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.EmptyStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.EqualExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ExplicitConstructorCall;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Expression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.FalseLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.FieldReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ForInStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ForeachStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.FunctionExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.IfStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ImportReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Initializer;
-import org.eclipse.wst.jsdt.internal.compiler.ast.InstanceOfExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.IntLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.LabeledStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ListExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend;
-import org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.NullLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.OR_OR_Expression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ObjectLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ObjectLiteralField;
-import org.eclipse.wst.jsdt.internal.compiler.ast.OperatorIds;
-import org.eclipse.wst.jsdt.internal.compiler.ast.PostfixExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.PrefixExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ProgramElement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedAllocationExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedNameReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedThisReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedTypeReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.RegExLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ReturnStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.SingleNameReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.SingleTypeReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Statement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.StringLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.StringLiteralConcatenation;
-import org.eclipse.wst.jsdt.internal.compiler.ast.SuperReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.SwitchStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ThisReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ThrowStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.TrueLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.TryStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.TypeReference;
-import org.eclipse.wst.jsdt.internal.compiler.ast.UnaryExpression;
-import org.eclipse.wst.jsdt.internal.compiler.ast.UndefinedLiteral;
-import org.eclipse.wst.jsdt.internal.compiler.ast.WhileStatement;
-import org.eclipse.wst.jsdt.internal.compiler.ast.WithStatement;
-import org.eclipse.wst.jsdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.wst.jsdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.wst.jsdt.internal.compiler.impl.Constant;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.Scope;
-import org.eclipse.wst.jsdt.internal.compiler.parser.Scanner;
-import org.eclipse.wst.jsdt.internal.compiler.parser.TerminalTokens;
-import org.eclipse.wst.jsdt.internal.core.util.CodeSnippetParsingUtil;
-import org.eclipse.wst.jsdt.internal.formatter.align.Alignment;
-import org.eclipse.wst.jsdt.internal.formatter.align.AlignmentException;
-import org.eclipse.wst.jsdt.internal.formatter.comment.CommentRegion;
-
-/**
- * This class is responsible for formatting a valid java source code.
- * @since 2.1
- */
-/*
- <extension
- id="org.eclipse.wst.jsdt.core.newformatter.codeformatter"
- name="org.eclipse.wst.jsdt.core.newformatter.codeformatter"
- point="org.eclipse.wst.jsdt.core.codeFormatter">
- <codeFormatter
- class="org.eclipse.wst.jsdt.internal.formatter.CodeFormatterVisitor">
- </codeFormatter>
- </extension>
-*/
-public class CodeFormatterVisitor extends ASTVisitor {
-
- public static class MultiFieldDeclaration extends FieldDeclaration {
-
- FieldDeclaration[] declarations;
-
- MultiFieldDeclaration(FieldDeclaration[] declarations){
- this.declarations = declarations;
- this.modifiers = declarations[0].modifiers;
- }
- }
-
- public final static boolean DEBUG = false;
- private static final int NO_MODIFIERS = 0;
- /*
- * Set of expected tokens type for a single type reference.
- * This array needs to be SORTED.
- */
- private static final int[] SINGLETYPEREFERENCE_EXPECTEDTOKENS = new int[] {
- TerminalTokens.TokenNameIdentifier,
- TerminalTokens.TokenNameboolean,
- TerminalTokens.TokenNamebyte,
- TerminalTokens.TokenNamechar,
- TerminalTokens.TokenNamedouble,
- TerminalTokens.TokenNamefloat,
- TerminalTokens.TokenNameint,
- TerminalTokens.TokenNamelong,
- TerminalTokens.TokenNameshort,
- TerminalTokens.TokenNamevoid
- };
- private static final int[] CLOSING_GENERICS_EXPECTEDTOKENS = new int[] {
- TerminalTokens.TokenNameRIGHT_SHIFT,
- TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT,
- TerminalTokens.TokenNameGREATER
- };
- private int chunkKind;
- public int lastLocalDeclarationSourceStart;
- private Scanner localScanner;
- public DefaultCodeFormatterOptions preferences;
- public Scribe scribe;
-
- public CodeFormatterVisitor(DefaultCodeFormatterOptions preferences, Map settings, int offset, int length, CodeSnippetParsingUtil codeSnippetParsingUtil) {
- long sourceLevel = settings == null
- ? ClassFileConstants.JDK1_3
- : CompilerOptions.versionToJdkLevel(settings.get(JavaScriptCore.COMPILER_SOURCE));
- this.localScanner = new Scanner(true, false, false/*nls*/, sourceLevel/*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
-
- this.preferences = preferences;
- this.scribe = new Scribe(this, sourceLevel, offset, length, codeSnippetParsingUtil);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#acceptProblem(org.eclipse.wst.jsdt.core.compiler.IProblem)
- */
- public void acceptProblem(IProblem problem) {
- super.acceptProblem(problem);
- }
-
- private BinaryExpressionFragmentBuilder buildFragments(BinaryExpression binaryExpression, BlockScope scope) {
- BinaryExpressionFragmentBuilder builder = new BinaryExpressionFragmentBuilder();
-
- if (binaryExpression instanceof CombinedBinaryExpression) {
- binaryExpression.traverse(builder, scope);
- return builder;
- }
- switch((binaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT) {
- case OperatorIds.MULTIPLY :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNameMULTIPLY));
- binaryExpression.right.traverse(builder, scope);
- break;
- case OperatorIds.PLUS :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNamePLUS));
- binaryExpression.right.traverse(builder, scope);
- break;
- case OperatorIds.DIVIDE :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNameDIVIDE));
- binaryExpression.right.traverse(builder, scope);
- break;
- case OperatorIds.REMAINDER :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNameREMAINDER));
- binaryExpression.right.traverse(builder, scope);
- break;
- case OperatorIds.XOR :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNameXOR));
- binaryExpression.right.traverse(builder, scope);
- break;
- case OperatorIds.MINUS :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNameMINUS));
- binaryExpression.right.traverse(builder, scope);
- break;
- case OperatorIds.OR :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNameOR));
- binaryExpression.right.traverse(builder, scope);
- break;
- case OperatorIds.AND :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNameAND));
- binaryExpression.right.traverse(builder, scope);
- break;
- case OperatorIds.AND_AND :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNameAND_AND));
- binaryExpression.right.traverse(builder, scope);
- break;
- case OperatorIds.OR_OR :
- binaryExpression.left.traverse(builder, scope);
- builder.operatorsList.add(new Integer(TerminalTokens.TokenNameOR_OR));
- binaryExpression.right.traverse(builder, scope);
- break;
- }
-
- return builder;
- }
-
- private CascadingMethodInvocationFragmentBuilder buildFragments(MessageSend messageSend, BlockScope scope) {
- CascadingMethodInvocationFragmentBuilder builder = new CascadingMethodInvocationFragmentBuilder();
-
- messageSend.traverse(builder, scope);
- return builder;
- }
- public boolean checkChunkStart(int kind) {
- if (this.chunkKind != kind) {
- this.chunkKind = kind;
- return true;
- }
- return false;
- }
-
- private boolean commentStartsBlock(int start, int end) {
- this.localScanner.resetTo(start, end);
- try {
- if (this.localScanner.getNextToken() == TerminalTokens.TokenNameLBRACE) {
- switch(this.localScanner.getNextToken()) {
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- case TerminalTokens.TokenNameCOMMENT_LINE :
- return true;
- }
- }
- } catch(InvalidInputException e) {
- // ignore
- }
- return false;
- }
-
- private ASTNode[] computeMergedMemberDeclarations(ASTNode[] nodes){
- ArrayList mergedNodes = new ArrayList();
- for (int i = 0, max = nodes.length; i < max; i++) {
- ASTNode currentNode = nodes[i];
- if (currentNode instanceof FieldDeclaration) {
- FieldDeclaration currentField = (FieldDeclaration) currentNode;
- if (mergedNodes.size() == 0) {
- // first node
- mergedNodes.add(currentNode);
- } else {
- // we need to check if the previous merged node is a field declaration
- ASTNode previousMergedNode = (ASTNode) mergedNodes.get(mergedNodes.size() - 1);
- if (previousMergedNode instanceof MultiFieldDeclaration) {
- // we merge the current node
- MultiFieldDeclaration multiFieldDeclaration = (MultiFieldDeclaration) previousMergedNode;
- int length = multiFieldDeclaration.declarations.length;
- System.arraycopy(multiFieldDeclaration.declarations, 0, multiFieldDeclaration.declarations= new FieldDeclaration[length+1], 0, length);
- multiFieldDeclaration.declarations[length] = currentField;
- } else if (previousMergedNode instanceof FieldDeclaration) {
- // need to check we need to create a multiple field declaration
- 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);
- }
- }
- } else {
- mergedNodes.add(currentNode);
- }
- }
- if (mergedNodes.size() != nodes.length) {
- ASTNode[] result = new ASTNode[mergedNodes.size()];
- mergedNodes.toArray(result);
- return result;
- } else {
- return nodes;
- }
- }
-
- private ASTNode[] computeMergedMemberDeclarations(TypeDeclaration typeDeclaration){
-
- int fieldIndex = 0, fieldCount = (typeDeclaration.fields == null) ? 0 : typeDeclaration.fields.length;
- FieldDeclaration field = fieldCount == 0 ? null : typeDeclaration.fields[fieldIndex];
- int fieldStart = field == null ? Integer.MAX_VALUE : field.declarationSourceStart;
-
- int methodIndex = 0, methodCount = (typeDeclaration.methods == null) ? 0 : typeDeclaration.methods.length;
- AbstractMethodDeclaration method = methodCount == 0 ? null : typeDeclaration.methods[methodIndex];
- int methodStart = method == null ? Integer.MAX_VALUE : method.declarationSourceStart;
-
- int typeIndex = 0, typeCount = (typeDeclaration.memberTypes == null) ? 0 : typeDeclaration.memberTypes.length;
- TypeDeclaration type = typeCount == 0 ? null : typeDeclaration.memberTypes[typeIndex];
- int typeStart = type == null ? Integer.MAX_VALUE : type.declarationSourceStart;
-
- final int memberLength = fieldCount+methodCount+typeCount;
- ASTNode[] members = new ASTNode[memberLength];
- if (memberLength != 0) {
- int index = 0;
- int previousFieldStart = -1;
- do {
- if (fieldStart < methodStart && fieldStart < typeStart) {
- // next member is a field
- if (fieldStart == previousFieldStart){
- ASTNode previousMember = members[index - 1];
- if (previousMember instanceof MultiFieldDeclaration) {
- MultiFieldDeclaration multiField = (MultiFieldDeclaration) previousMember;
- int length = multiField.declarations.length;
- System.arraycopy(multiField.declarations, 0, multiField.declarations=new FieldDeclaration[length+1], 0, length);
- multiField.declarations[length] = field;
- } else {
- members[index - 1] = new MultiFieldDeclaration(new FieldDeclaration[]{ (FieldDeclaration)previousMember, field});
- }
- } else {
- members[index++] = field;
- }
- previousFieldStart = fieldStart;
- if (++fieldIndex < fieldCount) { // find next field if any
- fieldStart = (field = typeDeclaration.fields[fieldIndex]).declarationSourceStart;
- } else {
- fieldStart = Integer.MAX_VALUE;
- }
- } else if (methodStart < fieldStart && methodStart < typeStart) {
- // next member is a method
- if (!method.isDefaultConstructor() && !method.isClinit()) {
- members[index++] = method;
- }
- if (++methodIndex < methodCount) { // find next method if any
- methodStart = (method = typeDeclaration.methods[methodIndex]).declarationSourceStart;
- } else {
- methodStart = Integer.MAX_VALUE;
- }
- } else {
- // next member is a type
- members[index++] = type;
- if (++typeIndex < typeCount) { // find next type if any
- typeStart = (type = typeDeclaration.memberTypes[typeIndex]).declarationSourceStart;
- } else {
- typeStart = Integer.MAX_VALUE;
- }
- }
- } while ((fieldIndex < fieldCount) || (typeIndex < typeCount) || (methodIndex < methodCount));
-
- if (members.length != index) {
- System.arraycopy(members, 0, members=new ASTNode[index], 0, index);
- }
- }
- return members;
- }
-
- private boolean dumpBinaryExpression(
- BinaryExpression binaryExpression,
- int operator,
- BlockScope scope) {
-
-// boolean addSpace= operator==TerminalTokens.TokenNamein || operator==TerminalTokens.TokenNameinstanceof;
- final int numberOfParens = (binaryExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
-
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(binaryExpression, numberOfParens);
- }
- BinaryExpressionFragmentBuilder builder = buildFragments(binaryExpression, scope);
- final int fragmentsSize = builder.size();
-
- if ((builder.realFragmentsSize() > 1 || builder.size() > 4) && numberOfParens == 0) {
- this.scribe.printComment();
- Alignment binaryExpressionAlignment = this.scribe.createAlignment("binaryExpressionAlignment", this.preferences.alignment_for_binary_expression, Alignment.R_OUTERMOST, fragmentsSize, this.scribe.scanner.currentPosition); //$NON-NLS-1$
- this.scribe.enterAlignment(binaryExpressionAlignment);
- boolean ok = false;
- ASTNode[] fragments = builder.fragments();
- int[] operators = builder.operators();
- do {
- try {
- for (int i = 0; i < fragmentsSize - 1; i++) {
- ASTNode fragment = fragments[i];
- fragment.traverse(this, scope);
- this.scribe.printTrailingComment();
- if (this.scribe.lastNumberOfNewLines == 1) {
- // a new line has been inserted by printTrailingComment()
- this.scribe.indentationLevel = binaryExpressionAlignment.breakIndentationLevel;
- }
- if (this.preferences.wrap_before_binary_operator) {
- this.scribe.alignFragment(binaryExpressionAlignment, i);
- this.scribe.printNextToken(operators[i], this.preferences.insert_space_before_binary_operator);
- } else {
- this.scribe.printNextToken(operators[i], this.preferences.insert_space_before_binary_operator);
- this.scribe.alignFragment(binaryExpressionAlignment, i);
- }
- if (operators[i] == TerminalTokens.TokenNameMINUS && isNextToken(TerminalTokens.TokenNameMINUS)) {
- // the next character is a minus (unary operator)
- this.scribe.space();
- }
- if (this.preferences.insert_space_after_binary_operator) {
- this.scribe.space();
- }
- }
- fragments[fragmentsSize - 1].traverse(this, scope);
- this.scribe.printTrailingComment();
- ok = true;
- } catch(AlignmentException e){
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(binaryExpressionAlignment, true);
- } else {
- binaryExpression.left.traverse(this, scope);
- this.scribe.printNextToken(operator, this.preferences.insert_space_before_binary_operator);
- if (operator == TerminalTokens.TokenNameMINUS && isNextToken(TerminalTokens.TokenNameMINUS)) {
- // the next character is a minus (unary operator)
- this.scribe.space();
- }
- if (this.preferences.insert_space_after_binary_operator) {
- this.scribe.space();
- }
- binaryExpression.right.traverse(this, scope);
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(binaryExpression, numberOfParens);
- }
- return false;
- }
-
- private boolean dumpEqualityExpression(
- BinaryExpression binaryExpression,
- int operator,
- BlockScope scope) {
-
- final int numberOfParens = (binaryExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
-
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(binaryExpression, numberOfParens);
- }
- binaryExpression.left.traverse(this, scope);
- this.scribe.printNextToken(operator, this.preferences.insert_space_before_binary_operator);
- if (this.preferences.insert_space_after_binary_operator) {
- this.scribe.space();
- }
- binaryExpression.right.traverse(this, scope);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(binaryExpression, numberOfParens);
- }
- return false;
- }
-
- private final TextEdit failedToFormat() {
- if (DEBUG) {
- System.out.println("COULD NOT FORMAT \n" + this.scribe.scanner); //$NON-NLS-1$
- System.out.println(this.scribe);
- }
- return null;
- }
-
- private void format(
- AbstractMethodDeclaration methodDeclaration,
- ClassScope scope,
- boolean isChunkStart,
- boolean isFirstClassBodyDeclaration) {
-
- if (isFirstClassBodyDeclaration) {
- int newLinesBeforeFirstClassBodyDeclaration = this.preferences.blank_lines_before_first_class_body_declaration;
- if (newLinesBeforeFirstClassBodyDeclaration > 0) {
- this.scribe.printEmptyLines(newLinesBeforeFirstClassBodyDeclaration);
- }
- } else {
- final int newLineBeforeChunk = isChunkStart ? this.preferences.blank_lines_before_new_chunk : 0;
- if (newLineBeforeChunk > 0) {
- this.scribe.printEmptyLines(newLineBeforeChunk);
- }
- }
- final int newLinesBeforeMethod = this.preferences.blank_lines_before_method;
- if (newLinesBeforeMethod > 0 && !isFirstClassBodyDeclaration) {
- this.scribe.printEmptyLines(newLinesBeforeMethod);
- } else if (this.scribe.line != 0 || this.scribe.column != 1) {
- this.scribe.printNewLine();
- }
- methodDeclaration.traverse(this, scope);
- }
-
- private void format(AbstractVariableDeclaration fieldDeclaration, ASTVisitor visitor, MethodScope scope, boolean isChunkStart, boolean isFirstClassBodyDeclaration) {
-
- if (isFirstClassBodyDeclaration) {
- int newLinesBeforeFirstClassBodyDeclaration = this.preferences.blank_lines_before_first_class_body_declaration;
- if (newLinesBeforeFirstClassBodyDeclaration > 0) {
- this.scribe.printEmptyLines(newLinesBeforeFirstClassBodyDeclaration);
- }
- } else {
- int newLineBeforeChunk = isChunkStart ? this.preferences.blank_lines_before_new_chunk : 0;
- if (newLineBeforeChunk > 0) {
- this.scribe.printEmptyLines(newLineBeforeChunk);
- }
- final int newLinesBeforeField = this.preferences.blank_lines_before_field;
- if (newLinesBeforeField > 0) {
- this.scribe.printEmptyLines(newLinesBeforeField);
- }
- }
- Alignment memberAlignment = this.scribe.getMemberAlignment();
-
- this.scribe.printComment();
- this.scribe.printModifiers(this);
- this.scribe.space();
-
- this.scribe.printNextToken(TerminalTokens.TokenNamevar, true);
-
-
- /*
- * Field type
- */
-// fieldDeclaration.type.traverse(this, scope);
-
- /*
- * Field name
- */
- this.scribe.alignFragment(memberAlignment, 0);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
-
- /*
- * Check for extra dimensions
- */
- int extraDimensions = getDimensions();
- if (extraDimensions != 0) {
- for (int i = 0; i < extraDimensions; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
- }
- }
-
- /*
- * Field initialization
- */
- final Expression initialization = fieldDeclaration.initialization;
- if (initialization != null) {
- this.scribe.alignFragment(memberAlignment, 1);
- this.scribe.printNextToken(TerminalTokens.TokenNameEQUAL, this.preferences.insert_space_before_assignment_operator);
- if (this.preferences.insert_space_after_assignment_operator) {
- this.scribe.space();
- }
- Alignment assignmentAlignment = this.scribe.createAlignment("fieldDeclarationAssignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_OUTERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$
- this.scribe.enterAlignment(assignmentAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(assignmentAlignment, 0);
- initialization.traverse(this, scope);
- ok = true;
- } catch(AlignmentException e){
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(assignmentAlignment, true);
- }
-
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
-
- if (memberAlignment != null) {
- this.scribe.alignFragment(memberAlignment, 2);
- this.scribe.printTrailingComment();
- } else {
- this.scribe.space();
- this.scribe.printTrailingComment();
- }
- }
-
- private void format(ImportReference importRef, boolean isLast) {
- if (importRef.isInternal())
- return;
- this.scribe.printNextToken(TerminalTokens.TokenNameimport);
- this.preferences.number_of_empty_lines_to_preserve = this.preferences.blank_lines_between_import_groups;
- this.scribe.space();
- if ((importRef.bits & ASTNode.OnDemand) != 0) {
- this.scribe.printQualifiedReference(importRef.sourceEnd);
- this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
- this.scribe.printNextToken(TerminalTokens.TokenNameMULTIPLY);
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- } else {
- this.scribe.printQualifiedReference(importRef.sourceEnd);
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- }
- if (isLast) {
- this.scribe.printTrailingComment();
- } else {
- this.scribe.printTrailingComment(this.preferences.blank_lines_between_import_groups);
- }
- this.scribe.printNewLine();
- }
-
-
- private void format(MultiFieldDeclaration multiFieldDeclaration, ASTVisitor visitor, MethodScope scope, boolean isChunkStart, boolean isFirstClassBodyDeclaration) {
-
- if (isFirstClassBodyDeclaration) {
- int newLinesBeforeFirstClassBodyDeclaration = this.preferences.blank_lines_before_first_class_body_declaration;
- if (newLinesBeforeFirstClassBodyDeclaration > 0) {
- this.scribe.printEmptyLines(newLinesBeforeFirstClassBodyDeclaration);
- }
- } else {
- int newLineBeforeChunk = isChunkStart ? this.preferences.blank_lines_before_new_chunk : 0;
- if (newLineBeforeChunk > 0) {
- this.scribe.printEmptyLines(newLineBeforeChunk);
- }
- final int newLinesBeforeField = this.preferences.blank_lines_before_field;
- if (newLinesBeforeField > 0) {
- this.scribe.printEmptyLines(newLinesBeforeField);
- }
- }
- Alignment fieldAlignment = this.scribe.getMemberAlignment();
-
- this.scribe.printComment();
- this.scribe.printModifiers(this);
- this.scribe.space();
-
- multiFieldDeclaration.declarations[0].type.traverse(this, scope);
-
- final int multipleFieldDeclarationsLength = multiFieldDeclaration.declarations.length;
-
- Alignment multiFieldDeclarationsAlignment =this.scribe.createAlignment(
- "multiple_field",//$NON-NLS-1$
- this.preferences.alignment_for_multiple_fields,
- multipleFieldDeclarationsLength - 1,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(multiFieldDeclarationsAlignment);
-
- boolean ok = false;
- do {
- try {
- for (int i = 0, length = multipleFieldDeclarationsLength; i < length; i++) {
- FieldDeclaration fieldDeclaration = multiFieldDeclaration.declarations[i];
- /*
- * Field name
- */
- if (i == 0) {
- this.scribe.alignFragment(fieldAlignment, 0);
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false);
- }
-
- /*
- * Check for extra dimensions
- */
- int extraDimensions = getDimensions();
- if (extraDimensions != 0) {
- for (int index = 0; index < extraDimensions; index++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
- }
- }
-
- /*
- * Field initialization
- */
- final Expression initialization = fieldDeclaration.initialization;
- if (initialization != null) {
- if (i == 0) {
- this.scribe.alignFragment(fieldAlignment, 1);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameEQUAL, this.preferences.insert_space_before_assignment_operator);
- if (this.preferences.insert_space_after_assignment_operator) {
- this.scribe.space();
- }
- initialization.traverse(this, scope);
- }
-
- if (i != length - 1) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_multiple_field_declarations);
- this.scribe.printTrailingComment();
- this.scribe.alignFragment(multiFieldDeclarationsAlignment, i);
-
- if (this.preferences.insert_space_after_comma_in_multiple_field_declarations) {
- this.scribe.space();
- }
- } else {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.alignFragment(fieldAlignment, 2);
- this.scribe.printTrailingComment();
- }
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(multiFieldDeclarationsAlignment, true);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.formatter.CodeFormatter#format(int, String, int, int, int, String)
- */
- public TextEdit format(String string, ASTNode[] nodes) {
- // reset the scribe
- this.scribe.reset();
-
- long startTime = System.currentTimeMillis();
-
- final char[] compilationUnitSource = string.toCharArray();
-
- this.localScanner.setSource(compilationUnitSource);
- this.scribe.initializeScanner(compilationUnitSource);
-
- if (nodes == null) {
- return null;
- }
-
- this.lastLocalDeclarationSourceStart = -1;
- try {
- formatClassBodyDeclarations(nodes);
- } catch(AbortFormatting e){
- return failedToFormat();
- }
- if (DEBUG){
- System.out.println("Formatting time: " + (System.currentTimeMillis() - startTime)); //$NON-NLS-1$
- }
- return this.scribe.getRootEdit();
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.formatter.CodeFormatter#format(int, String, int, int, int, String)
- */
- public TextEdit format(String string, CompilationUnitDeclaration compilationUnitDeclaration) {
- // reset the scribe
- this.scribe.reset();
-
- if (compilationUnitDeclaration == null || compilationUnitDeclaration.ignoreFurtherInvestigation) {
- return failedToFormat();
- }
-
- long startTime = System.currentTimeMillis();
-
- final char[] compilationUnitSource = string.toCharArray();
-
- this.localScanner.setSource(compilationUnitSource);
- this.scribe.initializeScanner(compilationUnitSource);
-
- this.lastLocalDeclarationSourceStart = -1;
- try {
- compilationUnitDeclaration.traverse(this, compilationUnitDeclaration.scope);
- } catch(AbortFormatting e){
- return failedToFormat();
- }
- if (DEBUG){
- System.out.println("Formatting time: " + (System.currentTimeMillis() - startTime)); //$NON-NLS-1$
- }
- return this.scribe.getRootEdit();
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.formatter.CodeFormatter#format(int, String, int, int, int, String)
- */
- public TextEdit format(String string, ConstructorDeclaration constructorDeclaration) {
- // reset the scribe
- this.scribe.reset();
-
- long startTime = System.currentTimeMillis();
-
- final char[] compilationUnitSource = string.toCharArray();
-
- this.localScanner.setSource(compilationUnitSource);
- this.scribe.initializeScanner(compilationUnitSource);
-
- if (constructorDeclaration == null) {
- return null;
- }
-
- this.lastLocalDeclarationSourceStart = -1;
- try {
- ExplicitConstructorCall explicitConstructorCall = constructorDeclaration.constructorCall;
- if (explicitConstructorCall != null && !explicitConstructorCall.isImplicitSuper()) {
- explicitConstructorCall.traverse(this, null);
- }
- Statement[] statements = constructorDeclaration.statements;
- if (statements != null) {
- formatStatements(null, statements, false);
- }
- if (hasComments()) {
- this.scribe.printNewLine();
- }
- this.scribe.printComment();
- } catch(AbortFormatting e){
- return failedToFormat();
- }
- if (DEBUG){
- System.out.println("Formatting time: " + (System.currentTimeMillis() - startTime)); //$NON-NLS-1$
- }
- return this.scribe.getRootEdit();
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.formatter.CodeFormatter#format(int, String, int, int, int, String)
- */
- public TextEdit format(String string, Expression expression) {
- // reset the scribe
- this.scribe.reset();
-
- long startTime = System.currentTimeMillis();
-
- final char[] compilationUnitSource = string.toCharArray();
-
- this.localScanner.setSource(compilationUnitSource);
- this.scribe.initializeScanner(compilationUnitSource);
-
- if (expression == null) {
- return null;
- }
-
- this.lastLocalDeclarationSourceStart = -1;
- try {
- expression.traverse(this, (BlockScope) null);
- this.scribe.printComment();
- } catch(AbortFormatting e){
- return failedToFormat();
- }
- if (DEBUG){
- System.out.println("Formatting time: " + (System.currentTimeMillis() - startTime)); //$NON-NLS-1$
- }
- return this.scribe.getRootEdit();
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.formatter.CodeFormatter#format(int, String, int, int, int, String)
- */
- public TextEdit format(String string, CommentRegion region) {
- // reset the scribe
- this.scribe.reset();
-
- if (region == null) {
- return failedToFormat();
- }
-
- long startTime = 0;
- if (DEBUG){
- startTime = System.currentTimeMillis();
- }
-
- final char[] compilationUnitSource = string.toCharArray();
-
- this.scribe.initializeScanner(compilationUnitSource);
-
- TextEdit result = null;
- try {
- result = region.format(this.preferences.initial_indentation_level, true);
- } catch(AbortFormatting e){
- return failedToFormat();
- }
- if (DEBUG){
- System.out.println("Formatting time: " + (System.currentTimeMillis() - startTime)); //$NON-NLS-1$
- }
- return result;
- }
-
- private void format(TypeDeclaration typeDeclaration){
- /*
- * Print comments to get proper line number
- */
- this.scribe.printComment();
- int line = this.scribe.line;
-
- this.scribe.printModifiers(this);
-
- if (this.scribe.line > line) {
- // annotations introduced new line, but this is not a line wrapping
- // see 158267
- line = this.scribe.line;
- }
-
- /*
- * Type name
- */
- switch(TypeDeclaration.kind(typeDeclaration.modifiers)) {
- case TypeDeclaration.CLASS_DECL :
- this.scribe.printNextToken(TerminalTokens.TokenNameclass, true);
- break;
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
-
- /*
- * Superclass
- */
- final TypeReference superclass = typeDeclaration.superclass;
- if (superclass != null) {
- Alignment superclassAlignment =this.scribe.createAlignment(
- "superclass", //$NON-NLS-1$
- this.preferences.alignment_for_superclass_in_type_declaration,
- 2,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(superclassAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(superclassAlignment, 0);
- this.scribe.printNextToken(TerminalTokens.TokenNameextends, true);
- this.scribe.alignFragment(superclassAlignment, 1);
- this.scribe.space();
- superclass.traverse(this, typeDeclaration.scope);
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(superclassAlignment, true);
- }
-
- /*
- * Type body
- */
- String class_declaration_brace;
- boolean space_before_opening_brace;
- int kind = TypeDeclaration.kind(typeDeclaration.modifiers);
-
- class_declaration_brace = this.preferences.brace_position_for_type_declaration;
- space_before_opening_brace = this.preferences.insert_space_before_opening_brace_in_type_declaration;
-
- formatLeftCurlyBrace(line, class_declaration_brace);
- formatTypeOpeningBrace(class_declaration_brace, space_before_opening_brace, typeDeclaration);
-
- boolean indent_body_declarations_compare_to_header;
-
- indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_type_header;
-
- if (indent_body_declarations_compare_to_header) {
- this.scribe.indent();
- }
-
- formatTypeMembers(typeDeclaration);
-
- if (indent_body_declarations_compare_to_header) {
- this.scribe.unIndent();
- }
-
- if (this.preferences.insert_new_line_in_empty_type_declaration) {
- this.scribe.printNewLine();
- }
-
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
- this.scribe.printTrailingComment();
- if (class_declaration_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- if (hasComments()) {
- this.scribe.printNewLine();
- }
- }
-
- private void format(
- TypeDeclaration memberTypeDeclaration,
- ClassScope scope,
- boolean isChunkStart,
- boolean isFirstClassBodyDeclaration) {
-
- if (isFirstClassBodyDeclaration) {
- int newLinesBeforeFirstClassBodyDeclaration = this.preferences.blank_lines_before_first_class_body_declaration;
- if (newLinesBeforeFirstClassBodyDeclaration > 0) {
- this.scribe.printEmptyLines(newLinesBeforeFirstClassBodyDeclaration);
- }
- } else {
- int newLineBeforeChunk = isChunkStart ? this.preferences.blank_lines_before_new_chunk : 0;
- if (newLineBeforeChunk > 0) {
- this.scribe.printEmptyLines(newLineBeforeChunk);
- }
- final int newLinesBeforeMember = this.preferences.blank_lines_before_member_type;
- if (newLinesBeforeMember > 0) {
- this.scribe.printEmptyLines(newLinesBeforeMember);
- }
- }
- memberTypeDeclaration.traverse(this, scope);
- }
-
- private void formatAnonymousTypeDeclaration(TypeDeclaration typeDeclaration) {
- /*
- * Type body
- */
- String anonymous_type_declaration_brace_position = this.preferences.brace_position_for_anonymous_type_declaration;
-
- formatTypeOpeningBrace(anonymous_type_declaration_brace_position, this.preferences.insert_space_before_opening_brace_in_anonymous_type_declaration, typeDeclaration);
-
- this.scribe.indent();
-
- formatTypeMembers(typeDeclaration);
-
- this.scribe.unIndent();
- if (this.preferences.insert_new_line_in_empty_anonymous_type_declaration) {
- this.scribe.printNewLine();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
- if (anonymous_type_declaration_brace_position.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- }
-
- /**
- * @param block
- * @param scope
- * @param block_brace_position
- */
- private void formatBlock(Block block, BlockScope scope, String block_brace_position, boolean insertSpaceBeforeOpeningBrace) {
- formatOpeningBrace(block_brace_position, insertSpaceBeforeOpeningBrace);
- final Statement[] statements = block.statements;
- if (statements != null) {
- this.scribe.printNewLine();
- if (this.preferences.indent_statements_compare_to_block) {
- this.scribe.indent();
- }
- formatStatements(scope, statements, true);
- this.scribe.printComment();
-
- if (this.preferences.indent_statements_compare_to_block) {
- this.scribe.unIndent();
- }
- } else if (this.preferences.insert_new_line_in_empty_block) {
- this.scribe.printNewLine();
- if (this.preferences.indent_statements_compare_to_block) {
- this.scribe.indent();
- }
- this.scribe.printComment();
-
- if (this.preferences.indent_statements_compare_to_block) {
- this.scribe.unIndent();
- }
- } else {
- if (this.preferences.indent_statements_compare_to_block) {
- this.scribe.indent();
- }
- this.scribe.printComment();
-
- if (this.preferences.indent_statements_compare_to_block) {
- this.scribe.unIndent();
- }
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
- this.scribe.printTrailingComment();
- if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(block_brace_position)) {
- this.scribe.unIndent();
- }
- }
-
- private void formatCascadingMessageSends(CascadingMethodInvocationFragmentBuilder builder, BlockScope scope) {
- int size = builder.size();
- MessageSend[] fragments = builder.fragments();
- Expression fragment = fragments[0].receiver;
- int startingPositionInCascade = 1;
- if (fragment!=null &&!fragment.isImplicitThis()) {
- fragment.traverse(this, scope);
- } else {
- MessageSend currentMessageSend = fragments[1];
- final int numberOfParens = (currentMessageSend.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(currentMessageSend, numberOfParens);
- }
- ASTNode[] arguments = currentMessageSend.arguments;
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier); // selector
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_method_invocation);
- if (arguments != null) {
- if (this.preferences.insert_space_after_opening_paren_in_method_invocation) {
- this.scribe.space();
- }
- int argumentLength = arguments.length;
- Alignment argumentsAlignment = this.scribe.createAlignment(
- "messageArguments", //$NON-NLS-1$
- this.preferences.alignment_for_arguments_in_method_invocation,
- Alignment.R_OUTERMOST,
- argumentLength,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(argumentsAlignment);
- boolean okForArguments = false;
- do {
- try {
- for (int j = 0; j < argumentLength; j++) {
- if (j > 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments);
- this.scribe.printTrailingComment();
- }
- this.scribe.alignFragment(argumentsAlignment, j);
- if (j > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) {
- this.scribe.space();
- }
- arguments[j].traverse(this, scope);
- }
- okForArguments = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!okForArguments);
- this.scribe.exitAlignment(argumentsAlignment, true);
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_method_invocation);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_between_empty_parens_in_method_invocation);
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(currentMessageSend, numberOfParens);
- }
- startingPositionInCascade = 2;
- }
- Alignment cascadingMessageSendAlignment =
- this.scribe.createAlignment(
- "cascadingMessageSendAlignment", //$NON-NLS-1$
- this.preferences.alignment_for_selector_in_method_invocation,
- Alignment.R_INNERMOST,
- size,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(cascadingMessageSendAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(cascadingMessageSendAlignment, 0);
- //this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
- // Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=221018
- // functions can return functions in javascript so there won't always be a dot
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameDOT, false);
- for (int i = startingPositionInCascade; i < size; i++) {
- MessageSend currentMessageSend = fragments[i];
- final int numberOfParens = (currentMessageSend.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(currentMessageSend, numberOfParens);
- }
- ASTNode[] arguments = currentMessageSend.arguments;
- // Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=221018
- // functions can return functions in javascript so there won't always be another identifier name
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameIdentifier, false); // selector
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_method_invocation);
- if (arguments != null) {
- if (this.preferences.insert_space_after_opening_paren_in_method_invocation) {
- this.scribe.space();
- }
- int argumentLength = arguments.length;
- Alignment argumentsAlignment = this.scribe.createAlignment(
- "messageArguments", //$NON-NLS-1$
- this.preferences.alignment_for_arguments_in_method_invocation,
- Alignment.R_OUTERMOST,
- argumentLength,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(argumentsAlignment);
- boolean okForArguments = false;
- do {
- try {
- for (int j = 0; j < argumentLength; j++) {
- if (j > 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments);
- this.scribe.printTrailingComment();
- }
- this.scribe.alignFragment(argumentsAlignment, j);
- if (j > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) {
- this.scribe.space();
- }
- arguments[j].traverse(this, scope);
- }
- okForArguments = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!okForArguments);
- this.scribe.exitAlignment(argumentsAlignment, true);
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_method_invocation);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_between_empty_parens_in_method_invocation);
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(currentMessageSend, numberOfParens);
- }
- if (i < size - 1) {
- this.scribe.alignFragment(cascadingMessageSendAlignment, i);
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameDOT, false);
- }
- }
- ok = true;
- } catch(AlignmentException e){
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(cascadingMessageSendAlignment, true);
- }
-
- /*
- * Merged traversal of member (types, fields, methods)
- */
- private void formatClassBodyDeclarations(ASTNode[] nodes) {
- final int FIELD = 1, METHOD = 2;//, TYPE = 3;
- this.scribe.lastNumberOfNewLines = 1;
- ASTNode[] mergedNodes = computeMergedMemberDeclarations(nodes);
- Alignment memberAlignment = this.scribe.createMemberAlignment("typeMembers", this.preferences.align_type_members_on_columns ? Alignment.M_MULTICOLUMN : Alignment.M_NO_ALIGNMENT, 4, this.scribe.scanner.currentPosition); //$NON-NLS-1$
- this.scribe.enterMemberAlignment(memberAlignment);
- boolean isChunkStart = false;
- boolean ok = false;
- int startIndex = 0;
- do {
- try {
- for (int i = startIndex, max = mergedNodes.length; i < max; i++) {
- ASTNode member = mergedNodes[i];
- if (member instanceof FieldDeclaration) {
- isChunkStart = memberAlignment.checkChunkStart(FIELD, i, this.scribe.scanner.currentPosition);
- if (member instanceof MultiFieldDeclaration){
- MultiFieldDeclaration multiField = (MultiFieldDeclaration) member;
- format(multiField, this, null, isChunkStart, i == 0);
- } else if (member instanceof Initializer) {
- int newLineBeforeChunk = isChunkStart ? this.preferences.blank_lines_before_new_chunk : 0;
- if (newLineBeforeChunk > 0 && i != 0) {
- this.scribe.printEmptyLines(newLineBeforeChunk);
- } else if (i == 0) {
- int newLinesBeforeFirstClassBodyDeclaration = this.preferences.blank_lines_before_first_class_body_declaration;
- if (newLinesBeforeFirstClassBodyDeclaration > 0) {
- this.scribe.printEmptyLines(newLinesBeforeFirstClassBodyDeclaration);
- }
- }
- Initializer initializer = (Initializer) member;
- initializer.traverse(this, null);
- } else {
- FieldDeclaration field = (FieldDeclaration) member;
- format(field, this, null, isChunkStart, i == 0);
- }
- } else if (member instanceof LocalDeclaration) {
- LocalDeclaration field = (LocalDeclaration) member;
- format(field, this, null, isChunkStart, i == 0);
- } else if (member instanceof AbstractMethodDeclaration) {
- isChunkStart = memberAlignment.checkChunkStart(METHOD, i, this.scribe.scanner.currentPosition);
- format((AbstractMethodDeclaration) member, null, isChunkStart, i == 0);
- } else {
-// isChunkStart = memberAlignment.checkChunkStart(TYPE, i, this.scribe.scanner.currentPosition);
-// format((TypeDeclaration)member, null, isChunkStart, i == 0);
- member.traverse(this, null);
- }
- if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- if (i != max - 1) {
- this.scribe.printNewLine();
- }
- }
- ok = true;
- } catch(AlignmentException e){
- startIndex = memberAlignment.chunkStartIndex;
- this.scribe.redoMemberAlignment(e);
- }
- } while (!ok);
- this.scribe.exitMemberAlignment(memberAlignment);
- if (hasComments()) {
- this.scribe.printNewLine();
- }
- this.scribe.printComment();
- }
-
- private void formatEmptyTypeDeclaration(boolean isFirst) {
- boolean hasSemiColon = isNextToken(TerminalTokens.TokenNameSEMICOLON);
- while(isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
- this.scribe.printComment();
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- if (hasSemiColon && isFirst) {
- this.scribe.printNewLine();
- }
- }
-
- private void formatGuardClauseBlock(Block block, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, this.preferences.insert_space_before_opening_brace_in_block);
- this.scribe.space();
-
- final Statement[] statements = block.statements;
- statements[0].traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, true);
- this.scribe.printTrailingComment();
- }
-
- private void formatLeftCurlyBrace(final int line, final String bracePosition) {
- /*
- * deal with (quite unexpected) comments right before lcurly
- */
- this.scribe.printComment();
- if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition)
- && (this.scribe.line > line || this.scribe.column >= this.preferences.page_width))
- {
- this.scribe.printNewLine();
- }
- }
-
- private void formatLocalDeclaration(LocalDeclaration localDeclaration, BlockScope scope, boolean insertSpaceBeforeComma, boolean insertSpaceAfterComma) {
-
- if (!isMultipleLocalDeclaration(localDeclaration)) {
- if (localDeclaration.modifiers != NO_MODIFIERS) {
- this.scribe.printComment();
- this.scribe.printModifiers(this);
- this.scribe.space();
- }
-
- this.scribe.printNextToken(TerminalTokens.TokenNamevar, true);
-
- /*
- * Argument type
- */
- if (localDeclaration.type != null) {
- localDeclaration.type.traverse(this, scope);
- }
- /*
- * Print the argument name
- */
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
- } else {
- /*
- * Print the argument name
- */
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false);
- }
- /*
- * Check for extra dimensions
- */
- int extraDimensions = getDimensions();
- if (extraDimensions != 0) {
- for (int index = 0; index < extraDimensions; index++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
- }
- }
-
- final Expression initialization = localDeclaration.initialization;
- if (initialization != null) {
- /*
- * Print the method name
- */
- this.scribe.printNextToken(TerminalTokens.TokenNameEQUAL, this.preferences.insert_space_before_assignment_operator);
- if (this.preferences.insert_space_after_assignment_operator) {
- this.scribe.space();
- }
- Alignment assignmentAlignment = this.scribe.createAlignment("localDeclarationAssignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_OUTERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$
- this.scribe.enterAlignment(assignmentAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(assignmentAlignment, 0);
- initialization.traverse(this, scope);
- ok = true;
- } catch(AlignmentException e){
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(assignmentAlignment, true);
- }
-
- if (isPartOfMultipleLocalDeclaration()) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, insertSpaceBeforeComma);
- if (insertSpaceAfterComma) {
- this.scribe.space();
- }
- this.scribe.printTrailingComment();
- }
- }
-
- private void formatMessageSend(
- MessageSend messageSend,
- BlockScope scope,
- Alignment messageAlignment) {
-
- if (messageAlignment != null) {
- this.scribe.alignFragment(messageAlignment, 0);
- if (messageSend.selector!=null)
- this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
- }
- if (messageSend.selector!=null)
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier); // selector
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_method_invocation);
-
- final Expression[] arguments = messageSend.arguments;
- if (arguments != null) {
- if (this.preferences.insert_space_after_opening_paren_in_method_invocation) {
- this.scribe.space();
- }
- int argumentsLength = arguments.length;
- if (argumentsLength > 1) {
- Alignment argumentsAlignment = this.scribe.createAlignment(
- "messageArguments", //$NON-NLS-1$
- this.preferences.alignment_for_arguments_in_method_invocation,
- argumentsLength,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(argumentsAlignment);
- boolean ok = false;
- do {
- try {
- for (int i = 0; i < argumentsLength; i++) {
- if (i > 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments);
- this.scribe.printTrailingComment();
- }
- this.scribe.alignFragment(argumentsAlignment, i);
- if (i > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) {
- this.scribe.space();
- }
- arguments[i].traverse(this, scope);
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(argumentsAlignment, true);
- } else {
- for (int i = 0; i < argumentsLength; i++) {
- if (i > 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments);
- this.scribe.printTrailingComment();
- }
- if (i > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) {
- this.scribe.space();
- }
- arguments[i].traverse(this, scope);
- }
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_method_invocation);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_between_empty_parens_in_method_invocation);
- }
- }
-
- private void formatMethodArguments(
- AbstractMethodDeclaration methodDeclaration,
- boolean spaceBeforeOpenParen,
- boolean spaceBetweenEmptyParameters,
- boolean spaceBeforeClosingParen,
- boolean spaceBeforeFirstParameter,
- boolean spaceBeforeComma,
- boolean spaceAfterComma,
- int methodDeclarationParametersAlignment) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, spaceBeforeOpenParen);
-
- final Argument[] arguments = methodDeclaration.arguments;
- if (arguments != null) {
- if (spaceBeforeFirstParameter) {
- this.scribe.space();
- }
- int argumentLength = arguments.length;
- Alignment argumentsAlignment = this.scribe.createAlignment(
- "methodArguments",//$NON-NLS-1$
- methodDeclarationParametersAlignment,
- argumentLength,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(argumentsAlignment);
- boolean ok = false;
- do {
- try {
- for (int i = 0; i < argumentLength; i++) {
- if (i > 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, spaceBeforeComma);
- this.scribe.printTrailingComment();
- }
- this.scribe.alignFragment(argumentsAlignment, i);
- if (i > 0 && spaceAfterComma) {
- this.scribe.space();
- }
- arguments[i].traverse(this, methodDeclaration.scope);
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(argumentsAlignment, true);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, spaceBeforeClosingParen);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, spaceBetweenEmptyParameters);
- }
- }
-
- private void formatEnumConstantArguments(
- FieldDeclaration enumConstant,
- boolean spaceBeforeOpenParen,
- boolean spaceBetweenEmptyParameters,
- boolean spaceBeforeClosingParen,
- boolean spaceBeforeFirstParameter,
- boolean spaceBeforeComma,
- boolean spaceAfterComma,
- int methodDeclarationParametersAlignment) {
-
- if (!isNextToken(TerminalTokens.TokenNameLPAREN)) {
- return;
- }
-
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, spaceBeforeOpenParen);
- final Expression[] arguments = ((AllocationExpression) enumConstant.initialization).arguments;
- if (arguments != null) {
- int argumentLength = arguments.length;
- Alignment argumentsAlignment = this.scribe.createAlignment(
- "enumConstantArguments",//$NON-NLS-1$
- methodDeclarationParametersAlignment,
- argumentLength,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(argumentsAlignment);
- boolean ok = false;
- do {
- try {
- if (spaceBeforeFirstParameter) {
- this.scribe.space();
- }
- for (int i = 0; i < argumentLength; i++) {
- if (i > 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, spaceBeforeComma);
- this.scribe.printTrailingComment();
- }
- this.scribe.alignFragment(argumentsAlignment, i);
- if (i > 0 && spaceAfterComma) {
- this.scribe.space();
- }
- arguments[i].traverse(this, (BlockScope) null);
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(argumentsAlignment, true);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, spaceBeforeClosingParen);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, spaceBetweenEmptyParameters);
- }
- }
-
- private void formatNecessaryEmptyStatement() {
- if (this.preferences.put_empty_statement_on_new_line) {
- this.scribe.printNewLine();
- this.scribe.indent();
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- this.scribe.unIndent();
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- }
-
- private void formatOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace) {
-
- if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) {
- this.scribe.printNewLine();
- } else if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(bracePosition)) {
- this.scribe.printNewLine();
- this.scribe.indent();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, insertSpaceBeforeBrace);
-
- this.scribe.printTrailingComment();
- }
-
-
- private void formatOpeningBracket(String bracePosition, boolean insertSpaceBeforeBrace) {
-
- if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) {
- this.scribe.printNewLine();
- } else if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(bracePosition)) {
- this.scribe.printNewLine();
- this.scribe.indent();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET, insertSpaceBeforeBrace);
-
- this.scribe.printTrailingComment();
- }
- private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) {
- int statementsLength = statements.length;
- for (int i = 0; i < statementsLength; i++) {
- final Statement statement = statements[i];
- if (i > 0 && (statements[i - 1] instanceof EmptyStatement) && !(statement instanceof EmptyStatement)) {
- this.scribe.printNewLine();
- }
- statement.traverse(this, scope);
- if (statement instanceof Expression) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- if (i != statementsLength - 1) {
- if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
- this.scribe.printNewLine();
- }
- } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
- this.scribe.printNewLine();
- }
- } else if (statement instanceof LocalDeclaration) {
- LocalDeclaration currentLocal = (LocalDeclaration) statement;
- if (i < (statementsLength - 1)) {
- /*
- * We need to check that the next statement is a local declaration
- */
- if (statements[i + 1] instanceof LocalDeclaration) {
- LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1];
- if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- if (i != statementsLength - 1) {
- if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
- this.scribe.printNewLine();
- }
- } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
- this.scribe.printNewLine();
- }
- }
- } else {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- if (i != statementsLength - 1) {
- if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
- this.scribe.printNewLine();
- }
- } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
- this.scribe.printNewLine();
- }
- }
- } else {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- if (i != statementsLength - 1) {
- if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
- this.scribe.printNewLine();
- }
- } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
- this.scribe.printNewLine();
- }
- }
- } else if (i != statementsLength - 1) {
- if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
- this.scribe.printNewLine();
- }
- } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
- this.scribe.printNewLine();
- }
- }
- }
-
- /*
- * Merged traversal of member (types, fields, methods)
- */
- private void formatTypeMembers(TypeDeclaration typeDeclaration) {
- Alignment memberAlignment = this.scribe.createMemberAlignment("typeMembers", this.preferences.align_type_members_on_columns ? Alignment.M_MULTICOLUMN : Alignment.M_NO_ALIGNMENT, 3, this.scribe.scanner.currentPosition); //$NON-NLS-1$
- this.scribe.enterMemberAlignment(memberAlignment);
- ASTNode[] members = computeMergedMemberDeclarations(typeDeclaration);
- boolean isChunkStart = false;
- boolean ok = false;
- int startIndex = 0;
- do {
- try {
- for (int i = startIndex, max = members.length; i < max; i++) {
- ASTNode member = members[i];
- if (member instanceof FieldDeclaration) {
- isChunkStart = memberAlignment.checkChunkStart(Alignment.CHUNK_FIELD, i, this.scribe.scanner.currentPosition);
- if (member instanceof MultiFieldDeclaration) {
- MultiFieldDeclaration multiField = (MultiFieldDeclaration) member;
-
- if (multiField.isStatic()) {
- format(multiField, this, typeDeclaration.staticInitializerScope, isChunkStart, i == 0);
- } else {
- format(multiField, this, typeDeclaration.initializerScope, isChunkStart, i == 0);
- }
- } else if (member instanceof Initializer) {
- int newLineBeforeChunk = isChunkStart ? this.preferences.blank_lines_before_new_chunk : 0;
- if (newLineBeforeChunk > 0 && i != 0) {
- this.scribe.printEmptyLines(newLineBeforeChunk);
- } else if (i == 0) {
- int newLinesBeforeFirstClassBodyDeclaration = this.preferences.blank_lines_before_first_class_body_declaration;
- if (newLinesBeforeFirstClassBodyDeclaration > 0) {
- this.scribe.printEmptyLines(newLinesBeforeFirstClassBodyDeclaration);
- }
- }
- Initializer initializer = (Initializer) member;
- if (initializer.isStatic()) {
- initializer.traverse(this, typeDeclaration.staticInitializerScope);
- } else {
- initializer.traverse(this, typeDeclaration.initializerScope);
- }
- } else {
- FieldDeclaration field = (FieldDeclaration) member;
- if (field.isStatic()) {
- format(field, this, typeDeclaration.staticInitializerScope, isChunkStart, i == 0);
- } else {
- format(field, this, typeDeclaration.initializerScope, isChunkStart, i == 0);
- }
- }
- } else if (member instanceof AbstractMethodDeclaration) {
- isChunkStart = memberAlignment.checkChunkStart(Alignment.CHUNK_METHOD, i, this.scribe.scanner.currentPosition);
- format((AbstractMethodDeclaration) member, typeDeclaration.scope, isChunkStart, i == 0);
- } else if (member instanceof TypeDeclaration) {
- isChunkStart = memberAlignment.checkChunkStart(Alignment.CHUNK_TYPE, i, this.scribe.scanner.currentPosition);
- format((TypeDeclaration)member, typeDeclaration.scope, isChunkStart, i == 0);
- }
- if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- this.scribe.printNewLine();
- // realign to the proper value
- if (this.scribe.memberAlignment != null) {
- // select the last alignment
- this.scribe.indentationLevel = this.scribe.memberAlignment.originalIndentationLevel;
- }
- }
- ok = true;
- } catch(AlignmentException e){
- startIndex = memberAlignment.chunkStartIndex;
- this.scribe.redoMemberAlignment(e);
- }
- } while (!ok);
- this.scribe.printComment();
- this.scribe.exitMemberAlignment(memberAlignment);
- }
-
- private void formatTypeOpeningBraceForEnumConstant(String bracePosition, boolean insertSpaceBeforeBrace, TypeDeclaration typeDeclaration) {
- int fieldCount = (typeDeclaration.fields == null) ? 0 : typeDeclaration.fields.length;
- int methodCount = (typeDeclaration.methods == null) ? 0 : typeDeclaration.methods.length;
- int typeCount = (typeDeclaration.memberTypes == null) ? 0 : typeDeclaration.memberTypes.length;
-
- if (methodCount <= 2) {
- for (int i = 0, max = methodCount; i < max; i++) {
- final AbstractMethodDeclaration abstractMethodDeclaration = typeDeclaration.methods[i];
- if (abstractMethodDeclaration.isDefaultConstructor()) {
- methodCount--;
- } else if (abstractMethodDeclaration.isClinit()) {
- methodCount--;
- }
- }
- }
- final int memberLength = fieldCount + methodCount+typeCount;
-
- boolean insertNewLine = memberLength > 0;
-
- if (!insertNewLine) {
- if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
- insertNewLine = this.preferences.insert_new_line_in_empty_enum_constant;
- }
- }
-
- formatOpeningBrace(bracePosition, insertSpaceBeforeBrace);
-
- if (insertNewLine) {
- this.scribe.printNewLine();
- }
- }
- private void formatTypeOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace, TypeDeclaration typeDeclaration) {
- int fieldCount = (typeDeclaration.fields == null) ? 0 : typeDeclaration.fields.length;
- int methodCount = (typeDeclaration.methods == null) ? 0 : typeDeclaration.methods.length;
- int typeCount = (typeDeclaration.memberTypes == null) ? 0 : typeDeclaration.memberTypes.length;
-
- if (methodCount <= 2) {
- for (int i = 0, max = methodCount; i < max; i++) {
- final AbstractMethodDeclaration abstractMethodDeclaration = typeDeclaration.methods[i];
- if (abstractMethodDeclaration.isDefaultConstructor()) {
- methodCount--;
- } else if (abstractMethodDeclaration.isClinit()) {
- methodCount--;
- }
- }
- }
- final int memberLength = fieldCount + methodCount + typeCount;
-
- boolean insertNewLine = memberLength > 0;
-
- if (!insertNewLine) {
- if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
- insertNewLine = this.preferences.insert_new_line_in_empty_anonymous_type_declaration;
- } else {
- insertNewLine = this.preferences.insert_new_line_in_empty_type_declaration;
- }
- }
-
- formatOpeningBrace(bracePosition, insertSpaceBeforeBrace);
-
- if (insertNewLine) {
- this.scribe.printNewLine();
- }
- }
- private int getDimensions() {
-
- this.localScanner.resetTo(this.scribe.scanner.currentPosition, this.scribe.scannerEndPosition - 1);
- int dimensions = 0;
- int balance = 0;
- try {
- int token;
- loop: while ((token = this.localScanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
- switch(token) {
- case TerminalTokens.TokenNameRBRACKET:
- dimensions++;
- balance--;
- break;
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- case TerminalTokens.TokenNameCOMMENT_LINE :
- break;
- case TerminalTokens.TokenNameLBRACKET :
- balance++;
- break;
- default:
- break loop;
- }
- }
- } catch(InvalidInputException e) {
- // ignore
- }
- if (balance == 0) {
- return dimensions;
- }
- return 0;
- }
-
- private boolean hasComments() {
-
- this.localScanner.resetTo(this.scribe.scanner.startPosition, this.scribe.scannerEndPosition - 1);
- try {
- switch(this.localScanner.getNextToken()) {
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- case TerminalTokens.TokenNameCOMMENT_LINE :
- return true;
- }
- } catch(InvalidInputException e) {
- // ignore
- }
- return false;
- }
-
- private boolean isNextToken(int tokenName) {
- this.localScanner.resetTo(this.scribe.scanner.currentPosition, this.scribe.scannerEndPosition - 1);
- try {
- int token = this.localScanner.getNextToken();
- loop: while(true) {
- switch(token) {
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- case TerminalTokens.TokenNameCOMMENT_LINE :
- token = this.localScanner.getNextToken();
- continue loop;
- default:
- break loop;
- }
- }
- return token == tokenName;
- } catch(InvalidInputException e) {
- // ignore
- }
- return false;
- }
-
- private boolean isClosingGenericToken() {
- this.localScanner.resetTo(this.scribe.scanner.currentPosition, this.scribe.scannerEndPosition - 1);
- try {
- int token = this.localScanner.getNextToken();
- loop: while(true) {
- switch(token) {
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- case TerminalTokens.TokenNameCOMMENT_LINE :
- token = this.localScanner.getNextToken();
- continue loop;
- default:
- break loop;
- }
- }
- switch(token) {
- case TerminalTokens.TokenNameGREATER :
- case TerminalTokens.TokenNameRIGHT_SHIFT :
- case TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT :
- return true;
- }
- } catch(InvalidInputException e) {
- // ignore
- }
- return false;
- }
-
- private boolean isGuardClause(Block block) {
- return !commentStartsBlock(block.sourceStart, block.sourceEnd)
- && block.statements != null
- && block.statements.length == 1
- && (block.statements[0] instanceof ReturnStatement || block.statements[0] instanceof ThrowStatement);
- }
-
- private boolean isMultipleLocalDeclaration(LocalDeclaration localDeclaration) {
-
- if (localDeclaration.declarationSourceStart == this.lastLocalDeclarationSourceStart) return true;
- this.lastLocalDeclarationSourceStart = localDeclaration.declarationSourceStart;
- return false;
- }
-
- private boolean isPartOfMultipleLocalDeclaration() {
- this.localScanner.resetTo(this.scribe.scanner.currentPosition, this.scribe.scannerEndPosition - 1);
- try {
- int token;
- while ((token = this.localScanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
- switch(token) {
- case TerminalTokens.TokenNameCOMMA ://90
- return true;
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- case TerminalTokens.TokenNameCOMMENT_LINE :
- break;
- default:
- return false;
- }
- }
- } catch(InvalidInputException e) {
- // ignore
- }
- return false;
- }
-
- private void manageClosingParenthesizedExpression(Expression expression, int numberOfParens) {
- for (int i = 0; i < numberOfParens; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_parenthesized_expression);
- }
- }
-
- private void manageOpeningParenthesizedExpression(Expression expression, int numberOfParens) {
- for (int i = 0; i < numberOfParens; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_parenthesized_expression);
- if (this.preferences.insert_space_after_opening_paren_in_parenthesized_expression) {
- this.scribe.space();
- }
- }
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.AllocationExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- AllocationExpression allocationExpression,
- BlockScope scope) {
- // 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
-
- final int numberOfParens = (allocationExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(allocationExpression, numberOfParens);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNamenew);
- this.scribe.space();
-
- if (allocationExpression.type!=null)
- allocationExpression.type.traverse(this, scope);
- else
- allocationExpression.member.traverse(this, scope);
-
- if (!allocationExpression.isShort) {
- this.scribe
- .printNextToken(
- TerminalTokens.TokenNameLPAREN,
- this.preferences.insert_space_before_opening_paren_in_method_invocation);
- final Expression[] arguments = allocationExpression.arguments;
- if (arguments != null) {
- if (this.preferences.insert_space_after_opening_paren_in_method_invocation) {
- this.scribe.space();
- }
- int argumentLength = arguments.length;
- Alignment argumentsAlignment = this.scribe
- .createAlignment(
- "allocation",//$NON-NLS-1$
- this.preferences.alignment_for_arguments_in_allocation_expression,
- argumentLength,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(argumentsAlignment);
- boolean ok = false;
- do {
- try {
- for (int i = 0; i < argumentLength; i++) {
- if (i > 0) {
- this.scribe
- .printNextToken(
- TerminalTokens.TokenNameCOMMA,
- this.preferences.insert_space_before_comma_in_allocation_expression);
- this.scribe.printTrailingComment();
- }
- this.scribe.alignFragment(argumentsAlignment, i);
- if (i > 0
- && this.preferences.insert_space_after_comma_in_allocation_expression) {
- this.scribe.space();
- }
- arguments[i].traverse(this, scope);
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(argumentsAlignment, true);
- this.scribe
- .printNextToken(
- TerminalTokens.TokenNameRPAREN,
- this.preferences.insert_space_before_closing_paren_in_method_invocation);
- } else {
- this.scribe
- .printNextToken(
- TerminalTokens.TokenNameRPAREN,
- this.preferences.insert_space_between_empty_parens_in_method_invocation);
- }
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(allocationExpression, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.AND_AND_Expression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- AND_AND_Expression and_and_Expression,
- BlockScope scope) {
-
- return dumpBinaryExpression(and_and_Expression, TerminalTokens.TokenNameAND_AND, scope);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.Argument, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(Argument argument, BlockScope scope) {
-
- if (argument.modifiers != NO_MODIFIERS) {
- this.scribe.printComment();
- this.scribe.printModifiers(this);
- this.scribe.space();
- }
-
- /*
- * Argument type
- */
- if (argument.type != null) {
- argument.type.traverse(this, scope);
- }
-
-// if (argument.isVarArgs()) {
-// this.scribe.printNextToken(TerminalTokens.TokenNameELLIPSIS, this.preferences.insert_space_before_ellipsis);
-// if (this.preferences.insert_space_after_ellipsis) {
-// this.scribe.space();
-// }
-// this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false);
-// } else {
- /*
- * Print the argument name
- */
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false);
-// }
-
-
- /*
- * Check for extra dimensions
- */
- int extraDimensions = getDimensions();
- if (extraDimensions != 0) {
- for (int i = 0; i < extraDimensions; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
- }
- }
-
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ArrayAllocationExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- ArrayAllocationExpression arrayAllocationExpression,
- BlockScope scope) {
-
- final int numberOfParens = (arrayAllocationExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(arrayAllocationExpression, numberOfParens);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNamenew);
- this.scribe.space();
- arrayAllocationExpression.type.traverse(this, scope);
-
- final Expression[] dimensions = arrayAllocationExpression.dimensions;
- int dimensionsLength = dimensions.length;
- for (int i = 0; i < dimensionsLength; i++) {
- if (this.preferences.insert_space_before_opening_bracket_in_array_allocation_expression) {
- this.scribe.space();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET, false);
- if (dimensions[i] != null) {
- if (this.preferences.insert_space_after_opening_bracket_in_array_allocation_expression) {
- this.scribe.space();
- }
- dimensions[i].traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET, this.preferences.insert_space_before_closing_bracket_in_array_allocation_expression);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET, this.preferences.insert_space_between_empty_brackets_in_array_allocation_expression);
- }
- }
- final ArrayInitializer initializer = arrayAllocationExpression.initializer;
- if (initializer != null) {
- initializer.traverse(this, scope);
- }
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(arrayAllocationExpression, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ArrayInitializer, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(ArrayInitializer arrayInitializer, BlockScope scope) { final int numberOfParens = (arrayInitializer.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(arrayInitializer, numberOfParens);
- }
-
- final Expression[] expressions = arrayInitializer.expressions;
- if (expressions != null) {
- String array_initializer_brace_position = this.preferences.brace_position_for_array_initializer;
- formatOpeningBracket(array_initializer_brace_position, this.preferences.insert_space_before_opening_brace_in_array_initializer);
-
- int expressionsLength = expressions.length;
- final boolean insert_new_line_after_opening_brace = this.preferences.insert_new_line_after_opening_brace_in_array_initializer;
- if (expressionsLength > 1) {
- if (insert_new_line_after_opening_brace) {
- this.scribe.printNewLine();
- }
- Alignment arrayInitializerAlignment =this.scribe.createAlignment(
- "array_initializer",//$NON-NLS-1$
- this.preferences.alignment_for_expressions_in_array_initializer,
- Alignment.R_OUTERMOST,
- expressionsLength,
- this.scribe.scanner.currentPosition,
- this.preferences.continuation_indentation_for_array_initializer,
- true);
-
- if (insert_new_line_after_opening_brace) {
- arrayInitializerAlignment.fragmentIndentations[0] = arrayInitializerAlignment.breakIndentationLevel;
- }
-
- this.scribe.enterAlignment(arrayInitializerAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(arrayInitializerAlignment, 0);
- if (this.preferences.insert_space_after_opening_brace_in_array_initializer) {
- this.scribe.space();
- }
- expressions[0].traverse(this, scope);
- for (int i = 1; i < expressionsLength; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer);
- this.scribe.printTrailingComment();
- this.scribe.alignFragment(arrayInitializerAlignment, i);
- if (this.preferences.insert_space_after_comma_in_array_initializer) {
- this.scribe.space();
- }
- expressions[i].traverse(this, scope);
- if (i == expressionsLength - 1) {
- if (isNextToken(TerminalTokens.TokenNameCOMMA)) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer);
- this.scribe.printTrailingComment();
- }
- }
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(arrayInitializerAlignment, true);
- } else {
- if (insert_new_line_after_opening_brace) {
- this.scribe.printNewLine();
- this.scribe.indent();
- }
- // we don't need to use an alignment
- if (this.preferences.insert_space_after_opening_brace_in_array_initializer) {
- this.scribe.space();
- } else {
- this.scribe.needSpace = false;
- }
- expressions[0].traverse(this, scope);
- if (isNextToken(TerminalTokens.TokenNameCOMMA)) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer);
- this.scribe.printTrailingComment();
- }
- if (insert_new_line_after_opening_brace) {
- this.scribe.unIndent();
- }
- }
- if (this.preferences.insert_new_line_before_closing_brace_in_array_initializer) {
- this.scribe.printNewLine();
- } else if (this.preferences.insert_space_before_closing_brace_in_array_initializer) {
- this.scribe.space();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET, false);
- if (array_initializer_brace_position.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- } else {
- boolean keepEmptyArrayInitializerOnTheSameLine = this.preferences.keep_empty_array_initializer_on_one_line;
- String array_initializer_brace_position = this.preferences.brace_position_for_array_initializer;
- if (keepEmptyArrayInitializerOnTheSameLine) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET, this.preferences.insert_space_before_opening_brace_in_array_initializer);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET, this.preferences.insert_space_between_empty_braces_in_array_initializer);
- } else {
- formatOpeningBracket(array_initializer_brace_position, this.preferences.insert_space_before_opening_brace_in_array_initializer);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET, false);
- if (array_initializer_brace_position.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- }
- }
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(arrayInitializer, numberOfParens);
- }
- return false;
- }
-
- public boolean visit(ObjectLiteral objectLiteral, BlockScope scope) {
- final int numberOfParens = (objectLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(objectLiteral, numberOfParens);
- }
-
- final ObjectLiteralField[] expressions = objectLiteral.fields;
- if (expressions != null) {
- String objlit_initializer_brace_position = this.preferences.brace_position_for_objlit_initializer;
- formatOpeningBrace(objlit_initializer_brace_position, this.preferences.insert_space_before_opening_brace_in_array_initializer);
-
- int expressionsLength = expressions.length;
- final boolean insert_new_line_after_opening_brace = this.preferences.insert_new_line_after_opening_brace_in_objlit_initializer;
- if (expressionsLength > 1) {
- if (insert_new_line_after_opening_brace) {
- this.scribe.printNewLine();
- }
- Alignment objlitInitializerAlignment =this.scribe.createAlignment(
- "objlit_initializer",//$NON-NLS-1$
- this.preferences.alignment_for_expressions_in_array_initializer,
- Alignment.R_OUTERMOST,
- expressionsLength,
- this.scribe.scanner.currentPosition,
- this.preferences.continuation_indentation_for_objlit_initializer,
- true);
-
- if (insert_new_line_after_opening_brace) {
- objlitInitializerAlignment.fragmentIndentations[0] = objlitInitializerAlignment.breakIndentationLevel;
- }
-
- this.scribe.enterAlignment(objlitInitializerAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(objlitInitializerAlignment, 0);
- if (this.preferences.insert_space_after_opening_brace_in_array_initializer) {
- this.scribe.space();
- }
- expressions[0].traverse(this, scope);
- for (int i = 1; i < expressionsLength; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer);
- this.scribe.printTrailingComment();
- this.scribe.alignFragment(objlitInitializerAlignment, i);
- if (this.preferences.insert_space_after_comma_in_array_initializer) {
- this.scribe.space();
- }
-
- if (this.preferences.insert_new_line_after_comma_in_objlit_initializer) {
- this.scribe.printNewLine();
- }
-
-
- expressions[i].traverse(this, scope);
-
- if (i == expressionsLength - 1) {
- if (isNextToken(TerminalTokens.TokenNameCOMMA)) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer);
- this.scribe.printTrailingComment();
- }
- }
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(objlitInitializerAlignment, true);
- } else {
- if (insert_new_line_after_opening_brace) {
- this.scribe.printNewLine();
- this.scribe.indent();
- }
- // we don't need to use an alignment
- if (this.preferences.insert_space_after_opening_brace_in_array_initializer) {
- this.scribe.space();
- } else {
- this.scribe.needSpace = false;
- }
- expressions[0].traverse(this, scope);
- if (isNextToken(TerminalTokens.TokenNameCOMMA)) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_array_initializer);
- this.scribe.printTrailingComment();
- }
- if (insert_new_line_after_opening_brace) {
- this.scribe.unIndent();
- }
- }
- if (this.preferences.insert_new_line_before_closing_brace_in_objlit_initializer) {
- this.scribe.printNewLine();
- } else if (this.preferences.insert_space_before_closing_brace_in_array_initializer) {
- this.scribe.space();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, false);
- if (objlit_initializer_brace_position.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- } else {
- boolean keepEmptyObjLitInitializerOnTheSameLine = this.preferences.keep_empty_objlit_initializer_on_one_line;
- String objlit_initializer_brace_position = this.preferences.brace_position_for_objlit_initializer;
- if (keepEmptyObjLitInitializerOnTheSameLine) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, this.preferences.insert_space_before_opening_brace_in_array_initializer);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, this.preferences.insert_space_between_empty_braces_in_array_initializer);
- } else {
- formatOpeningBrace(objlit_initializer_brace_position, this.preferences.insert_space_before_opening_brace_in_array_initializer);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, false);
- if (objlit_initializer_brace_position.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- }
- }
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(objectLiteral, numberOfParens);
- }
- return false;
-}
-
- public boolean visit(ObjectLiteralField literalField,BlockScope scope)
- {
- literalField.fieldName.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_object_initializer);
- if(this.preferences.insert_space_after_colon_in_object_initializer) {
- this.scribe.space();
- }
- literalField.initializer.traverse(this, scope);
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ArrayQualifiedTypeReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- ArrayQualifiedTypeReference arrayQualifiedTypeReference,
- BlockScope scope) {
-
- final int numberOfParens = (arrayQualifiedTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(arrayQualifiedTypeReference, numberOfParens);
- }
- this.scribe.printArrayQualifiedReference(arrayQualifiedTypeReference.tokens.length, arrayQualifiedTypeReference.sourceEnd);
- int dimensions = getDimensions();
- if (dimensions != 0) {
- for (int i = 0; i < dimensions; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
- }
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(arrayQualifiedTypeReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ArrayQualifiedTypeReference, org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope)
- */
- public boolean visit(
- ArrayQualifiedTypeReference arrayQualifiedTypeReference,
- ClassScope scope) {
-
- final int numberOfParens = (arrayQualifiedTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(arrayQualifiedTypeReference, numberOfParens);
- }
- this.scribe.printArrayQualifiedReference(arrayQualifiedTypeReference.tokens.length, arrayQualifiedTypeReference.sourceEnd);
- int dimensions = getDimensions();
- if (dimensions != 0) {
- for (int i = 0; i < dimensions; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
- }
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(arrayQualifiedTypeReference, numberOfParens);
- }
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ArrayReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(ArrayReference arrayReference, BlockScope scope) {
-
- final int numberOfParens = (arrayReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(arrayReference, numberOfParens);
- }
- arrayReference.receiver.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET, this.preferences.insert_space_before_opening_bracket_in_array_reference);
- if (this.preferences.insert_space_after_opening_bracket_in_array_reference) {
- this.scribe.space();
- }
- arrayReference.position.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET, this.preferences.insert_space_before_closing_bracket_in_array_reference);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(arrayReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ArrayTypeReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- ArrayTypeReference arrayTypeReference,
- BlockScope scope) {
-
- final int numberOfParens = (arrayTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(arrayTypeReference, numberOfParens);
- }
- this.scribe.printNextToken(SINGLETYPEREFERENCE_EXPECTEDTOKENS);
-
- int dimensions = getDimensions();
- if (dimensions != 0) {
- if (this.preferences.insert_space_before_opening_bracket_in_array_type_reference) {
- this.scribe.space();
- }
- for (int i = 0; i < dimensions; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
- if (this.preferences.insert_space_between_brackets_in_array_type_reference) {
- this.scribe.space();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
- }
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(arrayTypeReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ArrayTypeReference, org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope)
- */
- public boolean visit(
- ArrayTypeReference arrayTypeReference,
- ClassScope scope) {
-
- final int numberOfParens = (arrayTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(arrayTypeReference, numberOfParens);
- }
- this.scribe.printNextToken(SINGLETYPEREFERENCE_EXPECTEDTOKENS);
- int dimensions = getDimensions();
- if (dimensions != 0) {
- if (this.preferences.insert_space_before_opening_bracket_in_array_type_reference) {
- this.scribe.space();
- }
- for (int i = 0; i < dimensions; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
- if (this.preferences.insert_space_between_brackets_in_array_type_reference) {
- this.scribe.space();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
- }
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(arrayTypeReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.AssertStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
-// public boolean visit(AssertStatement assertStatement, BlockScope scope) {
-//
-// this.scribe.printNextToken(TerminalTokens.TokenNameassert);
-// this.scribe.space();
-// assertStatement.assertExpression.traverse(this, scope);
-//
-// if (assertStatement.exceptionArgument != null) {
-// this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_assert);
-// if (this.preferences.insert_space_after_colon_in_assert) {
-// this.scribe.space();
-// }
-// assertStatement.exceptionArgument.traverse(this, scope);
-// }
-// this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
-// this.scribe.printTrailingComment();
-// return false;
-// }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.Assignment, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(Assignment assignment, BlockScope scope) {
-
- final int numberOfParens = (assignment.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(assignment, numberOfParens);
- }
- assignment.lhs.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameEQUAL, this.preferences.insert_space_before_assignment_operator);
- if (this.preferences.insert_space_after_assignment_operator) {
- this.scribe.space();
- }
-
- Alignment assignmentAlignment = this.scribe.createAlignment("assignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_OUTERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$
- this.scribe.enterAlignment(assignmentAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(assignmentAlignment, 0);
- assignment.expression.traverse(this, scope);
- ok = true;
- } catch(AlignmentException e){
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(assignmentAlignment, true);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(assignment, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.BinaryExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(BinaryExpression binaryExpression, BlockScope scope) {
-
- switch((binaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT) {
- case OperatorIds.AND :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameAND, scope);
- case OperatorIds.DIVIDE :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameDIVIDE, scope);
- case OperatorIds.GREATER :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameGREATER, scope);
- case OperatorIds.GREATER_EQUAL :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameGREATER_EQUAL, scope);
- case OperatorIds.LEFT_SHIFT :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameLEFT_SHIFT, scope);
- case OperatorIds.LESS :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameLESS, scope);
- case OperatorIds.LESS_EQUAL :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameLESS_EQUAL, scope);
- case OperatorIds.MINUS :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameMINUS, scope);
- case OperatorIds.MULTIPLY :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameMULTIPLY, scope);
- case OperatorIds.OR :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameOR, scope);
- case OperatorIds.PLUS :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNamePLUS, scope);
- case OperatorIds.REMAINDER :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameREMAINDER, scope);
- case OperatorIds.RIGHT_SHIFT :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameRIGHT_SHIFT, scope);
- case OperatorIds.UNSIGNED_RIGHT_SHIFT :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT, scope);
- case OperatorIds.XOR :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameXOR, scope);
- case OperatorIds.INSTANCEOF :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNameinstanceof, scope);
- case OperatorIds.IN :
- return dumpBinaryExpression(binaryExpression, TerminalTokens.TokenNamein, scope);
- default:
- throw new IllegalStateException();
- }
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.Block, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(Block block, BlockScope scope) {
- formatBlock(block, scope, this.preferences.brace_position_for_block, this.preferences.insert_space_before_opening_brace_in_block);
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.BreakStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(BreakStatement breakStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNamebreak);
- if (breakStatement.label != null) {
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
- }
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.CaseStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(CaseStatement caseStatement, BlockScope scope) {
- if (caseStatement.constantExpression == null) {
- this.scribe.printNextToken(TerminalTokens.TokenNamedefault);
- this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_default);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNamecase);
- this.scribe.space();
- caseStatement.constantExpression.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_case);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ClassLiteralAccess, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(ClassLiteralAccess classLiteral, BlockScope scope) {
-
- final int numberOfParens = (classLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(classLiteral, numberOfParens);
- }
- classLiteral.type.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
- this.scribe.printNextToken(TerminalTokens.TokenNameclass);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(classLiteral, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.Clinit, org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope)
- */
- public boolean visit(Clinit clinit, ClassScope scope) {
-
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration, org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope)
- */
- public boolean visit(
- CompilationUnitDeclaration compilationUnitDeclaration,
- CompilationUnitScope scope) {
-
- // fake new line to handle empty lines before package declaration or import declarations
- this.scribe.lastNumberOfNewLines = 1;
- /*
- * Package declaration
- */
- final boolean hasPackage = compilationUnitDeclaration.currentPackage != null;
- if (hasPackage) {
- if (hasComments()) {
- this.scribe.printComment();
- }
- int blankLinesBeforePackage = this.preferences.blank_lines_before_package;
- if (blankLinesBeforePackage > 0) {
- this.scribe.printEmptyLines(blankLinesBeforePackage);
- }
-
- this.scribe.space();
- // dump the package keyword
- this.scribe.printNextToken(TerminalTokens.TokenNamepackage);
- this.scribe.space();
- this.scribe.printQualifiedReference(compilationUnitDeclaration.currentPackage.sourceEnd);
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- int blankLinesAfterPackage = this.preferences.blank_lines_after_package;
- if (blankLinesAfterPackage > 0) {
- this.scribe.printEmptyLines(blankLinesAfterPackage);
- } else {
- this.scribe.printNewLine();
- }
- } else {
- this.scribe.printComment();
- }
-
- /*
- * Import statements
- */
- final ImportReference[] imports = compilationUnitDeclaration.imports;
- if (imports != null) {
- if (hasPackage) {
- int blankLinesBeforeImports = this.preferences.blank_lines_before_imports;
- if (blankLinesBeforeImports > 0) {
- this.scribe.printEmptyLines(blankLinesBeforeImports);
- }
- }
- int importLength = imports.length;
- int savedNumberOfLineToPreserve = this.preferences.number_of_empty_lines_to_preserve;
- if (importLength != 1) {
- format(imports[0], false);
- for (int i = 1; i < importLength - 1; i++) {
- format(imports[i], false);
- }
- format(imports[importLength - 1], true);
- this.preferences.number_of_empty_lines_to_preserve = savedNumberOfLineToPreserve;
- } else {
- format(imports[0], true);
- }
- this.preferences.number_of_empty_lines_to_preserve = savedNumberOfLineToPreserve;
-
- int blankLinesAfterImports = this.preferences.blank_lines_after_imports;
- if (blankLinesAfterImports > 0) {
- this.scribe.printEmptyLines(blankLinesAfterImports);
- }
- }
-
- formatEmptyTypeDeclaration(true);
-
- int blankLineBetweenTypeDeclarations = this.preferences.blank_lines_between_type_declarations;
-// /*
-// * Type declarations
-// */
-// final TypeDeclaration[] types = compilationUnitDeclaration.types;
-// if (types != null) {
-// int typesLength = types.length;
-// for (int i = 0; i < typesLength - 1; i++) {
-// types[i].traverse(this, scope);
-// formatEmptyTypeDeclaration(false);
-// if (blankLineBetweenTypeDeclarations != 0) {
-// this.scribe.printEmptyLines(blankLineBetweenTypeDeclarations);
-// } else {
-// this.scribe.printNewLine();
-// }
-// }
-// types[typesLength - 1].traverse(this, scope);
-// }
-//
- final ProgramElement[] statements = compilationUnitDeclaration.statements;
- if (statements != null && statements.length>0) {
- int statementsLength = statements.length;
- for (int i = 0; i < statementsLength - 1; i++) {
- statements[i].traverse(this, scope);
- formatEmptyTypeDeclaration(false);
- if (blankLineBetweenTypeDeclarations != 0) {
- this.scribe.printEmptyLines(blankLineBetweenTypeDeclarations);
- } else {
- this.scribe.printNewLine();
- }
- }
- statements[statementsLength - 1].traverse(this, scope);
- }
-
-
- this.scribe.printEndOfCompilationUnit();
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.CompoundAssignment, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- CompoundAssignment compoundAssignment,
- BlockScope scope) {
-
- final int numberOfParens = (compoundAssignment.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(compoundAssignment, numberOfParens);
- }
- compoundAssignment.lhs.traverse(this, scope);
-
- /*
- * Print the operator
- */
- int operator;
- switch(compoundAssignment.operator) {
- case OperatorIds.PLUS :
- operator = TerminalTokens.TokenNamePLUS_EQUAL;
- break;
- case OperatorIds.MINUS :
- operator = TerminalTokens.TokenNameMINUS_EQUAL;
- break;
- case OperatorIds.MULTIPLY :
- operator = TerminalTokens.TokenNameMULTIPLY_EQUAL;
- break;
- case OperatorIds.DIVIDE :
- operator = TerminalTokens.TokenNameDIVIDE_EQUAL;
- break;
- case OperatorIds.AND :
- operator = TerminalTokens.TokenNameAND_EQUAL;
- break;
- case OperatorIds.OR :
- operator = TerminalTokens.TokenNameOR_EQUAL;
- break;
- case OperatorIds.XOR :
- operator = TerminalTokens.TokenNameXOR_EQUAL;
- break;
- case OperatorIds.REMAINDER :
- operator = TerminalTokens.TokenNameREMAINDER_EQUAL;
- break;
- case OperatorIds.LEFT_SHIFT :
- operator = TerminalTokens.TokenNameLEFT_SHIFT_EQUAL;
- break;
- case OperatorIds.RIGHT_SHIFT :
- operator = TerminalTokens.TokenNameRIGHT_SHIFT_EQUAL;
- break;
- default: // OperatorIds.UNSIGNED_RIGHT_SHIFT :
- operator = TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL;
- }
-
- this.scribe.printNextToken(operator, this.preferences.insert_space_before_assignment_operator);
- if (this.preferences.insert_space_after_assignment_operator) {
- this.scribe.space();
- }
- Alignment assignmentAlignment = this.scribe.createAlignment("compoundAssignmentAlignment", this.preferences.alignment_for_assignment, Alignment.R_OUTERMOST, 1, this.scribe.scanner.currentPosition); //$NON-NLS-1$
- this.scribe.enterAlignment(assignmentAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(assignmentAlignment, 0);
- compoundAssignment.expression.traverse(this, scope);
- ok = true;
- } catch(AlignmentException e){
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(assignmentAlignment, true);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(compoundAssignment, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ConditionalExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- ConditionalExpression conditionalExpression,
- BlockScope scope) {
-
- final int numberOfParens = (conditionalExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(conditionalExpression, numberOfParens);
- }
- conditionalExpression.condition.traverse(this, scope);
-
- Alignment conditionalExpressionAlignment =this.scribe.createAlignment(
- "conditionalExpression", //$NON-NLS-1$
- this.preferences.alignment_for_conditional_expression,
- 2,
- this.scribe.scanner.currentPosition);
-
- this.scribe.enterAlignment(conditionalExpressionAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(conditionalExpressionAlignment, 0);
- this.scribe.printNextToken(TerminalTokens.TokenNameQUESTION, this.preferences.insert_space_before_question_in_conditional);
-
- if (this.preferences.insert_space_after_question_in_conditional) {
- this.scribe.space();
- }
- conditionalExpression.valueIfTrue.traverse(this, scope);
- this.scribe.printTrailingComment();
- this.scribe.alignFragment(conditionalExpressionAlignment, 1);
- this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_conditional);
-
- if (this.preferences.insert_space_after_colon_in_conditional) {
- this.scribe.space();
- }
- conditionalExpression.valueIfFalse.traverse(this, scope);
-
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(conditionalExpressionAlignment, true);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(conditionalExpression, numberOfParens);
- }
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ConstructorDeclaration, org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope)
- */
- public boolean visit(
- ConstructorDeclaration constructorDeclaration,
- ClassScope scope) {
-
- if (constructorDeclaration.ignoreFurtherInvestigation) {
- this.scribe.printComment();
- if (this.scribe.indentationLevel != 0) {
- this.scribe.printIndentationIfNecessary();
- }
- this.scribe.scanner.resetTo(constructorDeclaration.declarationSourceEnd + 1, this.scribe.scannerEndPosition - 1);
- this.scribe.printTrailingComment();
- switch(this.scribe.scanner.source[this.scribe.scanner.currentPosition]) {
- case '\n' :
- this.scribe.scanner.currentPosition++;
- this.scribe.lastNumberOfNewLines = 1;
- break;
- case '\r' :
- this.scribe.scanner.currentPosition++;
- if (this.scribe.scanner.source[this.scribe.scanner.currentPosition] == '\n') {
- this.scribe.scanner.currentPosition++;
- }
- this.scribe.lastNumberOfNewLines = 1;
- }
- return false;
- }
- /*
- * Print comments to get proper line number
- */
- this.scribe.printComment();
- int line = this.scribe.line;
- this.scribe.printModifiers(this);
- if (this.scribe.line > line) {
- // annotations introduced new line, but this is not a line wrapping
- // see 158267
- line = this.scribe.line;
- }
- this.scribe.space();
-
- /*
- * Print the method name
- */
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
-
- formatMethodArguments(
- constructorDeclaration,
- this.preferences.insert_space_before_opening_paren_in_constructor_declaration,
- this.preferences.insert_space_between_empty_parens_in_constructor_declaration,
- this.preferences.insert_space_before_closing_paren_in_constructor_declaration,
- this.preferences.insert_space_after_opening_paren_in_constructor_declaration,
- this.preferences.insert_space_before_comma_in_constructor_declaration_parameters,
- this.preferences.insert_space_after_comma_in_constructor_declaration_parameters,
- this.preferences.alignment_for_parameters_in_constructor_declaration);
-
- if (!constructorDeclaration.isAbstract()) {
- /*
- * Method body
- */
- String constructor_declaration_brace = this.preferences.brace_position_for_constructor_declaration;
- formatLeftCurlyBrace(line, constructor_declaration_brace);
- formatOpeningBrace(constructor_declaration_brace, this.preferences.insert_space_before_opening_brace_in_constructor_declaration);
- final int numberOfBlankLinesAtBeginningOfMethodBody = this.preferences.blank_lines_at_beginning_of_method_body;
- if (numberOfBlankLinesAtBeginningOfMethodBody > 0) {
- this.scribe.printEmptyLines(numberOfBlankLinesAtBeginningOfMethodBody);
- }
- if (constructorDeclaration.constructorCall != null && !constructorDeclaration.constructorCall.isImplicitSuper()) {
- this.scribe.printNewLine();
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.indent();
- }
- constructorDeclaration.constructorCall.traverse(this, constructorDeclaration.scope);
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.unIndent();
- }
- }
- final Statement[] statements = constructorDeclaration.statements;
- if (statements != null) {
- this.scribe.printNewLine();
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.indent();
- }
- formatStatements(constructorDeclaration.scope, statements, true);
- this.scribe.printComment();
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.unIndent();
- }
- } else if (this.preferences.insert_new_line_in_empty_method_body) {
- this.scribe.printNewLine();
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.indent();
- }
- this.scribe.printComment();
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.unIndent();
- }
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
- this.scribe.printTrailingComment();
- if (constructor_declaration_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- } else {
- // no method body
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ContinueStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(ContinueStatement continueStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNamecontinue);
- if (continueStatement.label != null) {
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
- }
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.DoStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(DoStatement doStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNamedo);
- final int line = this.scribe.line;
-
- final Statement action = doStatement.action;
- if (action != null) {
- if (action instanceof Block) {
- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
- action.traverse(this, scope);
- } else if (action instanceof EmptyStatement) {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- } else {
- this.scribe.printNewLine();
- this.scribe.indent();
- action.traverse(this, scope);
- if (action instanceof Expression || action instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- this.scribe.printNewLine();
- this.scribe.unIndent();
- }
- } else {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- }
-
- if (this.preferences.insert_new_line_before_while_in_do_statement) {
- this.scribe.printNewLine();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNamewhile, this.preferences.insert_space_after_closing_brace_in_block);
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_while);
-
- if (this.preferences.insert_space_after_opening_paren_in_while) {
- this.scribe.space();
- }
-
- doStatement.condition.traverse(this, scope);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while);
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.DoubleLiteral, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(DoubleLiteral doubleLiteral, BlockScope scope) {
-
- final int numberOfParens = (doubleLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(doubleLiteral, numberOfParens);
- }
- Constant constant = doubleLiteral.constant;
- if (constant != null && constant.doubleValue() < 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameMINUS);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameDoubleLiteral);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(doubleLiteral, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.EmptyStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(EmptyStatement statement, BlockScope scope) {
- if (this.preferences.put_empty_statement_on_new_line) {
- this.scribe.printNewLine();
- }
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- return false;
- }
- // field is an enum constant
- public boolean visit(FieldDeclaration enumConstant, MethodScope scope) {
- /*
- * Print comments to get proper line number
- */
- this.scribe.printComment();
- final int line = this.scribe.line;
-
- this.scribe.printModifiers(this);
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false);
- formatEnumConstantArguments(
- enumConstant,
- this.preferences.insert_space_before_opening_paren_in_enum_constant,
- this.preferences.insert_space_between_empty_parens_in_enum_constant,
- this.preferences.insert_space_before_closing_paren_in_enum_constant,
- this.preferences.insert_space_after_opening_paren_in_enum_constant,
- this.preferences.insert_space_before_comma_in_enum_constant_arguments,
- this.preferences.insert_space_after_comma_in_enum_constant_arguments,
- this.preferences.alignment_for_arguments_in_enum_constant);
-
- Expression initialization = enumConstant.initialization;
- if (initialization instanceof QualifiedAllocationExpression) {
- TypeDeclaration typeDeclaration = ((QualifiedAllocationExpression) initialization).anonymousType;
- int fieldsCount = typeDeclaration.fields == null ? 0 : typeDeclaration.fields.length;
- int methodsCount = typeDeclaration.methods == null ? 0 : typeDeclaration.methods.length;
- int membersCount = typeDeclaration.memberTypes == null ? 0 : typeDeclaration.memberTypes.length;
-
- /*
- * Type body
- */
- String enum_constant_brace = this.preferences.brace_position_for_enum_constant;
-
- formatLeftCurlyBrace(line, enum_constant_brace);
- formatTypeOpeningBraceForEnumConstant(enum_constant_brace, this.preferences.insert_space_before_opening_brace_in_enum_constant, typeDeclaration);
-
- if (this.preferences.indent_body_declarations_compare_to_enum_constant_header) {
- this.scribe.indent();
- }
-
- if (fieldsCount != 0 || methodsCount != 0 || membersCount != 0) {
- formatTypeMembers(typeDeclaration);
- }
-
- if (this.preferences.indent_body_declarations_compare_to_enum_constant_header) {
- this.scribe.unIndent();
- }
-
- if (this.preferences.insert_new_line_in_empty_enum_constant) {
- this.scribe.printNewLine();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
- this.scribe.printTrailingComment();
- if (enum_constant_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- if (hasComments()) {
- this.scribe.printNewLine();
- }
- }
- return false;
- }
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.EqualExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(EqualExpression equalExpression, BlockScope scope) {
-
- int operator = (equalExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT;
- if (operator == OperatorIds.EQUAL_EQUAL) {
- return dumpEqualityExpression(equalExpression, TerminalTokens.TokenNameEQUAL_EQUAL, scope);
- } if (operator == OperatorIds.NOT_EQUAL) {
- return dumpEqualityExpression(equalExpression, TerminalTokens.TokenNameNOT_EQUAL, scope);
- } if (operator == OperatorIds.EQUAL_EQUAL_EQUAL) {
- return dumpEqualityExpression(equalExpression, TerminalTokens.TokenNameEQUAL_EQUAL_EQUAL, scope);
-
- }else {
- return dumpEqualityExpression(equalExpression, TerminalTokens.TokenNameNOT_EQUAL_EQUAL, scope);
- }
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ExplicitConstructorCall, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- ExplicitConstructorCall explicitConstructor,
- BlockScope scope) {
-
- if (explicitConstructor.isImplicitSuper()) {
- return false;
- }
- final Expression qualification = explicitConstructor.qualification;
- if (qualification != null) {
- qualification.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
- }
-
- TypeReference[] typeArguments = explicitConstructor.typeArguments;
- if (typeArguments != null) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_type_arguments);
- if (this.preferences.insert_space_after_opening_angle_bracket_in_type_arguments) {
- this.scribe.space();
- }
- int length = typeArguments.length;
- for (int i = 0; i < length - 1; i++) {
- typeArguments[i].traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_type_arguments);
- if (this.preferences.insert_space_after_comma_in_type_arguments) {
- this.scribe.space();
- }
- }
- typeArguments[length - 1].traverse(this, scope);
- if (isClosingGenericToken()) {
- this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS, this.preferences.insert_space_before_closing_angle_bracket_in_type_arguments);
- }
- if (this.preferences.insert_space_after_closing_angle_bracket_in_type_arguments) {
- this.scribe.space();
- }
- }
-
- if (explicitConstructor.isSuperAccess()) {
- this.scribe.printNextToken(TerminalTokens.TokenNamesuper);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNamethis);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_method_invocation);
-
- final Expression[] arguments = explicitConstructor.arguments;
- if (arguments != null) {
- if (this.preferences.insert_space_after_opening_paren_in_method_invocation) {
- this.scribe.space();
- }
- int argumentLength = arguments.length;
- Alignment argumentsAlignment =this.scribe.createAlignment(
- "explicit_constructor_call",//$NON-NLS-1$
- this.preferences.alignment_for_arguments_in_explicit_constructor_call,
- argumentLength,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(argumentsAlignment);
- boolean ok = false;
- do {
- try {
- for (int i = 0; i < argumentLength; i++) {
- if (i > 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_explicit_constructor_call_arguments);
- this.scribe.printTrailingComment();
- }
- this.scribe.alignFragment(argumentsAlignment, i);
- if (i > 0 && this.preferences.insert_space_after_comma_in_explicit_constructor_call_arguments) {
- this.scribe.space();
- }
- arguments[i].traverse(this, scope);
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(argumentsAlignment, true);
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_method_invocation);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_between_empty_parens_in_method_invocation);
- }
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- return false;
- }
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.FalseLiteral, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(FalseLiteral falseLiteral, BlockScope scope) {
-
- final int numberOfParens = (falseLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(falseLiteral, numberOfParens);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNamefalse);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(falseLiteral, numberOfParens);
- }
- return false;
- }
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.FieldReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(FieldReference fieldReference, BlockScope scope) {
-
- final int numberOfParens = (fieldReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(fieldReference, numberOfParens);
- }
- fieldReference.receiver.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(fieldReference, numberOfParens);
- }
- return false;
- }
-
- public boolean visit(ForeachStatement forStatement, BlockScope scope) {
- this.scribe.printNextToken(TerminalTokens.TokenNamefor);
- final int line = this.scribe.line;
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_for);
-
- if (this.preferences.insert_space_after_opening_paren_in_for) {
- this.scribe.space();
- }
- formatLocalDeclaration(forStatement.elementVariable, scope, false, false);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_for);
- if (this.preferences.insert_space_after_colon_in_for) {
- this.scribe.space();
- }
- forStatement.collection.traverse(this, scope);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_for);
-
- final Statement action = forStatement.action;
- if (action != null) {
- if (action instanceof Block) {
- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
- action.traverse(this, scope);
- } else if (action instanceof EmptyStatement) {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- } else {
- this.scribe.indent();
- this.scribe.printNewLine();
- action.traverse(this, scope);
- this.scribe.unIndent();
- }
- if (action instanceof Expression || action instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- } else {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- }
- return false;
- }
-
- public boolean visit(ForInStatement forStatement, BlockScope scope) {
- this.scribe.printNextToken(TerminalTokens.TokenNamefor);
- final int line = this.scribe.line;
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_for);
-
- if (this.preferences.insert_space_after_opening_paren_in_for) {
- this.scribe.space();
- }
- forStatement.iterationVariable.traverse(this, scope);
-
- this.scribe.printNextToken(TerminalTokens.TokenNamein, this.preferences.insert_space_before_colon_in_for);
- if (this.preferences.insert_space_after_colon_in_for) {
- this.scribe.space();
- }
- forStatement.collection.traverse(this, scope);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_for);
-
- final Statement action = forStatement.action;
- if (action != null) {
- if (action instanceof Block) {
- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
- action.traverse(this, scope);
- } else if (action instanceof EmptyStatement) {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- } else {
- this.scribe.indent();
- this.scribe.printNewLine();
- action.traverse(this, scope);
- this.scribe.unIndent();
- }
- if (action instanceof Expression || action instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- } else {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- }
- return false;
- }
-
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(ForStatement forStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNamefor);
- final int line = this.scribe.line;
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_for);
-
- if (this.preferences.insert_space_after_opening_paren_in_for) {
- this.scribe.space();
- }
- final Statement[] initializations = forStatement.initializations;
- if (initializations != null) {
- int length = initializations.length;
- for (int i = 0; i < length; i++) {
- if (initializations[i] instanceof LocalDeclaration) {
- formatLocalDeclaration((LocalDeclaration) initializations[i], scope, this.preferences.insert_space_before_comma_in_for_inits, this.preferences.insert_space_after_comma_in_for_inits);
- } else {
- initializations[i].traverse(this, scope);
- if (i >= 0 && (i < length - 1)) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_for_inits);
- if (this.preferences.insert_space_after_comma_in_for_inits) {
- this.scribe.space();
- }
- this.scribe.printTrailingComment();
- }
- }
- }
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon_in_for);
- final Expression condition = forStatement.condition;
- if (condition != null) {
- if (this.preferences.insert_space_after_semicolon_in_for) {
- this.scribe.space();
- }
- condition.traverse(this, scope);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon_in_for);
- final Statement[] increments = forStatement.increments;
- if (increments != null) {
- if (this.preferences.insert_space_after_semicolon_in_for) {
- this.scribe.space();
- }
- for (int i = 0, length = increments.length; i < length; i++) {
- increments[i].traverse(this, scope);
- if (i != length - 1) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_for_increments);
- if (this.preferences.insert_space_after_comma_in_for_increments) {
- this.scribe.space();
- }
- this.scribe.printTrailingComment();
- }
- }
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_for);
-
- final Statement action = forStatement.action;
- if (action != null) {
- if (action instanceof Block) {
- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
- action.traverse(this, scope);
- } else if (action instanceof EmptyStatement) {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- } else {
- this.scribe.indent();
- this.scribe.printNewLine();
- action.traverse(this, scope);
- this.scribe.unIndent();
- }
- if (action instanceof Expression || action instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- } else {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- }
- return false;
- }
-
- public boolean visit(FunctionExpression functionExpression, BlockScope scope) {
-
- final int numberOfParens = (functionExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(functionExpression, numberOfParens);
- }
- visit(functionExpression.methodDeclaration,scope);
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(functionExpression, numberOfParens);
- }
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.IfStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(IfStatement ifStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNameif);
- final int line = this.scribe.line;
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_if);
- if (this.preferences.insert_space_after_opening_paren_in_if) {
- this.scribe.space();
- }
- ifStatement.condition.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_if);
-
- final Statement thenStatement = ifStatement.thenStatement;
- final Statement elseStatement = ifStatement.elseStatement;
-
- boolean thenStatementIsBlock = false;
- if (thenStatement != null) {
- if (thenStatement instanceof Block) {
- thenStatementIsBlock = true;
- if (isGuardClause((Block)thenStatement) && elseStatement == null && this.preferences.keep_guardian_clause_on_one_line) {
- /*
- * Need a specific formatting for guard clauses
- * guard clauses are block with a single return or throw
- * statement
- */
- formatGuardClauseBlock((Block) thenStatement, scope);
- } else {
- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
- thenStatement.traverse(this, scope);
- if (elseStatement != null && (this.preferences.insert_new_line_before_else_in_if_statement)) {
- this.scribe.printNewLine();
- }
- }
- } else if (elseStatement == null && this.preferences.keep_simple_if_on_one_line) {
- Alignment compactIfAlignment = this.scribe.createAlignment(
- "compactIf", //$NON-NLS-1$
- this.preferences.alignment_for_compact_if,
- Alignment.R_OUTERMOST,
- 1,
- this.scribe.scanner.currentPosition,
- 1,
- false);
- this.scribe.enterAlignment(compactIfAlignment);
- boolean ok = false;
- do {
- try {
- this.scribe.alignFragment(compactIfAlignment, 0);
- this.scribe.space();
- thenStatement.traverse(this, scope);
- if (thenStatement instanceof Expression || thenStatement instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(compactIfAlignment, true);
- } else if (this.preferences.keep_then_statement_on_same_line) {
- this.scribe.space();
- thenStatement.traverse(this, scope);
- if (thenStatement instanceof Expression || thenStatement instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- if (elseStatement != null) {
- this.scribe.printNewLine();
- }
- } else {
- this.scribe.printTrailingComment();
- this.scribe.printNewLine();
- this.scribe.indent();
- thenStatement.traverse(this, scope);
- if (thenStatement instanceof Expression || thenStatement instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- if (elseStatement != null) {
- this.scribe.printNewLine();
- }
- this.scribe.unIndent();
- }
- }
-
- if (elseStatement != null) {
- if (thenStatementIsBlock) {
- this.scribe.printNextToken(TerminalTokens.TokenNameelse, this.preferences.insert_space_after_closing_brace_in_block);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameelse, true);
- }
- if (elseStatement instanceof Block) {
- elseStatement.traverse(this, scope);
- } else if (elseStatement instanceof IfStatement) {
- if (!this.preferences.compact_else_if) {
- this.scribe.printNewLine();
- this.scribe.indent();
- }
- this.scribe.space();
- elseStatement.traverse(this, scope);
- if (!this.preferences.compact_else_if) {
- this.scribe.unIndent();
- }
- } else if (this.preferences.keep_else_statement_on_same_line) {
- this.scribe.space();
- elseStatement.traverse(this, scope);
- if (elseStatement instanceof Expression || elseStatement instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- } else {
- this.scribe.printNewLine();
- this.scribe.indent();
- elseStatement.traverse(this, scope);
- if (elseStatement instanceof Expression || elseStatement instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- this.scribe.unIndent();
- }
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.Initializer, org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope)
- */
- public boolean visit(Initializer initializer, MethodScope scope) {
-
- if (initializer.isStatic()) {
- this.scribe.printNextToken(TerminalTokens.TokenNamestatic);
- }
- initializer.block.traverse(this, scope);
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.InstanceOfExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- InstanceOfExpression instanceOfExpression,
- BlockScope scope) {
-
- final int numberOfParens = (instanceOfExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(instanceOfExpression, numberOfParens);
- }
- instanceOfExpression.expression.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameinstanceof, true);
- this.scribe.space();
- instanceOfExpression.type.traverse(this, scope);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(instanceOfExpression, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.IntLiteral, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(IntLiteral intLiteral, BlockScope scope) {
-
- final int numberOfParens = (intLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(intLiteral, numberOfParens);
- }
- Constant constant = intLiteral.constant;
- if (constant != null && constant.intValue() < 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameMINUS);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameIntegerLiteral);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(intLiteral, numberOfParens);
- }
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.LabeledStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(LabeledStatement labeledStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier);
- this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_labeled_statement);
- if (this.preferences.insert_space_after_colon_in_labeled_statement) {
- this.scribe.space();
- }
- final Statement statement = labeledStatement.statement;
- statement.traverse(this, scope);
- if (statement instanceof Expression || statement instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
- formatLocalDeclaration(localDeclaration, scope, this.preferences.insert_space_before_comma_in_multiple_local_declarations, this.preferences.insert_space_after_comma_in_multiple_local_declarations);
- return false;
- }
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(MessageSend messageSend, BlockScope scope) {
-
- final int numberOfParens = (messageSend.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(messageSend, numberOfParens);
- }
- CascadingMethodInvocationFragmentBuilder builder = buildFragments(messageSend, scope);
-
- if (builder.size() >= 3 && numberOfParens == 0) {
- formatCascadingMessageSends(builder, scope);
- } else {
- Alignment messageAlignment = null;
- if (messageSend.receiver!=null && !messageSend.receiver.isImplicitThis()) {
- messageSend.receiver.traverse(this, scope);
- messageAlignment = this.scribe.createAlignment(
- "messageAlignment", //$NON-NLS-1$
- this.preferences.alignment_for_selector_in_method_invocation,
- 1,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(messageAlignment);
- boolean ok = false;
- do {
- try {
- formatMessageSend(messageSend, scope, messageAlignment);
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(messageAlignment, true);
- } else {
- formatMessageSend(messageSend, scope, null);
- }
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(messageSend, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration, org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope)
- */
- public boolean visit(
- MethodDeclaration methodDeclaration,
- Scope scope) {
-
- if (methodDeclaration.ignoreFurtherInvestigation) {
- this.scribe.printComment();
- if (this.scribe.indentationLevel != 0) {
- this.scribe.printIndentationIfNecessary();
- }
- this.scribe.scanner.resetTo(methodDeclaration.declarationSourceEnd + 1, this.scribe.scannerEndPosition - 1);
- this.scribe.printTrailingComment();
- switch(this.scribe.scanner.source[this.scribe.scanner.currentPosition]) {
- case '\n' :
- this.scribe.scanner.currentPosition++;
- this.scribe.lastNumberOfNewLines = 1;
- break;
- case '\r' :
- this.scribe.scanner.currentPosition++;
- if (this.scribe.scanner.source[this.scribe.scanner.currentPosition] == '\n') {
- this.scribe.scanner.currentPosition++;
- }
- this.scribe.lastNumberOfNewLines = 1;
- }
- return false;
- }
-
- /*
- * Print comments to get proper line number
- */
- this.scribe.printComment();
- int line = this.scribe.line;
-
- this.scribe.printModifiers(this);
-
- if (this.scribe.line > line) {
- // annotations introduced new line, but this is not a line wrapping
- // see 158267
- line = this.scribe.line;
- }
- // fix for 258956
- //this.scribe.space();
-
- /*
- * Print the method name
- */
- this.scribe.printNextToken(TerminalTokens.TokenNamefunction);
-
- if (methodDeclaration.selector!=null)
- this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
-
- formatMethodArguments(
- methodDeclaration,
- this.preferences.insert_space_before_opening_paren_in_method_declaration,
- this.preferences.insert_space_between_empty_parens_in_method_declaration,
- this.preferences.insert_space_before_closing_paren_in_method_declaration,
- this.preferences.insert_space_after_opening_paren_in_method_declaration,
- this.preferences.insert_space_before_comma_in_method_declaration_parameters,
- this.preferences.insert_space_after_comma_in_method_declaration_parameters,
- this.preferences.alignment_for_parameters_in_method_declaration);
-
- /*
- * Check for extra dimensions
- */
- int extraDimensions = getDimensions();
- if (extraDimensions != 0) {
- for (int i = 0; i < extraDimensions; i++) {
- this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
- }
- }
-
- final MethodScope methodDeclarationScope = methodDeclaration.scope;
-
- if (!methodDeclaration.isAbstract() && ((methodDeclaration.modifiers & ExtraCompilerModifiers.AccSemicolonBody) == 0)) {
- /*
- * Method body
- */
- String method_declaration_brace = this.preferences.brace_position_for_method_declaration;
- formatLeftCurlyBrace(line, method_declaration_brace);
- formatOpeningBrace(method_declaration_brace, this.preferences.insert_space_before_opening_brace_in_method_declaration);
- final int numberOfBlankLinesAtBeginningOfMethodBody = this.preferences.blank_lines_at_beginning_of_method_body;
- if (numberOfBlankLinesAtBeginningOfMethodBody > 0) {
- this.scribe.printEmptyLines(numberOfBlankLinesAtBeginningOfMethodBody);
- }
- final Statement[] statements = methodDeclaration.statements;
- if (statements != null) {
- this.scribe.printNewLine();
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.indent();
- }
- formatStatements(methodDeclarationScope, statements, true);
- this.scribe.printComment();
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.unIndent();
- }
- } else if (this.preferences.insert_new_line_in_empty_method_body) {
- this.scribe.printNewLine();
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.indent();
- }
- this.scribe.printComment();
- if (this.preferences.indent_statements_compare_to_body) {
- this.scribe.unIndent();
- }
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
- this.scribe.printTrailingComment();
- if (method_declaration_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- } else {
- // no method body
- this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- return false;
- }
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.NullLiteral, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(NullLiteral nullLiteral, BlockScope scope) {
-
- final int numberOfParens = (nullLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(nullLiteral, numberOfParens);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNamenull);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(nullLiteral, numberOfParens);
- }
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.OR_OR_Expression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(OR_OR_Expression or_or_Expression, BlockScope scope) {
- return dumpBinaryExpression(or_or_Expression, TerminalTokens.TokenNameOR_OR, scope);
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.PostfixExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- PostfixExpression postfixExpression,
- BlockScope scope) {
-
- final int numberOfParens = (postfixExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(postfixExpression, numberOfParens);
- }
- postfixExpression.lhs.traverse(this, scope);
- int operator = postfixExpression.operator == OperatorIds.PLUS
- ? TerminalTokens.TokenNamePLUS_PLUS : TerminalTokens.TokenNameMINUS_MINUS;
- this.scribe.printNextToken(operator, this.preferences.insert_space_before_postfix_operator);
- if (this.preferences.insert_space_after_postfix_operator) {
- this.scribe.space();
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(postfixExpression, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.PrefixExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(PrefixExpression prefixExpression, BlockScope scope) {
-
- final int numberOfParens = (prefixExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(prefixExpression, numberOfParens);
- }
- int operator = prefixExpression.operator == OperatorIds.PLUS
- ? TerminalTokens.TokenNamePLUS_PLUS : TerminalTokens.TokenNameMINUS_MINUS;
- this.scribe.printNextToken(operator, this.preferences.insert_space_before_prefix_operator);
- if (this.preferences.insert_space_after_prefix_operator) {
- this.scribe.space();
- }
- prefixExpression.lhs.traverse(this, scope);
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(prefixExpression, numberOfParens);
- }
- return false;
- }
-
- public boolean visit(RegExLiteral regexLiteral, BlockScope scope) {
-
- final int numberOfParens = (regexLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(regexLiteral, numberOfParens);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameRegExLiteral);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(regexLiteral, numberOfParens);
- }
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedAllocationExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- QualifiedAllocationExpression qualifiedAllocationExpression,
- BlockScope scope) {
-
- final int numberOfParens = (qualifiedAllocationExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(qualifiedAllocationExpression, numberOfParens);
- }
- final Expression enclosingInstance = qualifiedAllocationExpression.enclosingInstance;
- if (enclosingInstance != null) {
- enclosingInstance.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
- }
-
- this.scribe.printNextToken(TerminalTokens.TokenNamenew);
- this.scribe.space();
-
- final int line = this.scribe.line;
- qualifiedAllocationExpression.type.traverse(this, scope);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_method_invocation);
-
- final Expression[] arguments = qualifiedAllocationExpression.arguments;
- if (arguments != null) {
- if (this.preferences.insert_space_after_opening_paren_in_method_invocation) {
- this.scribe.space();
- }
- int argumentLength = arguments.length;
- Alignment argumentsAlignment =this.scribe.createAlignment(
- "allocation",//$NON-NLS-1$
- this.preferences.alignment_for_arguments_in_qualified_allocation_expression,
- argumentLength,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(argumentsAlignment);
- boolean ok = false;
- do {
- try {
- for (int i = 0; i < argumentLength; i++) {
- if (i > 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_allocation_expression);
- this.scribe.printTrailingComment();
- }
- this.scribe.alignFragment(argumentsAlignment, i);
- if (i > 0 && this.preferences.insert_space_after_comma_in_allocation_expression) {
- this.scribe.space();
- }
- arguments[i].traverse(this, scope);
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(argumentsAlignment, true);
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_method_invocation);
- } else {
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_between_empty_parens_in_method_invocation);
- }
- final TypeDeclaration anonymousType = qualifiedAllocationExpression.anonymousType;
- if (anonymousType != null) {
- formatLeftCurlyBrace(line, this.preferences.brace_position_for_anonymous_type_declaration);
- formatAnonymousTypeDeclaration(anonymousType);
- }
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(qualifiedAllocationExpression, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedNameReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- QualifiedNameReference qualifiedNameReference,
- BlockScope scope) {
-
- final int numberOfParens = (qualifiedNameReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(qualifiedNameReference, numberOfParens);
- }
- this.scribe.printQualifiedReference(qualifiedNameReference.sourceEnd);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(qualifiedNameReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedThisReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- QualifiedThisReference qualifiedThisReference,
- BlockScope scope) {
-
- final int numberOfParens = (qualifiedThisReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(qualifiedThisReference, numberOfParens);
- }
- qualifiedThisReference.qualification.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
- this.scribe.printNextToken(TerminalTokens.TokenNamethis);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(qualifiedThisReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedTypeReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- QualifiedTypeReference qualifiedTypeReference,
- BlockScope scope) {
-
- final int numberOfParens = (qualifiedTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(qualifiedTypeReference, numberOfParens);
- }
- this.scribe.printQualifiedReference(qualifiedTypeReference.sourceEnd);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(qualifiedTypeReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.QualifiedTypeReference, org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope)
- */
- public boolean visit(
- QualifiedTypeReference qualifiedTypeReference,
- ClassScope scope) {
-
- final int numberOfParens = (qualifiedTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(qualifiedTypeReference, numberOfParens);
- }
- this.scribe.printQualifiedReference(qualifiedTypeReference.sourceEnd);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(qualifiedTypeReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ReturnStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(ReturnStatement returnStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNamereturn);
- final Expression expression = returnStatement.expression;
- if (expression != null) {
- final int numberOfParens = (expression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if ((numberOfParens != 0 && this.preferences.insert_space_before_parenthesized_expression_in_return)
- || numberOfParens == 0) {
- this.scribe.space();
- }
- expression.traverse(this, scope);
- }
- /*
- * Print the semi-colon
- */
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- return false;
- }
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.SingleNameReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(SingleNameReference singleNameReference, BlockScope scope) {
-
- final int numberOfParens = (singleNameReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(singleNameReference, numberOfParens);
- }
- this.scribe.printNextToken(SINGLETYPEREFERENCE_EXPECTEDTOKENS);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(singleNameReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.SingleTypeReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- SingleTypeReference singleTypeReference,
- BlockScope scope) {
-
- final int numberOfParens = (singleTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(singleTypeReference, numberOfParens);
- }
- this.scribe.printNextToken(SINGLETYPEREFERENCE_EXPECTEDTOKENS);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(singleTypeReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.SingleTypeReference, org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope)
- */
- public boolean visit(
- SingleTypeReference singleTypeReference,
- ClassScope scope) {
-
- final int numberOfParens = (singleTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(singleTypeReference, numberOfParens);
- }
- this.scribe.printNextToken(SINGLETYPEREFERENCE_EXPECTEDTOKENS);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(singleTypeReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.StringLiteral, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(StringLiteral stringLiteral, BlockScope scope) {
- final int numberOfParens = (stringLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(stringLiteral, numberOfParens);
- }
- this.scribe.checkNLSTag(stringLiteral.sourceStart);
- this.scribe.printNextToken(new int[]{TerminalTokens.TokenNameCharacterLiteral, TerminalTokens.TokenNameStringLiteral});
- this.scribe.printTrailingComment();
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(stringLiteral, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.NullLiteral, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(StringLiteralConcatenation stringLiteral, BlockScope scope) {
- final int numberOfParens = (stringLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(stringLiteral, numberOfParens);
- }
-
- this.scribe.printComment();
- ASTNode[] fragments = stringLiteral.literals;
- int fragmentsSize = stringLiteral.counter;
- Alignment binaryExpressionAlignment = this.scribe.createAlignment("binaryExpressionAlignment", this.preferences.alignment_for_binary_expression, Alignment.R_OUTERMOST, fragmentsSize, this.scribe.scanner.currentPosition); //$NON-NLS-1$
- this.scribe.enterAlignment(binaryExpressionAlignment);
- boolean ok = false;
- do {
- try {
- for (int i = 0; i < fragmentsSize - 1; i++) {
- ASTNode fragment = fragments[i];
- fragment.traverse(this, scope);
- this.scribe.printTrailingComment();
- if (this.scribe.lastNumberOfNewLines == 1) {
- // a new line has been inserted by printTrailingComment()
- this.scribe.indentationLevel = binaryExpressionAlignment.breakIndentationLevel;
- }
- this.scribe.alignFragment(binaryExpressionAlignment, i);
- this.scribe.printNextToken(TerminalTokens.TokenNamePLUS, this.preferences.insert_space_before_binary_operator);
- if (this.preferences.insert_space_after_binary_operator) {
- this.scribe.space();
- }
- }
- fragments[fragmentsSize - 1].traverse(this, scope);
- this.scribe.printTrailingComment();
- ok = true;
- } catch(AlignmentException e){
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(binaryExpressionAlignment, true);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(stringLiteral, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.SuperReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(SuperReference superReference, BlockScope scope) {
-
- final int numberOfParens = (superReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(superReference, numberOfParens);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNamesuper);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(superReference, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.SwitchStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(SwitchStatement switchStatement, BlockScope scope) {
- this.scribe.printNextToken(TerminalTokens.TokenNameswitch);
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_switch);
-
- if (this.preferences.insert_space_after_opening_paren_in_switch) {
- this.scribe.space();
- }
-
- switchStatement.expression.traverse(this, scope);
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_switch);
- /*
- * Type body
- */
- String switch_brace = this.preferences.brace_position_for_switch;
- formatOpeningBrace(switch_brace, this.preferences.insert_space_before_opening_brace_in_switch);
- this.scribe.printNewLine();
-
- if (this.preferences.indent_switchstatements_compare_to_switch) {
- this.scribe.indent();
- }
- final Statement[] statements = switchStatement.statements;
- boolean wasACase = false;
- boolean wasAStatement = false;
- if (statements != null) {
- int statementsLength = statements.length;
- for (int i = 0; i < statementsLength; i++) {
- final Statement statement = statements[i];
- if (statement instanceof CaseStatement) {
- if (wasACase) {
- this.scribe.printNewLine();
- }
- if ((wasACase && this.preferences.indent_switchstatements_compare_to_cases)
- || (wasAStatement && this.preferences.indent_switchstatements_compare_to_cases)) {
- this.scribe.unIndent();
- }
- statement.traverse(this, scope);
- this.scribe.printTrailingComment();
- wasACase = true;
- wasAStatement = false;
- if (this.preferences.indent_switchstatements_compare_to_cases) {
- this.scribe.indent();
- }
- } else if (statement instanceof BreakStatement) {
- if (this.preferences.indent_breaks_compare_to_cases) {
- if (wasAStatement && !this.preferences.indent_switchstatements_compare_to_cases) {
- this.scribe.indent();
- }
- } else {
- if (wasAStatement) {
- if (this.preferences.indent_switchstatements_compare_to_cases) {
- this.scribe.unIndent();
- }
- }
- if (wasACase && this.preferences.indent_switchstatements_compare_to_cases) {
- this.scribe.unIndent();
- }
- }
- if (wasACase) {
- this.scribe.printNewLine();
- }
- statement.traverse(this, scope);
- if (this.preferences.indent_breaks_compare_to_cases) {
- this.scribe.unIndent();
- }
- wasACase = false;
- wasAStatement = false;
- } else if (statement instanceof Block) {
- String bracePosition;
- if (wasACase) {
- if (this.preferences.indent_switchstatements_compare_to_cases) {
- this.scribe.unIndent();
- }
- bracePosition = this.preferences.brace_position_for_block_in_case;
- formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_after_colon_in_case);
- if (this.preferences.indent_switchstatements_compare_to_cases) {
- this.scribe.indent();
- }
- } else {
- bracePosition = this.preferences.brace_position_for_block;
- formatBlock((Block) statement, scope, bracePosition, this.preferences.insert_space_before_opening_brace_in_block);
- }
- wasAStatement = true;
- wasACase = false;
- } else {
- this.scribe.printNewLine();
- statement.traverse(this, scope);
- wasAStatement = true;
- wasACase = false;
- }
- if (statement instanceof Expression || statement instanceof LocalDeclaration) {
- /*
- * Print the semi-colon
- */
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- this.scribe.printNewLine();
- } else if (statement instanceof LocalDeclaration) {
- LocalDeclaration currentLocal = (LocalDeclaration) statement;
- if (i < (statementsLength - 1)) {
- /*
- * We need to check that the next statement is a local declaration
- */
- if (statements[i + 1] instanceof LocalDeclaration) {
- LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1];
- if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) {
- /*
- * Print the semi-colon
- */
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- this.scribe.printNewLine();
- }
- } else {
- /*
- * Print the semi-colon
- */
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- this.scribe.printNewLine();
- }
- } else {
- /*
- * Print the semi-colon
- */
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- this.scribe.printNewLine();
- }
- } else if (!wasACase) {
- this.scribe.printNewLine();
- }
- this.scribe.printComment();
- }
- }
-
- if ((wasACase || wasAStatement) && this.preferences.indent_switchstatements_compare_to_cases) {
- this.scribe.unIndent();
- }
- if (this.preferences.indent_switchstatements_compare_to_switch) {
- this.scribe.unIndent();
- }
- this.scribe.printNewLine();
- this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
- this.scribe.printTrailingComment();
- if (switch_brace.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
- this.scribe.unIndent();
- }
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ThisReference, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(ThisReference thisReference, BlockScope scope) {
-
- if (!thisReference.isImplicitThis()) {
- final int numberOfParens = (thisReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(thisReference, numberOfParens);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNamethis);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(thisReference, numberOfParens);
- }
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.ThrowStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(ThrowStatement throwStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNamethrow);
- Expression expression = throwStatement.exception;
- final int numberOfParens = (expression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if ((numberOfParens > 0 && this.preferences.insert_space_before_parenthesized_expression_in_throw)
- || numberOfParens == 0) {
- this.scribe.space();
- }
- expression.traverse(this, scope);
- /*
- * Print the semi-colon
- */
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.TrueLiteral, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(TrueLiteral trueLiteral, BlockScope scope) {
-
- final int numberOfParens = (trueLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(trueLiteral, numberOfParens);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNametrue);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(trueLiteral, numberOfParens);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.TryStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(TryStatement tryStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNametry);
- tryStatement.tryBlock.traverse(this, scope);
- if (tryStatement.catchArguments != null) {
- for (int i = 0, max = tryStatement.catchBlocks.length; i < max; i++) {
- if (this.preferences.insert_new_line_before_catch_in_try_statement) {
- this.scribe.printNewLine();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNamecatch, this.preferences.insert_space_after_closing_brace_in_block);
- final int line = this.scribe.line;
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_catch);
-
- if (this.preferences.insert_space_after_opening_paren_in_catch) {
- this.scribe.space();
- }
-
- tryStatement.catchArguments[i].traverse(this, scope);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_catch);
-
- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
- tryStatement.catchBlocks[i].traverse(this, scope);
- }
- }
- if (tryStatement.finallyBlock != null) {
- if (this.preferences.insert_new_line_before_finally_in_try_statement) {
- this.scribe.printNewLine();
- }
- this.scribe.printNextToken(TerminalTokens.TokenNamefinally, this.preferences.insert_space_after_closing_brace_in_block);
- tryStatement.finallyBlock.traverse(this, scope);
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.TypeDeclaration, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(
- TypeDeclaration localTypeDeclaration,
- BlockScope scope) {
-
- format(localTypeDeclaration);
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.TypeDeclaration, org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope)
- */
- public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
- format(memberTypeDeclaration);
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.TypeDeclaration, org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope)
- */
- public boolean visit(
- TypeDeclaration typeDeclaration,
- CompilationUnitScope scope) {
-
- format(typeDeclaration);
- return false;
- }
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.UnaryExpression, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(UnaryExpression unaryExpression, BlockScope scope) {
-
- final int numberOfParens = (unaryExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(unaryExpression, numberOfParens);
- }
-
- /*
- * Print the operator
- */
- int operator;
- boolean addSpace=false;
- int operatorValue = (unaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT;
- switch(operatorValue) {
- case OperatorIds.PLUS:
- operator = TerminalTokens.TokenNamePLUS;
- break;
- case OperatorIds.MINUS:
- operator = TerminalTokens.TokenNameMINUS;
- break;
- case OperatorIds.TWIDDLE:
- operator = TerminalTokens.TokenNameTWIDDLE;
- break;
- case OperatorIds.DELETE:
- operator = TerminalTokens.TokenNamedelete;
- addSpace=true;
- break;
- case OperatorIds.VOID:
- operator = TerminalTokens.TokenNamevoid;
- addSpace=true;
- break;
- case OperatorIds.TYPEOF:
- operator = TerminalTokens.TokenNametypeof;
- addSpace=true;
- break;
- default:
- operator = TerminalTokens.TokenNameNOT;
- }
-
- this.scribe.printNextToken(operator, this.preferences.insert_space_before_unary_operator);
- if (this.preferences.insert_space_after_unary_operator || addSpace) {
- this.scribe.space();
- }
- Expression expression = unaryExpression.expression;
-
- if (expression instanceof PrefixExpression) {
- PrefixExpression prefixExpression = (PrefixExpression) expression;
- final int numberOfParensForExpression = (prefixExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParensForExpression == 0) {
- switch(operatorValue) {
- case OperatorIds.PLUS:
- if (prefixExpression.operator == OperatorIds.PLUS) {
- this.scribe.space();
- }
- break;
- case OperatorIds.MINUS:
- if (prefixExpression.operator == OperatorIds.MINUS) {
- this.scribe.space();
- }
- break;
- }
- }
- expression.traverse(this, scope);
- } else {
- expression.traverse(this, scope);
- }
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(unaryExpression, numberOfParens);
- }
- return false;
- }
-
- public boolean visit(UndefinedLiteral undefinedLiteral, BlockScope scope) {
-
- final int numberOfParens = (undefinedLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
- if (numberOfParens > 0) {
- manageOpeningParenthesizedExpression(undefinedLiteral, numberOfParens);
- }
- this.scribe.printNextToken(TerminalTokens.TokenNameundefined);
-
- if (numberOfParens > 0) {
- manageClosingParenthesizedExpression(undefinedLiteral, numberOfParens);
- }
- return false;
- }
-
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.WhileStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(WhileStatement whileStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNamewhile);
- final int line = this.scribe.line;
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_while);
-
- if (this.preferences.insert_space_after_opening_paren_in_while) {
- this.scribe.space();
- }
- whileStatement.condition.traverse(this, scope);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while);
-
- final Statement action = whileStatement.action;
- if (action != null) {
- if (action instanceof Block) {
- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
- action.traverse(this, scope);
- } else if (action instanceof EmptyStatement) {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- } else {
- this.scribe.printNewLine();
- this.scribe.indent();
- action.traverse(this, scope);
- if (action instanceof Expression || action instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- this.scribe.unIndent();
- }
- } else {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- }
- return false;
- }
-
-
- /**
- * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.WhileStatement, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
- */
- public boolean visit(WithStatement withStatement, BlockScope scope) {
-
- this.scribe.printNextToken(TerminalTokens.TokenNamewith);
- final int line = this.scribe.line;
- this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_while);
-
- if (this.preferences.insert_space_after_opening_paren_in_while) {
- this.scribe.space();
- }
- withStatement.condition.traverse(this, scope);
-
- this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while);
-
- final Statement action = withStatement.action;
- if (action != null) {
- if (action instanceof Block) {
- formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
- action.traverse(this, scope);
- } else if (action instanceof EmptyStatement) {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- } else {
- this.scribe.printNewLine();
- this.scribe.indent();
- action.traverse(this, scope);
- if (action instanceof Expression|| action instanceof LocalDeclaration) {
- this.scribe.printOptionalNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
- this.scribe.printTrailingComment();
- }
- this.scribe.unIndent();
- }
- } else {
- /*
- * This is an empty statement
- */
- formatNecessaryEmptyStatement();
- }
- return false;
- }
-
- public boolean visit(ListExpression listExpression, BlockScope scope) {
- int expressionsLength=listExpression.expressions.length;
- Alignment argumentsAlignment = this.scribe.createAlignment(
- "messageArguments", //$NON-NLS-1$
- this.preferences.alignment_for_arguments_in_method_invocation,
- expressionsLength,
- this.scribe.scanner.currentPosition);
- this.scribe.enterAlignment(argumentsAlignment);
- boolean ok = false;
- do {
- try {
- for (int i = 0; i < expressionsLength; i++) {
- if (i > 0) {
- this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_method_invocation_arguments);
- this.scribe.printTrailingComment();
- }
- this.scribe.alignFragment(argumentsAlignment, i);
- if (i > 0 && this.preferences.insert_space_after_comma_in_method_invocation_arguments) {
- this.scribe.space();
- }
- listExpression.expressions[i].traverse(this, scope);
- }
- ok = true;
- } catch (AlignmentException e) {
- this.scribe.redoAlignment(e);
- }
- } while (!ok);
- this.scribe.exitAlignment(argumentsAlignment, true);
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/DefaultCodeFormatter.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/DefaultCodeFormatter.java
deleted file mode 100644
index 4183b493..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/DefaultCodeFormatter.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.wst.jsdt.internal.formatter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.compiler.ITerminalSymbols;
-import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
-import org.eclipse.wst.jsdt.core.formatter.CodeFormatter;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ASTNode;
-import org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.ConstructorDeclaration;
-import org.eclipse.wst.jsdt.internal.compiler.ast.Expression;
-import org.eclipse.wst.jsdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.wst.jsdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.wst.jsdt.internal.compiler.parser.Scanner;
-import org.eclipse.wst.jsdt.internal.compiler.util.Util;
-import org.eclipse.wst.jsdt.internal.core.util.CodeSnippetParsingUtil;
-import org.eclipse.wst.jsdt.internal.formatter.comment.CommentRegion;
-import org.eclipse.wst.jsdt.internal.formatter.comment.JavaDocRegion;
-import org.eclipse.wst.jsdt.internal.formatter.comment.MultiCommentRegion;
-
-public class DefaultCodeFormatter extends CodeFormatter {
-
- public static final boolean DEBUG = false;
- private static Scanner ProbingScanner;
-
- /**
- * Creates a comment region for a specific document partition type.
- *
- * @param kind the comment snippet kind
- * @param document the document which contains the comment region
- * @param range range of the comment region in the document
- * @return a new comment region for the comment region range in the
- * document
- * @since 3.1
- */
- public static CommentRegion createRegion(int kind, IDocument document, Position range, CodeFormatterVisitor formatter) {
- switch (kind) {
- case CodeFormatter.K_SINGLE_LINE_COMMENT:
- return new CommentRegion(document, range, formatter);
- case CodeFormatter.K_MULTI_LINE_COMMENT:
- return new MultiCommentRegion(document, range, formatter);
- case CodeFormatter.K_JAVA_DOC:
- return new JavaDocRegion(document, range, formatter);
- }
- return null;
- }
-
- private CodeSnippetParsingUtil codeSnippetParsingUtil;
- private Map defaultCompilerOptions;
-
- private CodeFormatterVisitor newCodeFormatter;
- private Map options;
-
- private DefaultCodeFormatterOptions preferences;
-
- public DefaultCodeFormatter() {
- this(new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings()), null);
- }
-
- public DefaultCodeFormatter(DefaultCodeFormatterOptions preferences) {
- this(preferences, null);
- }
-
- public DefaultCodeFormatter(DefaultCodeFormatterOptions defaultCodeFormatterOptions, Map options) {
- if (options != null) {
- this.options = options;
- this.preferences = new DefaultCodeFormatterOptions(options);
- } else {
- this.options = JavaScriptCore.getOptions();
- this.preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getJavaConventionsSettings());
- }
- this.defaultCompilerOptions = getDefaultCompilerOptions();
- if (defaultCodeFormatterOptions != null) {
- this.preferences.set(defaultCodeFormatterOptions.getMap());
- }
- }
-
- public DefaultCodeFormatter(Map options) {
- this(null, options);
- }
-
- public String createIndentationString(final int indentationLevel) {
- if (indentationLevel < 0) {
- throw new IllegalArgumentException();
- }
-
- int tabs = 0;
- int spaces = 0;
- switch(this.preferences.tab_char) {
- case DefaultCodeFormatterOptions.SPACE :
- spaces = indentationLevel * this.preferences.tab_size;
- break;
- case DefaultCodeFormatterOptions.TAB :
- tabs = indentationLevel;
- break;
- case DefaultCodeFormatterOptions.MIXED :
- int tabSize = this.preferences.tab_size;
- int spaceEquivalents = indentationLevel * this.preferences.indentation_size;
- tabs = spaceEquivalents / tabSize;
- spaces = spaceEquivalents % tabSize;
- break;
- default:
- return Util.EMPTY_STRING;
- }
- if (tabs == 0 && spaces == 0) {
- return Util.EMPTY_STRING;
- }
- StringBuffer buffer = new StringBuffer(tabs + spaces);
- for(int i = 0; i < tabs; i++) {
- buffer.append('\t');
- }
- for(int i = 0; i < spaces; i++) {
- buffer.append(' ');
- }
- return buffer.toString();
- }
-
- /**
- * @see org.eclipse.wst.jsdt.core.formatter.CodeFormatter#format(int, java.lang.String, int, int, int, java.lang.String)
- */
- public TextEdit format(
- int kind,
- String source,
- int offset,
- int length,
- int indentationLevel,
- String lineSeparator) {
-
- if (offset < 0 || length < 0 || length > source.length()) {
- throw new IllegalArgumentException();
- }
- this.codeSnippetParsingUtil = new CodeSnippetParsingUtil();
- switch(kind) {
- case K_CLASS_BODY_DECLARATIONS :
- return formatClassBodyDeclarations(source, indentationLevel, lineSeparator, offset, length);
- case K_JAVASCRIPT_UNIT :
- return formatCompilationUnit(source, indentationLevel, lineSeparator, offset, length);
- case K_EXPRESSION :
- return formatExpression(source, indentationLevel, lineSeparator, offset, length);
- case K_STATEMENTS :
- return formatStatements(source, indentationLevel, lineSeparator, offset, length);
- case K_UNKNOWN :
- return probeFormatting(source, indentationLevel, lineSeparator, offset, length);
- case K_JAVA_DOC :
- case K_MULTI_LINE_COMMENT :
- case K_SINGLE_LINE_COMMENT :
- return formatComment(kind, source, indentationLevel, lineSeparator, offset, length);
- }
- return null;
- }
-
- private TextEdit formatClassBodyDeclarations(String source, int indentationLevel, String lineSeparator, int offset, int length) {
- ASTNode[] bodyDeclarations = this.codeSnippetParsingUtil.parseClassBodyDeclarations(source.toCharArray(), getDefaultCompilerOptions(), true);
-
- if (bodyDeclarations == null) {
- // a problem occured while parsing the source
- return null;
- }
- return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, offset, length);
- }
-
- /**
- * Returns the resulting text edit after formatting the given comment.
- *
- * @param kind the given kind
- * @param source the given source
- * @param indentationLevel the given indentation level
- * @param lineSeparator the given line separator
- * @param offset the given offset
- * @param length the given length
- * @return the resulting text edit
- * @deprecated
- */
- private TextEdit formatComment(int kind, String source, int indentationLevel, String lineSeparator, int offset, int length) {
- Object oldOption = this.options.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT);
- boolean isFormattingComments = false;
- if (oldOption == null) {
- switch (kind) {
- case CodeFormatter.K_SINGLE_LINE_COMMENT:
- isFormattingComments = DefaultCodeFormatterConstants.TRUE.equals(this.options.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT));
- break;
- case CodeFormatter.K_MULTI_LINE_COMMENT:
- isFormattingComments = DefaultCodeFormatterConstants.TRUE.equals(this.options.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT));
- break;
- case CodeFormatter.K_JAVA_DOC:
- isFormattingComments = DefaultCodeFormatterConstants.TRUE.equals(this.options.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT));
- }
- } else {
- isFormattingComments = DefaultCodeFormatterConstants.TRUE.equals(oldOption);
- }
- if (isFormattingComments) {
- if (lineSeparator != null) {
- this.preferences.line_separator = lineSeparator;
- } else {
- this.preferences.line_separator = Util.LINE_SEPARATOR;
- }
- this.preferences.initial_indentation_level = indentationLevel;
- this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length, null);
- final CommentRegion region = createRegion(kind, new Document(source), new Position(offset, length), this.newCodeFormatter);
- if (region != null) {
- return this.newCodeFormatter.format(source, region);
- }
- }
- return new MultiTextEdit();
- }
-
- private TextEdit formatCompilationUnit(String source, int indentationLevel, String lineSeparator, int offset, int length) {
- CompilationUnitDeclaration compilationUnitDeclaration = this.codeSnippetParsingUtil.parseCompilationUnit(source.toCharArray(), getDefaultCompilerOptions(), true);
-
- if (lineSeparator != null) {
- this.preferences.line_separator = lineSeparator;
- } else {
- this.preferences.line_separator = Util.LINE_SEPARATOR;
- }
- this.preferences.initial_indentation_level = indentationLevel;
-
- this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length, this.codeSnippetParsingUtil);
-
- return this.newCodeFormatter.format(source, compilationUnitDeclaration);
- }
-
- private TextEdit formatExpression(String source, int indentationLevel, String lineSeparator, int offset, int length) {
- Expression expression = this.codeSnippetParsingUtil.parseExpression(source.toCharArray(), getDefaultCompilerOptions(), true);
-
- if (expression == null) {
- // a problem occured while parsing the source
- return null;
- }
- return internalFormatExpression(source, indentationLevel, lineSeparator, expression, offset, length);
- }
-
- private TextEdit formatStatements(String source, int indentationLevel, String lineSeparator, int offset, int length) {
- ConstructorDeclaration constructorDeclaration = this.codeSnippetParsingUtil.parseStatements(source.toCharArray(), getDefaultCompilerOptions(), true, false);
-
- if (constructorDeclaration.statements == null) {
- // a problem occured while parsing the source
- return null;
- }
- return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, offset, length);
- }
-
- public String getDebugOutput() {
- return this.newCodeFormatter.scribe.toString();
- }
-
- private Map getDefaultCompilerOptions() {
- if (this.defaultCompilerOptions == null) {
- Map optionsMap = new HashMap(30);
- optionsMap.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
- optionsMap.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
- optionsMap.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE);
- optionsMap.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
- optionsMap.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportMethodWithConstructorName, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportUndefinedField, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportHiddenCatchBlock, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportWrongNumberOfArguments, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportNoEffectAssignment, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportIndirectStaticAccess, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportLocalVariableHiding, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportPossibleAccidentalBooleanAssignment, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportEmptyStatement, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportAssertIdentifier, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportEnumIdentifier, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.PUBLIC);
- optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsDeprecatedRef, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsNotVisibleRef, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocTags, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocTagsVisibility, CompilerOptions.PUBLIC);
- optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocTagsOverriding, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocComments, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocCommentsVisibility, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocCommentsOverriding, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportFinallyBlockNotCompletingNormally, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportUnqualifiedFieldAccess, CompilerOptions.IGNORE);
- optionsMap.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
- optionsMap.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_2);
- optionsMap.put(CompilerOptions.OPTION_TaskTags, ""); //$NON-NLS-1$
- optionsMap.put(CompilerOptions.OPTION_TaskPriorities, ""); //$NON-NLS-1$
- optionsMap.put(CompilerOptions.OPTION_TaskCaseSensitive, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_ReportSpecialParameterHidingField, CompilerOptions.DISABLED);
- optionsMap.put(CompilerOptions.OPTION_MaxProblemPerUnit, String.valueOf(100));
- optionsMap.put(CompilerOptions.OPTION_InlineJsr, CompilerOptions.DISABLED);
- this.defaultCompilerOptions = optionsMap;
- }
- Object sourceOption = this.options.get(CompilerOptions.OPTION_Source);
- if (sourceOption != null) {
- this.defaultCompilerOptions.put(CompilerOptions.OPTION_Source, sourceOption);
- } else {
- this.defaultCompilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
- }
- return this.defaultCompilerOptions;
- }
-
- private TextEdit internalFormatClassBodyDeclarations(String source, int indentationLevel, String lineSeparator, ASTNode[] bodyDeclarations, int offset, int length) {
- if (lineSeparator != null) {
- this.preferences.line_separator = lineSeparator;
- } else {
- this.preferences.line_separator = Util.LINE_SEPARATOR;
- }
- this.preferences.initial_indentation_level = indentationLevel;
-
- this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length, this.codeSnippetParsingUtil);
- return this.newCodeFormatter.format(source, bodyDeclarations);
- }
-
- private TextEdit internalFormatExpression(String source, int indentationLevel, String lineSeparator, Expression expression, int offset, int length) {
- if (lineSeparator != null) {
- this.preferences.line_separator = lineSeparator;
- } else {
- this.preferences.line_separator = Util.LINE_SEPARATOR;
- }
- this.preferences.initial_indentation_level = indentationLevel;
-
- this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length, this.codeSnippetParsingUtil);
-
- TextEdit textEdit = this.newCodeFormatter.format(source, expression);
- return textEdit;
- }
-
- private TextEdit internalFormatStatements(String source, int indentationLevel, String lineSeparator, ConstructorDeclaration constructorDeclaration, int offset, int length) {
- if (lineSeparator != null) {
- this.preferences.line_separator = lineSeparator;
- } else {
- this.preferences.line_separator = Util.LINE_SEPARATOR;
- }
- this.preferences.initial_indentation_level = indentationLevel;
-
- this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, offset, length, this.codeSnippetParsingUtil);
-
- return this.newCodeFormatter.format(source, constructorDeclaration);
- }
-
- private TextEdit probeFormatting(String source, int indentationLevel, String lineSeparator, int offset, int length) {
- if (ProbingScanner == null) {
- // scanner use to check if the kind could be K_JAVA_DOC, K_MULTI_LINE_COMMENT or K_SINGLE_LINE_COMMENT
- ProbingScanner = new Scanner(true, true, false/*nls*/, ClassFileConstants.JDK1_3, ClassFileConstants.JDK1_3, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
- }
- ProbingScanner.setSource(source.toCharArray());
- ProbingScanner.resetTo(offset, offset + length);
- try {
- switch(ProbingScanner.getNextToken()) {
- case ITerminalSymbols.TokenNameCOMMENT_BLOCK :
- if (ProbingScanner.getCurrentTokenEndPosition() == offset + length - 1) {
- return formatComment(K_MULTI_LINE_COMMENT, source, indentationLevel, lineSeparator, offset, length);
- }
- break;
- case ITerminalSymbols.TokenNameCOMMENT_LINE :
- if (ProbingScanner.getCurrentTokenEndPosition() == offset + length - 1) {
- return formatComment(K_SINGLE_LINE_COMMENT, source, indentationLevel, lineSeparator, offset, length);
- }
- break;
- case ITerminalSymbols.TokenNameCOMMENT_JAVADOC :
- if (ProbingScanner.getCurrentTokenEndPosition() == offset + length - 1) {
- return formatComment(K_JAVA_DOC, source, indentationLevel, lineSeparator, offset, length);
- }
- }
- } catch (InvalidInputException e) {
- // ignore
- }
- 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);
- }
-
- // 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);
- }
-
- // probe for statements
- ConstructorDeclaration constructorDeclaration = this.codeSnippetParsingUtil.parseStatements(source.toCharArray(), getDefaultCompilerOptions(), true, false);
- if (constructorDeclaration.statements != null) {
- return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, offset, length);
- }
-
- // this has to be a compilation unit
- return formatCompilationUnit(source, indentationLevel, lineSeparator, offset, length);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/DefaultCodeFormatterOptions.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/DefaultCodeFormatterOptions.java
deleted file mode 100644
index 3d8b8986..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/DefaultCodeFormatterOptions.java
+++ /dev/null
@@ -1,2483 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.wst.jsdt.internal.formatter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.wst.jsdt.internal.formatter.align.Alignment;
-
-/**
- * This is still subject to changes before 3.0.
- * @since 3.0
- */
-
-public class DefaultCodeFormatterOptions {
- public static final int TAB = 1;
- public static final int SPACE = 2;
- public static final int MIXED = 4;
-
- public static DefaultCodeFormatterOptions getDefaultSettings() {
- DefaultCodeFormatterOptions options = new DefaultCodeFormatterOptions();
- options.setDefaultSettings();
- return options;
- }
-
- public static DefaultCodeFormatterOptions getEclipseDefaultSettings() {
- DefaultCodeFormatterOptions options = new DefaultCodeFormatterOptions();
- options.setEclipseDefaultSettings();
- return options;
- }
-
- public static DefaultCodeFormatterOptions getJavaConventionsSettings() {
- DefaultCodeFormatterOptions options = new DefaultCodeFormatterOptions();
- options.setJavaConventionsSettings();
- return options;
- }
-
- public int alignment_for_arguments_in_allocation_expression;
- public int alignment_for_arguments_in_enum_constant;
- public int alignment_for_arguments_in_explicit_constructor_call;
- public int alignment_for_arguments_in_method_invocation;
- public int alignment_for_arguments_in_qualified_allocation_expression;
- public int alignment_for_assignment;
- public int alignment_for_binary_expression;
- public int alignment_for_compact_if;
- public int alignment_for_conditional_expression;
- public int alignment_for_enum_constants;
- public int alignment_for_expressions_in_array_initializer;
- public int alignment_for_multiple_fields;
- public int alignment_for_parameters_in_constructor_declaration;
- public int alignment_for_parameters_in_method_declaration;
- public int alignment_for_selector_in_method_invocation;
- public int alignment_for_superclass_in_type_declaration;
- public int alignment_for_superinterfaces_in_enum_declaration;
- public int alignment_for_superinterfaces_in_type_declaration;
- public int alignment_for_throws_clause_in_constructor_declaration;
- public int alignment_for_throws_clause_in_method_declaration;
- public int alignment_for_fields_in_object_literal;
-
- public boolean align_type_members_on_columns;
-
- public String brace_position_for_annotation_type_declaration;
- public String brace_position_for_anonymous_type_declaration;
- public String brace_position_for_array_initializer;
- public String brace_position_for_objlit_initializer;
- public String brace_position_for_block;
- public String brace_position_for_block_in_case;
- public String brace_position_for_constructor_declaration;
- public String brace_position_for_enum_constant;
- public String brace_position_for_enum_declaration;
- public String brace_position_for_method_declaration;
- public String brace_position_for_type_declaration;
- public String brace_position_for_switch;
-
- public int continuation_indentation;
- public int continuation_indentation_for_array_initializer;
- public int continuation_indentation_for_objlit_initializer;
-
- public int blank_lines_after_imports;
- public int blank_lines_after_package;
- public int blank_lines_before_field;
- public int blank_lines_before_first_class_body_declaration;
- public int blank_lines_before_imports;
- public int blank_lines_before_member_type;
- public int blank_lines_before_method;
- public int blank_lines_before_new_chunk;
- public int blank_lines_before_package;
- public int blank_lines_between_import_groups;
- public int blank_lines_between_type_declarations;
- public int blank_lines_at_beginning_of_method_body;
-
- public boolean comment_clear_blank_lines_in_javadoc_comment;
- public boolean comment_clear_blank_lines_in_block_comment;
- public boolean comment_format_javadoc_comment;
- public boolean comment_format_line_comment;
- public boolean comment_format_block_comment;
- public boolean comment_format_header;
- public boolean comment_format_html;
- public boolean comment_format_source;
- public boolean comment_indent_parameter_description;
- public boolean comment_indent_root_tags;
- public boolean comment_insert_empty_line_before_root_tags;
- public boolean comment_insert_new_line_for_parameter;
- public int comment_line_length;
-
- public boolean indent_statements_compare_to_block;
- public boolean indent_statements_compare_to_body;
- public boolean indent_body_declarations_compare_to_annotation_declaration_header;
- public boolean indent_body_declarations_compare_to_enum_constant_header;
- public boolean indent_body_declarations_compare_to_enum_declaration_header;
- public boolean indent_body_declarations_compare_to_type_header;
- public boolean indent_breaks_compare_to_cases;
- public boolean indent_empty_lines;
- public boolean indent_switchstatements_compare_to_cases;
- public boolean indent_switchstatements_compare_to_switch;
- public int indentation_size;
-
- public boolean insert_new_line_after_annotation;
- public boolean insert_new_line_after_opening_brace_in_array_initializer;
- public boolean insert_new_line_after_opening_brace_in_objlit_initializer;
- public boolean insert_new_line_after_comma_in_objlit_initializer;
- public boolean insert_new_line_at_end_of_file_if_missing;
- public boolean insert_new_line_before_catch_in_try_statement;
- public boolean insert_new_line_before_closing_brace_in_array_initializer;
- public boolean insert_new_line_before_closing_brace_in_objlit_initializer;
- public boolean insert_new_line_before_else_in_if_statement;
- public boolean insert_new_line_before_finally_in_try_statement;
- public boolean insert_new_line_before_while_in_do_statement;
- public boolean insert_new_line_in_empty_anonymous_type_declaration;
- public boolean insert_new_line_in_empty_block;
- public boolean insert_new_line_in_empty_annotation_declaration;
- public boolean insert_new_line_in_empty_enum_constant;
- public boolean insert_new_line_in_empty_enum_declaration;
- public boolean insert_new_line_in_empty_method_body;
- public boolean insert_new_line_in_empty_type_declaration;
- public boolean insert_space_after_and_in_type_parameter;
- public boolean insert_space_after_assignment_operator;
- public boolean insert_space_after_at_in_annotation;
- public boolean insert_space_after_at_in_annotation_type_declaration;
- public boolean insert_space_after_binary_operator;
- public boolean insert_space_after_closing_angle_bracket_in_type_arguments;
- public boolean insert_space_after_closing_angle_bracket_in_type_parameters;
- public boolean insert_space_after_closing_paren_in_cast;
- public boolean insert_space_after_closing_brace_in_block;
- public boolean insert_space_after_colon_in_assert;
- public boolean insert_space_after_colon_in_case;
- public boolean insert_space_after_colon_in_conditional;
- public boolean insert_space_after_colon_in_object_initializer;
- public boolean insert_space_after_colon_in_for;
- public boolean insert_space_after_colon_in_labeled_statement;
- public boolean insert_space_after_comma_in_allocation_expression;
- public boolean insert_space_after_comma_in_annotation;
- public boolean insert_space_after_comma_in_array_initializer;
- public boolean insert_space_after_comma_in_constructor_declaration_parameters;
- public boolean insert_space_after_comma_in_constructor_declaration_throws;
- public boolean insert_space_after_comma_in_enum_constant_arguments;
- public boolean insert_space_after_comma_in_enum_declarations;
- public boolean insert_space_after_comma_in_explicit_constructor_call_arguments;
- public boolean insert_space_after_comma_in_for_increments;
- public boolean insert_space_after_comma_in_for_inits;
- public boolean insert_space_after_comma_in_method_invocation_arguments;
- public boolean insert_space_after_comma_in_method_declaration_parameters;
- public boolean insert_space_after_comma_in_method_declaration_throws;
- public boolean insert_space_after_comma_in_multiple_field_declarations;
- public boolean insert_space_after_comma_in_multiple_local_declarations;
- public boolean insert_space_after_comma_in_parameterized_type_reference;
- public boolean insert_space_after_comma_in_superinterfaces;
- public boolean insert_space_after_comma_in_type_arguments;
- public boolean insert_space_after_comma_in_type_parameters;
- public boolean insert_space_after_ellipsis;
- public boolean insert_space_after_opening_angle_bracket_in_parameterized_type_reference;
- public boolean insert_space_after_opening_angle_bracket_in_type_arguments;
- public boolean insert_space_after_opening_angle_bracket_in_type_parameters;
- public boolean insert_space_after_opening_bracket_in_array_allocation_expression;
- public boolean insert_space_after_opening_bracket_in_array_reference;
- public boolean insert_space_after_opening_brace_in_array_initializer;
- public boolean insert_space_after_opening_paren_in_annotation;
- public boolean insert_space_after_opening_paren_in_cast;
- public boolean insert_space_after_opening_paren_in_catch;
- public boolean insert_space_after_opening_paren_in_constructor_declaration;
- public boolean insert_space_after_opening_paren_in_enum_constant;
- public boolean insert_space_after_opening_paren_in_for;
- public boolean insert_space_after_opening_paren_in_if;
- public boolean insert_space_after_opening_paren_in_method_declaration;
- public boolean insert_space_after_opening_paren_in_method_invocation;
- public boolean insert_space_after_opening_paren_in_parenthesized_expression;
- public boolean insert_space_after_opening_paren_in_switch;
- public boolean insert_space_after_opening_paren_in_synchronized;
- public boolean insert_space_after_opening_paren_in_while;
- public boolean insert_space_after_postfix_operator;
- public boolean insert_space_after_prefix_operator;
- public boolean insert_space_after_question_in_conditional;
- public boolean insert_space_after_semicolon_in_for;
- public boolean insert_space_after_unary_operator;
- public boolean insert_space_before_at_in_annotation_type_declaration;
- public boolean insert_space_before_assignment_operator;
- public boolean insert_space_before_binary_operator;
- public boolean insert_space_before_closing_angle_bracket_in_parameterized_type_reference;
- public boolean insert_space_before_closing_angle_bracket_in_type_arguments;
- public boolean insert_space_before_closing_angle_bracket_in_type_parameters;
- public boolean insert_space_before_closing_brace_in_array_initializer;
- public boolean insert_space_before_closing_bracket_in_array_allocation_expression;
- public boolean insert_space_before_closing_bracket_in_array_reference;
- public boolean insert_space_before_closing_paren_in_annotation;
- public boolean insert_space_before_closing_paren_in_cast;
- public boolean insert_space_before_closing_paren_in_catch;
- public boolean insert_space_before_closing_paren_in_constructor_declaration;
- public boolean insert_space_before_closing_paren_in_enum_constant;
- public boolean insert_space_before_closing_paren_in_for;
- public boolean insert_space_before_closing_paren_in_if;
- public boolean insert_space_before_closing_paren_in_method_declaration;
- public boolean insert_space_before_closing_paren_in_method_invocation;
- public boolean insert_space_before_closing_paren_in_parenthesized_expression;
- public boolean insert_space_before_closing_paren_in_switch;
- public boolean insert_space_before_closing_paren_in_synchronized;
- public boolean insert_space_before_closing_paren_in_while;
- public boolean insert_space_before_colon_in_assert;
- public boolean insert_space_before_colon_in_case;
- public boolean insert_space_before_colon_in_conditional;
- public boolean insert_space_before_colon_in_object_initializer;
- public boolean insert_space_before_colon_in_default;
- public boolean insert_space_before_colon_in_for;
- public boolean insert_space_before_colon_in_labeled_statement;
- public boolean insert_space_before_comma_in_allocation_expression;
- public boolean insert_space_before_comma_in_annotation;
- public boolean insert_space_before_comma_in_array_initializer;
- public boolean insert_space_before_comma_in_constructor_declaration_parameters;
- public boolean insert_space_before_comma_in_constructor_declaration_throws;
- public boolean insert_space_before_comma_in_enum_constant_arguments;
- public boolean insert_space_before_comma_in_enum_declarations;
- public boolean insert_space_before_comma_in_explicit_constructor_call_arguments;
- public boolean insert_space_before_comma_in_for_increments;
- public boolean insert_space_before_comma_in_for_inits;
- public boolean insert_space_before_comma_in_method_invocation_arguments;
- public boolean insert_space_before_comma_in_method_declaration_parameters;
- public boolean insert_space_before_comma_in_method_declaration_throws;
- public boolean insert_space_before_comma_in_multiple_field_declarations;
- public boolean insert_space_before_comma_in_multiple_local_declarations;
- public boolean insert_space_before_comma_in_parameterized_type_reference;
- public boolean insert_space_before_comma_in_superinterfaces;
- public boolean insert_space_before_comma_in_type_arguments;
- public boolean insert_space_before_comma_in_type_parameters;
- public boolean insert_space_before_ellipsis;
- public boolean insert_space_before_parenthesized_expression_in_return;
- public boolean insert_space_before_parenthesized_expression_in_throw;
- public boolean insert_space_before_opening_angle_bracket_in_parameterized_type_reference;
- public boolean insert_space_before_opening_angle_bracket_in_type_arguments;
- public boolean insert_space_before_opening_angle_bracket_in_type_parameters;
- public boolean insert_space_before_opening_brace_in_annotation_type_declaration;
- public boolean insert_space_before_opening_brace_in_anonymous_type_declaration;
- public boolean insert_space_before_opening_brace_in_array_initializer;
- public boolean insert_space_before_opening_brace_in_block;
- public boolean insert_space_before_opening_brace_in_constructor_declaration;
- public boolean insert_space_before_opening_brace_in_enum_constant;
- public boolean insert_space_before_opening_brace_in_enum_declaration;
- public boolean insert_space_before_opening_brace_in_method_declaration;
- public boolean insert_space_before_opening_brace_in_type_declaration;
- public boolean insert_space_before_opening_bracket_in_array_allocation_expression;
- public boolean insert_space_before_opening_bracket_in_array_reference;
- public boolean insert_space_before_opening_bracket_in_array_type_reference;
- public boolean insert_space_before_opening_paren_in_annotation;
- public boolean insert_space_before_opening_paren_in_annotation_type_member_declaration;
- public boolean insert_space_before_opening_paren_in_catch;
- public boolean insert_space_before_opening_paren_in_constructor_declaration;
- public boolean insert_space_before_opening_paren_in_enum_constant;
- public boolean insert_space_before_opening_paren_in_for;
- public boolean insert_space_before_opening_paren_in_if;
- public boolean insert_space_before_opening_paren_in_method_invocation;
- public boolean insert_space_before_opening_paren_in_method_declaration;
- public boolean insert_space_before_opening_paren_in_switch;
- public boolean insert_space_before_opening_brace_in_switch;
- public boolean insert_space_before_opening_paren_in_synchronized;
- public boolean insert_space_before_opening_paren_in_parenthesized_expression;
- public boolean insert_space_before_opening_paren_in_while;
- public boolean insert_space_before_postfix_operator;
- public boolean insert_space_before_prefix_operator;
- public boolean insert_space_before_question_in_conditional;
- public boolean insert_space_before_semicolon;
- public boolean insert_space_before_semicolon_in_for;
- public boolean insert_space_before_unary_operator;
- public boolean insert_space_between_brackets_in_array_type_reference;
- public boolean insert_space_between_empty_braces_in_array_initializer;
- public boolean insert_space_between_empty_brackets_in_array_allocation_expression;
- public boolean insert_space_between_empty_parens_in_annotation_type_member_declaration;
- public boolean insert_space_between_empty_parens_in_constructor_declaration;
- public boolean insert_space_between_empty_parens_in_enum_constant;
- public boolean insert_space_between_empty_parens_in_method_declaration;
- public boolean insert_space_between_empty_parens_in_method_invocation;
- public boolean compact_else_if;
- public boolean keep_guardian_clause_on_one_line;
- public boolean keep_else_statement_on_same_line;
- public boolean keep_empty_array_initializer_on_one_line;
- public boolean keep_empty_objlit_initializer_on_one_line;
- public boolean keep_simple_if_on_one_line;
- public boolean keep_then_statement_on_same_line;
- public boolean never_indent_block_comments_on_first_column;
- public boolean never_indent_line_comments_on_first_column;
- public int number_of_empty_lines_to_preserve;
- public boolean put_empty_statement_on_new_line;
- public int tab_size;
- public final char filling_space = ' ';
- public int page_width;
- public int tab_char;
- public boolean use_tabs_only_for_leading_indentations;
- public boolean wrap_before_binary_operator;
-
- public int initial_indentation_level;
- public String line_separator;
-
- private DefaultCodeFormatterOptions() {
- // cannot be instantiated
- }
-
- public DefaultCodeFormatterOptions(Map settings) {
- setDefaultSettings();
- if (settings == null) return;
- set(settings);
- }
-
- private String getAlignment(int alignment) {
- return Integer.toString(alignment);
- }
-
- public Map getMap() {
- Map options = new HashMap();
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_allocation_expression));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT, getAlignment(this.alignment_for_arguments_in_enum_constant));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL, getAlignment(this.alignment_for_arguments_in_explicit_constructor_call));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_arguments_in_method_invocation));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_qualified_allocation_expression));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, getAlignment(this.alignment_for_assignment));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, getAlignment(this.alignment_for_binary_expression));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF, getAlignment(this.alignment_for_compact_if));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, getAlignment(this.alignment_for_conditional_expression));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, getAlignment(this.alignment_for_enum_constants));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, getAlignment(this.alignment_for_expressions_in_array_initializer));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS, getAlignment(this.alignment_for_multiple_fields));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_parameters_in_constructor_declaration));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_parameters_in_method_declaration));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_selector_in_method_invocation));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_superclass_in_type_declaration));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION, getAlignment(this.alignment_for_superinterfaces_in_enum_declaration));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_superinterfaces_in_type_declaration));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_constructor_declaration));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_method_declaration));
- options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, this.align_type_members_on_columns ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANNOTATION_TYPE_DECLARATION, this.brace_position_for_annotation_type_declaration);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION, this.brace_position_for_anonymous_type_declaration);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, this.brace_position_for_array_initializer);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_OBJLIT_INITIALIZER, this.brace_position_for_objlit_initializer);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, this.brace_position_for_block);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, this.brace_position_for_block_in_case);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, this.brace_position_for_constructor_declaration);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT, this.brace_position_for_enum_constant);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION, this.brace_position_for_enum_declaration);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, this.brace_position_for_method_declaration);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, this.brace_position_for_type_declaration);
- options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, this.brace_position_for_switch);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, this.comment_clear_blank_lines_in_javadoc_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, this.comment_clear_blank_lines_in_block_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, this.comment_format_javadoc_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, this.comment_format_line_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT, this.comment_format_block_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, this.comment_format_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML, this.comment_format_html ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, this.comment_format_source ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION, this.comment_indent_parameter_description ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_ROOT_TAGS, this.comment_indent_root_tags ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS, this.comment_insert_empty_line_before_root_tags ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER, this.comment_insert_new_line_for_parameter ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, Integer.toString(this.comment_line_length));
- options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, Integer.toString(this.continuation_indentation));
- options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, Integer.toString(this.continuation_indentation_for_array_initializer));
- options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_OBJLIT_INITIALIZER, Integer.toString(this.continuation_indentation_for_objlit_initializer));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, Integer.toString(this.blank_lines_after_imports));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, Integer.toString(this.blank_lines_after_package));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD, Integer.toString(this.blank_lines_before_field));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION, Integer.toString(this.blank_lines_before_first_class_body_declaration));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_IMPORTS, Integer.toString(this.blank_lines_before_imports));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE, Integer.toString(this.blank_lines_before_member_type));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD, Integer.toString(this.blank_lines_before_method));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK, Integer.toString(this.blank_lines_before_new_chunk));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, Integer.toString(this.blank_lines_before_package));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS, Integer.toString(this.blank_lines_between_import_groups));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS, Integer.toString(this.blank_lines_between_type_declarations));
- options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY, Integer.toString(this.blank_lines_at_beginning_of_method_body));
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, this.indent_statements_compare_to_block ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, this.indent_statements_compare_to_body ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER, this.indent_body_declarations_compare_to_annotation_declaration_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER, this.indent_body_declarations_compare_to_enum_constant_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER, this.indent_body_declarations_compare_to_enum_declaration_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER, this.indent_body_declarations_compare_to_type_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, this.indent_breaks_compare_to_cases ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, this.indent_empty_lines ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, this.indent_switchstatements_compare_to_cases ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, this.indent_switchstatements_compare_to_switch ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, Integer.toString(this.indentation_size));
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, this.insert_new_line_after_annotation ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_new_line_after_opening_brace_in_array_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_OBJLIT_INITIALIZER, this.insert_new_line_after_opening_brace_in_objlit_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_COMMA_IN_OBJLIT_INITIALIZER, this.insert_new_line_after_comma_in_objlit_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, this.insert_new_line_at_end_of_file_if_missing ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, this.insert_new_line_before_catch_in_try_statement? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, this.insert_new_line_before_closing_brace_in_array_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_OBJLIT_INITIALIZER, this.insert_new_line_before_closing_brace_in_objlit_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, this.insert_new_line_before_else_in_if_statement? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT, this.insert_new_line_before_finally_in_try_statement? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, this.insert_new_line_before_while_in_do_statement? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION, this.insert_new_line_in_empty_anonymous_type_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK, this.insert_new_line_in_empty_block? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION, this.insert_new_line_in_empty_annotation_declaration ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT, this.insert_new_line_in_empty_enum_constant? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION, this.insert_new_line_in_empty_enum_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY, this.insert_new_line_in_empty_method_body? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION, this.insert_new_line_in_empty_type_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER, this.insert_space_after_and_in_type_parameter? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, this.insert_space_after_assignment_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION, this.insert_space_after_at_in_annotation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION_TYPE_DECLARATION, this.insert_space_after_at_in_annotation_type_declaration ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, this.insert_space_after_binary_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, this.insert_space_after_closing_angle_bracket_in_type_arguments ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, this.insert_space_after_closing_angle_bracket_in_type_parameters ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, this.insert_space_after_closing_paren_in_cast? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, this.insert_space_after_closing_brace_in_block? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT, this.insert_space_after_colon_in_assert ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE, this.insert_space_after_colon_in_case ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, this.insert_space_after_colon_in_conditional ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_OBJECT_INITIALIZER, this.insert_space_after_colon_in_object_initializer ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR, this.insert_space_after_colon_in_for ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, this.insert_space_after_colon_in_labeled_statement? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, this.insert_space_after_comma_in_allocation_expression? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ANNOTATION, this.insert_space_after_comma_in_annotation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, this.insert_space_after_comma_in_array_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, this.insert_space_after_comma_in_constructor_declaration_parameters? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, this.insert_space_after_comma_in_constructor_declaration_throws? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_CONSTANT_ARGUMENTS, this.insert_space_after_comma_in_enum_constant_arguments ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_DECLARATIONS, this.insert_space_after_comma_in_enum_declarations ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, this.insert_space_after_comma_in_explicit_constructor_call_arguments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, this.insert_space_after_comma_in_for_increments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, this.insert_space_after_comma_in_for_inits? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, this.insert_space_after_comma_in_method_invocation_arguments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, this.insert_space_after_comma_in_method_declaration_parameters? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, this.insert_space_after_comma_in_method_declaration_throws? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, this.insert_space_after_comma_in_multiple_field_declarations? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, this.insert_space_after_comma_in_multiple_local_declarations? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE, this.insert_space_after_comma_in_parameterized_type_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES, this.insert_space_after_comma_in_superinterfaces? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS, this.insert_space_after_comma_in_type_arguments ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_PARAMETERS, this.insert_space_after_comma_in_type_parameters ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, this.insert_space_after_opening_bracket_in_array_allocation_expression? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, this.insert_space_after_ellipsis ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, this.insert_space_after_opening_angle_bracket_in_parameterized_type_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, this.insert_space_after_opening_angle_bracket_in_type_arguments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, this.insert_space_after_opening_angle_bracket_in_type_parameters? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE, this.insert_space_after_opening_bracket_in_array_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_space_after_opening_brace_in_array_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION, this.insert_space_after_opening_paren_in_annotation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, this.insert_space_after_opening_paren_in_cast? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, this.insert_space_after_opening_paren_in_catch? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, this.insert_space_after_opening_paren_in_constructor_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT, this.insert_space_after_opening_paren_in_enum_constant? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, this.insert_space_after_opening_paren_in_for? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, this.insert_space_after_opening_paren_in_if? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, this.insert_space_after_opening_paren_in_method_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, this.insert_space_after_opening_paren_in_method_invocation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, this.insert_space_after_opening_paren_in_parenthesized_expression? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, this.insert_space_after_opening_paren_in_switch? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED, this.insert_space_after_opening_paren_in_synchronized? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, this.insert_space_after_opening_paren_in_while? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, this.insert_space_after_postfix_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, this.insert_space_after_prefix_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, this.insert_space_after_question_in_conditional? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, this.insert_space_after_semicolon_in_for? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, this.insert_space_after_unary_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_AT_IN_ANNOTATION_TYPE_DECLARATION, this.insert_space_before_at_in_annotation_type_declaration ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, this.insert_space_before_assignment_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, this.insert_space_before_binary_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, this.insert_space_before_closing_angle_bracket_in_parameterized_type_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, this.insert_space_before_closing_angle_bracket_in_type_arguments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, this.insert_space_before_closing_angle_bracket_in_type_parameters? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, this.insert_space_before_closing_brace_in_array_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, this.insert_space_before_closing_bracket_in_array_allocation_expression? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE, this.insert_space_before_closing_bracket_in_array_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ANNOTATION, this.insert_space_before_closing_paren_in_annotation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, this.insert_space_before_closing_paren_in_cast? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, this.insert_space_before_closing_paren_in_catch? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION, this.insert_space_before_closing_paren_in_constructor_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ENUM_CONSTANT, this.insert_space_before_closing_paren_in_enum_constant? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, this.insert_space_before_closing_paren_in_for? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, this.insert_space_before_closing_paren_in_if? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, this.insert_space_before_closing_paren_in_method_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, this.insert_space_before_closing_paren_in_method_invocation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, this.insert_space_before_closing_paren_in_parenthesized_expression? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, this.insert_space_before_closing_paren_in_switch? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED, this.insert_space_before_closing_paren_in_synchronized? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, this.insert_space_before_closing_paren_in_while? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT, this.insert_space_before_colon_in_assert? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, this.insert_space_before_colon_in_case? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, this.insert_space_before_colon_in_conditional? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_OBJECT_INITIALIZER, this.insert_space_before_colon_in_object_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, this.insert_space_before_colon_in_default? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR, this.insert_space_before_colon_in_for ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, this.insert_space_before_colon_in_labeled_statement? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, this.insert_space_before_comma_in_allocation_expression? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ANNOTATION, this.insert_space_before_comma_in_annotation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER, this.insert_space_before_comma_in_array_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, this.insert_space_before_comma_in_constructor_declaration_parameters? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, this.insert_space_before_comma_in_constructor_declaration_throws? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_CONSTANT_ARGUMENTS, this.insert_space_before_comma_in_enum_constant_arguments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_DECLARATIONS, this.insert_space_before_comma_in_enum_declarations? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, this.insert_space_before_comma_in_explicit_constructor_call_arguments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, this.insert_space_before_comma_in_for_increments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, this.insert_space_before_comma_in_for_inits? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, this.insert_space_before_comma_in_method_invocation_arguments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, this.insert_space_before_comma_in_method_declaration_parameters? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, this.insert_space_before_comma_in_method_declaration_throws? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, this.insert_space_before_comma_in_multiple_field_declarations? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, this.insert_space_before_comma_in_multiple_local_declarations? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES, this.insert_space_before_comma_in_superinterfaces? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_ARGUMENTS, this.insert_space_before_comma_in_type_arguments ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_PARAMETERS, this.insert_space_before_comma_in_type_parameters? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE, this.insert_space_before_comma_in_parameterized_type_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, this.insert_space_before_ellipsis ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, this.insert_space_before_opening_angle_bracket_in_parameterized_type_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS, this.insert_space_before_opening_angle_bracket_in_type_arguments? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS, this.insert_space_before_opening_angle_bracket_in_type_parameters? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANNOTATION_TYPE_DECLARATION, this.insert_space_before_opening_brace_in_annotation_type_declaration ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION, this.insert_space_before_opening_brace_in_anonymous_type_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_space_before_opening_brace_in_array_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, this.insert_space_before_opening_brace_in_block? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION, this.insert_space_before_opening_brace_in_constructor_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_CONSTANT, this.insert_space_before_opening_brace_in_enum_constant? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_DECLARATION, this.insert_space_before_opening_brace_in_enum_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, this.insert_space_before_opening_brace_in_method_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, this.insert_space_before_opening_brace_in_type_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, this.insert_space_before_opening_bracket_in_array_allocation_expression ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE, this.insert_space_before_opening_bracket_in_array_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE, this.insert_space_before_opening_bracket_in_array_type_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION, this.insert_space_before_opening_paren_in_annotation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION, this.insert_space_before_opening_paren_in_annotation_type_member_declaration ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, this.insert_space_before_opening_paren_in_catch? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, this.insert_space_before_opening_paren_in_constructor_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT, this.insert_space_before_opening_paren_in_enum_constant? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, this.insert_space_before_opening_paren_in_for? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, this.insert_space_before_opening_paren_in_if? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, this.insert_space_before_opening_paren_in_method_invocation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, this.insert_space_before_opening_paren_in_method_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, this.insert_space_before_opening_paren_in_switch? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, this.insert_space_before_opening_brace_in_switch? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, this.insert_space_before_opening_paren_in_synchronized? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, this.insert_space_before_opening_paren_in_parenthesized_expression? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, this.insert_space_before_opening_paren_in_while? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, this.insert_space_before_parenthesized_expression_in_return ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, this.insert_space_before_parenthesized_expression_in_throw ? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, this.insert_space_before_postfix_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, this.insert_space_before_prefix_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, this.insert_space_before_question_in_conditional? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, this.insert_space_before_semicolon? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, this.insert_space_before_semicolon_in_for? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, this.insert_space_before_unary_operator? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE, this.insert_space_between_brackets_in_array_type_reference? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, this.insert_space_between_empty_braces_in_array_initializer? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION, this.insert_space_between_empty_brackets_in_array_allocation_expression? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION_TYPE_MEMBER_DECLARATION, this.insert_space_between_empty_parens_in_annotation_type_member_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, this.insert_space_between_empty_parens_in_constructor_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ENUM_CONSTANT, this.insert_space_between_empty_parens_in_enum_constant? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, this.insert_space_between_empty_parens_in_method_declaration? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, this.insert_space_between_empty_parens_in_method_invocation? JavaScriptCore.INSERT : JavaScriptCore.DO_NOT_INSERT);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF, this.compact_else_if ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE, this.keep_guardian_clause_on_one_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE, this.keep_else_statement_on_same_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE, this.keep_empty_array_initializer_on_one_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_OBJLIT_INITIALIZER_ON_ONE_LINE, this.keep_empty_objlit_initializer_on_one_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE, this.keep_simple_if_on_one_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE, this.keep_then_statement_on_same_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN, this.never_indent_block_comments_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, this.never_indent_line_comments_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, Integer.toString(this.number_of_empty_lines_to_preserve));
- options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, this.put_empty_statement_on_new_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(this.page_width));
- switch(this.tab_char) {
- case SPACE :
- options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaScriptCore.SPACE);
- break;
- case TAB :
- options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaScriptCore.TAB);
- break;
- case MIXED :
- options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED);
- break;
- }
- options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, Integer.toString(this.tab_size));
- options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, this.use_tabs_only_for_leading_indentations ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_BINARY_OPERATOR, this.wrap_before_binary_operator ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- return options;
- }
-
- public void set(Map settings) {
- final Object alignmentForArgumentsInAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION);
- if (alignmentForArgumentsInAllocationExpressionOption != null) {
- try {
- this.alignment_for_arguments_in_allocation_expression = Integer.parseInt((String) alignmentForArgumentsInAllocationExpressionOption);
- } catch (NumberFormatException e) {
- this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForArgumentsInEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT);
- if (alignmentForArgumentsInEnumConstantOption != null) {
- try {
- this.alignment_for_arguments_in_enum_constant = Integer.parseInt((String) alignmentForArgumentsInEnumConstantOption);
- } catch (NumberFormatException e) {
- this.alignment_for_arguments_in_enum_constant = Alignment.M_COMPACT_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_arguments_in_enum_constant = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForArgumentsInExplicitConstructorCallOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL);
- if (alignmentForArgumentsInExplicitConstructorCallOption != null) {
- try {
- this.alignment_for_arguments_in_explicit_constructor_call = Integer.parseInt((String) alignmentForArgumentsInExplicitConstructorCallOption);
- } catch (NumberFormatException e) {
- this.alignment_for_arguments_in_explicit_constructor_call = Alignment.M_COMPACT_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_arguments_in_explicit_constructor_call = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForArgumentsInMethodInvocationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
- if (alignmentForArgumentsInMethodInvocationOption != null) {
- try {
- this.alignment_for_arguments_in_method_invocation = Integer.parseInt((String) alignmentForArgumentsInMethodInvocationOption);
- } catch (NumberFormatException e) {
- this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForArgumentsInQualifiedAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION);
- if (alignmentForArgumentsInQualifiedAllocationExpressionOption != null) {
- try {
- this.alignment_for_arguments_in_qualified_allocation_expression = Integer.parseInt((String) alignmentForArgumentsInQualifiedAllocationExpressionOption);
- } catch (NumberFormatException e) {
- this.alignment_for_arguments_in_qualified_allocation_expression = Alignment.M_COMPACT_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_arguments_in_qualified_allocation_expression = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForAssignmentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT);
- if (alignmentForAssignmentOption != null) {
- try {
- this.alignment_for_assignment = Integer.parseInt((String) alignmentForAssignmentOption);
- } catch (NumberFormatException e) {
- this.alignment_for_assignment = Alignment.M_ONE_PER_LINE_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_assignment = Alignment.M_ONE_PER_LINE_SPLIT;
- }
- }
- final Object alignmentForBinaryExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION);
- if (alignmentForBinaryExpressionOption != null) {
- try {
- this.alignment_for_binary_expression = Integer.parseInt((String) alignmentForBinaryExpressionOption);
- } catch (NumberFormatException e) {
- this.alignment_for_binary_expression = Alignment.M_COMPACT_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_binary_expression = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForCompactIfOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF);
- if (alignmentForCompactIfOption != null) {
- try {
- this.alignment_for_compact_if = Integer.parseInt((String) alignmentForCompactIfOption);
- } catch (NumberFormatException e) {
- this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
- } catch (ClassCastException e) {
- this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
- }
- }
- final Object alignmentForConditionalExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
- if (alignmentForConditionalExpressionOption != null) {
- try {
- this.alignment_for_conditional_expression = Integer.parseInt((String) alignmentForConditionalExpressionOption);
- } catch (NumberFormatException e) {
- this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT;
- }
- }
- final Object alignmentForEnumConstantsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS);
- if (alignmentForEnumConstantsOption != null) {
- try {
- this.alignment_for_enum_constants = Integer.parseInt((String) alignmentForEnumConstantsOption);
- } catch (NumberFormatException e) {
- this.alignment_for_enum_constants = Alignment.NONE;
- } catch (ClassCastException e) {
- this.alignment_for_enum_constants = Alignment.NONE;
- }
- }
- final Object alignmentForExpressionsInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
- if (alignmentForExpressionsInArrayInitializerOption != null) {
- try {
- this.alignment_for_expressions_in_array_initializer = Integer.parseInt((String) alignmentForExpressionsInArrayInitializerOption);
- } catch (NumberFormatException e) {
- this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForMultipleFieldsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS);
- if (alignmentForMultipleFieldsOption != null) {
- try {
- this.alignment_for_multiple_fields = Integer.parseInt((String) alignmentForMultipleFieldsOption);
- } catch (NumberFormatException e) {
- this.alignment_for_multiple_fields = Alignment.M_COMPACT_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_multiple_fields = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForParametersInConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION);
- if (alignmentForParametersInConstructorDeclarationOption != null) {
- try {
- this.alignment_for_parameters_in_constructor_declaration = Integer.parseInt((String) alignmentForParametersInConstructorDeclarationOption);
- } catch (NumberFormatException e) {
- this.alignment_for_parameters_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
- } catch (ClassCastException e) {
- this.alignment_for_parameters_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForParametersInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
- if (alignmentForParametersInMethodDeclarationOption != null) {
- try {
- this.alignment_for_parameters_in_method_declaration = Integer.parseInt((String) alignmentForParametersInMethodDeclarationOption);
- } catch (NumberFormatException e) {
- this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
- } catch(ClassCastException e) {
- this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForSelectorInMethodInvocationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION);
- if (alignmentForSelectorInMethodInvocationOption != null) {
- try {
- this.alignment_for_selector_in_method_invocation = Integer.parseInt((String) alignmentForSelectorInMethodInvocationOption);
- } catch (NumberFormatException e) {
- this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT;
- } catch(ClassCastException e) {
- this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForSuperclassInTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION);
- if (alignmentForSuperclassInTypeDeclarationOption != null) {
- try {
- this.alignment_for_superclass_in_type_declaration = Integer.parseInt((String) alignmentForSuperclassInTypeDeclarationOption);
- } catch (NumberFormatException e) {
- this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
- } catch(ClassCastException e) {
- this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
- }
- }
- final Object alignmentForSuperinterfacesInEnumDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION);
- if (alignmentForSuperinterfacesInEnumDeclarationOption != null) {
- try {
- this.alignment_for_superinterfaces_in_enum_declaration = Integer.parseInt((String) alignmentForSuperinterfacesInEnumDeclarationOption);
- } catch (NumberFormatException e) {
- this.alignment_for_superinterfaces_in_enum_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
- } catch(ClassCastException e) {
- this.alignment_for_superinterfaces_in_enum_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
- }
- }
- final Object alignmentForSuperinterfacesInTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION);
- if (alignmentForSuperinterfacesInTypeDeclarationOption != null) {
- try {
- this.alignment_for_superinterfaces_in_type_declaration = Integer.parseInt((String) alignmentForSuperinterfacesInTypeDeclarationOption);
- } catch (NumberFormatException e) {
- this.alignment_for_superinterfaces_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
- } catch(ClassCastException e) {
- this.alignment_for_superinterfaces_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
- }
- }
- final Object alignmentForThrowsClauseInConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION);
- if (alignmentForThrowsClauseInConstructorDeclarationOption != null) {
- try {
- this.alignment_for_throws_clause_in_constructor_declaration = Integer.parseInt((String) alignmentForThrowsClauseInConstructorDeclarationOption);
- } catch (NumberFormatException e) {
- this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
- } catch(ClassCastException e) {
- this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignmentForThrowsClauseInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION);
- if (alignmentForThrowsClauseInMethodDeclarationOption != null) {
- try {
- this.alignment_for_throws_clause_in_method_declaration = Integer.parseInt((String) alignmentForThrowsClauseInMethodDeclarationOption);
- } catch (NumberFormatException e) {
- this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
- } catch(ClassCastException e) {
- this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
- }
- }
- final Object alignTypeMembersOnColumnsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS);
- if (alignTypeMembersOnColumnsOption != null) {
- this.align_type_members_on_columns = DefaultCodeFormatterConstants.TRUE.equals(alignTypeMembersOnColumnsOption);
- }
- final Object bracePositionForAnnotationTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANNOTATION_TYPE_DECLARATION);
- if (bracePositionForAnnotationTypeDeclarationOption != null) {
- try {
- this.brace_position_for_annotation_type_declaration = (String) bracePositionForAnnotationTypeDeclarationOption;
- } catch(ClassCastException e) {
- this.brace_position_for_annotation_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForAnonymousTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION);
- if (bracePositionForAnonymousTypeDeclarationOption != null) {
- try {
- this.brace_position_for_anonymous_type_declaration = (String) bracePositionForAnonymousTypeDeclarationOption;
- } catch(ClassCastException e) {
- this.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER);
- if (bracePositionForArrayInitializerOption != null) {
- try {
- this.brace_position_for_array_initializer = (String) bracePositionForArrayInitializerOption;
- } catch(ClassCastException e) {
- this.brace_position_for_array_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForObjLitInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_OBJLIT_INITIALIZER);
- if (bracePositionForObjLitInitializerOption != null) {
- try {
- this.brace_position_for_objlit_initializer = (String) bracePositionForObjLitInitializerOption;
- } catch(ClassCastException e) {
- this.brace_position_for_objlit_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForBlockOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
- if (bracePositionForBlockOption != null) {
- try {
- this.brace_position_for_block = (String) bracePositionForBlockOption;
- } catch(ClassCastException e) {
- this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForBlockInCaseOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE);
- if (bracePositionForBlockInCaseOption != null) {
- try {
- this.brace_position_for_block_in_case = (String) bracePositionForBlockInCaseOption;
- } catch(ClassCastException e) {
- this.brace_position_for_block_in_case = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION);
- if (bracePositionForConstructorDeclarationOption != null) {
- try {
- this.brace_position_for_constructor_declaration = (String) bracePositionForConstructorDeclarationOption;
- } catch(ClassCastException e) {
- this.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT);
- if (bracePositionForEnumConstantOption != null) {
- try {
- this.brace_position_for_enum_constant = (String) bracePositionForEnumConstantOption;
- } catch(ClassCastException e) {
- this.brace_position_for_enum_constant = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForEnumDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION);
- if (bracePositionForEnumDeclarationOption != null) {
- try {
- this.brace_position_for_enum_declaration = (String) bracePositionForEnumDeclarationOption;
- } catch(ClassCastException e) {
- this.brace_position_for_enum_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION);
- if (bracePositionForMethodDeclarationOption != null) {
- try {
- this.brace_position_for_method_declaration = (String) bracePositionForMethodDeclarationOption;
- } catch(ClassCastException e) {
- this.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForSwitchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH);
- if (bracePositionForSwitchOption != null) {
- try {
- this.brace_position_for_switch = (String) bracePositionForSwitchOption;
- } catch(ClassCastException e) {
- this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object bracePositionForTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION);
- if (bracePositionForTypeDeclarationOption != null) {
- try {
- this.brace_position_for_type_declaration = (String) bracePositionForTypeDeclarationOption;
- } catch(ClassCastException e) {
- this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- }
- }
- final Object continuationIndentationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
- if (continuationIndentationOption != null) {
- try {
- this.continuation_indentation = Integer.parseInt((String) continuationIndentationOption);
- } catch (NumberFormatException e) {
- this.continuation_indentation = 2;
- } catch(ClassCastException e) {
- this.continuation_indentation = 2;
- }
- }
- final Object continuationIndentationForArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER);
- if (continuationIndentationForArrayInitializerOption != null) {
- try {
- this.continuation_indentation_for_array_initializer = Integer.parseInt((String) continuationIndentationForArrayInitializerOption);
- } catch (NumberFormatException e) {
- this.continuation_indentation_for_array_initializer = 2;
- } catch(ClassCastException e) {
- this.continuation_indentation_for_array_initializer = 2;
- }
- }
- final Object continuationIndentationForObjLitInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_OBJLIT_INITIALIZER);
- if (continuationIndentationForObjLitInitializerOption != null) {
- try {
- this.continuation_indentation_for_objlit_initializer = Integer.parseInt((String) continuationIndentationForObjLitInitializerOption);
- } catch (NumberFormatException e) {
- this.continuation_indentation_for_objlit_initializer = 1;
- } catch(ClassCastException e) {
- this.continuation_indentation_for_objlit_initializer = 1;
- }
- }
- final Object blankLinesAfterImportsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS);
- if (blankLinesAfterImportsOption != null) {
- try {
- this.blank_lines_after_imports = Integer.parseInt((String) blankLinesAfterImportsOption);
- } catch (NumberFormatException e) {
- this.blank_lines_after_imports = 0;
- } catch(ClassCastException e) {
- this.blank_lines_after_imports = 0;
- }
- }
- final Object blankLinesAfterPackageOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE);
- if (blankLinesAfterPackageOption != null) {
- try {
- this.blank_lines_after_package = Integer.parseInt((String) blankLinesAfterPackageOption);
- } catch (NumberFormatException e) {
- this.blank_lines_after_package = 0;
- } catch(ClassCastException e) {
- this.blank_lines_after_package = 0;
- }
- }
- final Object blankLinesBeforeFieldOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD);
- if (blankLinesBeforeFieldOption != null) {
- try {
- this.blank_lines_before_field = Integer.parseInt((String) blankLinesBeforeFieldOption);
- } catch (NumberFormatException e) {
- this.blank_lines_before_field = 0;
- } catch(ClassCastException e) {
- this.blank_lines_before_field = 0;
- }
- }
- final Object blankLinesBeforeFirstClassBodyDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION);
- if (blankLinesBeforeFirstClassBodyDeclarationOption != null) {
- try {
- this.blank_lines_before_first_class_body_declaration = Integer.parseInt((String) blankLinesBeforeFirstClassBodyDeclarationOption);
- } catch (NumberFormatException e) {
- this.blank_lines_before_first_class_body_declaration = 0;
- } catch(ClassCastException e) {
- this.blank_lines_before_first_class_body_declaration = 0;
- }
- }
- final Object blankLinesBeforeImportsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_IMPORTS);
- if (blankLinesBeforeImportsOption != null) {
- try {
- this.blank_lines_before_imports = Integer.parseInt((String) blankLinesBeforeImportsOption);
- } catch (NumberFormatException e) {
- this.blank_lines_before_imports = 0;
- } catch(ClassCastException e) {
- this.blank_lines_before_imports = 0;
- }
- }
- final Object blankLinesBeforeMemberTypeOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE);
- if (blankLinesBeforeMemberTypeOption != null) {
- try {
- this.blank_lines_before_member_type = Integer.parseInt((String) blankLinesBeforeMemberTypeOption);
- } catch (NumberFormatException e) {
- this.blank_lines_before_member_type = 0;
- } catch(ClassCastException e) {
- this.blank_lines_before_member_type = 0;
- }
- }
- final Object blankLinesBeforeMethodOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD);
- if (blankLinesBeforeMethodOption != null) {
- try {
- this.blank_lines_before_method = Integer.parseInt((String) blankLinesBeforeMethodOption);
- } catch (NumberFormatException e) {
- this.blank_lines_before_method = 0;
- } catch(ClassCastException e) {
- this.blank_lines_before_method = 0;
- }
- }
- final Object blankLinesBeforeNewChunkOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK);
- if (blankLinesBeforeNewChunkOption != null) {
- try {
- this.blank_lines_before_new_chunk = Integer.parseInt((String) blankLinesBeforeNewChunkOption);
- } catch (NumberFormatException e) {
- this.blank_lines_before_new_chunk = 0;
- } catch(ClassCastException e) {
- this.blank_lines_before_new_chunk = 0;
- }
- }
- final Object blankLinesBeforePackageOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE);
- if (blankLinesBeforePackageOption != null) {
- try {
- this.blank_lines_before_package = Integer.parseInt((String) blankLinesBeforePackageOption);
- } catch (NumberFormatException e) {
- this.blank_lines_before_package = 0;
- } catch(ClassCastException e) {
- this.blank_lines_before_package = 0;
- }
- }
- final Object blankLinesBetweenImportGroupsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS);
- if (blankLinesBetweenImportGroupsOption != null) {
- try {
- this.blank_lines_between_import_groups = Integer.parseInt((String) blankLinesBetweenImportGroupsOption);
- } catch (NumberFormatException e) {
- this.blank_lines_between_import_groups = 1;
- } catch(ClassCastException e) {
- this.blank_lines_between_import_groups = 1;
- }
- }
- final Object blankLinesBetweenTypeDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS);
- if (blankLinesBetweenTypeDeclarationsOption != null) {
- try {
- this.blank_lines_between_type_declarations = Integer.parseInt((String) blankLinesBetweenTypeDeclarationsOption);
- } catch (NumberFormatException e) {
- this.blank_lines_between_type_declarations = 0;
- } catch(ClassCastException e) {
- this.blank_lines_between_type_declarations = 0;
- }
- }
- final Object blankLinesAtBeginningOfMethodBodyOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY);
- if (blankLinesAtBeginningOfMethodBodyOption != null) {
- try {
- this.blank_lines_at_beginning_of_method_body = Integer.parseInt((String) blankLinesAtBeginningOfMethodBodyOption);
- } catch (NumberFormatException e) {
- this.blank_lines_at_beginning_of_method_body = 0;
- } catch(ClassCastException e) {
- this.blank_lines_at_beginning_of_method_body = 0;
- }
- }
- setDeprecatedOptions(settings);
- final Object commentFormatJavadocCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT);
- if (commentFormatJavadocCommentOption != null) {
- this.comment_format_javadoc_comment = DefaultCodeFormatterConstants.TRUE.equals(commentFormatJavadocCommentOption);
- }
- final Object commentFormatBlockCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT);
- if (commentFormatBlockCommentOption != null) {
- this.comment_format_block_comment = DefaultCodeFormatterConstants.TRUE.equals(commentFormatBlockCommentOption);
- }
- final Object commentFormatLineCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT);
- if (commentFormatLineCommentOption != null) {
- this.comment_format_line_comment = DefaultCodeFormatterConstants.TRUE.equals(commentFormatLineCommentOption);
- }
- final Object commentFormatHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER);
- if (commentFormatHeaderOption != null) {
- this.comment_format_header = DefaultCodeFormatterConstants.TRUE.equals(commentFormatHeaderOption);
- }
- final Object commentFormatHtmlOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML);
- if (commentFormatHtmlOption != null) {
- this.comment_format_html = DefaultCodeFormatterConstants.TRUE.equals(commentFormatHtmlOption);
- }
- final Object commentFormatSourceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE);
- if (commentFormatSourceOption != null) {
- this.comment_format_source = DefaultCodeFormatterConstants.TRUE.equals(commentFormatSourceOption);
- }
- final Object commentIndentParameterDescriptionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION);
- if (commentIndentParameterDescriptionOption != null) {
- this.comment_indent_parameter_description = DefaultCodeFormatterConstants.TRUE.equals(commentIndentParameterDescriptionOption);
- }
- final Object commentIndentRootTagsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_ROOT_TAGS);
- if (commentIndentRootTagsOption != null) {
- this.comment_indent_root_tags = DefaultCodeFormatterConstants.TRUE.equals(commentIndentRootTagsOption);
- }
- final Object commentInsertEmptyLineBeforeRootTagsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS);
- if (commentInsertEmptyLineBeforeRootTagsOption != null) {
- this.comment_insert_empty_line_before_root_tags = JavaScriptCore.INSERT.equals(commentInsertEmptyLineBeforeRootTagsOption);
- }
- final Object commentInsertNewLineForParameterOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER);
- if (commentInsertNewLineForParameterOption != null) {
- this.comment_insert_new_line_for_parameter = JavaScriptCore.INSERT.equals(commentInsertNewLineForParameterOption);
- }
- final Object commentLineLengthOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH);
- if (commentLineLengthOption != null) {
- try {
- this.comment_line_length = Integer.parseInt((String) commentLineLengthOption);
- } catch (NumberFormatException e) {
- this.comment_line_length = 80;
- } catch(ClassCastException e) {
- this.comment_line_length = 80;
- }
- }
- final Object indentStatementsCompareToBlockOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
- if (indentStatementsCompareToBlockOption != null) {
- this.indent_statements_compare_to_block = DefaultCodeFormatterConstants.TRUE.equals(indentStatementsCompareToBlockOption);
- }
- final Object indentStatementsCompareToBodyOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY);
- if (indentStatementsCompareToBodyOption != null) {
- this.indent_statements_compare_to_body = DefaultCodeFormatterConstants.TRUE.equals(indentStatementsCompareToBodyOption);
- }
- final Object indentBodyDeclarationsCompareToAnnotationDeclarationHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER);
- if (indentBodyDeclarationsCompareToAnnotationDeclarationHeaderOption != null) {
- this.indent_body_declarations_compare_to_annotation_declaration_header = DefaultCodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToAnnotationDeclarationHeaderOption);
- }
- final Object indentBodyDeclarationsCompareToEnumConstantHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER);
- if (indentBodyDeclarationsCompareToEnumConstantHeaderOption != null) {
- this.indent_body_declarations_compare_to_enum_constant_header = DefaultCodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToEnumConstantHeaderOption);
- }
- final Object indentBodyDeclarationsCompareToEnumDeclarationHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER);
- if (indentBodyDeclarationsCompareToEnumDeclarationHeaderOption != null) {
- this.indent_body_declarations_compare_to_enum_declaration_header = DefaultCodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToEnumDeclarationHeaderOption);
- }
- final Object indentBodyDeclarationsCompareToTypeHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER);
- if (indentBodyDeclarationsCompareToTypeHeaderOption != null) {
- this.indent_body_declarations_compare_to_type_header = DefaultCodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToTypeHeaderOption);
- }
- final Object indentBreaksCompareToCasesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES);
- if (indentBreaksCompareToCasesOption != null) {
- this.indent_breaks_compare_to_cases = DefaultCodeFormatterConstants.TRUE.equals(indentBreaksCompareToCasesOption);
- }
- final Object indentEmptyLinesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES);
- if (indentEmptyLinesOption != null) {
- this.indent_empty_lines = DefaultCodeFormatterConstants.TRUE.equals(indentEmptyLinesOption);
- }
- final Object indentSwitchstatementsCompareToCasesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES);
- if (indentSwitchstatementsCompareToCasesOption != null) {
- this.indent_switchstatements_compare_to_cases = DefaultCodeFormatterConstants.TRUE.equals(indentSwitchstatementsCompareToCasesOption);
- }
- final Object indentSwitchstatementsCompareToSwitchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH);
- if (indentSwitchstatementsCompareToSwitchOption != null) {
- this.indent_switchstatements_compare_to_switch = DefaultCodeFormatterConstants.TRUE.equals(indentSwitchstatementsCompareToSwitchOption);
- }
- final Object indentationSizeOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
- if (indentationSizeOption != null) {
- try {
- this.indentation_size = Integer.parseInt((String) indentationSizeOption);
- } catch (NumberFormatException e) {
- this.indentation_size = 4;
- } catch(ClassCastException e) {
- this.indentation_size = 4;
- }
- }
- final Object insertNewLineAfterAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION);
- if (insertNewLineAfterAnnotationOption != null) {
- this.insert_new_line_after_annotation = JavaScriptCore.INSERT.equals(insertNewLineAfterAnnotationOption);
- }
- final Object insertNewLineAfterOpeningBraceInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER);
- if (insertNewLineAfterOpeningBraceInArrayInitializerOption != null) {
- this.insert_new_line_after_opening_brace_in_array_initializer = JavaScriptCore.INSERT.equals(insertNewLineAfterOpeningBraceInArrayInitializerOption);
- }
- final Object insertNewLineAfterOpeningBraceInObjLitInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_OBJLIT_INITIALIZER);
- if (insertNewLineAfterOpeningBraceInObjLitInitializerOption != null) {
- this.insert_new_line_after_opening_brace_in_objlit_initializer = JavaScriptCore.INSERT.equals(insertNewLineAfterOpeningBraceInObjLitInitializerOption);
- }
- final Object insertNewLineAfterCommaInObjLitInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_COMMA_IN_OBJLIT_INITIALIZER);
- if (insertNewLineAfterCommaInObjLitInitializerOption != null) {
- this.insert_new_line_after_comma_in_objlit_initializer = JavaScriptCore.INSERT.equals(insertNewLineAfterCommaInObjLitInitializerOption);
- }
- final Object insertNewLineAtEndOfFileIfMissingOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING);
- if (insertNewLineAtEndOfFileIfMissingOption != null) {
- this.insert_new_line_at_end_of_file_if_missing = JavaScriptCore.INSERT.equals(insertNewLineAtEndOfFileIfMissingOption);
- }
- final Object insertNewLineBeforeCatchInTryStatementOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT);
- if (insertNewLineBeforeCatchInTryStatementOption != null) {
- this.insert_new_line_before_catch_in_try_statement = JavaScriptCore.INSERT.equals(insertNewLineBeforeCatchInTryStatementOption);
- }
- final Object insertNewLineBeforeClosingBraceInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER);
- if (insertNewLineBeforeClosingBraceInArrayInitializerOption != null) {
- this.insert_new_line_before_closing_brace_in_array_initializer = JavaScriptCore.INSERT.equals(insertNewLineBeforeClosingBraceInArrayInitializerOption);
- }
- final Object insertNewLineBeforeClosingBraceInObjLitInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_OBJLIT_INITIALIZER);
- if (insertNewLineBeforeClosingBraceInObjLitInitializerOption != null) {
- this.insert_new_line_before_closing_brace_in_objlit_initializer = JavaScriptCore.INSERT.equals(insertNewLineBeforeClosingBraceInObjLitInitializerOption);
- }
- final Object insertNewLineBeforeElseInIfStatementOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT);
- if (insertNewLineBeforeElseInIfStatementOption != null) {
- this.insert_new_line_before_else_in_if_statement = JavaScriptCore.INSERT.equals(insertNewLineBeforeElseInIfStatementOption);
- }
- final Object insertNewLineBeforeFinallyInTryStatementOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT);
- if (insertNewLineBeforeFinallyInTryStatementOption != null) {
- this.insert_new_line_before_finally_in_try_statement = JavaScriptCore.INSERT.equals(insertNewLineBeforeFinallyInTryStatementOption);
- }
- final Object insertNewLineBeforeWhileInDoStatementOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT);
- if (insertNewLineBeforeWhileInDoStatementOption != null) {
- this.insert_new_line_before_while_in_do_statement = JavaScriptCore.INSERT.equals(insertNewLineBeforeWhileInDoStatementOption);
- }
- final Object insertNewLineInEmptyAnonymousTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION);
- if (insertNewLineInEmptyAnonymousTypeDeclarationOption != null) {
- this.insert_new_line_in_empty_anonymous_type_declaration = JavaScriptCore.INSERT.equals(insertNewLineInEmptyAnonymousTypeDeclarationOption);
- }
- final Object insertNewLineInEmptyBlockOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK);
- if (insertNewLineInEmptyBlockOption != null) {
- this.insert_new_line_in_empty_block = JavaScriptCore.INSERT.equals(insertNewLineInEmptyBlockOption);
- }
- final Object insertNewLineInEmptyAnnotationDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION);
- if (insertNewLineInEmptyAnnotationDeclarationOption != null) {
- this.insert_new_line_in_empty_annotation_declaration = JavaScriptCore.INSERT.equals(insertNewLineInEmptyAnnotationDeclarationOption);
- }
- final Object insertNewLineInEmptyEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT);
- if (insertNewLineInEmptyEnumConstantOption != null) {
- this.insert_new_line_in_empty_enum_constant = JavaScriptCore.INSERT.equals(insertNewLineInEmptyEnumConstantOption);
- }
- final Object insertNewLineInEmptyEnumDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION);
- if (insertNewLineInEmptyEnumDeclarationOption != null) {
- this.insert_new_line_in_empty_enum_declaration = JavaScriptCore.INSERT.equals(insertNewLineInEmptyEnumDeclarationOption);
- }
- final Object insertNewLineInEmptyMethodBodyOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY);
- if (insertNewLineInEmptyMethodBodyOption != null) {
- this.insert_new_line_in_empty_method_body = JavaScriptCore.INSERT.equals(insertNewLineInEmptyMethodBodyOption);
- }
- final Object insertNewLineInEmptyTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION);
- if (insertNewLineInEmptyTypeDeclarationOption != null) {
- this.insert_new_line_in_empty_type_declaration = JavaScriptCore.INSERT.equals(insertNewLineInEmptyTypeDeclarationOption);
- }
- final Object insertSpaceAfterAndInWildcardOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER);
- if (insertSpaceAfterAndInWildcardOption != null) {
- this.insert_space_after_and_in_type_parameter = JavaScriptCore.INSERT.equals(insertSpaceAfterAndInWildcardOption);
- }
- final Object insertSpaceAfterAssignmentOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR);
- if (insertSpaceAfterAssignmentOperatorOption != null) {
- this.insert_space_after_assignment_operator = JavaScriptCore.INSERT.equals(insertSpaceAfterAssignmentOperatorOption);
- }
- final Object insertSpaceAfterAtInAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION);
- if (insertSpaceAfterAtInAnnotationOption != null) {
- this.insert_space_after_at_in_annotation = JavaScriptCore.INSERT.equals(insertSpaceAfterAtInAnnotationOption);
- }
- final Object insertSpaceAfterAtInAnnotationTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION_TYPE_DECLARATION);
- if (insertSpaceAfterAtInAnnotationTypeDeclarationOption != null) {
- this.insert_space_after_at_in_annotation_type_declaration = JavaScriptCore.INSERT.equals(insertSpaceAfterAtInAnnotationTypeDeclarationOption);
- }
- final Object insertSpaceAfterBinaryOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR);
- if (insertSpaceAfterBinaryOperatorOption != null) {
- this.insert_space_after_binary_operator = JavaScriptCore.INSERT.equals(insertSpaceAfterBinaryOperatorOption);
- }
- final Object insertSpaceAfterClosingAngleBracketInTypeArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS);
- if (insertSpaceAfterClosingAngleBracketInTypeArgumentsOption != null) {
- this.insert_space_after_closing_angle_bracket_in_type_arguments = JavaScriptCore.INSERT.equals(insertSpaceAfterClosingAngleBracketInTypeArgumentsOption);
- }
- final Object insertSpaceAfterClosingAngleBracketInTypeParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS);
- if (insertSpaceAfterClosingAngleBracketInTypeParametersOption != null) {
- this.insert_space_after_closing_angle_bracket_in_type_parameters = JavaScriptCore.INSERT.equals(insertSpaceAfterClosingAngleBracketInTypeParametersOption);
- }
- final Object insertSpaceAfterClosingParenInCastOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST);
- if (insertSpaceAfterClosingParenInCastOption != null) {
- this.insert_space_after_closing_paren_in_cast = JavaScriptCore.INSERT.equals(insertSpaceAfterClosingParenInCastOption);
- }
- final Object insertSpaceAfterClosingBraceInBlockOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK);
- if (insertSpaceAfterClosingBraceInBlockOption != null) {
- this.insert_space_after_closing_brace_in_block = JavaScriptCore.INSERT.equals(insertSpaceAfterClosingBraceInBlockOption);
- }
- final Object insertSpaceAfterColonInAssertOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT);
- if (insertSpaceAfterColonInAssertOption != null) {
- this.insert_space_after_colon_in_assert = JavaScriptCore.INSERT.equals(insertSpaceAfterColonInAssertOption);
- }
- final Object insertSpaceAfterColonInCaseOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE);
- if (insertSpaceAfterColonInCaseOption != null) {
- this.insert_space_after_colon_in_case = JavaScriptCore.INSERT.equals(insertSpaceAfterColonInCaseOption);
- }
- final Object insertSpaceAfterColonInConditionalOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL);
- if (insertSpaceAfterColonInConditionalOption != null) {
- this.insert_space_after_colon_in_conditional = JavaScriptCore.INSERT.equals(insertSpaceAfterColonInConditionalOption);
- }
- final Object insertSpaceAfterColonInObjectInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_OBJECT_INITIALIZER);
- if (insertSpaceAfterColonInObjectInitializerOption != null) {
- this.insert_space_after_colon_in_object_initializer = JavaScriptCore.INSERT.equals(insertSpaceAfterColonInObjectInitializerOption);
- }
- final Object insertSpaceAfterColonInForOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR);
- if (insertSpaceAfterColonInForOption != null) {
- this.insert_space_after_colon_in_for = JavaScriptCore.INSERT.equals(insertSpaceAfterColonInForOption);
- }
- final Object insertSpaceAfterColonInLabeledStatementOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT);
- if (insertSpaceAfterColonInLabeledStatementOption != null) {
- this.insert_space_after_colon_in_labeled_statement = JavaScriptCore.INSERT.equals(insertSpaceAfterColonInLabeledStatementOption);
- }
- final Object insertSpaceAfterCommaInAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION);
- if (insertSpaceAfterCommaInAllocationExpressionOption != null) {
- this.insert_space_after_comma_in_allocation_expression = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInAllocationExpressionOption);
- }
- final Object insertSpaceAfterCommaInAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ANNOTATION);
- if (insertSpaceAfterCommaInAnnotationOption != null) {
- this.insert_space_after_comma_in_annotation = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInAnnotationOption);
- }
- final Object insertSpaceAfterCommaInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER);
- if (insertSpaceAfterCommaInArrayInitializerOption != null) {
- this.insert_space_after_comma_in_array_initializer = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInArrayInitializerOption);
- }
- final Object insertSpaceAfterCommaInConstructorDeclarationParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS);
- if (insertSpaceAfterCommaInConstructorDeclarationParametersOption != null) {
- this.insert_space_after_comma_in_constructor_declaration_parameters = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInConstructorDeclarationParametersOption);
- }
- final Object insertSpaceAfterCommaInConstructorDeclarationThrowsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS);
- if (insertSpaceAfterCommaInConstructorDeclarationThrowsOption != null) {
- this.insert_space_after_comma_in_constructor_declaration_throws = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInConstructorDeclarationThrowsOption);
- }
- final Object insertSpaceAfterCommaInEnumConstantArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_CONSTANT_ARGUMENTS);
- if (insertSpaceAfterCommaInEnumConstantArgumentsOption != null) {
- this.insert_space_after_comma_in_enum_constant_arguments = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInEnumConstantArgumentsOption);
- }
- final Object insertSpaceAfterCommaInEnumDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_DECLARATIONS);
- if (insertSpaceAfterCommaInEnumDeclarationsOption != null) {
- this.insert_space_after_comma_in_enum_declarations = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInEnumDeclarationsOption);
- }
- final Object insertSpaceAfterCommaInExplicitConstructorCallArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS);
- if (insertSpaceAfterCommaInExplicitConstructorCallArgumentsOption != null) {
- this.insert_space_after_comma_in_explicit_constructor_call_arguments = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInExplicitConstructorCallArgumentsOption);
- }
- final Object insertSpaceAfterCommaInForIncrementsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS);
- if (insertSpaceAfterCommaInForIncrementsOption != null) {
- this.insert_space_after_comma_in_for_increments = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInForIncrementsOption);
- }
- final Object insertSpaceAfterCommaInForInitsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS);
- if (insertSpaceAfterCommaInForInitsOption != null) {
- this.insert_space_after_comma_in_for_inits = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInForInitsOption);
- }
- final Object insertSpaceAfterCommaInMethodInvocationArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS);
- if (insertSpaceAfterCommaInMethodInvocationArgumentsOption != null) {
- this.insert_space_after_comma_in_method_invocation_arguments = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInMethodInvocationArgumentsOption);
- }
- final Object insertSpaceAfterCommaInMethodDeclarationParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS);
- if (insertSpaceAfterCommaInMethodDeclarationParametersOption != null) {
- this.insert_space_after_comma_in_method_declaration_parameters = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInMethodDeclarationParametersOption);
- }
- final Object insertSpaceAfterCommaInMethodDeclarationThrowsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS);
- if (insertSpaceAfterCommaInMethodDeclarationThrowsOption != null) {
- this.insert_space_after_comma_in_method_declaration_throws = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInMethodDeclarationThrowsOption);
- }
- final Object insertSpaceAfterCommaInMultipleFieldDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS);
- if (insertSpaceAfterCommaInMultipleFieldDeclarationsOption != null) {
- this.insert_space_after_comma_in_multiple_field_declarations = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInMultipleFieldDeclarationsOption);
- }
- final Object insertSpaceAfterCommaInMultipleLocalDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS);
- if (insertSpaceAfterCommaInMultipleLocalDeclarationsOption != null) {
- this.insert_space_after_comma_in_multiple_local_declarations = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInMultipleLocalDeclarationsOption);
- }
- final Object insertSpaceAfterCommaInParameterizedTypeReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE);
- if (insertSpaceAfterCommaInParameterizedTypeReferenceOption != null) {
- this.insert_space_after_comma_in_parameterized_type_reference = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInParameterizedTypeReferenceOption);
- }
- final Object insertSpaceAfterCommaInSuperinterfacesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES);
- if (insertSpaceAfterCommaInSuperinterfacesOption != null) {
- this.insert_space_after_comma_in_superinterfaces = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInSuperinterfacesOption);
- }
- final Object insertSpaceAfterCommaInTypeArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS);
- if (insertSpaceAfterCommaInTypeArgumentsOption != null) {
- this.insert_space_after_comma_in_type_arguments = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInTypeArgumentsOption);
- }
- final Object insertSpaceAfterCommaInTypeParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_PARAMETERS);
- if (insertSpaceAfterCommaInTypeParametersOption != null) {
- this.insert_space_after_comma_in_type_parameters = JavaScriptCore.INSERT.equals(insertSpaceAfterCommaInTypeParametersOption);
- }
- final Object insertSpaceAfterEllipsisOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS);
- if (insertSpaceAfterEllipsisOption != null) {
- this.insert_space_after_ellipsis = JavaScriptCore.INSERT.equals(insertSpaceAfterEllipsisOption);
- }
- final Object insertSpaceAfterOpeningAngleBracketInParameterizedTypeReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE);
- if (insertSpaceAfterOpeningAngleBracketInParameterizedTypeReferenceOption != null) {
- this.insert_space_after_opening_angle_bracket_in_parameterized_type_reference = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningAngleBracketInParameterizedTypeReferenceOption);
- }
- final Object insertSpaceAfterOpeningAngleBracketInTypeArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS);
- if (insertSpaceAfterOpeningAngleBracketInTypeArgumentsOption != null) {
- this.insert_space_after_opening_angle_bracket_in_type_arguments = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningAngleBracketInTypeArgumentsOption);
- }
- final Object insertSpaceAfterOpeningAngleBracketInTypeParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS);
- if (insertSpaceAfterOpeningAngleBracketInTypeParametersOption != null) {
- this.insert_space_after_opening_angle_bracket_in_type_parameters = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningAngleBracketInTypeParametersOption);
- }
- final Object insertSpaceAfterOpeningBracketInArrayAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION);
- if (insertSpaceAfterOpeningBracketInArrayAllocationExpressionOption != null) {
- this.insert_space_after_opening_bracket_in_array_allocation_expression = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningBracketInArrayAllocationExpressionOption);
- }
- final Object insertSpaceAfterOpeningBracketInArrayReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE);
- if (insertSpaceAfterOpeningBracketInArrayReferenceOption != null) {
- this.insert_space_after_opening_bracket_in_array_reference = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningBracketInArrayReferenceOption);
- }
- final Object insertSpaceAfterOpeningBraceInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER);
- if (insertSpaceAfterOpeningBraceInArrayInitializerOption != null) {
- this.insert_space_after_opening_brace_in_array_initializer = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningBraceInArrayInitializerOption);
- }
- final Object insertSpaceAfterOpeningParenInAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION);
- if (insertSpaceAfterOpeningParenInAnnotationOption != null) {
- this.insert_space_after_opening_paren_in_annotation = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInAnnotationOption);
- }
- final Object insertSpaceAfterOpeningParenInCastOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST);
- if (insertSpaceAfterOpeningParenInCastOption != null) {
- this.insert_space_after_opening_paren_in_cast = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInCastOption);
- }
- final Object insertSpaceAfterOpeningParenInCatchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH);
- if (insertSpaceAfterOpeningParenInCatchOption != null) {
- this.insert_space_after_opening_paren_in_catch = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInCatchOption);
- }
- final Object insertSpaceAfterOpeningParenInConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION);
- if (insertSpaceAfterOpeningParenInConstructorDeclarationOption != null) {
- this.insert_space_after_opening_paren_in_constructor_declaration = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInConstructorDeclarationOption);
- }
- final Object insertSpaceAfterOpeningParenInEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT);
- if (insertSpaceAfterOpeningParenInEnumConstantOption != null) {
- this.insert_space_after_opening_paren_in_enum_constant = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInEnumConstantOption);
- }
- final Object insertSpaceAfterOpeningParenInForOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR);
- if (insertSpaceAfterOpeningParenInForOption != null) {
- this.insert_space_after_opening_paren_in_for = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInForOption);
- }
- final Object insertSpaceAfterOpeningParenInIfOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF);
- if (insertSpaceAfterOpeningParenInIfOption != null) {
- this.insert_space_after_opening_paren_in_if = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInIfOption);
- }
- final Object insertSpaceAfterOpeningParenInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION);
- if (insertSpaceAfterOpeningParenInMethodDeclarationOption != null) {
- this.insert_space_after_opening_paren_in_method_declaration = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInMethodDeclarationOption);
- }
- final Object insertSpaceAfterOpeningParenInMethodInvocationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION);
- if (insertSpaceAfterOpeningParenInMethodInvocationOption != null) {
- this.insert_space_after_opening_paren_in_method_invocation = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInMethodInvocationOption);
- }
- final Object insertSpaceAfterOpeningParenInParenthesizedExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION);
- if (insertSpaceAfterOpeningParenInParenthesizedExpressionOption != null) {
- this.insert_space_after_opening_paren_in_parenthesized_expression = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInParenthesizedExpressionOption);
- }
- final Object insertSpaceAfterOpeningParenInSwitchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH);
- if (insertSpaceAfterOpeningParenInSwitchOption != null) {
- this.insert_space_after_opening_paren_in_switch = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInSwitchOption);
- }
- final Object insertSpaceAfterOpeningParenInSynchronizedOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED);
- if (insertSpaceAfterOpeningParenInSynchronizedOption != null) {
- this.insert_space_after_opening_paren_in_synchronized = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInSynchronizedOption);
- }
- final Object insertSpaceAfterOpeningParenInWhileOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE);
- if (insertSpaceAfterOpeningParenInWhileOption != null) {
- this.insert_space_after_opening_paren_in_while = JavaScriptCore.INSERT.equals(insertSpaceAfterOpeningParenInWhileOption);
- }
- final Object insertSpaceAfterPostfixOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR);
- if (insertSpaceAfterPostfixOperatorOption != null) {
- this.insert_space_after_postfix_operator = JavaScriptCore.INSERT.equals(insertSpaceAfterPostfixOperatorOption);
- }
- final Object insertSpaceAfterPrefixOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR);
- if (insertSpaceAfterPrefixOperatorOption != null) {
- this.insert_space_after_prefix_operator = JavaScriptCore.INSERT.equals(insertSpaceAfterPrefixOperatorOption);
- }
- final Object insertSpaceAfterQuestionInConditionalOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL);
- if (insertSpaceAfterQuestionInConditionalOption != null) {
- this.insert_space_after_question_in_conditional = JavaScriptCore.INSERT.equals(insertSpaceAfterQuestionInConditionalOption);
- }
- final Object insertSpaceAfterSemicolonInForOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR);
- if (insertSpaceAfterSemicolonInForOption != null) {
- this.insert_space_after_semicolon_in_for = JavaScriptCore.INSERT.equals(insertSpaceAfterSemicolonInForOption);
- }
- final Object insertSpaceAfterUnaryOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR);
- if (insertSpaceAfterUnaryOperatorOption != null) {
- this.insert_space_after_unary_operator = JavaScriptCore.INSERT.equals(insertSpaceAfterUnaryOperatorOption);
- }
- final Object insertSpaceBeforeAtInAnnotationTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_AT_IN_ANNOTATION_TYPE_DECLARATION);
- if (insertSpaceBeforeAtInAnnotationTypeDeclarationOption != null) {
- this.insert_space_before_at_in_annotation_type_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeAtInAnnotationTypeDeclarationOption);
- }
- final Object insertSpaceBeforeAssignmentOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR);
- if (insertSpaceBeforeAssignmentOperatorOption != null) {
- this.insert_space_before_assignment_operator = JavaScriptCore.INSERT.equals(insertSpaceBeforeAssignmentOperatorOption);
- }
- final Object insertSpaceBeforeBinaryOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR);
- if (insertSpaceBeforeBinaryOperatorOption != null) {
- this.insert_space_before_binary_operator = JavaScriptCore.INSERT.equals(insertSpaceBeforeBinaryOperatorOption);
- }
- final Object insertSpaceBeforeClosingAngleBracketInParameterizedTypeReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE);
- if (insertSpaceBeforeClosingAngleBracketInParameterizedTypeReferenceOption != null) {
- this.insert_space_before_closing_angle_bracket_in_parameterized_type_reference = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingAngleBracketInParameterizedTypeReferenceOption);
- }
- final Object insertSpaceBeforeClosingAngleBracketInTypeArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS);
- if (insertSpaceBeforeClosingAngleBracketInTypeArgumentsOption != null) {
- this.insert_space_before_closing_angle_bracket_in_type_arguments = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingAngleBracketInTypeArgumentsOption);
- }
- final Object insertSpaceBeforeClosingAngleBracketInTypeParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS);
- if (insertSpaceBeforeClosingAngleBracketInTypeParametersOption != null) {
- this.insert_space_before_closing_angle_bracket_in_type_parameters = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingAngleBracketInTypeParametersOption);
- }
- final Object insertSpaceBeforeClosingBraceInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER);
- if (insertSpaceBeforeClosingBraceInArrayInitializerOption != null) {
- this.insert_space_before_closing_brace_in_array_initializer = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingBraceInArrayInitializerOption);
- }
- final Object insertSpaceBeforeClosingBracketInArrayAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION);
- if (insertSpaceBeforeClosingBracketInArrayAllocationExpressionOption != null) {
- this.insert_space_before_closing_bracket_in_array_allocation_expression = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingBracketInArrayAllocationExpressionOption);
- }
- final Object insertSpaceBeforeClosingBracketInArrayReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE);
- if (insertSpaceBeforeClosingBracketInArrayReferenceOption != null) {
- this.insert_space_before_closing_bracket_in_array_reference = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingBracketInArrayReferenceOption);
- }
- final Object insertSpaceBeforeClosingParenInAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ANNOTATION);
- if (insertSpaceBeforeClosingParenInAnnotationOption != null) {
- this.insert_space_before_closing_paren_in_annotation = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInAnnotationOption);
- }
- final Object insertSpaceBeforeClosingParenInCastOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST);
- if (insertSpaceBeforeClosingParenInCastOption != null) {
- this.insert_space_before_closing_paren_in_cast = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInCastOption);
- }
- final Object insertSpaceBeforeClosingParenInCatchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH);
- if (insertSpaceBeforeClosingParenInCatchOption != null) {
- this.insert_space_before_closing_paren_in_catch = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInCatchOption);
- }
- final Object insertSpaceBeforeClosingParenInConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION);
- if (insertSpaceBeforeClosingParenInConstructorDeclarationOption != null) {
- this.insert_space_before_closing_paren_in_constructor_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInConstructorDeclarationOption);
- }
- final Object insertSpaceBeforeClosingParenInEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ENUM_CONSTANT);
- if (insertSpaceBeforeClosingParenInEnumConstantOption != null) {
- this.insert_space_before_closing_paren_in_enum_constant = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInEnumConstantOption);
- }
- final Object insertSpaceBeforeClosingParenInForOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR);
- if (insertSpaceBeforeClosingParenInForOption != null) {
- this.insert_space_before_closing_paren_in_for = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInForOption);
- }
- final Object insertSpaceBeforeClosingParenInIfOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF);
- if (insertSpaceBeforeClosingParenInIfOption != null) {
- this.insert_space_before_closing_paren_in_if = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInIfOption);
- }
- final Object insertSpaceBeforeClosingParenInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION);
- if (insertSpaceBeforeClosingParenInMethodDeclarationOption != null) {
- this.insert_space_before_closing_paren_in_method_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInMethodDeclarationOption);
- }
- final Object insertSpaceBeforeClosingParenInMethodInvocationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION);
- if (insertSpaceBeforeClosingParenInMethodInvocationOption != null) {
- this.insert_space_before_closing_paren_in_method_invocation = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInMethodInvocationOption);
- }
- final Object insertSpaceBeforeClosingParenInParenthesizedExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION);
- if (insertSpaceBeforeClosingParenInParenthesizedExpressionOption != null) {
- this.insert_space_before_closing_paren_in_parenthesized_expression = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInParenthesizedExpressionOption);
- }
- final Object insertSpaceBeforeClosingParenInSwitchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH);
- if (insertSpaceBeforeClosingParenInSwitchOption != null) {
- this.insert_space_before_closing_paren_in_switch = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInSwitchOption);
- }
- final Object insertSpaceBeforeClosingParenInSynchronizedOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED);
- if (insertSpaceBeforeClosingParenInSynchronizedOption != null) {
- this.insert_space_before_closing_paren_in_synchronized = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInSynchronizedOption);
- }
- final Object insertSpaceBeforeClosingParenInWhileOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE);
- if (insertSpaceBeforeClosingParenInWhileOption != null) {
- this.insert_space_before_closing_paren_in_while = JavaScriptCore.INSERT.equals(insertSpaceBeforeClosingParenInWhileOption);
- }
- final Object insertSpaceBeforeColonInAssertOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT);
- if (insertSpaceBeforeColonInAssertOption != null) {
- this.insert_space_before_colon_in_assert = JavaScriptCore.INSERT.equals(insertSpaceBeforeColonInAssertOption);
- }
- final Object insertSpaceBeforeColonInCaseOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE);
- if (insertSpaceBeforeColonInCaseOption != null) {
- this.insert_space_before_colon_in_case = JavaScriptCore.INSERT.equals(insertSpaceBeforeColonInCaseOption);
- }
- final Object insertSpaceBeforeColonInConditionalOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL);
- if (insertSpaceBeforeColonInConditionalOption != null) {
- this.insert_space_before_colon_in_conditional = JavaScriptCore.INSERT.equals(insertSpaceBeforeColonInConditionalOption);
- }
- final Object insertSpaceBeforeColonInObjectInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_OBJECT_INITIALIZER);
- if (insertSpaceBeforeColonInObjectInitializerOption != null) {
- this.insert_space_before_colon_in_object_initializer = JavaScriptCore.INSERT.equals(insertSpaceBeforeColonInObjectInitializerOption);
- }
- final Object insertSpaceBeforeColonInDefaultOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT);
- if (insertSpaceBeforeColonInDefaultOption != null) {
- this.insert_space_before_colon_in_default = JavaScriptCore.INSERT.equals(insertSpaceBeforeColonInDefaultOption);
- }
- final Object insertSpaceBeforeColonInForOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR);
- if (insertSpaceBeforeColonInForOption != null) {
- this.insert_space_before_colon_in_for = JavaScriptCore.INSERT.equals(insertSpaceBeforeColonInForOption);
- }
- final Object insertSpaceBeforeColonInLabeledStatementOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT);
- if (insertSpaceBeforeColonInLabeledStatementOption != null) {
- this.insert_space_before_colon_in_labeled_statement = JavaScriptCore.INSERT.equals(insertSpaceBeforeColonInLabeledStatementOption);
- }
- final Object insertSpaceBeforeCommaInAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION);
- if (insertSpaceBeforeCommaInAllocationExpressionOption != null) {
- this.insert_space_before_comma_in_allocation_expression = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInAllocationExpressionOption);
- }
- final Object insertSpaceBeforeCommaInAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ANNOTATION);
- if (insertSpaceBeforeCommaInAnnotationOption != null) {
- this.insert_space_before_comma_in_annotation = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInAnnotationOption);
- }
- final Object insertSpaceBeforeCommaInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER);
- if (insertSpaceBeforeCommaInArrayInitializerOption != null) {
- this.insert_space_before_comma_in_array_initializer = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInArrayInitializerOption);
- }
- final Object insertSpaceBeforeCommaInConstructorDeclarationParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS);
- if (insertSpaceBeforeCommaInConstructorDeclarationParametersOption != null) {
- this.insert_space_before_comma_in_constructor_declaration_parameters = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInConstructorDeclarationParametersOption);
- }
- final Object insertSpaceBeforeCommaInConstructorDeclarationThrowsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS);
- if (insertSpaceBeforeCommaInConstructorDeclarationThrowsOption != null) {
- this.insert_space_before_comma_in_constructor_declaration_throws = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInConstructorDeclarationThrowsOption);
- }
- final Object insertSpaceBeforeCommaInEnumConstantArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_CONSTANT_ARGUMENTS);
- if (insertSpaceBeforeCommaInEnumConstantArgumentsOption != null) {
- this.insert_space_before_comma_in_enum_constant_arguments = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInEnumConstantArgumentsOption);
- }
- final Object insertSpaceBeforeCommaInEnumDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_DECLARATIONS);
- if (insertSpaceBeforeCommaInEnumDeclarationsOption != null) {
- this.insert_space_before_comma_in_enum_declarations = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInEnumDeclarationsOption);
- }
- final Object insertSpaceBeforeCommaInExplicitConstructorCallArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS);
- if (insertSpaceBeforeCommaInExplicitConstructorCallArgumentsOption != null) {
- this.insert_space_before_comma_in_explicit_constructor_call_arguments = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInExplicitConstructorCallArgumentsOption);
- }
- final Object insertSpaceBeforeCommaInForIncrementsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS);
- if (insertSpaceBeforeCommaInForIncrementsOption != null) {
- this.insert_space_before_comma_in_for_increments = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInForIncrementsOption);
- }
- final Object insertSpaceBeforeCommaInForInitsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS);
- if (insertSpaceBeforeCommaInForInitsOption != null) {
- this.insert_space_before_comma_in_for_inits = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInForInitsOption);
- }
- final Object insertSpaceBeforeCommaInMethodInvocationArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS);
- if (insertSpaceBeforeCommaInMethodInvocationArgumentsOption != null) {
- this.insert_space_before_comma_in_method_invocation_arguments = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInMethodInvocationArgumentsOption);
- }
- final Object insertSpaceBeforeCommaInMethodDeclarationParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS);
- if (insertSpaceBeforeCommaInMethodDeclarationParametersOption != null) {
- this.insert_space_before_comma_in_method_declaration_parameters = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInMethodDeclarationParametersOption);
- }
- final Object insertSpaceBeforeCommaInMethodDeclarationThrowsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS);
- if (insertSpaceBeforeCommaInMethodDeclarationThrowsOption != null) {
- this.insert_space_before_comma_in_method_declaration_throws = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInMethodDeclarationThrowsOption);
- }
- final Object insertSpaceBeforeCommaInMultipleFieldDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS);
- if (insertSpaceBeforeCommaInMultipleFieldDeclarationsOption != null) {
- this.insert_space_before_comma_in_multiple_field_declarations = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInMultipleFieldDeclarationsOption);
- }
- final Object insertSpaceBeforeCommaInMultipleLocalDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS);
- if (insertSpaceBeforeCommaInMultipleLocalDeclarationsOption != null) {
- this.insert_space_before_comma_in_multiple_local_declarations = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInMultipleLocalDeclarationsOption);
- }
- final Object insertSpaceBeforeCommaInParameterizedTypeReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE);
- if (insertSpaceBeforeCommaInParameterizedTypeReferenceOption != null) {
- this.insert_space_before_comma_in_parameterized_type_reference = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInParameterizedTypeReferenceOption);
- }
- final Object insertSpaceBeforeCommaInSuperinterfacesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES);
- if (insertSpaceBeforeCommaInSuperinterfacesOption != null) {
- this.insert_space_before_comma_in_superinterfaces = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInSuperinterfacesOption);
- }
- final Object insertSpaceBeforeCommaInTypeArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_ARGUMENTS);
- if (insertSpaceBeforeCommaInTypeArgumentsOption != null) {
- this.insert_space_before_comma_in_type_arguments = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInTypeArgumentsOption);
- }
- final Object insertSpaceBeforeCommaInTypeParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_PARAMETERS);
- if (insertSpaceBeforeCommaInTypeParametersOption != null) {
- this.insert_space_before_comma_in_type_parameters = JavaScriptCore.INSERT.equals(insertSpaceBeforeCommaInTypeParametersOption);
- }
- final Object insertSpaceBeforeEllipsisOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS);
- if (insertSpaceBeforeEllipsisOption != null) {
- this.insert_space_before_ellipsis = JavaScriptCore.INSERT.equals(insertSpaceBeforeEllipsisOption);
- }
- final Object insertSpaceBeforeOpeningAngleBrackerInParameterizedTypeReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE);
- if (insertSpaceBeforeOpeningAngleBrackerInParameterizedTypeReferenceOption != null) {
- this.insert_space_before_opening_angle_bracket_in_parameterized_type_reference = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningAngleBrackerInParameterizedTypeReferenceOption);
- }
- final Object insertSpaceBeforeOpeningAngleBrackerInTypeArgumentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS);
- if (insertSpaceBeforeOpeningAngleBrackerInTypeArgumentsOption != null) {
- this.insert_space_before_opening_angle_bracket_in_type_arguments = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningAngleBrackerInTypeArgumentsOption);
- }
- final Object insertSpaceBeforeOpeningAngleBrackerInTypeParametersOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS);
- if (insertSpaceBeforeOpeningAngleBrackerInTypeParametersOption != null) {
- this.insert_space_before_opening_angle_bracket_in_type_parameters = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningAngleBrackerInTypeParametersOption);
- }
- final Object insertSpaceBeforeOpeningBraceInAnnotationTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANNOTATION_TYPE_DECLARATION);
- if (insertSpaceBeforeOpeningBraceInAnnotationTypeDeclarationOption != null) {
- this.insert_space_before_opening_brace_in_annotation_type_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInAnnotationTypeDeclarationOption);
- }
- final Object insertSpaceBeforeOpeningBraceInAnonymousTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION);
- if (insertSpaceBeforeOpeningBraceInAnonymousTypeDeclarationOption != null) {
- this.insert_space_before_opening_brace_in_anonymous_type_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInAnonymousTypeDeclarationOption);
- }
- final Object insertSpaceBeforeOpeningBraceInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER);
- if (insertSpaceBeforeOpeningBraceInArrayInitializerOption != null) {
- this.insert_space_before_opening_brace_in_array_initializer = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInArrayInitializerOption);
- }
- final Object insertSpaceBeforeOpeningBraceInBlockOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK);
- if (insertSpaceBeforeOpeningBraceInBlockOption != null) {
- this.insert_space_before_opening_brace_in_block = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInBlockOption);
- }
- final Object insertSpaceBeforeOpeningBraceInConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION);
- if (insertSpaceBeforeOpeningBraceInConstructorDeclarationOption != null) {
- this.insert_space_before_opening_brace_in_constructor_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInConstructorDeclarationOption);
- }
- final Object insertSpaceBeforeOpeningBraceInEnumDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_DECLARATION);
- if (insertSpaceBeforeOpeningBraceInEnumDeclarationOption != null) {
- this.insert_space_before_opening_brace_in_enum_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInEnumDeclarationOption);
- }
- final Object insertSpaceBeforeOpeningBraceInEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_CONSTANT);
- if (insertSpaceBeforeOpeningBraceInEnumConstantOption != null) {
- this.insert_space_before_opening_brace_in_enum_constant = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInEnumConstantOption);
- }
- final Object insertSpaceBeforeOpeningBraceInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION);
- if (insertSpaceBeforeOpeningBraceInMethodDeclarationOption != null) {
- this.insert_space_before_opening_brace_in_method_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInMethodDeclarationOption);
- }
- final Object insertSpaceBeforeOpeningBraceInTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION);
- if (insertSpaceBeforeOpeningBraceInTypeDeclarationOption != null) {
- this.insert_space_before_opening_brace_in_type_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInTypeDeclarationOption);
- }
- final Object insertSpaceBeforeOpeningBracketInArrayAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION);
- if (insertSpaceBeforeOpeningBracketInArrayAllocationExpressionOption != null) {
- this.insert_space_before_opening_bracket_in_array_allocation_expression = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBracketInArrayAllocationExpressionOption);
- }
- final Object insertSpaceBeforeOpeningBracketInArrayReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE);
- if (insertSpaceBeforeOpeningBracketInArrayReferenceOption != null) {
- this.insert_space_before_opening_bracket_in_array_reference = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBracketInArrayReferenceOption);
- }
- final Object insertSpaceBeforeOpeningBracketInArrayTypeReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE);
- if (insertSpaceBeforeOpeningBracketInArrayTypeReferenceOption != null) {
- this.insert_space_before_opening_bracket_in_array_type_reference = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBracketInArrayTypeReferenceOption);
- }
- final Object insertSpaceBeforeOpeningParenInAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION);
- if (insertSpaceBeforeOpeningParenInAnnotationOption != null) {
- this.insert_space_before_opening_paren_in_annotation = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInAnnotationOption);
- }
- final Object insertSpaceBeforeOpeningParenInAnnotationTypeMemberDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION);
- if (insertSpaceBeforeOpeningParenInAnnotationTypeMemberDeclarationOption != null) {
- this.insert_space_before_opening_paren_in_annotation_type_member_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInAnnotationTypeMemberDeclarationOption);
- }
- final Object insertSpaceBeforeOpeningParenInCatchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH);
- if (insertSpaceBeforeOpeningParenInCatchOption != null) {
- this.insert_space_before_opening_paren_in_catch = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInCatchOption);
- }
- final Object insertSpaceBeforeOpeningParenInConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION);
- if (insertSpaceBeforeOpeningParenInConstructorDeclarationOption != null) {
- this.insert_space_before_opening_paren_in_constructor_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInConstructorDeclarationOption);
- }
- final Object insertSpaceBeforeOpeningParenInEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT);
- if (insertSpaceBeforeOpeningParenInEnumConstantOption != null) {
- this.insert_space_before_opening_paren_in_enum_constant = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInEnumConstantOption);
- }
- final Object insertSpaceBeforeOpeningParenInForOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR);
- if (insertSpaceBeforeOpeningParenInForOption != null) {
- this.insert_space_before_opening_paren_in_for = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInForOption);
- }
- final Object insertSpaceBeforeOpeningParenInIfOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF);
- if (insertSpaceBeforeOpeningParenInIfOption != null) {
- this.insert_space_before_opening_paren_in_if = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInIfOption);
- }
- final Object insertSpaceBeforeOpeningParenInMethodInvocationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION);
- if (insertSpaceBeforeOpeningParenInMethodInvocationOption != null) {
- this.insert_space_before_opening_paren_in_method_invocation = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInMethodInvocationOption);
- }
- final Object insertSpaceBeforeOpeningParenInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION);
- if (insertSpaceBeforeOpeningParenInMethodDeclarationOption != null) {
- this.insert_space_before_opening_paren_in_method_declaration = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInMethodDeclarationOption);
- }
- final Object insertSpaceBeforeOpeningParenInSwitchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH);
- if (insertSpaceBeforeOpeningParenInSwitchOption != null) {
- this.insert_space_before_opening_paren_in_switch = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInSwitchOption);
- }
- final Object insertSpaceBeforeOpeningBraceInSwitchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH);
- if (insertSpaceBeforeOpeningBraceInSwitchOption != null) {
- this.insert_space_before_opening_brace_in_switch = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningBraceInSwitchOption);
- }
- final Object insertSpaceBeforeOpeningParenInSynchronizedOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED);
- if (insertSpaceBeforeOpeningParenInSynchronizedOption != null) {
- this.insert_space_before_opening_paren_in_synchronized = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInSynchronizedOption);
- }
- final Object insertSpaceBeforeOpeningParenInParenthesizedExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION);
- if (insertSpaceBeforeOpeningParenInParenthesizedExpressionOption != null) {
- this.insert_space_before_opening_paren_in_parenthesized_expression = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInParenthesizedExpressionOption);
- }
- final Object insertSpaceBeforeOpeningParenInWhileOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE);
- if (insertSpaceBeforeOpeningParenInWhileOption != null) {
- this.insert_space_before_opening_paren_in_while = JavaScriptCore.INSERT.equals(insertSpaceBeforeOpeningParenInWhileOption);
- }
- final Object insertSpaceBeforeParenthesizedExpressionInReturnOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN);
- if (insertSpaceBeforeParenthesizedExpressionInReturnOption != null) {
- this.insert_space_before_parenthesized_expression_in_return = JavaScriptCore.INSERT.equals(insertSpaceBeforeParenthesizedExpressionInReturnOption);
- }
- final Object insertSpaceBeforeParenthesizedExpressionInThrowOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW);
- if (insertSpaceBeforeParenthesizedExpressionInThrowOption != null) {
- this.insert_space_before_parenthesized_expression_in_throw = JavaScriptCore.INSERT.equals(insertSpaceBeforeParenthesizedExpressionInThrowOption);
- }
- final Object insertSpaceBeforePostfixOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR);
- if (insertSpaceBeforePostfixOperatorOption != null) {
- this.insert_space_before_postfix_operator = JavaScriptCore.INSERT.equals(insertSpaceBeforePostfixOperatorOption);
- }
- final Object insertSpaceBeforePrefixOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR);
- if (insertSpaceBeforePrefixOperatorOption != null) {
- this.insert_space_before_prefix_operator = JavaScriptCore.INSERT.equals(insertSpaceBeforePrefixOperatorOption);
- }
- final Object insertSpaceBeforeQuestionInConditionalOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL);
- if (insertSpaceBeforeQuestionInConditionalOption != null) {
- this.insert_space_before_question_in_conditional = JavaScriptCore.INSERT.equals(insertSpaceBeforeQuestionInConditionalOption);
- }
- final Object insertSpaceBeforeSemicolonOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON);
- if (insertSpaceBeforeSemicolonOption != null) {
- this.insert_space_before_semicolon = JavaScriptCore.INSERT.equals(insertSpaceBeforeSemicolonOption);
- }
- final Object insertSpaceBeforeSemicolonInForOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR);
- if (insertSpaceBeforeSemicolonInForOption != null) {
- this.insert_space_before_semicolon_in_for = JavaScriptCore.INSERT.equals(insertSpaceBeforeSemicolonInForOption);
- }
- final Object insertSpaceBeforeUnaryOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR);
- if (insertSpaceBeforeUnaryOperatorOption != null) {
- this.insert_space_before_unary_operator = JavaScriptCore.INSERT.equals(insertSpaceBeforeUnaryOperatorOption);
- }
- final Object insertSpaceBetweenBracketsInArrayTypeReferenceOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE);
- if (insertSpaceBetweenBracketsInArrayTypeReferenceOption != null) {
- this.insert_space_between_brackets_in_array_type_reference = JavaScriptCore.INSERT.equals(insertSpaceBetweenBracketsInArrayTypeReferenceOption);
- }
- final Object insertSpaceBetweenEmptyBracesInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER);
- if (insertSpaceBetweenEmptyBracesInArrayInitializerOption != null) {
- this.insert_space_between_empty_braces_in_array_initializer = JavaScriptCore.INSERT.equals(insertSpaceBetweenEmptyBracesInArrayInitializerOption);
- }
- final Object insertSpaceBetweenEmptyBracketsInArrayAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION);
- if (insertSpaceBetweenEmptyBracketsInArrayAllocationExpressionOption != null) {
- this.insert_space_between_empty_brackets_in_array_allocation_expression = JavaScriptCore.INSERT.equals(insertSpaceBetweenEmptyBracketsInArrayAllocationExpressionOption);
- }
- final Object insertSpaceBetweenEmptyParensInConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION);
- if (insertSpaceBetweenEmptyParensInConstructorDeclarationOption != null) {
- this.insert_space_between_empty_parens_in_constructor_declaration = JavaScriptCore.INSERT.equals(insertSpaceBetweenEmptyParensInConstructorDeclarationOption);
- }
- final Object insertSpaceBetweenEmptyParensInAnnotationTypeMemberDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION_TYPE_MEMBER_DECLARATION);
- if (insertSpaceBetweenEmptyParensInAnnotationTypeMemberDeclarationOption != null) {
- this.insert_space_between_empty_parens_in_annotation_type_member_declaration = JavaScriptCore.INSERT.equals(insertSpaceBetweenEmptyParensInAnnotationTypeMemberDeclarationOption);
- }
- final Object insertSpaceBetweenEmptyParensInEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ENUM_CONSTANT);
- if (insertSpaceBetweenEmptyParensInEnumConstantOption != null) {
- this.insert_space_between_empty_parens_in_enum_constant = JavaScriptCore.INSERT.equals(insertSpaceBetweenEmptyParensInEnumConstantOption);
- }
- final Object insertSpaceBetweenEmptyParensInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION);
- if (insertSpaceBetweenEmptyParensInMethodDeclarationOption != null) {
- this.insert_space_between_empty_parens_in_method_declaration = JavaScriptCore.INSERT.equals(insertSpaceBetweenEmptyParensInMethodDeclarationOption);
- }
- final Object insertSpaceBetweenEmptyParensInMethodInvocationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION);
- if (insertSpaceBetweenEmptyParensInMethodInvocationOption != null) {
- this.insert_space_between_empty_parens_in_method_invocation = JavaScriptCore.INSERT.equals(insertSpaceBetweenEmptyParensInMethodInvocationOption);
- }
- final Object compactElseIfOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF);
- if (compactElseIfOption != null) {
- this.compact_else_if = DefaultCodeFormatterConstants.TRUE.equals(compactElseIfOption);
- }
- final Object keepGuardianClauseOnOneLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE);
- if (keepGuardianClauseOnOneLineOption != null) {
- this.keep_guardian_clause_on_one_line = DefaultCodeFormatterConstants.TRUE.equals(keepGuardianClauseOnOneLineOption);
- }
- final Object keepElseStatementOnSameLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE);
- if (keepElseStatementOnSameLineOption != null) {
- this.keep_else_statement_on_same_line = DefaultCodeFormatterConstants.TRUE.equals(keepElseStatementOnSameLineOption);
- }
- final Object keepEmptyArrayInitializerOnOneLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE);
- if (keepEmptyArrayInitializerOnOneLineOption != null) {
- this.keep_empty_array_initializer_on_one_line = DefaultCodeFormatterConstants.TRUE.equals(keepEmptyArrayInitializerOnOneLineOption);
- }
- final Object keepEmptyObjLitInitializerOnOneLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_OBJLIT_INITIALIZER_ON_ONE_LINE);
- if (keepEmptyObjLitInitializerOnOneLineOption != null) {
- this.keep_empty_objlit_initializer_on_one_line = DefaultCodeFormatterConstants.TRUE.equals(keepEmptyObjLitInitializerOnOneLineOption);
- }
- final Object keepSimpleIfOnOneLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE);
- if (keepSimpleIfOnOneLineOption != null) {
- this.keep_simple_if_on_one_line = DefaultCodeFormatterConstants.TRUE.equals(keepSimpleIfOnOneLineOption);
- }
- final Object keepThenStatementOnSameLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE);
- if (keepThenStatementOnSameLineOption != null) {
- this.keep_then_statement_on_same_line = DefaultCodeFormatterConstants.TRUE.equals(keepThenStatementOnSameLineOption);
- }
- final Object neverIndentBlockCommentOnFirstColumnOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN);
- if (neverIndentBlockCommentOnFirstColumnOption != null) {
- this.never_indent_block_comments_on_first_column = DefaultCodeFormatterConstants.TRUE.equals(neverIndentBlockCommentOnFirstColumnOption);
- }
- final Object neverIndentLineCommentOnFirstColumnOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN);
- if (neverIndentLineCommentOnFirstColumnOption != null) {
- this.never_indent_line_comments_on_first_column = DefaultCodeFormatterConstants.TRUE.equals(neverIndentLineCommentOnFirstColumnOption);
- }
- final Object numberOfEmptyLinesToPreserveOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE);
- if (numberOfEmptyLinesToPreserveOption != null) {
- try {
- this.number_of_empty_lines_to_preserve = Integer.parseInt((String) numberOfEmptyLinesToPreserveOption);
- } catch (NumberFormatException e) {
- this.number_of_empty_lines_to_preserve = 0;
- } catch(ClassCastException e) {
- this.number_of_empty_lines_to_preserve = 0;
- }
- }
- final Object putEmptyStatementOnNewLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE);
- if (putEmptyStatementOnNewLineOption != null) {
- this.put_empty_statement_on_new_line = DefaultCodeFormatterConstants.TRUE.equals(putEmptyStatementOnNewLineOption);
- }
- final Object tabSizeOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
- if (tabSizeOption != null) {
- try {
- this.tab_size = Integer.parseInt((String) tabSizeOption);
- } catch (NumberFormatException e) {
- this.tab_size = 4;
- } catch(ClassCastException e) {
- this.tab_size = 4;
- }
- }
- final Object useTabsOnlyForLeadingIndentationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS);
- if (useTabsOnlyForLeadingIndentationsOption != null) {
- this.use_tabs_only_for_leading_indentations = DefaultCodeFormatterConstants.TRUE.equals(useTabsOnlyForLeadingIndentationsOption);
- }
- final Object pageWidthOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT);
- if (pageWidthOption != null) {
- try {
- this.page_width = Integer.parseInt((String) pageWidthOption);
- } catch (NumberFormatException e) {
- this.page_width = 80;
- } catch(ClassCastException e) {
- this.page_width = 80;
- }
- }
- final Object useTabOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
- if (useTabOption != null) {
- if (JavaScriptCore.TAB.equals(useTabOption)) {
- this.tab_char = TAB;
- } else if (JavaScriptCore.SPACE.equals(useTabOption)) {
- this.tab_char = SPACE;
- } else {
- this.tab_char = MIXED;
- }
- }
- final Object wrapBeforeBinaryOperatorOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_BINARY_OPERATOR);
- if (wrapBeforeBinaryOperatorOption != null) {
- this.wrap_before_binary_operator = DefaultCodeFormatterConstants.TRUE.equals(wrapBeforeBinaryOperatorOption);
- }
- }
-
- /**
- * @param settings the given map
- * @deprecated
- */
- private void setDeprecatedOptions(Map settings) {
- // backward compatibility code
- final Object commentClearBlankLinesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES);
- if (commentClearBlankLinesOption != null) {
- this.comment_clear_blank_lines_in_javadoc_comment = DefaultCodeFormatterConstants.TRUE.equals(commentClearBlankLinesOption);
- this.comment_clear_blank_lines_in_block_comment = DefaultCodeFormatterConstants.TRUE.equals(commentClearBlankLinesOption);
- } else {
- final Object commentClearBlankLinesInJavadocCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT);
- if (commentClearBlankLinesInJavadocCommentOption != null) {
- this.comment_clear_blank_lines_in_javadoc_comment = DefaultCodeFormatterConstants.TRUE.equals(commentClearBlankLinesInJavadocCommentOption);
- }
- final Object commentClearBlankLinesInBlockCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT);
- if (commentClearBlankLinesInBlockCommentOption != null) {
- this.comment_clear_blank_lines_in_block_comment = DefaultCodeFormatterConstants.TRUE.equals(commentClearBlankLinesInBlockCommentOption);
- }
- }
- }
-
- public void setDefaultSettings() {
- this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_arguments_in_enum_constant = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_arguments_in_explicit_constructor_call = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_arguments_in_qualified_allocation_expression = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_assignment = Alignment.M_NO_ALIGNMENT;
- this.alignment_for_binary_expression = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
- this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT;
- this.alignment_for_enum_constants = Alignment.NONE;
- this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_multiple_fields = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_parameters_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
- this.alignment_for_superinterfaces_in_enum_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
- this.alignment_for_superinterfaces_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
- this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
- this.align_type_members_on_columns = false;
- this.brace_position_for_annotation_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_array_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_objlit_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_block_in_case = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_enum_constant = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_enum_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE;
- this.comment_clear_blank_lines_in_block_comment = false;
- this.comment_clear_blank_lines_in_javadoc_comment = false;
- this.comment_format_block_comment = true;
- this.comment_format_javadoc_comment = true;
- this.comment_format_line_comment = true;
- this.comment_format_header = false;
- this.comment_format_html = true;
- this.comment_format_source = true;
- this.comment_indent_parameter_description = true;
- this.comment_indent_root_tags = true;
- this.comment_insert_empty_line_before_root_tags = true;
- this.comment_insert_new_line_for_parameter = true;
- this.comment_line_length = 80;
- this.continuation_indentation = 2;
- this.continuation_indentation_for_array_initializer = 2;
- this.continuation_indentation_for_objlit_initializer = 1;
- this.blank_lines_after_imports = 0;
- this.blank_lines_after_package = 0;
- this.blank_lines_before_field = 0;
- this.blank_lines_before_first_class_body_declaration = 0;
- this.blank_lines_before_imports = 0;
- this.blank_lines_before_member_type = 0;
- this.blank_lines_before_method = 0;
- this.blank_lines_before_new_chunk = 0;
- this.blank_lines_before_package = 0;
- this.blank_lines_between_import_groups = 1;
- this.blank_lines_between_type_declarations = 0;
- this.blank_lines_at_beginning_of_method_body = 0;
- this.indent_statements_compare_to_block = true;
- this.indent_statements_compare_to_body = true;
- this.indent_body_declarations_compare_to_annotation_declaration_header = true;
- this.indent_body_declarations_compare_to_enum_constant_header = true;
- this.indent_body_declarations_compare_to_enum_declaration_header = true;
- this.indent_body_declarations_compare_to_type_header = true;
- this.indent_breaks_compare_to_cases = true;
- this.indent_empty_lines = false;
- this.indent_switchstatements_compare_to_cases = true;
- this.indent_switchstatements_compare_to_switch = true;
- this.indentation_size = 4;
- this.insert_new_line_after_annotation = true;
- this.insert_new_line_after_opening_brace_in_array_initializer = false;
- this.insert_new_line_after_opening_brace_in_objlit_initializer = true;
- this.insert_new_line_after_comma_in_objlit_initializer = true;
- this.insert_new_line_at_end_of_file_if_missing = false;
- this.insert_new_line_before_catch_in_try_statement = false;
- this.insert_new_line_before_closing_brace_in_array_initializer = false;
- this.insert_new_line_before_closing_brace_in_objlit_initializer = true;
- this.insert_new_line_before_else_in_if_statement = false;
- this.insert_new_line_before_finally_in_try_statement = false;
- this.insert_new_line_before_while_in_do_statement = false;
- this.insert_new_line_in_empty_anonymous_type_declaration = true;
- this.insert_new_line_in_empty_block = true;
- this.insert_new_line_in_empty_annotation_declaration = true;
- this.insert_new_line_in_empty_enum_constant = true;
- this.insert_new_line_in_empty_enum_declaration = true;
- this.insert_new_line_in_empty_method_body = true;
- this.insert_new_line_in_empty_type_declaration = true;
- this.insert_space_after_and_in_type_parameter = true;
- this.insert_space_after_assignment_operator = true;
- this.insert_space_after_at_in_annotation = false;
- this.insert_space_after_at_in_annotation_type_declaration = false;
- this.insert_space_after_binary_operator = true;
- this.insert_space_after_closing_angle_bracket_in_type_arguments = true;
- this.insert_space_after_closing_angle_bracket_in_type_parameters = true;
- this.insert_space_after_closing_paren_in_cast = true;
- this.insert_space_after_closing_brace_in_block = true;
- this.insert_space_after_colon_in_assert = true;
- this.insert_space_after_colon_in_case = true;
- this.insert_space_after_colon_in_conditional = true;
- this.insert_space_after_colon_in_object_initializer = true;
- this.insert_space_after_colon_in_for = true;
- this.insert_space_after_colon_in_labeled_statement = true;
- this.insert_space_after_comma_in_allocation_expression = true;
- this.insert_space_after_comma_in_annotation = true;
- this.insert_space_after_comma_in_array_initializer = true;
- this.insert_space_after_comma_in_constructor_declaration_parameters = true;
- this.insert_space_after_comma_in_constructor_declaration_throws = true;
- this.insert_space_after_comma_in_enum_constant_arguments = true;
- this.insert_space_after_comma_in_enum_declarations = true;
- this.insert_space_after_comma_in_explicit_constructor_call_arguments = true;
- this.insert_space_after_comma_in_for_increments = true;
- this.insert_space_after_comma_in_for_inits = true;
- this.insert_space_after_comma_in_method_invocation_arguments = true;
- this.insert_space_after_comma_in_method_declaration_parameters = true;
- this.insert_space_after_comma_in_method_declaration_throws = true;
- this.insert_space_after_comma_in_multiple_field_declarations = true;
- this.insert_space_after_comma_in_multiple_local_declarations = true;
- this.insert_space_after_comma_in_parameterized_type_reference = true;
- this.insert_space_after_comma_in_superinterfaces = true;
- this.insert_space_after_comma_in_type_arguments = true;
- this.insert_space_after_comma_in_type_parameters = true;
- this.insert_space_after_ellipsis = true;
- this.insert_space_after_opening_angle_bracket_in_parameterized_type_reference = false;
- this.insert_space_after_opening_angle_bracket_in_type_arguments = false;
- this.insert_space_after_opening_angle_bracket_in_type_parameters = false;
- this.insert_space_after_opening_bracket_in_array_allocation_expression = false;
- this.insert_space_after_opening_bracket_in_array_reference = false;
- this.insert_space_after_opening_brace_in_array_initializer = false;
- this.insert_space_after_opening_paren_in_annotation = false;
- this.insert_space_after_opening_paren_in_cast = false;
- this.insert_space_after_opening_paren_in_catch = false;
- this.insert_space_after_opening_paren_in_constructor_declaration = false;
- this.insert_space_after_opening_paren_in_enum_constant = false;
- this.insert_space_after_opening_paren_in_for = false;
- this.insert_space_after_opening_paren_in_if = false;
- this.insert_space_after_opening_paren_in_method_declaration = false;
- this.insert_space_after_opening_paren_in_method_invocation = false;
- this.insert_space_after_opening_paren_in_parenthesized_expression = false;
- this.insert_space_after_opening_paren_in_switch = false;
- this.insert_space_after_opening_paren_in_synchronized = false;
- this.insert_space_after_opening_paren_in_while = false;
- this.insert_space_after_postfix_operator = false;
- this.insert_space_after_prefix_operator = false;
- this.insert_space_after_question_in_conditional = true;
- this.insert_space_after_semicolon_in_for = true;
- this.insert_space_after_unary_operator = false;
- this.insert_space_before_at_in_annotation_type_declaration = true;
- this.insert_space_before_assignment_operator = true;
- this.insert_space_before_binary_operator = true;
- this.insert_space_before_closing_angle_bracket_in_parameterized_type_reference = false;
- this.insert_space_before_closing_angle_bracket_in_type_arguments = false;
- this.insert_space_before_closing_angle_bracket_in_type_parameters = false;
- this.insert_space_before_closing_brace_in_array_initializer = false;
- this.insert_space_before_closing_bracket_in_array_allocation_expression = false;
- this.insert_space_before_closing_bracket_in_array_reference = false;
- this.insert_space_before_closing_paren_in_annotation = false;
- this.insert_space_before_closing_paren_in_cast = false;
- this.insert_space_before_closing_paren_in_catch = false;
- this.insert_space_before_closing_paren_in_constructor_declaration = false;
- this.insert_space_before_closing_paren_in_enum_constant = false;
- this.insert_space_before_closing_paren_in_for = false;
- this.insert_space_before_closing_paren_in_if = false;
- this.insert_space_before_closing_paren_in_method_declaration = false;
- this.insert_space_before_closing_paren_in_method_invocation = false;
- this.insert_space_before_closing_paren_in_parenthesized_expression = false;
- this.insert_space_before_closing_paren_in_switch = false;
- this.insert_space_before_closing_paren_in_synchronized = false;
- this.insert_space_before_closing_paren_in_while = false;
- this.insert_space_before_colon_in_assert = true;
- this.insert_space_before_colon_in_case = true;
- this.insert_space_before_colon_in_conditional = true;
- this.insert_space_before_colon_in_object_initializer = true;
- this.insert_space_before_colon_in_default = true;
- this.insert_space_before_colon_in_for = true;
- this.insert_space_before_colon_in_labeled_statement = true;
- this.insert_space_before_comma_in_allocation_expression = false;
- this.insert_space_before_comma_in_array_initializer = false;
- this.insert_space_before_comma_in_constructor_declaration_parameters = false;
- this.insert_space_before_comma_in_constructor_declaration_throws = false;
- this.insert_space_before_comma_in_enum_constant_arguments = false;
- this.insert_space_before_comma_in_enum_declarations = false;
- this.insert_space_before_comma_in_explicit_constructor_call_arguments = false;
- this.insert_space_before_comma_in_for_increments = false;
- this.insert_space_before_comma_in_for_inits = false;
- this.insert_space_before_comma_in_method_invocation_arguments = false;
- this.insert_space_before_comma_in_method_declaration_parameters = false;
- this.insert_space_before_comma_in_method_declaration_throws = false;
- this.insert_space_before_comma_in_multiple_field_declarations = false;
- this.insert_space_before_comma_in_multiple_local_declarations = false;
- this.insert_space_before_comma_in_parameterized_type_reference = false;
- this.insert_space_before_comma_in_superinterfaces = false;
- this.insert_space_before_comma_in_type_arguments = false;
- this.insert_space_before_comma_in_type_parameters = false;
- this.insert_space_before_ellipsis = false;
- this.insert_space_before_parenthesized_expression_in_return = true;
- this.insert_space_before_parenthesized_expression_in_throw = true;
- this.insert_space_before_opening_angle_bracket_in_parameterized_type_reference = false;
- this.insert_space_before_opening_angle_bracket_in_type_arguments = false;
- this.insert_space_before_opening_angle_bracket_in_type_parameters = false;
- this.insert_space_before_opening_brace_in_annotation_type_declaration = true;
- this.insert_space_before_opening_brace_in_anonymous_type_declaration = true;
- this.insert_space_before_opening_brace_in_array_initializer = false;
- this.insert_space_before_opening_brace_in_block = true;
- this.insert_space_before_opening_brace_in_constructor_declaration = true;
- this.insert_space_before_opening_brace_in_enum_constant = true;
- this.insert_space_before_opening_brace_in_enum_declaration = true;
- this.insert_space_before_opening_brace_in_method_declaration = true;
- this.insert_space_before_opening_brace_in_switch = true;
- this.insert_space_before_opening_brace_in_type_declaration = true;
- this.insert_space_before_opening_bracket_in_array_allocation_expression = false;
- this.insert_space_before_opening_bracket_in_array_reference = false;
- this.insert_space_before_opening_bracket_in_array_type_reference = false;
- this.insert_space_before_opening_paren_in_annotation = false;
- this.insert_space_before_opening_paren_in_annotation_type_member_declaration = false;
- this.insert_space_before_opening_paren_in_catch = true;
- this.insert_space_before_opening_paren_in_constructor_declaration = false;
- this.insert_space_before_opening_paren_in_enum_constant = false;
- this.insert_space_before_opening_paren_in_for = true;
- this.insert_space_before_opening_paren_in_if = true;
- this.insert_space_before_opening_paren_in_method_invocation = false;
- this.insert_space_before_opening_paren_in_method_declaration = false;
- this.insert_space_before_opening_paren_in_switch = true;
- this.insert_space_before_opening_paren_in_synchronized = true;
- this.insert_space_before_opening_paren_in_parenthesized_expression = false;
- this.insert_space_before_opening_paren_in_while = true;
- this.insert_space_before_postfix_operator = false;
- this.insert_space_before_prefix_operator = false;
- this.insert_space_before_question_in_conditional = true;
- this.insert_space_before_semicolon = false;
- this.insert_space_before_semicolon_in_for = false;
- this.insert_space_before_unary_operator = false;
- this.insert_space_between_brackets_in_array_type_reference = false;
- this.insert_space_between_empty_braces_in_array_initializer = false;
- this.insert_space_between_empty_brackets_in_array_allocation_expression = false;
- this.insert_space_between_empty_parens_in_annotation_type_member_declaration = false;
- this.insert_space_between_empty_parens_in_constructor_declaration = false;
- this.insert_space_between_empty_parens_in_enum_constant = false;
- this.insert_space_between_empty_parens_in_method_declaration = false;
- this.insert_space_between_empty_parens_in_method_invocation = false;
- this.compact_else_if = true;
- this.keep_guardian_clause_on_one_line = false;
- this.keep_else_statement_on_same_line = false;
- this.keep_empty_array_initializer_on_one_line = false;
- this.keep_empty_objlit_initializer_on_one_line = false;
- this.keep_simple_if_on_one_line = false;
- this.keep_then_statement_on_same_line = false;
- this.never_indent_block_comments_on_first_column = false;
- this.never_indent_line_comments_on_first_column = false;
- this.number_of_empty_lines_to_preserve = 1;
- this.put_empty_statement_on_new_line = false;
- this.tab_size = 4;
- this.page_width = 80;
- this.tab_char = TAB; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49081
- this.use_tabs_only_for_leading_indentations = false;
- this.wrap_before_binary_operator = true;
- }
-
- public void setEclipseDefaultSettings() {
- setJavaConventionsSettings();
- this.tab_char = TAB;
- this.tab_size = 4;
- }
-
- public void setJavaConventionsSettings() {
- this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_arguments_in_enum_constant = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_arguments_in_explicit_constructor_call = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_arguments_in_qualified_allocation_expression = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_assignment = Alignment.M_NO_ALIGNMENT;
- this.alignment_for_binary_expression = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_compact_if = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_conditional_expression = Alignment.M_NEXT_PER_LINE_SPLIT;
- this.alignment_for_enum_constants = Alignment.NONE;
- this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_multiple_fields = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_parameters_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_superclass_in_type_declaration = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_superinterfaces_in_enum_declaration = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_superinterfaces_in_type_declaration = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
- this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
- this.align_type_members_on_columns = false;
- this.brace_position_for_annotation_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_array_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_objlit_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_block_in_case = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_enum_constant = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_enum_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
- this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE;
- this.comment_clear_blank_lines_in_block_comment = false;
- this.comment_clear_blank_lines_in_javadoc_comment = false;
- this.comment_format_block_comment = true;
- this.comment_format_javadoc_comment = true;
- this.comment_format_line_comment = true;
- this.comment_format_header = false;
- this.comment_format_html = true;
- this.comment_format_source = true;
- this.comment_indent_parameter_description = true;
- this.comment_indent_root_tags = true;
- this.comment_insert_empty_line_before_root_tags = true;
- this.comment_insert_new_line_for_parameter = true;
- this.comment_line_length = 80;
- this.continuation_indentation = 2;
- this.continuation_indentation_for_array_initializer = 2;
- this.continuation_indentation_for_objlit_initializer = 1;
- this.blank_lines_after_imports = 1;
- this.blank_lines_after_package = 1;
- this.blank_lines_before_field = 0;
- this.blank_lines_before_first_class_body_declaration = 0;
- this.blank_lines_before_imports = 1;
- this.blank_lines_before_member_type = 1;
- this.blank_lines_before_method = 1;
- this.blank_lines_before_new_chunk = 1;
- this.blank_lines_before_package = 0;
- this.blank_lines_between_import_groups = 1;
- this.blank_lines_between_type_declarations = 0;
- this.blank_lines_at_beginning_of_method_body = 0;
- this.indent_statements_compare_to_block = true;
- this.indent_statements_compare_to_body = true;
- this.indent_body_declarations_compare_to_annotation_declaration_header = true;
- this.indent_body_declarations_compare_to_enum_constant_header = true;
- this.indent_body_declarations_compare_to_enum_declaration_header = true;
- this.indent_body_declarations_compare_to_type_header = true;
- this.indent_breaks_compare_to_cases = true;
- this.indent_empty_lines = false;
- this.indent_switchstatements_compare_to_cases = true;
- this.indent_switchstatements_compare_to_switch = false;
- this.indentation_size = 4;
- this.insert_new_line_after_annotation = true;
- this.insert_new_line_after_opening_brace_in_array_initializer = false;
- this.insert_new_line_after_opening_brace_in_objlit_initializer = true;
- this.insert_new_line_after_comma_in_objlit_initializer = true;
- this.insert_new_line_at_end_of_file_if_missing = false;
- this.insert_new_line_before_catch_in_try_statement = false;
- this.insert_new_line_before_closing_brace_in_array_initializer = false;
- this.insert_new_line_before_closing_brace_in_objlit_initializer = true;
- this.insert_new_line_before_else_in_if_statement = false;
- this.insert_new_line_before_finally_in_try_statement = false;
- this.insert_new_line_before_while_in_do_statement = false;
- this.insert_new_line_in_empty_anonymous_type_declaration = true;
- this.insert_new_line_in_empty_block = true;
- this.insert_new_line_in_empty_annotation_declaration = true;
- this.insert_new_line_in_empty_enum_constant = true;
- this.insert_new_line_in_empty_enum_declaration = true;
- this.insert_new_line_in_empty_method_body = true;
- this.insert_new_line_in_empty_type_declaration = true;
- this.insert_space_after_and_in_type_parameter = true;
- this.insert_space_after_assignment_operator = true;
- this.insert_space_after_at_in_annotation = false;
- this.insert_space_after_at_in_annotation_type_declaration = false;
- this.insert_space_after_binary_operator = true;
- this.insert_space_after_closing_angle_bracket_in_type_arguments = true;
- this.insert_space_after_closing_angle_bracket_in_type_parameters = true;
- this.insert_space_after_closing_paren_in_cast = true;
- this.insert_space_after_closing_brace_in_block = true;
- this.insert_space_after_colon_in_assert = true;
- this.insert_space_after_colon_in_case = true;
- this.insert_space_after_colon_in_conditional = true;
- this.insert_space_after_colon_in_object_initializer = true;
- this.insert_space_after_colon_in_for = true;
- this.insert_space_after_colon_in_labeled_statement = true;
- this.insert_space_after_comma_in_allocation_expression = true;
- this.insert_space_after_comma_in_annotation = true;
- this.insert_space_after_comma_in_array_initializer = true;
- this.insert_space_after_comma_in_constructor_declaration_parameters = true;
- this.insert_space_after_comma_in_constructor_declaration_throws = true;
- this.insert_space_after_comma_in_enum_constant_arguments = true;
- this.insert_space_after_comma_in_enum_declarations = true;
- this.insert_space_after_comma_in_explicit_constructor_call_arguments = true;
- this.insert_space_after_comma_in_for_increments = true;
- this.insert_space_after_comma_in_for_inits = true;
- this.insert_space_after_comma_in_method_invocation_arguments = true;
- this.insert_space_after_comma_in_method_declaration_parameters = true;
- this.insert_space_after_comma_in_method_declaration_throws = true;
- this.insert_space_after_comma_in_multiple_field_declarations = true;
- this.insert_space_after_comma_in_multiple_local_declarations = true;
- this.insert_space_after_comma_in_parameterized_type_reference = true;
- this.insert_space_after_comma_in_superinterfaces = true;
- this.insert_space_after_comma_in_type_arguments = true;
- this.insert_space_after_comma_in_type_parameters = true;
- this.insert_space_after_ellipsis = true;
- this.insert_space_after_opening_angle_bracket_in_parameterized_type_reference = false;
- this.insert_space_after_opening_angle_bracket_in_type_arguments = false;
- this.insert_space_after_opening_angle_bracket_in_type_parameters = false;
- this.insert_space_after_opening_bracket_in_array_allocation_expression = false;
- this.insert_space_after_opening_bracket_in_array_reference = false;
- this.insert_space_after_opening_brace_in_array_initializer = true;
- this.insert_space_after_opening_paren_in_annotation = false;
- this.insert_space_after_opening_paren_in_cast = false;
- this.insert_space_after_opening_paren_in_catch = false;
- this.insert_space_after_opening_paren_in_constructor_declaration = false;
- this.insert_space_after_opening_paren_in_enum_constant = false;
- this.insert_space_after_opening_paren_in_for = false;
- this.insert_space_after_opening_paren_in_if = false;
- this.insert_space_after_opening_paren_in_method_declaration = false;
- this.insert_space_after_opening_paren_in_method_invocation = false;
- this.insert_space_after_opening_paren_in_parenthesized_expression = false;
- this.insert_space_after_opening_paren_in_switch = false;
- this.insert_space_after_opening_paren_in_synchronized = false;
- this.insert_space_after_opening_paren_in_while = false;
- this.insert_space_after_postfix_operator = false;
- this.insert_space_after_prefix_operator = false;
- this.insert_space_after_question_in_conditional = true;
- this.insert_space_after_semicolon_in_for = true;
- this.insert_space_after_unary_operator = false;
- this.insert_space_before_at_in_annotation_type_declaration = true;
- this.insert_space_before_assignment_operator = true;
- this.insert_space_before_binary_operator = true;
- this.insert_space_before_closing_angle_bracket_in_parameterized_type_reference = false;
- this.insert_space_before_closing_angle_bracket_in_type_arguments = false;
- this.insert_space_before_closing_angle_bracket_in_type_parameters = false;
- this.insert_space_before_closing_brace_in_array_initializer = true;
- this.insert_space_before_closing_bracket_in_array_allocation_expression = false;
- this.insert_space_before_closing_bracket_in_array_reference = false;
- this.insert_space_before_closing_paren_in_annotation = false;
- this.insert_space_before_closing_paren_in_cast = false;
- this.insert_space_before_closing_paren_in_catch = false;
- this.insert_space_before_closing_paren_in_constructor_declaration = false;
- this.insert_space_before_closing_paren_in_enum_constant = false;
- this.insert_space_before_closing_paren_in_for = false;
- this.insert_space_before_closing_paren_in_if = false;
- this.insert_space_before_closing_paren_in_method_declaration = false;
- this.insert_space_before_closing_paren_in_method_invocation = false;
- this.insert_space_before_closing_paren_in_parenthesized_expression = false;
- this.insert_space_before_closing_paren_in_switch = false;
- this.insert_space_before_closing_paren_in_synchronized = false;
- this.insert_space_before_closing_paren_in_while = false;
- this.insert_space_before_colon_in_assert = true;
- this.insert_space_before_colon_in_case = false;
- this.insert_space_before_colon_in_conditional = true;
- this.insert_space_before_colon_in_object_initializer = true;
- this.insert_space_before_colon_in_default = false;
- this.insert_space_before_colon_in_for = true;
- this.insert_space_before_colon_in_labeled_statement = false;
- this.insert_space_before_comma_in_allocation_expression = false;
- this.insert_space_before_comma_in_array_initializer = false;
- this.insert_space_before_comma_in_constructor_declaration_parameters = false;
- this.insert_space_before_comma_in_constructor_declaration_throws = false;
- this.insert_space_before_comma_in_enum_constant_arguments = false;
- this.insert_space_before_comma_in_enum_declarations = false;
- this.insert_space_before_comma_in_explicit_constructor_call_arguments = false;
- this.insert_space_before_comma_in_for_increments = false;
- this.insert_space_before_comma_in_for_inits = false;
- this.insert_space_before_comma_in_method_invocation_arguments = false;
- this.insert_space_before_comma_in_method_declaration_parameters = false;
- this.insert_space_before_comma_in_method_declaration_throws = false;
- this.insert_space_before_comma_in_multiple_field_declarations = false;
- this.insert_space_before_comma_in_multiple_local_declarations = false;
- this.insert_space_before_comma_in_parameterized_type_reference = false;
- this.insert_space_before_comma_in_superinterfaces = false;
- this.insert_space_before_comma_in_type_arguments = false;
- this.insert_space_before_comma_in_type_parameters = false;
- this.insert_space_before_ellipsis = false;
- this.insert_space_before_parenthesized_expression_in_return = true;
- this.insert_space_before_parenthesized_expression_in_throw = true;
- this.insert_space_before_opening_angle_bracket_in_parameterized_type_reference = false;
- this.insert_space_before_opening_angle_bracket_in_type_arguments = false;
- this.insert_space_before_opening_angle_bracket_in_type_parameters = false;
- this.insert_space_before_opening_brace_in_annotation_type_declaration = true;
- this.insert_space_before_opening_brace_in_anonymous_type_declaration = true;
- this.insert_space_before_opening_brace_in_array_initializer = true;
- this.insert_space_before_opening_brace_in_block = true;
- this.insert_space_before_opening_brace_in_constructor_declaration = true;
- this.insert_space_before_opening_brace_in_enum_constant = true;
- this.insert_space_before_opening_brace_in_enum_declaration = true;
- this.insert_space_before_opening_brace_in_method_declaration = true;
- this.insert_space_before_opening_brace_in_switch = true;
- this.insert_space_before_opening_brace_in_type_declaration = true;
- this.insert_space_before_opening_bracket_in_array_allocation_expression = false;
- this.insert_space_before_opening_bracket_in_array_reference = false;
- this.insert_space_before_opening_bracket_in_array_type_reference = false;
- this.insert_space_before_opening_paren_in_annotation = false;
- this.insert_space_before_opening_paren_in_annotation_type_member_declaration = false;
- this.insert_space_before_opening_paren_in_catch = true;
- this.insert_space_before_opening_paren_in_constructor_declaration = false;
- this.insert_space_before_opening_paren_in_enum_constant = false;
- this.insert_space_before_opening_paren_in_for = true;
- this.insert_space_before_opening_paren_in_if = true;
- this.insert_space_before_opening_paren_in_method_invocation = false;
- this.insert_space_before_opening_paren_in_method_declaration = false;
- this.insert_space_before_opening_paren_in_switch = true;
- this.insert_space_before_opening_paren_in_synchronized = true;
- this.insert_space_before_opening_paren_in_parenthesized_expression = false;
- this.insert_space_before_opening_paren_in_while = true;
- this.insert_space_before_postfix_operator = false;
- this.insert_space_before_prefix_operator = false;
- this.insert_space_before_question_in_conditional = true;
- this.insert_space_before_semicolon = false;
- this.insert_space_before_semicolon_in_for = false;
- this.insert_space_before_unary_operator = false;
- this.insert_space_between_brackets_in_array_type_reference = false;
- this.insert_space_between_empty_braces_in_array_initializer = false;
- this.insert_space_between_empty_brackets_in_array_allocation_expression = false;
- this.insert_space_between_empty_parens_in_annotation_type_member_declaration = false;
- this.insert_space_between_empty_parens_in_constructor_declaration = false;
- this.insert_space_between_empty_parens_in_enum_constant = false;
- this.insert_space_between_empty_parens_in_method_declaration = false;
- this.insert_space_between_empty_parens_in_method_invocation = false;
- this.compact_else_if = true;
- this.keep_guardian_clause_on_one_line = false;
- this.keep_else_statement_on_same_line = false;
- this.keep_empty_array_initializer_on_one_line = false;
- this.keep_empty_objlit_initializer_on_one_line = false;
- this.keep_simple_if_on_one_line = false;
- this.keep_then_statement_on_same_line = false;
- this.never_indent_block_comments_on_first_column = false;
- this.never_indent_line_comments_on_first_column = false;
- this.number_of_empty_lines_to_preserve = 1;
- this.put_empty_statement_on_new_line = true;
- this.tab_size = 8;
- this.page_width = 80;
- this.tab_char = MIXED;
- this.use_tabs_only_for_leading_indentations = false;
- this.wrap_before_binary_operator = true;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/Location.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/Location.java
deleted file mode 100644
index ee5c4f60..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/Location.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter;
-
-/**
- * A location maintains positional information both in original source and in the output source.
- * It remembers source offsets, line/column and indentation level.
- * @since 2.1
- */
-public class Location {
-
- public int inputOffset;
- public int outputLine;
- public int outputColumn;
- public int outputIndentationLevel;
- public boolean needSpace;
- public boolean pendingSpace;
- public int nlsTagCounter;
- public int lastLocalDeclarationSourceStart;
- public int numberOfIndentations;
- public int inputToken;
- public int inputTokenNonWS;
-
- // chunk management
- public int lastNumberOfNewLines;
-
- // edits management
- int editsIndex;
- OptimizedReplaceEdit textEdit;
-
- public Location(Scribe scribe, int sourceRestart){
- update(scribe, sourceRestart);
- }
-
- public void update(Scribe scribe, int sourceRestart){
- this.outputColumn = scribe.column;
- this.outputLine = scribe.line;
- this.inputOffset = sourceRestart;
- this.inputToken=scribe.scanner.currentToken;
- this.inputTokenNonWS=scribe.scanner.currentNonWhitespaceToken;
- this.outputIndentationLevel = scribe.indentationLevel;
- this.lastNumberOfNewLines = scribe.lastNumberOfNewLines;
- this.needSpace = scribe.needSpace;
- this.pendingSpace = scribe.pendingSpace;
- this.editsIndex = scribe.editsIndex;
- this.nlsTagCounter = scribe.nlsTagCounter;
- this.numberOfIndentations = scribe.numberOfIndentations;
- textEdit = scribe.getLastEdit();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/OptimizedReplaceEdit.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/OptimizedReplaceEdit.java
deleted file mode 100644
index 60acf44f..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/OptimizedReplaceEdit.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter;
-
-public class OptimizedReplaceEdit {
-
- int offset;
- int length;
- String replacement;
-
- public OptimizedReplaceEdit(int offset, int length, String replacement) {
- this.offset = offset;
- this.length = length;
- this.replacement = replacement;
- }
-
- public String toString() {
- return "(" + this.offset + ", length " + this.length + " :>" + this.replacement + "<"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/Scribe.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/Scribe.java
deleted file mode 100644
index 18d7c7f9..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/Scribe.java
+++ /dev/null
@@ -1,1807 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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.wst.jsdt.internal.formatter;
-
-import java.util.Arrays;
-
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
-import org.eclipse.wst.jsdt.internal.compiler.ASTVisitor;
-import org.eclipse.wst.jsdt.internal.compiler.parser.Scanner;
-import org.eclipse.wst.jsdt.internal.compiler.parser.ScannerHelper;
-import org.eclipse.wst.jsdt.internal.compiler.parser.TerminalTokens;
-import org.eclipse.wst.jsdt.internal.compiler.util.Util;
-import org.eclipse.wst.jsdt.internal.core.util.CodeSnippetParsingUtil;
-import org.eclipse.wst.jsdt.internal.core.util.RecordedParsingInformation;
-import org.eclipse.wst.jsdt.internal.formatter.align.Alignment;
-import org.eclipse.wst.jsdt.internal.formatter.align.AlignmentException;
-
-/**
- * This class is responsible for dumping formatted source
- * @since 2.1
- */
-public class Scribe {
- private static final int INITIAL_SIZE = 100;
-
- private boolean checkLineWrapping;
- /** one-based column */
- public int column;
- private int[][] commentPositions;
-
- // Most specific alignment.
- public Alignment currentAlignment;
- public int currentToken;
-
- // edits management
- private OptimizedReplaceEdit[] edits;
- public int editsIndex;
-
- public CodeFormatterVisitor formatter;
- public int indentationLevel;
- public int lastNumberOfNewLines;
- public int line;
-
- private int[] lineEnds;
- private String lineSeparator;
- public Alignment memberAlignment;
- public boolean needSpace = false;
-
- public int nlsTagCounter;
- public int pageWidth;
- public boolean pendingSpace = false;
-
- public Scanner scanner;
- public int scannerEndPosition;
- public int tabLength;
- public int indentationSize;
- private int textRegionEnd;
- private int textRegionStart;
- public int tabChar;
- public int numberOfIndentations;
- private boolean useTabsOnlyForLeadingIndents;
-
- /** indent empty lines*/
- private final boolean indentEmptyLines;
-
- private final boolean formatJavadocComment;
- private final boolean formatBlockComment;
-
- Scribe(CodeFormatterVisitor formatter, long sourceLevel, int offset, int length, CodeSnippetParsingUtil codeSnippetParsingUtil) {
- this.scanner = new Scanner(true, true, false/*nls*/, sourceLevel/*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
- this.formatter = formatter;
- this.pageWidth = formatter.preferences.page_width;
- this.tabLength = formatter.preferences.tab_size;
- this.indentationLevel= 0; // initialize properly
- this.numberOfIndentations = 0;
- this.useTabsOnlyForLeadingIndents = formatter.preferences.use_tabs_only_for_leading_indentations;
- this.indentEmptyLines = formatter.preferences.indent_empty_lines;
- this.tabChar = formatter.preferences.tab_char;
- if (this.tabChar == DefaultCodeFormatterOptions.MIXED) {
- this.indentationSize = formatter.preferences.indentation_size;
- } else {
- this.indentationSize = this.tabLength;
- }
- this.lineSeparator = formatter.preferences.line_separator;
- this.indentationLevel = formatter.preferences.initial_indentation_level * this.indentationSize;
- this.textRegionStart = offset;
- this.textRegionEnd = offset + length - 1;
- if (codeSnippetParsingUtil != null) {
- final RecordedParsingInformation information = codeSnippetParsingUtil.recordedParsingInformation;
- if (information != null) {
- this.lineEnds = information.lineEnds;
- this.commentPositions = information.commentPositions;
- }
- }
- this.formatBlockComment = formatter.preferences.comment_format_block_comment;
- this.formatJavadocComment = formatter.preferences.comment_format_javadoc_comment;
- reset();
- }
-
- private final void addDeleteEdit(int start, int end) {
- if (this.edits.length == this.editsIndex) {
- // resize
- resize();
- }
- addOptimizedReplaceEdit(start, end - start + 1, Util.EMPTY_STRING);
- }
-
- public final void addInsertEdit(int insertPosition, String insertedString) {
- if (this.edits.length == this.editsIndex) {
- // resize
- resize();
- }
- addOptimizedReplaceEdit(insertPosition, 0, insertedString);
- }
-
- private final void addOptimizedReplaceEdit(int offset, int length, String replacement) {
- if (this.editsIndex > 0) {
- // try to merge last two edits
- final OptimizedReplaceEdit previous = this.edits[this.editsIndex-1];
- final int previousOffset = previous.offset;
- final int previousLength = previous.length;
- final int endOffsetOfPreviousEdit = previousOffset + previousLength;
- final int replacementLength = replacement.length();
- final String previousReplacement = previous.replacement;
- final int previousReplacementLength = previousReplacement.length();
- if (previousOffset == offset && previousLength == length && (replacementLength == 0 || previousReplacementLength == 0)) {
- if (this.currentAlignment != null) {
- final Location location = this.currentAlignment.location;
- if (location.editsIndex == this.editsIndex) {
- location.editsIndex--;
- location.textEdit = previous;
- }
- }
- this.editsIndex--;
- return;
- }
- if (endOffsetOfPreviousEdit == offset) {
- if (length != 0) {
- if (replacementLength != 0) {
- this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement + replacement);
- } else if (previousLength + length == previousReplacementLength) {
- // check the characters. If they are identical, we can get rid of the previous edit
- boolean canBeRemoved = true;
- loop: for (int i = previousOffset; i < previousOffset + previousReplacementLength; i++) {
- if (scanner.source[i] != previousReplacement.charAt(i - previousOffset)) {
- this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousReplacementLength, previousReplacement);
- canBeRemoved = false;
- break loop;
- }
- }
- if (canBeRemoved) {
- if (this.currentAlignment != null) {
- final Location location = this.currentAlignment.location;
- if (location.editsIndex == this.editsIndex) {
- location.editsIndex--;
- location.textEdit = previous;
- }
- }
- this.editsIndex--;
- }
- } else {
- this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement);
- }
- } else {
- if (replacementLength != 0) {
- this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength, previousReplacement + replacement);
- }
- }
- } else if ((offset + length == previousOffset) && (previousLength + length == replacementLength + previousReplacementLength)) {
- // check if both edits corresponds to the orignal source code
- boolean canBeRemoved = true;
- String totalReplacement = replacement + previousReplacement;
- loop: for (int i = 0; i < previousLength + length; i++) {
- if (scanner.source[i + offset] != totalReplacement.charAt(i)) {
- this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(offset, previousLength + length, totalReplacement);
- canBeRemoved = false;
- break loop;
- }
- }
- if (canBeRemoved) {
- if (this.currentAlignment != null) {
- final Location location = this.currentAlignment.location;
- if (location.editsIndex == this.editsIndex) {
- location.editsIndex--;
- location.textEdit = previous;
- }
- }
- this.editsIndex--;
- }
- } else {
- this.edits[this.editsIndex++] = new OptimizedReplaceEdit(offset, length, replacement);
- }
- } else {
- this.edits[this.editsIndex++] = new OptimizedReplaceEdit(offset, length, replacement);
- }
- }
-
- public final void addReplaceEdit(int start, int end, String replacement) {
- if (this.edits.length == this.editsIndex) {
- // resize
- resize();
- }
- addOptimizedReplaceEdit(start, end - start + 1, replacement);
- }
-
- public void alignFragment(Alignment alignment, int fragmentIndex){
- alignment.fragmentIndex = fragmentIndex;
- alignment.checkColumn();
- alignment.performFragmentEffect();
- }
-
- public void checkNLSTag(int sourceStart) {
- if (hasNLSTag(sourceStart)) {
- this.nlsTagCounter++;
- }
- }
- public void consumeNextToken() {
- printComment();
- try {
- this.currentToken = this.scanner.getNextToken();
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- } catch (InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
- public Alignment createAlignment(String name, int mode, int count, int sourceRestart){
- return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart);
- }
-
- public Alignment createAlignment(String name, int mode, int count, int sourceRestart, boolean adjust){
- return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, adjust);
- }
-
- public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart){
- return createAlignment(name, mode, tieBreakRule, count, sourceRestart, this.formatter.preferences.continuation_indentation, false);
- }
-
- public Alignment createAlignment(String name, int mode, int count, int sourceRestart, int continuationIndent, boolean adjust){
- return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, continuationIndent, adjust);
- }
-
- public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart, int continuationIndent, boolean adjust){
- Alignment alignment = new Alignment(name, mode, tieBreakRule, this, count, sourceRestart, continuationIndent);
- // adjust break indentation
- if (adjust && this.memberAlignment != null) {
- Alignment current = this.memberAlignment;
- while (current.enclosing != null) {
- current = current.enclosing;
- }
- if ((current.mode & Alignment.M_MULTICOLUMN) != 0) {
- final int indentSize = this.indentationSize;
- switch(current.chunkKind) {
- case Alignment.CHUNK_METHOD :
- case Alignment.CHUNK_TYPE :
- if ((mode & Alignment.M_INDENT_BY_ONE) != 0) {
- alignment.breakIndentationLevel = this.indentationLevel + indentSize;
- } else {
- alignment.breakIndentationLevel = this.indentationLevel + continuationIndent * indentSize;
- }
- alignment.update();
- break;
- case Alignment.CHUNK_FIELD :
- if ((mode & Alignment.M_INDENT_BY_ONE) != 0) {
- alignment.breakIndentationLevel = current.originalIndentationLevel + indentSize;
- } else {
- alignment.breakIndentationLevel = current.originalIndentationLevel + continuationIndent * indentSize;
- }
- alignment.update();
- break;
- }
- } else {
- switch(current.mode & Alignment.SPLIT_MASK) {
- case Alignment.M_COMPACT_SPLIT :
- case Alignment.M_COMPACT_FIRST_BREAK_SPLIT :
- case Alignment.M_NEXT_PER_LINE_SPLIT :
- case Alignment.M_NEXT_SHIFTED_SPLIT :
- case Alignment.M_ONE_PER_LINE_SPLIT :
- final int indentSize = this.indentationSize;
- switch(current.chunkKind) {
- case Alignment.CHUNK_METHOD :
- case Alignment.CHUNK_TYPE :
- if ((mode & Alignment.M_INDENT_BY_ONE) != 0) {
- alignment.breakIndentationLevel = this.indentationLevel + indentSize;
- } else {
- alignment.breakIndentationLevel = this.indentationLevel + continuationIndent * indentSize;
- }
- alignment.update();
- break;
- case Alignment.CHUNK_FIELD :
- if ((mode & Alignment.M_INDENT_BY_ONE) != 0) {
- alignment.breakIndentationLevel = current.originalIndentationLevel + indentSize;
- } else {
- alignment.breakIndentationLevel = current.originalIndentationLevel + continuationIndent * indentSize;
- }
- alignment.update();
- break;
- }
- break;
- }
- }
- }
- return alignment;
- }
-
- public Alignment createMemberAlignment(String name, int mode, int count, int sourceRestart) {
- Alignment mAlignment = createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart);
- mAlignment.breakIndentationLevel = this.indentationLevel;
- return mAlignment;
- }
-
- public void enterAlignment(Alignment alignment){
- alignment.enclosing = this.currentAlignment;
- alignment.location.lastLocalDeclarationSourceStart = this.formatter.lastLocalDeclarationSourceStart;
- this.currentAlignment = alignment;
- }
-
- public void enterMemberAlignment(Alignment alignment) {
- alignment.enclosing = this.memberAlignment;
- alignment.location.lastLocalDeclarationSourceStart = this.formatter.lastLocalDeclarationSourceStart;
- this.memberAlignment = alignment;
- }
-
- public void exitAlignment(Alignment alignment, boolean discardAlignment){
- Alignment current = this.currentAlignment;
- while (current != null){
- if (current == alignment) break;
- current = current.enclosing;
- }
- if (current == null) {
- throw new AbortFormatting("could not find matching alignment: "+alignment); //$NON-NLS-1$
- }
- this.indentationLevel = alignment.location.outputIndentationLevel;
- this.numberOfIndentations = alignment.location.numberOfIndentations;
- this.formatter.lastLocalDeclarationSourceStart = alignment.location.lastLocalDeclarationSourceStart;
- if (discardAlignment){
- this.currentAlignment = alignment.enclosing;
- }
- }
-
- public void exitMemberAlignment(Alignment alignment){
- Alignment current = this.memberAlignment;
- while (current != null){
- if (current == alignment) break;
- current = current.enclosing;
- }
- if (current == null) {
- throw new AbortFormatting("could not find matching alignment: "+alignment); //$NON-NLS-1$
- }
- this.indentationLevel = current.location.outputIndentationLevel;
- this.numberOfIndentations = current.location.numberOfIndentations;
- this.formatter.lastLocalDeclarationSourceStart = alignment.location.lastLocalDeclarationSourceStart;
- this.memberAlignment = current.enclosing;
- }
-
- public Alignment getAlignment(String name){
- if (this.currentAlignment != null) {
- return this.currentAlignment.getAlignment(name);
- }
- return null;
- }
-
- /**
- * Answer actual indentation level based on true column position
- * @return int
- */
- public int getColumnIndentationLevel() {
- return this.column - 1;
- }
-
- public final int getCommentIndex(int position) {
- if (this.commentPositions == null)
- return -1;
- int length = this.commentPositions.length;
- if (length == 0) {
- return -1;
- }
- int g = 0, d = length - 1;
- int m = 0;
- while (g <= d) {
- m = g + (d - g) / 2;
- int bound = this.commentPositions[m][1];
- if (bound < 0) {
- bound = -bound;
- }
- if (bound < position) {
- g = m + 1;
- } else if (bound > position) {
- d = m - 1;
- } else {
- return m;
- }
- }
- return -(g + 1);
- }
-
- private int getCurrentCommentOffset(int start) {
- int linePtr = -Arrays.binarySearch(this.lineEnds, start);
- int offset = 0;
- int beginningOfLine = this.getLineEnd(linePtr - 1);
- if (beginningOfLine == -1) {
- beginningOfLine = 0;
- }
- int currentStartPosition = start;
- char[] source = scanner.source;
-
- // find the position of the beginning of the line containing the comment
- while (beginningOfLine > currentStartPosition) {
- if (linePtr > 0) {
- beginningOfLine = this.getLineEnd(--linePtr);
- } else {
- beginningOfLine = 0;
- break;
- }
- }
- for (int i = currentStartPosition - 1; i >= beginningOfLine ; i--) {
- char currentCharacter = source[i];
- switch (currentCharacter) {
- case '\t' :
- offset += this.tabLength;
- break;
- case ' ' :
- offset++;
- break;
- case '\r' :
- case '\n' :
- break;
- default:
- return offset;
- }
- }
- return offset;
- }
-
- public String getEmptyLines(int linesNumber) {
- if (this.nlsTagCounter > 0) {
- return Util.EMPTY_STRING;
- }
- StringBuffer buffer = new StringBuffer();
- if (lastNumberOfNewLines == 0) {
- linesNumber++; // add an extra line breaks
- for (int i = 0; i < linesNumber; i++) {
- if (indentEmptyLines) printIndentationIfNecessary(buffer);
- buffer.append(this.lineSeparator);
- }
- lastNumberOfNewLines += linesNumber;
- line += linesNumber;
- column = 1;
- needSpace = false;
- this.pendingSpace = false;
- } else if (lastNumberOfNewLines == 1) {
- for (int i = 0; i < linesNumber; i++) {
- if (indentEmptyLines) printIndentationIfNecessary(buffer);
- buffer.append(this.lineSeparator);
- }
- lastNumberOfNewLines += linesNumber;
- line += linesNumber;
- column = 1;
- needSpace = false;
- this.pendingSpace = false;
- } else {
- if ((lastNumberOfNewLines - 1) >= linesNumber) {
- // there is no need to add new lines
- return Util.EMPTY_STRING;
- }
- final int realNewLineNumber = linesNumber - lastNumberOfNewLines + 1;
- for (int i = 0; i < realNewLineNumber; i++) {
- if (indentEmptyLines) printIndentationIfNecessary(buffer);
- buffer.append(this.lineSeparator);
- }
- lastNumberOfNewLines += realNewLineNumber;
- line += realNewLineNumber;
- column = 1;
- needSpace = false;
- this.pendingSpace = false;
- }
- return String.valueOf(buffer);
- }
-
- public OptimizedReplaceEdit getLastEdit() {
- if (this.editsIndex > 0) {
- return this.edits[this.editsIndex - 1];
- }
- return null;
- }
-
- public final int getLineEnd(int lineNumber) {
- if (this.lineEnds == null)
- return -1;
- if (lineNumber >= this.lineEnds.length + 1)
- return this.scannerEndPosition;
- if (lineNumber <= 0)
- return -1;
- return this.lineEnds[lineNumber-1]; // next line start one character behind the lineEnd of the previous line
- }
-
- Alignment getMemberAlignment() {
- return this.memberAlignment;
- }
-
- public String getNewLine() {
- if (this.nlsTagCounter > 0) {
- return Util.EMPTY_STRING;
- }
- if (lastNumberOfNewLines >= 1) {
- column = 1; // ensure that the scribe is at the beginning of a new line
- return Util.EMPTY_STRING;
- }
- line++;
- lastNumberOfNewLines = 1;
- column = 1;
- needSpace = false;
- this.pendingSpace = false;
- return this.lineSeparator;
- }
-
- /**
- * Answer next indentation level based on column estimated position
- * (if column is not indented, then use indentationLevel)
- */
- public int getNextIndentationLevel(int someColumn) {
- int indent = someColumn - 1;
- if (indent == 0)
- return this.indentationLevel;
- if (this.tabChar == DefaultCodeFormatterOptions.TAB) {
- if (this.useTabsOnlyForLeadingIndents) {
- return indent;
- }
- int rem = indent % this.indentationSize;
- int addition = rem == 0 ? 0 : this.indentationSize - rem; // round to superior
- return indent + addition;
- } else {
- return indent;
- }
- }
-
- private String getPreserveEmptyLines(int count) {
- if (count > 0) {
- if (this.formatter.preferences.number_of_empty_lines_to_preserve != 0) {
- int linesToPreserve = Math.min(count, this.formatter.preferences.number_of_empty_lines_to_preserve);
- return this.getEmptyLines(linesToPreserve);
- } else {
- return getNewLine();
- }
- }
- return Util.EMPTY_STRING;
- }
-
- public TextEdit getRootEdit() {
- MultiTextEdit edit = null;
- int length = this.textRegionEnd - this.textRegionStart + 1;
- if (this.textRegionStart <= 0) {
- if (length <= 0) {
- edit = new MultiTextEdit(0, 0);
- } else {
- edit = new MultiTextEdit(0, this.textRegionEnd + 1);
- }
- } else {
- edit = new MultiTextEdit(this.textRegionStart, this.textRegionEnd - this.textRegionStart + 1);
- }
- for (int i= 0, max = this.editsIndex; i < max; i++) {
- OptimizedReplaceEdit currentEdit = edits[i];
- if (isValidEdit(currentEdit)) {
- edit.addChild(new ReplaceEdit(currentEdit.offset, currentEdit.length, currentEdit.replacement));
- }
- }
- this.edits = null;
- return edit;
- }
-
- public void handleLineTooLong() {
- // search for closest breakable alignment, using tiebreak rules
- // look for outermost breakable one
- int relativeDepth = 0, outerMostDepth = -1;
- Alignment targetAlignment = this.currentAlignment;
- while (targetAlignment != null){
- if (targetAlignment.tieBreakRule == Alignment.R_OUTERMOST && targetAlignment.couldBreak()){
- outerMostDepth = relativeDepth;
- }
- targetAlignment = targetAlignment.enclosing;
- relativeDepth++;
- }
- if (outerMostDepth >= 0) {
- throw new AlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth);
- }
- // look for innermost breakable one
- relativeDepth = 0;
- targetAlignment = this.currentAlignment;
- while (targetAlignment != null){
- if (targetAlignment.couldBreak()){
- throw new AlignmentException(AlignmentException.LINE_TOO_LONG, relativeDepth);
- }
- targetAlignment = targetAlignment.enclosing;
- relativeDepth++;
- }
- // did not find any breakable location - proceed
- }
-
- /*
- * Check if there is a NLS tag on this line. If yes, return true, returns false otherwise.
- */
- private boolean hasNLSTag(int sourceStart) {
- // search the last comment where commentEnd < current lineEnd
- if (this.lineEnds == null) return false;
- int index = Arrays.binarySearch(this.lineEnds, sourceStart);
- int currentLineEnd = this.getLineEnd(-index);
- if (currentLineEnd != -1) {
- int commentIndex = getCommentIndex(currentLineEnd);
- if (commentIndex < 0) {
- commentIndex = -commentIndex - 2;
- }
- if (commentIndex >= 0 && commentIndex < this.commentPositions.length) {
- int start = this.commentPositions[commentIndex][0];
- if (start < 0) {
- start = -start;
- // check that we are on the same line
- int lineIndexForComment = Arrays.binarySearch(this.lineEnds, start);
- if (lineIndexForComment == index) {
- return CharOperation.indexOf(Scanner.TAG_PREFIX, this.scanner.source, true, start, currentLineEnd) != -1;
- }
- }
- }
- }
- return false;
- }
-
- public void indent() {
- this.indentationLevel += this.indentationSize;
- this.numberOfIndentations++;
- }
-
- /**
- * @param compilationUnitSource
- */
- public void initializeScanner(char[] compilationUnitSource) {
- this.scanner.setSource(compilationUnitSource);
- this.scannerEndPosition = compilationUnitSource.length;
- this.scanner.resetTo(0, this.scannerEndPosition - 1);
- this.edits = new OptimizedReplaceEdit[INITIAL_SIZE];
- }
-
- private boolean isOnFirstColumn(int start) {
- if (this.lineEnds == null) return start == 0;
- int index = Arrays.binarySearch(this.lineEnds, start);
- // we want the line end of the previous line
- int previousLineEnd = this.getLineEnd(-index - 1);
- return previousLineEnd != -1 && previousLineEnd == start - 1;
- }
-
- private boolean isValidEdit(OptimizedReplaceEdit edit) {
- final int editLength= edit.length;
- final int editReplacementLength= edit.replacement.length();
- final int editOffset= edit.offset;
- if (editLength != 0) {
- if (this.textRegionStart <= editOffset && (editOffset + editLength - 1) <= this.textRegionEnd) {
- if (editReplacementLength != 0 && editLength == editReplacementLength) {
- for (int i = editOffset, max = editOffset + editLength; i < max; i++) {
- if (scanner.source[i] != edit.replacement.charAt(i - editOffset)) {
- return true;
- }
- }
- return false;
- } else {
- return true;
- }
- } else if (editOffset + editLength == this.textRegionStart) {
- int i = editOffset;
- for (int max = editOffset + editLength; i < max; i++) {
- int replacementStringIndex = i - editOffset;
- if (replacementStringIndex >= editReplacementLength || scanner.source[i] != edit.replacement.charAt(replacementStringIndex)) {
- break;
- }
- }
- if (i - editOffset != editReplacementLength && i != editOffset + editLength - 1) {
- edit.offset = textRegionStart;
- edit.length = 0;
- edit.replacement = edit.replacement.substring(i - editOffset);
- return true;
- }
- }
- } else if (this.textRegionStart <= editOffset && editOffset <= this.textRegionEnd) {
- return true;
- } else if (editOffset == this.scannerEndPosition && editOffset == this.textRegionEnd + 1) {
- return true;
- }
- return false;
- }
-
- private void preserveEmptyLines(int count, int insertPosition) {
- if (count > 0) {
- if (this.formatter.preferences.number_of_empty_lines_to_preserve != 0) {
- int linesToPreserve = Math.min(count, this.formatter.preferences.number_of_empty_lines_to_preserve);
- this.printEmptyLines(linesToPreserve, insertPosition);
- } else {
- printNewLine(insertPosition);
- }
- }
- }
-
- private void print(char[] s, boolean considerSpaceIfAny) {
- if (checkLineWrapping && s.length + column > this.pageWidth) {
- handleLineTooLong();
- }
- this.lastNumberOfNewLines = 0;
- if (this.indentationLevel != 0) {
- printIndentationIfNecessary();
- }
- if (considerSpaceIfAny) {
- this.space();
- }
- if (this.pendingSpace) {
- this.addInsertEdit(this.scanner.getCurrentTokenStartPosition(), " "); //$NON-NLS-1$
- }
- this.pendingSpace = false;
- this.needSpace = false;
- column += s.length;
- needSpace = true;
- }
-
- private void printBlockComment(char[] s, boolean isJavadoc) {
- int currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
- int currentTokenEndPosition = this.scanner.getCurrentTokenEndPosition() + 1;
-
- this.scanner.resetTo(currentTokenStartPosition, currentTokenEndPosition - 1);
- int currentCharacter;
- boolean isNewLine = false;
- int start = currentTokenStartPosition;
- int nextCharacterStart = currentTokenStartPosition;
- int previousStart = currentTokenStartPosition;
- boolean onFirstColumn = isOnFirstColumn(start);
-
- boolean indentComment = false;
- if (this.indentationLevel != 0) {
- if (isJavadoc
- || !this.formatter.preferences.never_indent_block_comments_on_first_column
- || !onFirstColumn) {
- indentComment = true;
- printIndentationIfNecessary();
- }
- }
- if (this.pendingSpace) {
- this.addInsertEdit(currentTokenStartPosition, " "); //$NON-NLS-1$
- }
- this.needSpace = false;
- this.pendingSpace = false;
-
- int currentCommentOffset = onFirstColumn ? 0 : getCurrentCommentOffset(start);
- boolean formatComment = (isJavadoc && formatJavadocComment) || (!isJavadoc && formatBlockComment);
-
- while (nextCharacterStart <= currentTokenEndPosition && (currentCharacter = this.scanner.getNextChar()) != -1) {
- nextCharacterStart = this.scanner.currentPosition;
-
- switch(currentCharacter) {
- case '\r' :
- start = previousStart;
- isNewLine = true;
- if (this.scanner.getNextChar('\n')) {
- currentCharacter = '\n';
- nextCharacterStart = this.scanner.currentPosition;
- }
- break;
- case '\n' :
- start = previousStart;
- isNewLine = true;
- nextCharacterStart = this.scanner.currentPosition;
- break;
- default:
- if (isNewLine) {
- this.column = 1;
- this.line++;
- isNewLine = false;
-
- StringBuffer buffer = new StringBuffer();
- if (onFirstColumn) {
- // simply insert indentation if necessary
- buffer.append(this.lineSeparator);
- if (indentComment) {
- printIndentationIfNecessary(buffer);
- }
- if (formatComment) {
- if (ScannerHelper.isWhitespace((char) currentCharacter)) {
- int previousStartPosition = this.scanner.currentPosition;
- while(currentCharacter != -1 && currentCharacter != '\r' && currentCharacter != '\n' && ScannerHelper.isWhitespace((char) currentCharacter)) {
- previousStart = nextCharacterStart;
- previousStartPosition = this.scanner.currentPosition;
- currentCharacter = this.scanner.getNextChar();
- nextCharacterStart = this.scanner.currentPosition;
- }
- if (currentCharacter == '\r' || currentCharacter == '\n') {
- nextCharacterStart = previousStartPosition;
- }
- }
- if (currentCharacter != '\r' && currentCharacter != '\n') {
- buffer.append(' ');
- }
- }
- } else {
- if (ScannerHelper.isWhitespace((char) currentCharacter)) {
- int previousStartPosition = this.scanner.currentPosition;
- int count = 0;
- loop: while(currentCharacter != -1 && currentCharacter != '\r' && currentCharacter != '\n' && ScannerHelper.isWhitespace((char) currentCharacter)) {
- if (count >= currentCommentOffset) {
- break loop;
- }
- previousStart = nextCharacterStart;
- previousStartPosition = this.scanner.currentPosition;
- switch(currentCharacter) {
- case '\t' :
- count += this.tabLength;
- break;
- default :
- count ++;
- }
- currentCharacter = this.scanner.getNextChar();
- nextCharacterStart = this.scanner.currentPosition;
- }
- if (currentCharacter == '\r' || currentCharacter == '\n') {
- nextCharacterStart = previousStartPosition;
- }
- }
- buffer.append(this.lineSeparator);
- if (indentComment) {
- printIndentationIfNecessary(buffer);
- }
- if (formatComment) {
- int previousStartTemp = previousStart;
- int nextCharacterStartTemp = nextCharacterStart;
- while(currentCharacter != -1 && currentCharacter != '\r' && currentCharacter != '\n' && ScannerHelper.isWhitespace((char) currentCharacter)) {
- previousStart = nextCharacterStart;
- currentCharacter = this.scanner.getNextChar();
- nextCharacterStart = this.scanner.currentPosition;
- }
- if (currentCharacter == '*') {
- buffer.append(' ');
- } else {
- previousStart = previousStartTemp;
- nextCharacterStart = nextCharacterStartTemp;
- }
- this.scanner.currentPosition = nextCharacterStart;
- }
- }
- addReplaceEdit(start, previousStart - 1, String.valueOf(buffer));
- } else {
- this.column += (nextCharacterStart - previousStart);
- }
- }
- previousStart = nextCharacterStart;
- this.scanner.currentPosition = nextCharacterStart;
- }
- this.lastNumberOfNewLines = 0;
- needSpace = false;
- this.scanner.resetTo(currentTokenEndPosition, this.scannerEndPosition - 1);
- if (isJavadoc) {
- printNewLine();
- }
- }
-
- public void printEndOfCompilationUnit() {
- try {
- // if we have a space between two tokens we ensure it will be dumped in the formatted string
- int currentTokenStartPosition = this.scanner.currentPosition;
- boolean hasComment = false;
- boolean hasLineComment = false;
- boolean hasWhitespace = false;
- int count = 0;
- while (true) {
- this.currentToken = this.scanner.getNextToken();
- switch(this.currentToken) {
- case TerminalTokens.TokenNameWHITESPACE :
- char[] whiteSpaces = this.scanner.getCurrentTokenSource();
- count = 0;
- for (int i = 0, max = whiteSpaces.length; i < max; i++) {
- switch(whiteSpaces[i]) {
- case '\r' :
- if ((i + 1) < max) {
- if (whiteSpaces[i + 1] == '\n') {
- i++;
- }
- }
- count++;
- break;
- case '\n' :
- count++;
- }
- }
- if (count == 0) {
- hasWhitespace = true;
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- } else if (hasComment) {
- if (count == 1) {
- this.printNewLine(this.scanner.getCurrentTokenStartPosition());
- } else {
- preserveEmptyLines(count - 1, this.scanner.getCurrentTokenStartPosition());
- }
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- } else if (hasLineComment) {
- this.preserveEmptyLines(count, this.scanner.getCurrentTokenStartPosition());
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- } else {
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- }
- currentTokenStartPosition = this.scanner.currentPosition;
- break;
- case TerminalTokens.TokenNameCOMMENT_LINE :
- if (count >= 1) {
- if (count > 1) {
- preserveEmptyLines(count - 1, this.scanner.getCurrentTokenStartPosition());
- } else if (count == 1) {
- printNewLine(this.scanner.getCurrentTokenStartPosition());
- }
- } else if (hasWhitespace) {
- space();
- }
- hasWhitespace = false;
- this.printLineComment(this.scanner.getRawTokenSource());
- currentTokenStartPosition = this.scanner.currentPosition;
- hasLineComment = true;
- count = 0;
- break;
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- if (count >= 1) {
- if (count > 1) {
- preserveEmptyLines(count - 1, this.scanner.getCurrentTokenStartPosition());
- } else if (count == 1) {
- printNewLine(this.scanner.getCurrentTokenStartPosition());
- }
- } else if (hasWhitespace) {
- space();
- }
- hasWhitespace = false;
- this.printBlockComment(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- hasLineComment = false;
- hasComment = true;
- count = 0;
- break;
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- if (count >= 1) {
- if (count > 1) {
- preserveEmptyLines(count - 1, this.scanner.getCurrentTokenStartPosition());
- } else if (count == 1) {
- printNewLine(this.scanner.getCurrentTokenStartPosition());
- }
- } else if (hasWhitespace) {
- space();
- }
- hasWhitespace = false;
- this.printBlockComment(this.scanner.getRawTokenSource(), true);
- currentTokenStartPosition = this.scanner.currentPosition;
- hasLineComment = false;
- hasComment = true;
- count = 0;
- break;
- case TerminalTokens.TokenNameSEMICOLON :
- char[] currentTokenSource = this.scanner.getRawTokenSource();
- this.print(currentTokenSource, this.formatter.preferences.insert_space_before_semicolon);
- break;
- case TerminalTokens.TokenNameEOF :
- if (count >= 1 || this.formatter.preferences.insert_new_line_at_end_of_file_if_missing) {
- this.printNewLine(this.scannerEndPosition);
- }
- return;
- default :
- // step back one token
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
- return;
- }
- }
- } catch (InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
-
- public void printComment() {
- try {
- // if we have a space between two tokens we ensure it will be dumped in the formatted string
- int currentTokenStartPosition = this.scanner.currentPosition;
- int previousToken=this.scanner.currentToken;
- int previousNonWSToken=this.scanner.currentNonWhitespaceToken;
- boolean hasComment = false;
- boolean hasLineComment = false;
- boolean hasWhitespace = false;
- int count = 0;
- while ((this.currentToken = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
- switch(this.currentToken) {
- case TerminalTokens.TokenNameWHITESPACE :
- char[] whiteSpaces = this.scanner.getCurrentTokenSource();
- count = 0;
- for (int i = 0, max = whiteSpaces.length; i < max; i++) {
- switch(whiteSpaces[i]) {
- case '\r' :
- if ((i + 1) < max) {
- if (whiteSpaces[i + 1] == '\n') {
- i++;
- }
- }
- count++;
- break;
- case '\n' :
- count++;
- }
- }
- if (count == 0) {
- hasWhitespace = true;
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- } else if (hasComment) {
- if (count == 1) {
- this.printNewLine(this.scanner.getCurrentTokenStartPosition());
- } else {
- preserveEmptyLines(count - 1, this.scanner.getCurrentTokenStartPosition());
- }
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- } else if (hasLineComment) {
- this.preserveEmptyLines(count, this.scanner.getCurrentTokenStartPosition());
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- } else if (count != 0 && this.formatter.preferences.number_of_empty_lines_to_preserve != 0) {
- addReplaceEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition(), this.getPreserveEmptyLines(count - 1));
- } else {
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- }
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- break;
- case TerminalTokens.TokenNameCOMMENT_LINE :
- if (count >= 1) {
- if (count > 1) {
- preserveEmptyLines(count - 1, this.scanner.getCurrentTokenStartPosition());
- } else if (count == 1) {
- printNewLine(this.scanner.getCurrentTokenStartPosition());
- }
- } else if (hasWhitespace) {
- space();
- }
- hasWhitespace = false;
- this.printLineComment(this.scanner.getRawTokenSource());
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- hasLineComment = true;
- count = 0;
- break;
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- if (count >= 1) {
- if (count > 1) {
- preserveEmptyLines(count - 1, this.scanner.getCurrentTokenStartPosition());
- } else if (count == 1) {
- printNewLine(this.scanner.getCurrentTokenStartPosition());
- }
- } else if (hasWhitespace) {
- space();
- }
- hasWhitespace = false;
- this.printBlockComment(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- hasLineComment = false;
- hasComment = true;
- count = 0;
- break;
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- if (count >= 1) {
- if (count > 1) {
- preserveEmptyLines(count - 1, this.scanner.getCurrentTokenStartPosition());
- } else if (count == 1) {
- printNewLine(this.scanner.getCurrentTokenStartPosition());
- }
- } else if (hasWhitespace) {
- space();
- }
- hasWhitespace = false;
- this.printBlockComment(this.scanner.getRawTokenSource(), true);
- previousToken=this.scanner.currentToken;
- currentTokenStartPosition = this.scanner.currentPosition;
- hasLineComment = false;
- hasComment = true;
- count = 0;
- break;
- default :
- // step back one token
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- }
- }
- } catch (InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
-
- private void printLineComment(char[] s) {
- int currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
- int currentTokenEndPosition = this.scanner.getCurrentTokenEndPosition() + 1;
- if (CharOperation.indexOf(Scanner.TAG_PREFIX, this.scanner.source, true, currentTokenStartPosition, currentTokenEndPosition) != -1) {
- this.nlsTagCounter = 0;
- }
- this.scanner.resetTo(currentTokenStartPosition, currentTokenEndPosition - 1);
- int currentCharacter;
- int start = currentTokenStartPosition;
- int nextCharacterStart = currentTokenStartPosition;
-
- if (this.indentationLevel != 0) {
- if (!this.formatter.preferences.never_indent_line_comments_on_first_column
- || !isOnFirstColumn(start)) {
- printIndentationIfNecessary();
- }
- }
- if (this.pendingSpace) {
- this.addInsertEdit(currentTokenStartPosition, " "); //$NON-NLS-1$
- }
- this.needSpace = false;
- this.pendingSpace = false;
- int previousStart = currentTokenStartPosition;
-
- loop: while (nextCharacterStart <= currentTokenEndPosition && (currentCharacter = this.scanner.getNextChar()) != -1) {
- nextCharacterStart = this.scanner.currentPosition;
-
- switch(currentCharacter) {
- case '\r' :
- start = previousStart;
- break loop;
- case '\n' :
- start = previousStart;
- break loop;
- }
- previousStart = nextCharacterStart;
- }
- if (start != currentTokenStartPosition) {
- // this means that the line comment doesn't end the file
- addReplaceEdit(start, currentTokenEndPosition - 1, lineSeparator);
- this.line++;
- this.column = 1;
- this.lastNumberOfNewLines = 1;
- }
- this.needSpace = false;
- this.pendingSpace = false;
- // realign to the proper value
- if (this.currentAlignment != null) {
- if (this.memberAlignment != null) {
- // select the last alignment
- if (this.currentAlignment.location.inputOffset > this.memberAlignment.location.inputOffset) {
- if (this.currentAlignment.couldBreak() && this.currentAlignment.wasSplit) {
- this.currentAlignment.performFragmentEffect();
- }
- } else {
- this.indentationLevel = Math.max(this.indentationLevel, this.memberAlignment.breakIndentationLevel);
- }
- } else if (this.currentAlignment.couldBreak() && this.currentAlignment.wasSplit) {
- this.currentAlignment.performFragmentEffect();
- }
- }
- this.scanner.resetTo(currentTokenEndPosition, this.scannerEndPosition - 1);
- }
- public void printEmptyLines(int linesNumber) {
- this.printEmptyLines(linesNumber, this.scanner.getCurrentTokenEndPosition() + 1);
- }
-
- private void printEmptyLines(int linesNumber, int insertPosition) {
- final String buffer = getEmptyLines(linesNumber);
- if (Util.EMPTY_STRING == buffer) return;
-
- addInsertEdit(insertPosition, buffer);
- }
-
- void printIndentationIfNecessary() {
- StringBuffer buffer = new StringBuffer();
- printIndentationIfNecessary(buffer);
- if (buffer.length() > 0) {
- addInsertEdit(this.scanner.getCurrentTokenStartPosition(), buffer.toString());
- this.pendingSpace = false;
- }
- }
-
- private void printIndentationIfNecessary(StringBuffer buffer) {
- switch(this.tabChar) {
- case DefaultCodeFormatterOptions.TAB :
- boolean useTabsForLeadingIndents = this.useTabsOnlyForLeadingIndents;
- int numberOfLeadingIndents = this.numberOfIndentations;
- int indentationsAsTab = 0;
- if (useTabsForLeadingIndents) {
- while (this.column <= this.indentationLevel) {
- if (indentationsAsTab < numberOfLeadingIndents) {
- buffer.append('\t');
- indentationsAsTab++;
- int complement = this.tabLength - ((this.column - 1) % this.tabLength); // amount of space
- this.column += complement;
- this.needSpace = false;
- } else {
- buffer.append(' ');
- this.column++;
- this.needSpace = false;
- }
- }
- } else {
- while (this.column <= this.indentationLevel) {
- buffer.append('\t');
- int complement = this.tabLength - ((this.column - 1) % this.tabLength); // amount of space
- this.column += complement;
- this.needSpace = false;
- }
- }
- break;
- case DefaultCodeFormatterOptions.SPACE :
- while (this.column <= this.indentationLevel) {
- buffer.append(' ');
- this.column++;
- this.needSpace = false;
- }
- break;
- case DefaultCodeFormatterOptions.MIXED :
- useTabsForLeadingIndents = this.useTabsOnlyForLeadingIndents;
- numberOfLeadingIndents = this.numberOfIndentations;
- indentationsAsTab = 0;
- if (useTabsForLeadingIndents) {
- final int columnForLeadingIndents = numberOfLeadingIndents * this.indentationSize;
- while (this.column <= this.indentationLevel) {
- if (this.column <= columnForLeadingIndents) {
- if ((this.column - 1 + this.tabLength) <= this.indentationLevel) {
- buffer.append('\t');
- this.column += this.tabLength;
- } else if ((this.column - 1 + this.indentationSize) <= this.indentationLevel) {
- // print one indentation
- for (int i = 0, max = this.indentationSize; i < max; i++) {
- buffer.append(' ');
- this.column++;
- }
- } else {
- buffer.append(' ');
- this.column++;
- }
- } else {
- for (int i = this.column, max = this.indentationLevel; i <= max; i++) {
- buffer.append(' ');
- this.column++;
- }
- }
- this.needSpace = false;
- }
- } else {
- while (this.column <= this.indentationLevel) {
- if ((this.column - 1 + this.tabLength) <= this.indentationLevel) {
- buffer.append('\t');
- this.column += this.tabLength;
- } else if ((this.column - 1 + this.indentationSize) <= this.indentationLevel) {
- // print one indentation
- for (int i = 0, max = this.indentationSize; i < max; i++) {
- buffer.append(' ');
- this.column++;
- }
- } else {
- buffer.append(' ');
- this.column++;
- }
- this.needSpace = false;
- }
- }
- break;
- }
- }
-
- public void printModifiers(ASTVisitor visitor) {
- try {
- boolean isFirstModifier = true;
- int currentTokenStartPosition = this.scanner.currentPosition;
- int previousToken=this.scanner.currentToken;
- int previousNonWSToken=this.scanner.currentNonWhitespaceToken;
- boolean hasComment = false;
- boolean hasModifiers = false;
- while ((this.currentToken = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
- switch(this.currentToken) {
- case TerminalTokens.TokenNamepublic :
- case TerminalTokens.TokenNameprotected :
- case TerminalTokens.TokenNameprivate :
- case TerminalTokens.TokenNamestatic :
- case TerminalTokens.TokenNameabstract :
- case TerminalTokens.TokenNamefinal :
- case TerminalTokens.TokenNamenative :
- case TerminalTokens.TokenNamesynchronized :
- case TerminalTokens.TokenNametransient :
- case TerminalTokens.TokenNamevolatile :
- case TerminalTokens.TokenNamestrictfp :
- hasModifiers = true;
- this.print(this.scanner.getRawTokenSource(), !isFirstModifier);
- isFirstModifier = false;
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=previousNonWSToken=this.scanner.currentToken;
- break;
- case TerminalTokens.TokenNameAT :
- hasModifiers = true;
- if (!isFirstModifier) {
- this.space();
- }
- this.scanner.resetTo(this.scanner.getCurrentTokenStartPosition(), this.scannerEndPosition - 1);
- return;
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- this.printBlockComment(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- hasComment = true;
- break;
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- this.printBlockComment(this.scanner.getRawTokenSource(), true);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- hasComment = true;
- break;
- case TerminalTokens.TokenNameCOMMENT_LINE :
- this.printLineComment(this.scanner.getRawTokenSource());
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- break;
- case TerminalTokens.TokenNameWHITESPACE :
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- int count = 0;
- char[] whiteSpaces = this.scanner.getCurrentTokenSource();
- for (int i = 0, max = whiteSpaces.length; i < max; i++) {
- switch(whiteSpaces[i]) {
- case '\r' :
- if ((i + 1) < max) {
- if (whiteSpaces[i + 1] == '\n') {
- i++;
- }
- }
- count++;
- break;
- case '\n' :
- count++;
- }
- }
- if (count >= 1 && hasComment) {
- printNewLine();
- }
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- hasComment = false;
- break;
- default:
- if (hasModifiers) {
- this.space();
- }
- // step back one token
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- }
- }
- } catch (InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
-
- public void printNewLine() {
- if (this.nlsTagCounter > 0) {
- return;
- }
- if (lastNumberOfNewLines >= 1) {
- column = 1; // ensure that the scribe is at the beginning of a new line
- return;
- }
- addInsertEdit(this.scanner.getCurrentTokenEndPosition() + 1, this.lineSeparator);
- line++;
- lastNumberOfNewLines = 1;
- column = 1;
- needSpace = false;
- this.pendingSpace = false;
- }
-
- public void printNewLine(int insertPosition) {
- if (this.nlsTagCounter > 0) {
- return;
- }
- if (lastNumberOfNewLines >= 1) {
- column = 1; // ensure that the scribe is at the beginning of a new line
- return;
- }
- addInsertEdit(insertPosition, this.lineSeparator);
- line++;
- lastNumberOfNewLines = 1;
- column = 1;
- needSpace = false;
- this.pendingSpace = false;
- }
-
- public void printNextToken(int expectedTokenType){
- printNextToken(expectedTokenType, false);
- }
-
- public void printNextToken(int expectedTokenType, boolean considerSpaceIfAny){
- printComment();
- try {
- this.currentToken = this.scanner.getNextToken();
- char[] currentTokenSource = this.scanner.getRawTokenSource();
- if (expectedTokenType != this.currentToken) {
- throw new AbortFormatting("unexpected token type, expecting:"+expectedTokenType+", actual:"+this.currentToken);//$NON-NLS-1$//$NON-NLS-2$
- }
- this.print(currentTokenSource, considerSpaceIfAny);
- } catch (InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
-
- public void printNextToken(int[] expectedTokenTypes) {
- printNextToken(expectedTokenTypes, false);
- }
-
- public void printNextToken(int[] expectedTokenTypes, boolean considerSpaceIfAny){
- printComment();
- try {
- this.currentToken = this.scanner.getNextToken();
- char[] currentTokenSource = this.scanner.getRawTokenSource();
- if (Arrays.binarySearch(expectedTokenTypes, this.currentToken) < 0) {
- StringBuffer expectations = new StringBuffer(5);
- for (int i = 0; i < expectedTokenTypes.length; i++){
- if (i > 0) {
- expectations.append(',');
- }
- expectations.append(expectedTokenTypes[i]);
- }
- throw new AbortFormatting("unexpected token type, expecting:["+expectations.toString()+"], actual:"+this.currentToken);//$NON-NLS-1$//$NON-NLS-2$
- }
- this.print(currentTokenSource, considerSpaceIfAny);
- } catch (InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
-
-
- public void printOptionalNextToken(int expectedTokenType, boolean considerSpaceIfAny){
- printComment();
- try {
- int tokenStart=this.scanner.currentPosition;
- if (this.scanner.atEnd())
- return;
- this.currentToken = this.scanner.getNextToken();
- char[] currentTokenSource = this.scanner.getRawTokenSource();
- if (expectedTokenType != this.currentToken) {
- this.scanner.resetTo(tokenStart, this.scannerEndPosition - 1);
- }
- else
- this.print(currentTokenSource, considerSpaceIfAny);
- } catch (InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
-
- public void printArrayQualifiedReference(int numberOfTokens, int sourceEnd) {
- int currentTokenStartPosition = this.scanner.currentPosition;
- int previousToken=this.scanner.currentToken;
- int previousNonWSToken=this.scanner.currentNonWhitespaceToken;
- int numberOfIdentifiers = 0;
- try {
- do {
- this.printComment();
- switch(this.currentToken = this.scanner.getNextToken()) {
- case TerminalTokens.TokenNameEOF :
- return;
- case TerminalTokens.TokenNameWHITESPACE :
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- break;
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- this.printBlockComment(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- break;
- case TerminalTokens.TokenNameCOMMENT_LINE :
- this.printLineComment(this.scanner.getRawTokenSource());
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- break;
- case TerminalTokens.TokenNameIdentifier :
- this.print(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=previousNonWSToken=this.scanner.currentToken;
- if (++ numberOfIdentifiers == numberOfTokens) {
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
- return;
- }
- break;
- case TerminalTokens.TokenNameDOT :
- this.print(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=previousNonWSToken=this.scanner.currentToken;
- break;
- default:
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- }
- } while (this.scanner.currentPosition <= sourceEnd);
- } catch(InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
-
- public void printQualifiedReference(int sourceEnd) {
- int currentTokenStartPosition = this.scanner.currentPosition;
- int previousToken=this.scanner.currentToken;
- int previousNonWSToken=this.scanner.currentNonWhitespaceToken;
- try {
- do {
- this.printComment();
- switch(this.currentToken = this.scanner.getNextToken()) {
- case TerminalTokens.TokenNameEOF :
- return;
- case TerminalTokens.TokenNameWHITESPACE :
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- break;
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- this.printBlockComment(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- break;
- case TerminalTokens.TokenNameCOMMENT_LINE :
- this.printLineComment(this.scanner.getRawTokenSource());
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- break;
- case TerminalTokens.TokenNameIdentifier :
- case TerminalTokens.TokenNameDOT :
- this.print(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=previousNonWSToken=this.scanner.currentToken;
- break;
- default:
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- }
- } while (this.scanner.currentPosition <= sourceEnd);
- } catch(InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
-
- private void printRule(StringBuffer stringBuffer) {
- for (int i = 0; i < this.pageWidth; i++){
- if ((i % this.tabLength) == 0) {
- stringBuffer.append('+');
- } else {
- stringBuffer.append('-');
- }
- }
- stringBuffer.append(this.lineSeparator);
-
- for (int i = 0; i < (pageWidth / tabLength); i++) {
- stringBuffer.append(i);
- stringBuffer.append('\t');
- }
- }
-
- public void printTrailingComment(int numberOfNewLinesToInsert) {
- try {
- // if we have a space between two tokens we ensure it will be dumped in the formatted string
- int currentTokenStartPosition = this.scanner.currentPosition;
- int previousToken=this.scanner.currentToken;
- int previousNonWSToken=this.scanner.currentNonWhitespaceToken;
- boolean hasWhitespaces = false;
- boolean hasLineComment = false;
- while ((this.currentToken = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
- switch(this.currentToken) {
- case TerminalTokens.TokenNameWHITESPACE :
- int count = 0;
- char[] whiteSpaces = this.scanner.getCurrentTokenSource();
- for (int i = 0, max = whiteSpaces.length; i < max; i++) {
- switch(whiteSpaces[i]) {
- case '\r' :
- if ((i + 1) < max) {
- if (whiteSpaces[i + 1] == '\n') {
- i++;
- }
- }
- count++;
- break;
- case '\n' :
- count++;
- }
- }
- if (hasLineComment) {
- if (count >= 1) {
- currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
- this.preserveEmptyLines(numberOfNewLinesToInsert, currentTokenStartPosition);
- addDeleteEdit(currentTokenStartPosition, this.scanner.getCurrentTokenEndPosition());
- this.scanner.resetTo(this.scanner.currentPosition, this.scannerEndPosition - 1);
- return;
- } else {
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- }
- } else if (count > 1) {
- this.printEmptyLines(numberOfNewLinesToInsert, this.scanner.getCurrentTokenStartPosition());
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- } else {
- hasWhitespaces = true;
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- }
- break;
- case TerminalTokens.TokenNameCOMMENT_LINE :
- if (hasWhitespaces) {
- space();
- }
- this.printLineComment(this.scanner.getRawTokenSource());
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- hasLineComment = true;
- break;
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- if (hasWhitespaces) {
- space();
- }
- this.printBlockComment(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- break;
- default :
- // step back one token
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- }
- }
- } catch (InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
- public void printTrailingComment() {
- try {
- // if we have a space between two tokens we ensure it will be dumped in the formatted string
- int currentTokenStartPosition = this.scanner.currentPosition;
- int previousToken=this.scanner.currentToken;
- int previousNonWSToken=this.scanner.currentNonWhitespaceToken;
-
- boolean hasWhitespaces = false;
- boolean hasComment = false;
- boolean hasLineComment = false;
- while ((this.currentToken = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
- switch(this.currentToken) {
- case TerminalTokens.TokenNameWHITESPACE :
- int count = 0;
- char[] whiteSpaces = this.scanner.getCurrentTokenSource();
- for (int i = 0, max = whiteSpaces.length; i < max; i++) {
- switch(whiteSpaces[i]) {
- case '\r' :
- if ((i + 1) < max) {
- if (whiteSpaces[i + 1] == '\n') {
- i++;
- }
- }
- count++;
- break;
- case '\n' :
- count++;
- }
- }
- if (hasLineComment) {
- if (count >= 1) {
- currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
- this.preserveEmptyLines(count, currentTokenStartPosition);
- addDeleteEdit(currentTokenStartPosition, this.scanner.getCurrentTokenEndPosition());
- this.scanner.resetTo(this.scanner.currentPosition, this.scannerEndPosition - 1);
- return;
- } else {
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- }
- } else if (count >= 1) {
- if (hasComment) {
- this.printNewLine(this.scanner.getCurrentTokenStartPosition());
- }
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- } else {
- hasWhitespaces = true;
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
- }
- break;
- case TerminalTokens.TokenNameCOMMENT_LINE :
- if (hasWhitespaces) {
- space();
- }
- this.printLineComment(this.scanner.getRawTokenSource());
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- hasLineComment = true;
- break;
- case TerminalTokens.TokenNameCOMMENT_BLOCK :
- if (hasWhitespaces) {
- space();
- }
- this.printBlockComment(this.scanner.getRawTokenSource(), false);
- currentTokenStartPosition = this.scanner.currentPosition;
- previousToken=this.scanner.currentToken;
- hasComment = true;
- break;
- default :
- // step back one token
- this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1,previousToken,previousNonWSToken);
- return;
- }
- }
- } catch (InvalidInputException e) {
- throw new AbortFormatting(e);
- }
- }
-
- void redoAlignment(AlignmentException e){
- if (e.relativeDepth > 0) { // if exception targets a distinct context
- e.relativeDepth--; // record fact that current context got traversed
- this.currentAlignment = this.currentAlignment.enclosing; // pop currentLocation
- throw e; // rethrow
- }
- // reset scribe/scanner to restart at this given location
- this.resetAt(this.currentAlignment.location);
- this.scanner.resetTo(this.currentAlignment.location.inputOffset, this.scanner.eofPosition,this.currentAlignment.location.inputToken,this.currentAlignment.location.inputTokenNonWS);
- // clean alignment chunkKind so it will think it is a new chunk again
- this.currentAlignment.chunkKind = 0;
- }
-
- void redoMemberAlignment(AlignmentException e){
- // reset scribe/scanner to restart at this given location
- this.resetAt(this.memberAlignment.location);
- this.scanner.resetTo(this.memberAlignment.location.inputOffset, this.scanner.eofPosition,this.memberAlignment.location.inputToken,this.currentAlignment.location.inputTokenNonWS);
- // clean alignment chunkKind so it will think it is a new chunk again
- this.memberAlignment.chunkKind = 0;
- }
-
- public void reset() {
- this.checkLineWrapping = true;
- this.line = 0;
- this.column = 1;
- this.editsIndex = 0;
- this.nlsTagCounter = 0;
- }
-
- private void resetAt(Location location) {
- this.line = location.outputLine;
- this.column = location.outputColumn;
- this.indentationLevel = location.outputIndentationLevel;
- this.numberOfIndentations = location.numberOfIndentations;
- this.lastNumberOfNewLines = location.lastNumberOfNewLines;
- this.needSpace = location.needSpace;
- this.pendingSpace = location.pendingSpace;
- this.editsIndex = location.editsIndex;
- this.nlsTagCounter = location.nlsTagCounter;
- if (this.editsIndex > 0) {
- this.edits[this.editsIndex - 1] = location.textEdit;
- }
- this.formatter.lastLocalDeclarationSourceStart = location.lastLocalDeclarationSourceStart;
- }
-
- private void resize() {
- System.arraycopy(this.edits, 0, (this.edits = new OptimizedReplaceEdit[this.editsIndex * 2]), 0, this.editsIndex);
- }
-
- public void space() {
- if (!this.needSpace) return;
- this.lastNumberOfNewLines = 0;
- this.pendingSpace = true;
- this.column++;
- this.needSpace = false;
- }
-
- public String toString() {
- StringBuffer stringBuffer = new StringBuffer();
- stringBuffer
- .append("(page width = " + this.pageWidth + ") - (tabChar = ");//$NON-NLS-1$//$NON-NLS-2$
- switch(this.tabChar) {
- case DefaultCodeFormatterOptions.TAB :
- stringBuffer.append("TAB");//$NON-NLS-1$
- break;
- case DefaultCodeFormatterOptions.SPACE :
- stringBuffer.append("SPACE");//$NON-NLS-1$
- break;
- default :
- stringBuffer.append("MIXED");//$NON-NLS-1$
- }
- stringBuffer
- .append(") - (tabSize = " + this.tabLength + ")")//$NON-NLS-1$//$NON-NLS-2$
- .append(this.lineSeparator)
- .append("(line = " + this.line + ") - (column = " + this.column + ") - (identationLevel = " + this.indentationLevel + ")") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- .append(this.lineSeparator)
- .append("(needSpace = " + this.needSpace + ") - (lastNumberOfNewLines = " + this.lastNumberOfNewLines + ") - (checkLineWrapping = " + this.checkLineWrapping + ")") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- .append(this.lineSeparator)
- .append("==================================================================================") //$NON-NLS-1$
- .append(this.lineSeparator);
- printRule(stringBuffer);
- return stringBuffer.toString();
- }
-
- public void unIndent() {
- this.indentationLevel -= this.indentationSize;
- this.numberOfIndentations--;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/align/Alignment.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/align/Alignment.java
deleted file mode 100644
index 1aff487e..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/align/Alignment.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.align;
-
-import org.eclipse.wst.jsdt.internal.formatter.Location;
-import org.eclipse.wst.jsdt.internal.formatter.Scribe;
-
-/**
- * Alignment management
- *
- * @since 2.1
- */
-public class Alignment {
-
- // name of alignment
- public String name;
-
- // link to enclosing alignment
- public Alignment enclosing;
-
- // start location of this alignment
- public Location location;
-
- // indentation management
- public int fragmentIndex;
- public int fragmentCount;
- public int[] fragmentIndentations;
- public boolean needRedoColumnAlignment;
-
- // chunk management
- public int chunkStartIndex;
- public int chunkKind;
-
- // break management
- public int originalIndentationLevel;
- public int breakIndentationLevel;
- public int shiftBreakIndentationLevel;
- public int[] fragmentBreaks;
- public boolean wasSplit;
-
- public Scribe scribe;
-
- /*
- * Alignment modes
- */
- public static final int M_FORCE = 1; // if bit set, then alignment will be non-optional (default is optional)
- public static final int M_INDENT_ON_COLUMN = 2; // if bit set, broken fragments will be aligned on current location column (default is to break at current indentation level)
- public static final int M_INDENT_BY_ONE = 4; // if bit set, broken fragments will be indented one level below current (not using continuation indentation)
-
- // split modes can be combined either with M_FORCE or M_INDENT_ON_COLUMN
-
- /** foobar(#fragment1, #fragment2, <ul>
- * <li> #fragment3, #fragment4 </li>
- * </ul>
- */
- public static final int M_COMPACT_SPLIT = 16; // fill each line with all possible fragments
-
- /** foobar(<ul>
- * <li> #fragment1, #fragment2, </li>
- * <li> #fragment5, #fragment4, </li>
- * </ul>
- */
- public static final int M_COMPACT_FIRST_BREAK_SPLIT = 32; // compact mode, but will first try to break before first fragment
-
- /** foobar(<ul>
- * <li> #fragment1, </li>
- * <li> #fragment2, </li>
- * <li> #fragment3 </li>
- * <li> #fragment4, </li>
- * </ul>
- */
- public static final int M_ONE_PER_LINE_SPLIT = 32+16; // one fragment per line
-
- /**
- * foobar(<ul>
- * <li> #fragment1, </li>
- * <li> #fragment2, </li>
- * <li> #fragment3 </li>
- * <li> #fragment4, </li>
- * </ul>
- */
- public static final int M_NEXT_SHIFTED_SPLIT = 64; // one fragment per line, subsequent are indented further
-
- /** foobar(#fragment1, <ul>
- * <li> #fragment2, </li>
- * <li> #fragment3 </li>
- * <li> #fragment4, </li>
- * </ul>
- */
- public static final int M_NEXT_PER_LINE_SPLIT = 64+16; // one per line, except first fragment (if possible)
-
- //64+32
- //64+32+16
-
- // mode controlling column alignments
- /**
- * <table BORDER COLS=4 WIDTH="100%" >
- * <tr><td>#fragment1A</td> <td>#fragment2A</td> <td>#fragment3A</td> <td>#very-long-fragment4A</td></tr>
- * <tr><td>#fragment1B</td> <td>#long-fragment2B</td> <td>#fragment3B</td> <td>#fragment4B</td></tr>
- * <tr><td>#very-long-fragment1C</td> <td>#fragment2C</td> <td>#fragment3C</td> <td>#fragment4C</td></tr>
- * </table>
- */
- public static final int M_MULTICOLUMN = 256; // fragments are on same line, but multiple line of fragments will be aligned vertically
-
- public static final int M_NO_ALIGNMENT = 0;
-
- public int mode;
-
- public static final int SPLIT_MASK = M_ONE_PER_LINE_SPLIT | M_NEXT_SHIFTED_SPLIT | M_COMPACT_SPLIT | M_COMPACT_FIRST_BREAK_SPLIT | M_NEXT_PER_LINE_SPLIT;
-
- // alignment tie-break rules - when split is needed, will decide whether innermost/outermost alignment is to be chosen
- public static final int R_OUTERMOST = 1;
- public static final int R_INNERMOST = 2;
- public int tieBreakRule;
-
- // alignment effects on a per fragment basis
- public static final int NONE = 0;
- public static final int BREAK = 1;
-
- // chunk kind
- public static final int CHUNK_FIELD = 1;
- public static final int CHUNK_METHOD = 2;
- public static final int CHUNK_TYPE = 3;
- public static final int CHUNK_ENUM = 4;
-
- // location to align and break on.
- public Alignment(String name, int mode, int tieBreakRule, Scribe scribe, int fragmentCount, int sourceRestart, int continuationIndent){
-
- this.name = name;
- this.location = new Location(scribe, sourceRestart);
- this.mode = mode;
- this.tieBreakRule = tieBreakRule;
- this.fragmentCount = fragmentCount;
- this.scribe = scribe;
- this.originalIndentationLevel = this.scribe.indentationLevel;
- this.wasSplit = false;
-
- // initialize the break indentation level, using modes and continuationIndentationLevel preference
- final int indentSize = this.scribe.indentationSize;
- int currentColumn = this.location.outputColumn;
- if (currentColumn == 1) {
- currentColumn = this.location.outputIndentationLevel + 1;
- }
-
- if ((mode & M_INDENT_ON_COLUMN) != 0) {
- // indent broken fragments at next indentation level, based on current column
- this.breakIndentationLevel = this.scribe.getNextIndentationLevel(currentColumn);
- if (this.breakIndentationLevel == this.location.outputIndentationLevel) {
- this.breakIndentationLevel += (continuationIndent * indentSize);
- }
- } else if ((mode & M_INDENT_BY_ONE) != 0) {
- // indent broken fragments exactly one level deeper than current indentation
- this.breakIndentationLevel = this.location.outputIndentationLevel + indentSize;
- } else {
- this.breakIndentationLevel = this.location.outputIndentationLevel + continuationIndent * indentSize;
- }
- this.shiftBreakIndentationLevel = this.breakIndentationLevel + indentSize;
-
- this.fragmentIndentations = new int[this.fragmentCount];
- this.fragmentBreaks = new int[this.fragmentCount];
-
- // check for forced alignments
- if ((this.mode & M_FORCE) != 0) {
- couldBreak();
- }
- }
-
- public boolean checkChunkStart(int kind, int startIndex, int sourceRestart) {
- if (this.chunkKind != kind) {
- this.chunkKind = kind;
-
- // when redoing same chunk alignment, must not reset
- if (startIndex != this.chunkStartIndex) {
- this.chunkStartIndex = startIndex;
- this.location.update(this.scribe, sourceRestart);
- reset();
- }
- return true;
- }
- return false;
- }
-
- public void checkColumn() {
- if ((this.mode & M_MULTICOLUMN) != 0) {
- int currentIndentation = this.scribe.getNextIndentationLevel(this.scribe.column+(this.scribe.needSpace ? 1 : 0));
- int fragmentIndentation = this.fragmentIndentations[this.fragmentIndex];
- if (currentIndentation > fragmentIndentation) {
- this.fragmentIndentations[this.fragmentIndex] = currentIndentation;
- if (fragmentIndentation != 0) {
- for (int i = this.fragmentIndex+1; i < this.fragmentCount; i++) {
- this.fragmentIndentations[i] = 0;
- }
- this.needRedoColumnAlignment = true;
- }
- }
- // backtrack only once all fragments got checked
- if (this.needRedoColumnAlignment && this.fragmentIndex == this.fragmentCount-1) { // alignment too small
-
-// if (CodeFormatterVisitor.DEBUG){
-// System.out.println("ALIGNMENT TOO SMALL");
-// System.out.println(this);
-// }
- this.needRedoColumnAlignment = false;
- int relativeDepth = 0;
- Alignment targetAlignment = this.scribe.memberAlignment;
- while (targetAlignment != null){
- if (targetAlignment == this){
- throw new AlignmentException(AlignmentException.ALIGN_TOO_SMALL, relativeDepth);
- }
- targetAlignment = targetAlignment.enclosing;
- relativeDepth++;
- }
- }
- }
- }
-
- public boolean couldBreak(){
- int i;
- switch(mode & SPLIT_MASK){
-
- /* # aligned fragment
- * foo(
- * #AAAAA, #BBBBB,
- * #CCCC);
- */
- case M_COMPACT_FIRST_BREAK_SPLIT :
- if (this.fragmentBreaks[0] == NONE) {
- this.fragmentBreaks[0] = BREAK;
- this.fragmentIndentations[0] = this.breakIndentationLevel;
- return wasSplit = true;
- }
- i = this.fragmentIndex;
- do {
- if (this.fragmentBreaks[i] == NONE) {
- this.fragmentBreaks[i] = BREAK;
- this.fragmentIndentations[i] = this.breakIndentationLevel;
- return wasSplit = true;
- }
- } while (--i >= 0);
- break;
- /* # aligned fragment
- * foo(#AAAAA, #BBBBB,
- * #CCCC);
- */
- case M_COMPACT_SPLIT :
- i = this.fragmentIndex;
- do {
- if (this.fragmentBreaks[i] == NONE) {
- this.fragmentBreaks[i] = BREAK;
- this.fragmentIndentations[i] = this.breakIndentationLevel;
- return wasSplit = true;
- }
- } while (--i >= 0);
- break;
-
- /* # aligned fragment
- * foo(
- * #AAAAA,
- * #BBBBB,
- * #CCCC);
- */
- case M_NEXT_SHIFTED_SPLIT :
- if (this.fragmentBreaks[0] == NONE) {
- this.fragmentBreaks[0] = BREAK;
- this.fragmentIndentations[0] = this.breakIndentationLevel;
- for (i = 1; i < this.fragmentCount; i++){
- this.fragmentBreaks[i] = BREAK;
- this.fragmentIndentations[i] = this.shiftBreakIndentationLevel;
- }
- return wasSplit = true;
- }
- break;
-
- /* # aligned fragment
- * foo(
- * #AAAAA,
- * #BBBBB,
- * #CCCC);
- */
- case M_ONE_PER_LINE_SPLIT :
- if (this.fragmentBreaks[0] == NONE) {
- for (i = 0; i < this.fragmentCount; i++){
- this.fragmentBreaks[i] = BREAK;
- this.fragmentIndentations[i] = this.breakIndentationLevel;
- }
- return wasSplit = true;
- }
- /* # aligned fragment
- * foo(#AAAAA,
- * #BBBBB,
- * #CCCC);
- */
- case M_NEXT_PER_LINE_SPLIT :
- if (this.fragmentBreaks[0] == NONE) {
- if (this.fragmentCount > 1
- && this.fragmentBreaks[1] == NONE) {
- if ((this.mode & M_INDENT_ON_COLUMN) != 0) {
- this.fragmentIndentations[0] = this.breakIndentationLevel;
- }
- for (i = 1; i < this.fragmentCount; i++) {
- this.fragmentBreaks[i] = BREAK;
- this.fragmentIndentations[i] = this.breakIndentationLevel;
- }
- return wasSplit = true;
- }
- }
- break;
- }
- return false; // cannot split better
- }
-
- public Alignment getAlignment(String targetName) {
-
- if (targetName.equals(this.name)) return this;
- if (this.enclosing == null) return null;
-
- return this.enclosing.getAlignment(targetName);
- }
-
- // perform alignment effect for current fragment
- public void performFragmentEffect(){
- if ((this.mode & M_MULTICOLUMN) == 0) {
- switch(this.mode & SPLIT_MASK) {
- case Alignment.M_COMPACT_SPLIT :
- case Alignment.M_COMPACT_FIRST_BREAK_SPLIT :
- case Alignment.M_NEXT_PER_LINE_SPLIT :
- case Alignment.M_NEXT_SHIFTED_SPLIT :
- case Alignment.M_ONE_PER_LINE_SPLIT :
- break;
- default:
- return;
- }
- }
-
- if (this.fragmentBreaks[this.fragmentIndex] == BREAK) {
- this.scribe.printNewLine();
- }
- if (this.fragmentIndentations[this.fragmentIndex] > 0) {
- this.scribe.indentationLevel = this.fragmentIndentations[this.fragmentIndex];
- }
- }
-
- // reset fragment indentation/break status
- public void reset() {
-
- if (fragmentCount > 0){
- this.fragmentIndentations = new int[this.fragmentCount];
- this.fragmentBreaks = new int[this.fragmentCount];
- }
-
- // check for forced alignments
- if ((mode & M_FORCE) != 0) {
- couldBreak();
- }
- }
-
- public void toFragmentsString(StringBuffer buffer){
- // default implementation
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer(10);
- buffer
- .append(getClass().getName())
- .append(':')
- .append("<name: ") //$NON-NLS-1$
- .append(this.name)
- .append(">"); //$NON-NLS-1$
- if (this.enclosing != null) {
- buffer
- .append("<enclosingName: ") //$NON-NLS-1$
- .append(this.enclosing.name)
- .append('>');
- }
- buffer.append('\n');
-
- for (int i = 0; i < this.fragmentCount; i++){
- buffer
- .append(" - fragment ") //$NON-NLS-1$
- .append(i)
- .append(": ") //$NON-NLS-1$
- .append("<break: ") //$NON-NLS-1$
- .append(this.fragmentBreaks[i] > 0 ? "YES" : "NO") //$NON-NLS-1$ //$NON-NLS-2$
- .append(">") //$NON-NLS-1$
- .append("<indent: ") //$NON-NLS-1$
- .append(this.fragmentIndentations[i])
- .append(">\n"); //$NON-NLS-1$
- }
- buffer.append('\n');
- return buffer.toString();
- }
-
- public void update() {
- for (int i = 1; i < this.fragmentCount; i++){
- if (this.fragmentBreaks[i] == BREAK) {
- this.fragmentIndentations[i] = this.breakIndentationLevel;
- }
- }
- }
-
- public boolean isWrapped() {
- for (int i = 0, max = this.fragmentCount; i < max; i++) {
- if (this.fragmentBreaks[i] == BREAK) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/align/AlignmentException.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/align/AlignmentException.java
deleted file mode 100644
index ba1b5585..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/align/AlignmentException.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.align;
-
-/**
- * Exception used to backtrack and break available alignments
- * When the exception is thrown, it is assumed that some alignment will be changed.
- *
- * @since 2.1
- */
-public class AlignmentException extends RuntimeException {
-
- public static final int LINE_TOO_LONG = 1;
- public static final int ALIGN_TOO_SMALL = 2;
- private static final long serialVersionUID = -3324134986466253314L; // backward compatible
-
- int reason;
- int value;
- public int relativeDepth;
-
- public AlignmentException(int reason, int relativeDepth) {
- this(reason, 0, relativeDepth);
- }
-
- public AlignmentException(int reason, int value, int relativeDepth) {
- this.reason = reason;
- this.value = value;
- this.relativeDepth = relativeDepth;
- }
-
- public String toString(){
- StringBuffer buffer = new StringBuffer(10);
- switch(this.reason){
- case LINE_TOO_LONG :
- buffer.append("LINE_TOO_LONG"); //$NON-NLS-1$
- break;
- case ALIGN_TOO_SMALL :
- buffer.append("ALIGN_TOO_SMALL"); //$NON-NLS-1$
- break;
- }
- buffer
- .append("<relativeDepth: ") //$NON-NLS-1$
- .append(this.relativeDepth)
- .append(">\n"); //$NON-NLS-1$
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentFormatterUtil.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentFormatterUtil.java
deleted file mode 100644
index ebdb1e0b..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentFormatterUtil.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.Position;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.jsdt.core.ToolFactory;
-import org.eclipse.wst.jsdt.internal.core.util.Util;
-
-/**
- * Comment formatting utils.
- *
- * @since 3.1
- */
-public class CommentFormatterUtil {
-
- /**
- * Evaluates the edit on the given string.
- *
- * @throws IllegalArgumentException if the positions are not inside the
- * string
- */
- public static String evaluateFormatterEdit(String string, TextEdit edit, Position[] positions) {
- try {
- Document doc= createDocument(string, positions);
- edit.apply(doc, 0);
- if (positions != null) {
- for (int i= 0; i < positions.length; i++) {
- Assert.isTrue(!positions[i].isDeleted, "Position got deleted"); //$NON-NLS-1$
- }
- }
- return doc.get();
- } catch (BadLocationException e) {
- log(e); // bug in the formatter
- Assert.isTrue(false, "Formatter created edits with wrong positions: " + e.getMessage()); //$NON-NLS-1$
- }
- return null;
- }
-
- /**
- * Creates edits that describe how to format the given string. Returns
- * <code>null</code> if the code could not be formatted for the given
- * kind.
- *
- * @throws IllegalArgumentException if the offset and length are not
- * inside the string
- */
- public static TextEdit format2(int kind, String string, int indentationLevel, String lineSeparator, Map options) {
- int length= string.length();
- if (0 < 0 || length < 0 || 0 + length > string.length()) {
- throw new IllegalArgumentException("offset or length outside of string. offset: " + 0 + ", length: " + length + ", string size: " + string.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
- return ToolFactory.createCodeFormatter(options).format(kind, string, 0, length, indentationLevel, lineSeparator);
- }
-
- /**
- * Returns a document with the given content and the given positions
- * registered with the {@link DefaultPositionUpdater}.
- *
- * @param content the content
- * @param positions the positions
- * @return the document
- * @throws IllegalArgumentException
- */
- private static Document createDocument(String content, Position[] positions) throws IllegalArgumentException {
- Document doc= new Document(content);
- try {
- if (positions != null) {
- final String POS_CATEGORY= "myCategory"; //$NON-NLS-1$
-
- doc.addPositionCategory(POS_CATEGORY);
- doc.addPositionUpdater(new DefaultPositionUpdater(POS_CATEGORY) {
- protected boolean notDeleted() {
- if (fOffset < fPosition.offset && (fPosition.offset + fPosition.length < fOffset + fLength)) {
- fPosition.offset= fOffset + fLength; // deleted positions: set to end of remove
- return false;
- }
- return true;
- }
- });
- for (int i= 0; i < positions.length; i++) {
- try {
- doc.addPosition(POS_CATEGORY, positions[i]);
- } catch (BadLocationException e) {
- throw new IllegalArgumentException("Position outside of string. offset: " + positions[i].offset + ", length: " + positions[i].length + ", string size: " + content.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
- }
- }
- } catch (BadPositionCategoryException cannotHappen) {
- // can not happen: category is correctly set up
- }
- return doc;
- }
-
- /**
- * Logs the given throwable.
- *
- * @param t the throwable
- * @since 3.1
- */
- public static void log(Throwable t) {
- Util.log(t, "Exception occured while formatting comments"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentLine.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentLine.java
deleted file mode 100644
index 88b77195..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentLine.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-import java.util.LinkedList;
-
-import org.eclipse.wst.jsdt.internal.compiler.parser.ScannerHelper;
-
-/**
- * General comment line in a comment region.
- *
- * @since 3.0
- */
-public abstract class CommentLine implements IBorderAttributes {
-
- /** Prefix of non-formattable comment lines */
- protected static final String NON_FORMAT_START_PREFIX= "/*-"; //$NON-NLS-1$
-
- /** The attributes of this line */
- private int fAttributes= 0;
-
- /** The parent region of this line */
- private final CommentRegion fParent;
-
- /** The comment ranges in this line */
- private final LinkedList fRanges= new LinkedList();
-
- /**
- * Creates a new comment line.
- *
- * @param parent comment region to create the comment line for
- */
- protected CommentLine(final CommentRegion parent) {
- fParent= parent;
- }
-
- /**
- * Adapts the line attributes from the previous line in the comment
- * region.
- *
- * @param previous the previous comment line in the comment region
- */
- protected abstract void adapt(final CommentLine previous);
-
- /**
- * Appends the specified comment range to this comment line.
- *
- * @param range comment range to append to this line
- */
- protected void append(final CommentRange range) {
- fRanges.add(range);
- }
-
- /**
- * Formats this comment line as content line.
- *
- * @param predecessor the predecessor comment line in the comment region
- * @param last the most recently processed comment range
- * @param indentation the indentation of the comment region
- * @param line the index of this comment line in the comment region
- * @return the first comment range in this comment line
- */
- protected CommentRange formatLine(final CommentLine predecessor, final CommentRange last, final String indentation, final int line) {
-
- int offset= 0;
- int length= 0;
-
- CommentRange next= last;
- CommentRange previous= null;
-
- final int stop= fRanges.size() - 1;
- final int end= fParent.getSize() - 1;
-
- for (int index= stop; index >= 0; index--) {
-
- previous= next;
- next= (CommentRange)fRanges.get(index);
-
- if (fParent.canFormat(previous, next)) {
-
- offset= next.getOffset() + next.getLength();
- length= previous.getOffset() - offset;
-
- if (index == stop && line != end)
- fParent.logEdit(fParent.getDelimiter(predecessor, this, previous, next, indentation), offset, length);
- else
- fParent.logEdit(fParent.getDelimiter(previous, next), offset, length);
- }
- }
- return next;
- }
-
- /**
- * Formats this comment line as end line having a lower border
- * consisting of content line prefixes.
- *
- * @param range last comment range of the last comment line in the
- * comment region
- * @param indentation the indentation of the comment region
- * @param length the maximal length of text in this comment region
- * measured in average character widths
- */
- protected void formatLowerBorder(final CommentRange range, final String indentation, final int length) {
-
- final int offset= range.getOffset() + range.getLength();
-
- final StringBuffer buffer= new StringBuffer(length);
- final String end= getEndingPrefix();
- final String delimiter= fParent.getDelimiter();
-
- if (fParent.isSingleLine() && fParent.getSize() == 1)
- buffer.append(end);
- else {
-
- final String filler= getContentPrefix().trim();
-
- buffer.append(delimiter);
- buffer.append(indentation);
-
- if (fParent.hasBorder(BORDER_LOWER)) {
-
- buffer.append(' ');
- for (int character= 0; character < length; character++)
- buffer.append(filler);
-
- buffer.append(end.trim());
-
- } else
- buffer.append(end);
- }
- fParent.logEdit(buffer.toString(), offset, fParent.getLength() - offset);
- }
-
- /**
- * Formats this comment line as start line having an upper border
- * consisting of content line prefixes.
- *
- * @param range the first comment range in the comment region
- * @param indentation the indentation of the comment region
- * @param length the maximal length of text in this comment region
- * measured in average character widths
- */
- protected void formatUpperBorder(final CommentRange range, final String indentation, final int length) {
-
- final StringBuffer buffer= new StringBuffer(length);
- final String start= getStartingPrefix();
- final String content= getContentPrefix();
-
- if (fParent.isSingleLine() && fParent.getSize() == 1)
- buffer.append(start);
- else {
-
- final String trimmed= start.trim();
- final String filler= content.trim();
-
- buffer.append(trimmed);
-
- if (fParent.hasBorder(BORDER_UPPER)) {
-
- for (int character= 0; character < length - trimmed.length() + start.length(); character++)
- buffer.append(filler);
- }
-
- buffer.append(fParent.getDelimiter());
- buffer.append(indentation);
- buffer.append(content);
- }
- fParent.logEdit(buffer.toString(), 0, range.getOffset());
- }
-
- /**
- * Returns the line prefix of content lines.
- *
- * @return line prefix of content lines
- */
- protected abstract String getContentPrefix();
-
- /**
- * Returns the line prefix of end lines.
- *
- * @return line prefix of end lines
- */
- protected abstract String getEndingPrefix();
-
- /**
- * Returns the first comment range in this comment line.
- *
- * @return the first comment range
- */
- protected final CommentRange getFirst() {
- return (CommentRange)fRanges.getFirst();
- }
-
- /**
- * Returns the indentation reference string for this line.
- *
- * @return the indentation reference string for this line
- */
- protected String getIndentationReference() {
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Returns the last comment range in this comment line.
- *
- * @return the last comment range
- */
- protected final CommentRange getLast() {
- return (CommentRange)fRanges.getLast();
- }
-
- /**
- * Returns the parent comment region of this comment line.
- *
- * @return the parent comment region
- */
- protected final CommentRegion getParent() {
- return fParent;
- }
-
- /**
- * Returns the number of comment ranges in this comment line.
- *
- * @return the number of ranges in this line
- */
- protected final int getSize() {
- return fRanges.size();
- }
-
- /**
- * Returns the line prefix of start lines.
- *
- * @return line prefix of start lines
- */
- protected abstract String getStartingPrefix();
-
- /**
- * Is the attribute <code>attribute</code> true?
- *
- * @param attribute the attribute to get.
- * @return <code>true</code> iff this attribute is <code>true</code>,
- * <code>false</code> otherwise.
- */
- protected final boolean hasAttribute(final int attribute) {
- return (fAttributes & attribute) == attribute;
- }
-
- /**
- * Scans this comment line for comment range boundaries.
- *
- * @param line the index of this line in the comment region
- */
- protected abstract void scanLine(final int line);
-
- /**
- * Set the attribute <code>attribute</code> to true.
- *
- * @param attribute the attribute to set.
- */
- protected final void setAttribute(final int attribute) {
- fAttributes |= attribute;
- }
-
- /**
- * Tokenizes this comment line into comment ranges
- *
- * @param line the index of this line in the comment region
- */
- protected void tokenizeLine(final int line) {
-
- int offset= 0;
- int index= offset;
-
- final CommentRange range= (CommentRange)fRanges.get(0);
- final int begin= range.getOffset();
-
- final String content= fParent.getText(begin, range.getLength());
- final int length= content.length();
-
- while (offset < length) {
-
- while (offset < length && ScannerHelper.isWhitespace(content.charAt(offset)))
- offset++;
-
- index= offset;
-
- while (index < length && !ScannerHelper.isWhitespace(content.charAt(index)))
- index++;
-
- if (index - offset > 0) {
- fParent.append(new CommentRange(begin + offset, index - offset));
-
- offset= index;
- }
- }
- }
-
- public String toString() {
- final StringBuffer buffer = new StringBuffer();
- final int size = this.fRanges.size();
- for (int i = 0; i < size; i++) {
- buffer.append(this.fRanges.get(i)).append("\n"); //$NON-NLS-1$
- }
- return String.valueOf(buffer);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentRange.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentRange.java
deleted file mode 100644
index 6ae66667..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentRange.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.Position;
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-
-/**
- * Range in a comment region in comment region coordinates.
- *
- * @since 3.0
- */
-public class CommentRange extends Position implements ICommentAttributes, IHtmlTagDelimiters {
-
- /** The attributes of this range */
- private int fAttributes= 0;
-
- /**
- * Creates a new comment range.
- *
- * @param position offset of the range
- * @param count length of the range
- */
- public CommentRange(final int position, final int count) {
- super(position, count);
- }
-
- /**
- * Is the attribute <code>attribute</code> true?
- *
- * @param attribute the attribute to get
- * @return <code>true</code> iff this attribute is <code>true</code>,
- * <code>false</code> otherwise
- */
- protected final boolean hasAttribute(final int attribute) {
- return (fAttributes & attribute) == attribute;
- }
-
- /**
- * Does this comment range contain a closing HTML tag?
- *
- * @param token token belonging to the comment range
- * @param tag the HTML tag to check
- * @return <code>true</code> iff this comment range contains a closing
- * html tag, <code>false</code> otherwise
- */
- protected final boolean isClosingTag(final char[] token, final char[] tag) {
-
- boolean result= (CharOperation.indexOf(HTML_CLOSE_PREFIX, token, false) == 0)
- && token[token.length - 1] == HTML_TAG_POSTFIX;
- if (result) {
-
- setAttribute(COMMENT_CLOSE);
- result= CharOperation.equals(tag, token, HTML_CLOSE_PREFIX.length, token.length - 1, false);
- }
- return result;
- }
-
- /**
- * Does this comment range contain an opening HTML tag?
- *
- * @param token token belonging to the comment range
- * @param tag the HTML tag to check
- * @return <code>true</code> iff this comment range contains an
- * opening html tag, <code>false</code> otherwise
- */
- protected final boolean isOpeningTag(final char[] token, final char[] tag) {
-
- boolean result= token.length > 0
- && token[0] == HTML_TAG_PREFIX
- && (CharOperation.indexOf(HTML_CLOSE_PREFIX, token, false) != 0)
- && token[token.length - 1] == HTML_TAG_POSTFIX;
- if (result) {
-
- setAttribute(COMMENT_OPEN);
- result= CharOperation.indexOf(tag, token, false) == 1;
- }
- return result;
- }
-
- /**
- * Mark the comment range with the occurred HTML tags.
- *
- * @param tags the HTML tags to test for their occurrence
- * @param token token belonging to the comment range
- * @param attribute attribute to set if a HTML tag is present
- * @param open <code>true</code> iff opening tags should be marked,
- * <code>false</code> otherwise
- * @param close <code>true</code> iff closing tags should be marked,
- * <code>false</code> otherwise
- */
- protected final void markHtmlTag(final char[][] tags, final char[] token, final int attribute, final boolean open, final boolean close) {
- if (token[0] == HTML_TAG_PREFIX && token[token.length - 1] == HTML_TAG_POSTFIX) {
-
- char[] tag= null;
- boolean isOpen= false;
- boolean isClose= false;
-
- for (int index= 0; index < tags.length; index++) {
-
- tag= tags[index];
-
- isOpen= isOpeningTag(token, tag);
- isClose= isClosingTag(token, tag);
-
- if ((open && isOpen) || (close && isClose)) {
-
- setAttribute(attribute);
- break;
- }
- }
- }
- }
-
- /**
- * Mark the comment range with the occurred tags.
- *
- * @param tags the tags to test for their occurrence
- * @param prefix the prefix which is common to all the tags to test
- * @param token the token belonging to the comment range
- * @param attribute attribute to set if a tag is present
- */
- protected final void markPrefixTag(final char[][] tags, final char prefix, final char[] token, final int attribute) {
-
- if (token[0] == prefix) {
-
- char[] tag= null;
- for (int index= 0; index < tags.length; index++) {
-
- tag= tags[index];
- if (CharOperation.equals(token, tag)) {
-
- setAttribute(attribute);
- break;
- }
- }
- }
- }
-
- /**
- * Marks the comment range with the HTML range tag.
- *
- * @param token the token belonging to the comment range
- * @param tag the HTML tag which confines the HTML range
- * @param level the nesting level of the current HTML range
- * @param key the key of the attribute to set if the comment range is in
- * the HTML range
- * @param html <code>true</code> iff the HTML tags in this HTML range
- * should be marked too, <code>false</code> otherwise
- * @return the new nesting level of the HTML range
- */
- protected final int markTagRange(final char[] token, final char[] tag, int level, final int key, final boolean html) {
-
- if (isOpeningTag(token, tag)) {
- if (level++ > 0)
- setAttribute(key);
- } else if (isClosingTag(token, tag)) {
- if (--level > 0)
- setAttribute(key);
- } else if (level > 0) {
- if (html || !hasAttribute(COMMENT_HTML))
- setAttribute(key);
- }
- return level;
- }
-
- /**
- * Moves this comment range.
- *
- * @param delta the delta to move the range
- */
- public final void move(final int delta) {
- offset += delta;
- }
-
- /**
- * Set the attribute <code>attribute</code> to true.
- *
- * @param attribute the attribute to set.
- */
- protected final void setAttribute(final int attribute) {
- fAttributes |= attribute;
- }
-
- /**
- * Trims this comment range at the beginning.
- *
- * @param delta amount to trim the range
- */
- public final void trimBegin(final int delta) {
- offset += delta;
- length -= delta;
- }
-
- /**
- * Trims this comment range at the end.
- *
- * @param delta amount to trim the range
- */
- public final void trimEnd(final int delta) {
- length += delta;
- }
-
- /*
- * @see java.lang.Object#toString()
- * @since 3.1
- */
- public String toString() {
- List attributes= new ArrayList();
- if (hasAttribute(COMMENT_BLANKLINE))
- attributes.add("COMMENT_BLANKLINE"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_BREAK))
- attributes.add("COMMENT_BREAK"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_CLOSE))
- attributes.add("COMMENT_CLOSE"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_CODE))
- attributes.add("COMMENT_CODE"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_HTML))
- attributes.add("COMMENT_HTML"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_IMMUTABLE))
- attributes.add("COMMENT_IMMUTABLE"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_NEWLINE))
- attributes.add("COMMENT_NEWLINE"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_OPEN))
- attributes.add("COMMENT_OPEN"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_PARAGRAPH))
- attributes.add("COMMENT_PARAGRAPH"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_PARAMETER))
- attributes.add("COMMENT_PARAMETER"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_ROOT))
- attributes.add("COMMENT_ROOT"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_SEPARATOR))
- attributes.add("COMMENT_SEPARATOR"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_FIRST_TOKEN))
- attributes.add("COMMENT_FIRST_TOKEN"); //$NON-NLS-1$
- if (hasAttribute(COMMENT_STARTS_WITH_RANGE_DELIMITER))
- attributes.add("COMMENT_STARTS_WITH_RANGE_DELIMITER"); //$NON-NLS-1$
-
- StringBuffer buf= new StringBuffer("CommentRange [" + offset + "+" + length + "] {"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- for (Iterator it= attributes.iterator(); it.hasNext();) {
- String string= (String) it.next();
- buf.append(string);
- if (it.hasNext())
- buf.append(", "); //$NON-NLS-1$
- }
-
- return buf.toString() + "}"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentRegion.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentRegion.java
deleted file mode 100644
index 005b4840..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/CommentRegion.java
+++ /dev/null
@@ -1,573 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.jsdt.internal.compiler.parser.ScannerHelper;
-import org.eclipse.wst.jsdt.internal.formatter.CodeFormatterVisitor;
-import org.eclipse.wst.jsdt.internal.formatter.DefaultCodeFormatterOptions;
-import org.eclipse.wst.jsdt.internal.formatter.Scribe;
-
-/**
- * Comment region in a source code document.
- *
- * @since 3.0
- */
-public class CommentRegion extends Position implements IHtmlTagDelimiters, IBorderAttributes, ICommentAttributes {
-
- /** Default comment range delimiter */
- protected static final String COMMENT_RANGE_DELIMITER= " "; //$NON-NLS-1$
-
- /** Default line prefix length */
- private static final int COMMENT_PREFIX_LENGTH= 3;
-
- /** The borders of this region */
- private int fBorders= 0;
-
- /** Should all blank lines be cleared during formatting? */
- protected boolean fClear;
-
- /** The line delimiter used in this comment region */
- private final String fDelimiter;
-
- /** The document to format */
- private final IDocument fDocument;
-
- /** The lines in this comment region */
- private final LinkedList fLines= new LinkedList();
-
- /** The formatting preferences */
- protected final DefaultCodeFormatterOptions preferences;
-
- /** The comment ranges in this comment region */
- private final LinkedList fRanges= new LinkedList();
-
- /** Is this comment region a single line region? */
- private final boolean fSingleLine;
-
- /** Number of spaces representing tabulator */
- private int fTabSize;
-
- /** the scribe used to create edits */
- protected Scribe scribe;
-
- /**
- * Creates a new comment region.
- *
- * @param document the document which contains the comment region
- * @param position the position of this comment region in the document
- * @param formatter the given code formatter
- */
- public CommentRegion(final IDocument document, final Position position, final CodeFormatterVisitor formatter) {
- super(position.getOffset(), position.getLength());
-
- this.preferences = formatter.preferences;
- fDelimiter = this.preferences.line_separator;
- fDocument= document;
-
- fTabSize= DefaultCodeFormatterOptions.SPACE == this.preferences.tab_char ? this.preferences.indentation_size : this.preferences.tab_size;
-
- this.scribe = formatter.scribe;
-
- final ILineTracker tracker= new DefaultLineTracker();
-
- IRegion range= null;
- CommentLine line= null;
-
- tracker.set(getText(0, getLength()));
- final int lines= tracker.getNumberOfLines();
-
- fSingleLine= lines == 1;
-
- try {
-
- for (int index= 0; index < lines; index++) {
-
- range= tracker.getLineInformation(index);
- line= createLine();
- line.append(new CommentRange(range.getOffset(), range.getLength()));
-
- fLines.add(line);
- }
-
- } catch (BadLocationException exception) {
- // Should not happen
- }
- }
-
- /**
- * Appends the comment range to this comment region.
- *
- * @param range comment range to append to this comment region
- */
- protected final void append(final CommentRange range) {
- fRanges.addLast(range);
- }
-
- /**
- * Can the comment range be appended to the comment line?
- *
- * @param line comment line where to append the comment range
- * @param previous comment range which is the predecessor of the current
- * comment range
- * @param next comment range to test whether it can be appended to the
- * comment line
- * @param index amount of space in the comment line used by already
- * inserted comment ranges
- * @param width the maximal width of text in this comment region
- * measured in average character widths
- * @return <code>true</code> iff the comment range can be added to the
- * line, <code>false</code> otherwise
- */
- protected boolean canAppend(final CommentLine line, final CommentRange previous, final CommentRange next, final int index, final int width) {
- return index == 0 || index + next.getLength() <= width;
- }
-
- /**
- * Can the whitespace between the two comment ranges be formatted?
- *
- * @param previous previous comment range which was already formatted,
- * can be <code>null</code>
- * @param next next comment range to be formatted
- * @return <code>true</code> iff the next comment range can be
- * formatted, <code>false</code> otherwise.
- */
- protected boolean canFormat(final CommentRange previous, final CommentRange next) {
- return previous != null;
- }
-
- /**
- * Formats the comment region with the given indentation level.
- *
- * @param indentationLevel the indentation level
- * @return the resulting text edit of the formatting process
- * @since 3.1
- */
- public final TextEdit format(int indentationLevel, boolean returnEdit) {
- final String probe= getText(0, CommentLine.NON_FORMAT_START_PREFIX.length());
- if (!probe.startsWith(CommentLine.NON_FORMAT_START_PREFIX)) {
-
- int margin= this.preferences.comment_line_length;
- String indentation= computeIndentation(indentationLevel);
- margin= Math.max(COMMENT_PREFIX_LENGTH + 1, margin - stringToLength(indentation) - COMMENT_PREFIX_LENGTH);
-
- tokenizeRegion();
- markRegion();
- wrapRegion(margin);
- formatRegion(indentation, margin);
-
- }
- if (returnEdit) {
- return this.scribe.getRootEdit();
- }
- return null;
- }
-
- /**
- * Formats this comment region.
- *
- * @param indentation the indentation of this comment region
- * @param width the maximal width of text in this comment region
- * measured in average character widths
- */
- protected void formatRegion(final String indentation, final int width) {
-
- final int last= fLines.size() - 1;
- if (last >= 0) {
-
- CommentLine lastLine= (CommentLine)fLines.get(last);
- CommentRange lastRange= lastLine.getLast();
- lastLine.formatLowerBorder(lastRange, indentation, width);
-
- CommentLine previous;
- CommentLine next= null;
- CommentRange range= null;
- for (int line= last; line >= 0; line--) {
-
- previous= next;
- next= (CommentLine)fLines.get(line);
-
- range= next.formatLine(previous, range, indentation, line);
- }
- next.formatUpperBorder(range, indentation, width);
- }
- }
-
- /**
- * Returns the line delimiter used in this comment region.
- *
- * @return the line delimiter for this comment region
- */
- protected final String getDelimiter() {
- return fDelimiter;
- }
-
- /**
- * Returns the line delimiter used in this comment line break.
- *
- * @param predecessor the predecessor comment line after the line break
- * @param successor the successor comment line before the line break
- * @param previous the comment range after the line break
- * @param next the comment range before the line break
- * @param indentation indentation of the formatted line break
- * @return the line delimiter for this comment line break
- */
- protected String getDelimiter(final CommentLine predecessor, final CommentLine successor, final CommentRange previous, final CommentRange next, final String indentation) {
- return fDelimiter + indentation + successor.getContentPrefix();
- }
-
- /**
- * Returns the range delimiter for this comment range break.
- *
- * @param previous the previous comment range to the right of the range
- * delimiter
- * @param next the next comment range to the left of the range delimiter
- * @return the delimiter for this comment range break
- */
- protected String getDelimiter(final CommentRange previous, final CommentRange next) {
- return COMMENT_RANGE_DELIMITER;
- }
-
- /**
- * Returns the document of this comment region.
- *
- * @return the document of this region
- */
- protected final IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * Returns the comment ranges in this comment region
- *
- * @return the comment ranges in this region
- */
- protected final LinkedList getRanges() {
- return fRanges;
- }
-
- /**
- * Returns the number of comment lines in this comment region.
- *
- * @return the number of lines in this comment region
- */
- protected final int getSize() {
- return fLines.size();
- }
-
- /**
- * Returns the text of this comment region in the indicated range.
- *
- * @param position the offset of the comment range to retrieve in
- * comment region coordinates
- * @param count the length of the comment range to retrieve
- * @return the content of this comment region in the indicated range
- */
- protected final String getText(final int position, final int count) {
-
- String content= ""; //$NON-NLS-1$
- try {
- content= fDocument.get(getOffset() + position, count);
- } catch (BadLocationException exception) {
- // Should not happen
- }
- return content;
- }
-
- /**
- * Does the border <code>border</code> exist?
- *
- * @param border the type of the border, must be a border attribute of
- * <code>CommentRegion</code>
- * @return <code>true</code> iff this border exists,
- * <code>false</code> otherwise
- */
- protected final boolean hasBorder(final int border) {
- return (fBorders & border) == border;
- }
-
- /**
- * Does the comment range consist of letters and digits only?
- *
- * @param range the comment range to text
- * @return <code>true</code> iff the comment range consists of letters
- * and digits only, <code>false</code> otherwise
- */
- protected final boolean isAlphaNumeric(final CommentRange range) {
-
- final String token= getText(range.getOffset(), range.getLength());
-
- for (int index= 0; index < token.length(); index++) {
- if (!ScannerHelper.isLetterOrDigit(token.charAt(index)))
- return false;
- }
- return true;
- }
-
- /**
- * Does the comment range contain no letters and digits?
- *
- * @param range the comment range to text
- * @return <code>true</code> iff the comment range contains no letters
- * and digits, <code>false</code> otherwise
- */
- protected final boolean isNonAlphaNumeric(final CommentRange range) {
-
- final String token= getText(range.getOffset(), range.getLength());
-
- for (int index= 0; index < token.length(); index++) {
- if (ScannerHelper.isLetterOrDigit(token.charAt(index)))
- return false;
- }
- return true;
- }
-
- /**
- * Should blank lines be cleared during formatting?
- *
- * @return <code>true</code> iff blank lines should be cleared,
- * <code>false</code> otherwise
- */
- protected final boolean isClearLines() {
- return fClear;
- }
-
- /**
- * Is this comment region a single line region?
- *
- * @return <code>true</code> iff this region is single line,
- * <code>false</code> otherwise
- */
- protected final boolean isSingleLine() {
- return fSingleLine;
- }
-
- /**
- * Logs a text edit operation occurred during the formatting process
- *
- * @param change the changed text
- * @param position offset measured in comment region coordinates where
- * to apply the changed text
- * @param count length of the range where to apply the changed text
- */
- protected final void logEdit(final String change, final int position, final int count) {
- try {
- final int base= getOffset() + position;
- final String content= fDocument.get(base, count);
-
- if (!change.equals(content)) {
- if (count > 0) {
- this.scribe.addReplaceEdit(base, base + count - 1, change);
- } else {
- this.scribe.addInsertEdit(base, change);
- }
- }
- } catch (BadLocationException exception) {
- // Should not happen
- CommentFormatterUtil.log(exception);
- } catch (MalformedTreeException exception) {
- // Do nothing
- CommentFormatterUtil.log(exception);
- }
- }
-
- /**
- * Marks the comment ranges in this comment region.
- */
- protected void markRegion() {
- // Do nothing
- }
-
- /**
- * Set the border type <code>border</code> to true.
- *
- * @param border the type of the border. Must be a border attribute of
- * <code>CommentRegion</code>
- */
- protected final void setBorder(final int border) {
- fBorders |= border;
- }
-
- /**
- * Returns the indentation of the given indentation level.
- *
- * @param indentationLevel the indentation level
- * @return the indentation of the given indentation level
- * @since 3.1
- */
- private String computeIndentation(int indentationLevel) {
- if (DefaultCodeFormatterOptions.TAB == this.preferences.tab_char)
- return replicate("\t", indentationLevel); //$NON-NLS-1$
-
- if (DefaultCodeFormatterOptions.SPACE == this.preferences.tab_char)
- return replicate(" ", indentationLevel * this.preferences.tab_size); //$NON-NLS-1$
-
- if (DefaultCodeFormatterOptions.MIXED == this.preferences.tab_char) {
- int tabSize= this.preferences.tab_size;
- int indentSize= this.preferences.indentation_size;
- int spaceEquivalents= indentationLevel * indentSize;
- return replicate("\t", spaceEquivalents / tabSize) + replicate(" ", spaceEquivalents % tabSize); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- Assert.isTrue(false);
- return null;
- }
-
- /**
- * Returns the given string n-times replicated.
- *
- * @param string the string
- * @param n n
- * @return the given string n-times replicated
- * @since 3.1
- */
- private String replicate(String string, int n) {
- StringBuffer buffer= new StringBuffer(n*string.length());
- for (int i= 0; i < n; i++)
- buffer.append(string);
- return buffer.toString();
- }
-
- /**
- * Computes the equivalent indentation for a string
- *
- * @param reference the string to compute the indentation for
- * @return the indentation string
- */
- protected final String stringToIndent(final String reference) {
- return replicate(" ", stringToLength(reference)); //$NON-NLS-1$
- }
-
- /**
- * Returns the length of the string in expanded characters.
- *
- * @param reference the string to get the length for
- * @return the length of the string in expanded characters
- */
- protected final int stringToLength(final String reference) {
- return expandTabs(reference).length();
- }
-
- /**
- * Expands the given string's tabs according to the given tab size.
- *
- * @param string the string
- * @return the expanded string
- * @since 3.1
- */
- private String expandTabs(String string) {
- StringBuffer expanded= new StringBuffer();
- for (int i= 0, n= string.length(), chars= 0; i < n; i++) {
- char ch= string.charAt(i);
- if (ch == '\t') {
- for (; chars < fTabSize; chars++)
- expanded.append(' ');
- chars= 0;
- } else {
- expanded.append(ch);
- chars++;
- if (chars >= fTabSize)
- chars= 0;
- }
-
- }
- return expanded.toString();
- }
-
- /**
- * Tokenizes the comment region.
- */
- protected void tokenizeRegion() {
-
- int index= 0;
- CommentLine line= null;
-
- for (final Iterator iterator= fLines.iterator(); iterator.hasNext(); index++) {
-
- line= (CommentLine)iterator.next();
-
- line.scanLine(index);
- line.tokenizeLine(index);
- }
- }
-
- /**
- * Wraps the comment ranges in this comment region into comment lines.
- *
- * @param width the maximal width of text in this comment region
- * measured in average character widths
- */
- protected void wrapRegion(final int width) {
-
- fLines.clear();
-
- int index= 0;
- boolean adapted= false;
-
- CommentLine successor= null;
- CommentLine predecessor= null;
-
- CommentRange previous= null;
- CommentRange next= null;
-
- while (!fRanges.isEmpty()) {
-
- index= 0;
- adapted= false;
-
- predecessor= successor;
- successor= createLine();
- fLines.add(successor);
-
- while (!fRanges.isEmpty()) {
- next= (CommentRange)fRanges.getFirst();
-
- if (canAppend(successor, previous, next, index, width)) {
-
- if (!adapted && predecessor != null) {
-
- successor.adapt(predecessor);
- adapted= true;
- }
-
- fRanges.removeFirst();
- successor.append(next);
-
- index += (next.getLength() + 1);
- previous= next;
- } else
- break;
- }
- }
- }
-
- /**
- * Creates a new line for this region.
- *
- * @return a new line for this region
- * @since 3.1
- */
- protected CommentLine createLine() {
- return new SingleCommentLine(this);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/HTMLEntity2JavaReader.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/HTMLEntity2JavaReader.java
deleted file mode 100644
index f1b38840..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/HTMLEntity2JavaReader.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.internal.compiler.parser.ScannerHelper;
-
-/**
- * <code>SubstitutionTextReader</code> that will substitute plain text values
- * for html entities encountered in the original text. Line breaks and
- * whitespace are preserved.
- *
- * @since 3.0
- */
-public class HTMLEntity2JavaReader extends SubstitutionTextReader {
-
- /** The hard-coded entity map. */
- private static final Map fgEntityLookup;
-
- static {
- fgEntityLookup= new HashMap(7);
- fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("circ", "^"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("tilde", "~"); //$NON-NLS-2$ //$NON-NLS-1$
- fgEntityLookup.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Creates a new instance that will read from <code>reader</code>
- *
- * @param reader the source reader
- */
- public HTMLEntity2JavaReader(Reader reader) {
- super(reader);
- setSkipWhitespace(false);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int)
- */
- protected String computeSubstitution(int c) throws IOException {
- if (c == '&')
- return processEntity();
- return null;
- }
-
- /**
- * Replaces an HTML entity body (without &amp; and ;) with its
- * plain/text (or plain/java) counterpart.
- *
- * @param symbol the entity body to resolve
- * @return the plain/text counterpart of <code>symbol</code>
- */
- protected String entity2Text(String symbol) {
- if (symbol.length() > 1 && symbol.charAt(0) == '#') {
- int ch;
- try {
- if (symbol.charAt(1) == 'x') {
- ch= Integer.parseInt(symbol.substring(2), 16);
- } else {
- ch= Integer.parseInt(symbol.substring(1), 10);
- }
- return " " + (char) ch; //$NON-NLS-1$
- } catch (NumberFormatException e) {
- // ignore
- }
- } else {
- String str= (String) fgEntityLookup.get(symbol);
- if (str != null) {
- return str;
- }
- }
- return "&" + symbol; // not found //$NON-NLS-1$
- }
-
- /**
- * Reads an HTML entity from the stream and returns its plain/text
- * counterpart.
- *
- * @return an entity read from the stream, or the stream content.
- * @throws IOException if the underlying reader throws one
- */
- private String processEntity() throws IOException {
- StringBuffer buf= new StringBuffer();
- int ch= nextChar();
- while (ScannerHelper.isLetterOrDigit((char) ch) || ch == '#') {
- buf.append((char) ch);
- ch= nextChar();
- }
- if (ch == ';')
- return entity2Text(buf.toString());
- buf.insert(0, '&');
- if (ch != -1)
- buf.append((char) ch);
- return buf.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IBorderAttributes.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IBorderAttributes.java
deleted file mode 100644
index 9ff5c2ac..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IBorderAttributes.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-/**
- * Comment region border attributes.
- *
- * @since 3.0
- */
-public interface IBorderAttributes {
-
- /** Region has lower border attribute */
- public static final int BORDER_LOWER= 1 << 0;
-
- /** Region has upper border attribute */
- public static final int BORDER_UPPER= 1 << 1;
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/ICommentAttributes.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/ICommentAttributes.java
deleted file mode 100644
index 9b0913b8..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/ICommentAttributes.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-/**
- * General comment range attributes.
- *
- * @since 3.0
- */
-public interface ICommentAttributes {
-
- /** Range has blank line attribute */
- public static final int COMMENT_BLANKLINE= 1 << 1;
-
- /** Range has line break attribute */
- public static final int COMMENT_BREAK= 1 << 2;
-
- /** Range has close tag attribute */
- public static final int COMMENT_CLOSE= 1 << 3;
-
- /** Range has source code attribute */
- public static final int COMMENT_CODE= 1 << 4;
-
- /** Range has html tag attribute */
- public static final int COMMENT_HTML= 1 << 5;
-
- /** Range has the immutable region attribute */
- public static final int COMMENT_IMMUTABLE= 1 << 6;
-
- /** Range has new line attribute */
- public static final int COMMENT_NEWLINE= 1 << 7;
-
- /** Range has open tag attribute */
- public static final int COMMENT_OPEN= 1 << 8;
-
- /** Range has paragraph attribute */
- public static final int COMMENT_PARAGRAPH= 1 << 9;
-
- /** Range has parameter tag attribute */
- public static final int COMMENT_PARAMETER= 1 << 10;
-
- /** Range has root tag attribute */
- public static final int COMMENT_ROOT= 1 << 11;
-
- /** Range has paragraph separator attribute */
- public static final int COMMENT_SEPARATOR= 1 << 12;
-
- /** Range is the first token on the line in the original source */
- public static final int COMMENT_FIRST_TOKEN= 1 << 13;
-
- /**
- * Range was preceded by whitespace / line delimiters
- * @since 3.1
- */
- public static final int COMMENT_STARTS_WITH_RANGE_DELIMITER= 1 << 14;
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IHtmlTagDelimiters.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IHtmlTagDelimiters.java
deleted file mode 100644
index e81f5b52..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IHtmlTagDelimiters.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-/**
- * Html tag constants.
- *
- * @since 3.0
- */
-public interface IHtmlTagDelimiters {
-
- /** Html tag close prefix */
- public static final char[] HTML_CLOSE_PREFIX= "</".toCharArray(); //$NON-NLS-1$
-
- /** Html tag postfix */
- public static final char HTML_TAG_POSTFIX= '>';
-
- /** Html tag prefix */
- public static final char HTML_TAG_PREFIX= '<';
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IJavaDocTagConstants.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IJavaDocTagConstants.java
deleted file mode 100644
index b2c829c0..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/IJavaDocTagConstants.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-/**
- * Javadoc tag constants.
- *
- * @since 3.0
- */
-public interface IJavaDocTagConstants {
-
- /** Javadoc break tags */
- public static final char[][] JAVADOC_BREAK_TAGS = new char[][] {
- "dd".toCharArray(), //$NON-NLS-1$
- "dt".toCharArray(), //$NON-NLS-1$
- "li".toCharArray(), //$NON-NLS-1$
- "td".toCharArray(), //$NON-NLS-1$
- "th".toCharArray(), //$NON-NLS-1$
- "tr".toCharArray(), //$NON-NLS-1$
- "h1".toCharArray(), //$NON-NLS-1$
- "h2".toCharArray(), //$NON-NLS-1$
- "h3".toCharArray(), //$NON-NLS-1$
- "h4".toCharArray(), //$NON-NLS-1$
- "h5".toCharArray(), //$NON-NLS-1$
- "h6".toCharArray(), //$NON-NLS-1$
- "q".toCharArray() //$NON-NLS-1$
- };
-
- /** Javadoc single break tag */
- public static final char[][] JAVADOC_SINGLE_BREAK_TAG= new char[][] { "br".toCharArray() }; //$NON-NLS-1$
-
- /** Javadoc code tags */
- public static final char[][] JAVADOC_CODE_TAGS= new char[][] { "pre".toCharArray() }; //$NON-NLS-1$
-
- /** Javadoc immutable tags */
- public static final char[][] JAVADOC_IMMUTABLE_TAGS= new char[][] {
- "code".toCharArray(), //$NON-NLS-1$
- "em".toCharArray(), //$NON-NLS-1$
- "pre".toCharArray(), //$NON-NLS-1$
- "q".toCharArray(), //$NON-NLS-1$
- "tt".toCharArray() //$NON-NLS-1$
- };
-
- /** Javadoc new line tags */
- public static final char[][] JAVADOC_NEWLINE_TAGS= new char[][] {
- "dd".toCharArray(), //$NON-NLS-1$
- "dt".toCharArray(), //$NON-NLS-1$
- "li".toCharArray(), //$NON-NLS-1$
- "td".toCharArray(), //$NON-NLS-1$
- "th".toCharArray(), //$NON-NLS-1$
- "tr".toCharArray(), //$NON-NLS-1$
- "h1".toCharArray(), //$NON-NLS-1$
- "h2".toCharArray(), //$NON-NLS-1$
- "h3".toCharArray(), //$NON-NLS-1$
- "h4".toCharArray(), //$NON-NLS-1$
- "h5".toCharArray(), //$NON-NLS-1$
- "h6".toCharArray(), //$NON-NLS-1$
- "q".toCharArray() //$NON-NLS-1$
- };
-
- /** Javadoc parameter tags */
- public static final char[][] JAVADOC_PARAM_TAGS= new char[][] {
- "@exception".toCharArray(), //$NON-NLS-1$
- "@param".toCharArray(), //$NON-NLS-1$
- "@serialField".toCharArray(), //$NON-NLS-1$
- "@throws".toCharArray() //$NON-NLS-1$
- };
-
- /** Javadoc separator tags */
- public static final char[][] JAVADOC_SEPARATOR_TAGS= new char[][] {
- "dl".toCharArray(), //$NON-NLS-1$
- "hr".toCharArray(), //$NON-NLS-1$
- "nl".toCharArray(), //$NON-NLS-1$
- "p".toCharArray(), //$NON-NLS-1$
- "pre".toCharArray(), //$NON-NLS-1$
- "ul".toCharArray(), //$NON-NLS-1$
- "ol".toCharArray() //$NON-NLS-1$
- };
-
- /** Javadoc tag prefix */
- public static final char JAVADOC_TAG_PREFIX= '@';
-
- /** Link tag postfix */
- public static final char LINK_TAG_POSTFIX= '}';
-
- /** Link tag prefix */
- public static final String LINK_TAG_PREFIX_STRING = "{@"; //$NON-NLS-1$
-
- public static final char[] LINK_TAG_PREFIX= LINK_TAG_PREFIX_STRING.toCharArray();
-
-
- /** Comment root tags */
- public static final char[][] COMMENT_ROOT_TAGS= new char[][] {
- "@deprecated".toCharArray(), //$NON-NLS-1$
- "@see".toCharArray(), //$NON-NLS-1$
- "@since".toCharArray(), //$NON-NLS-1$
- "@version".toCharArray() //$NON-NLS-1$
- };
-
- /** Tag prefix of comment tags */
- public static final char COMMENT_TAG_PREFIX= '@';
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/Java2HTMLEntityReader.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/Java2HTMLEntityReader.java
deleted file mode 100644
index def29409..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/Java2HTMLEntityReader.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * <code>SubstitutionTextReader</code> that will substitute html entities for
- * html symbols encountered in the original text. Line breaks and whitespaces
- * are preserved.
- *
- * @since 3.0
- */
-public class Java2HTMLEntityReader extends SubstitutionTextReader {
-
- /** The hardcoded entity map. */
- private static final Map fgEntityLookup;
-
- static {
- fgEntityLookup= new HashMap(7);
- fgEntityLookup.put("<", "&lt;"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put(">", "&gt;"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("&", "&amp;"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("^", "&circ;"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("~", "&tilde;"); //$NON-NLS-2$ //$NON-NLS-1$
- fgEntityLookup.put("\"", "&quot;"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Creates a new instance that will read from <code>reader</code>
- *
- * @param reader the source reader
- */
- public Java2HTMLEntityReader(Reader reader) {
- super(reader);
- setSkipWhitespace(false);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int)
- */
- protected String computeSubstitution(int c) {
- String lookup= (String) fgEntityLookup.get(String.valueOf((char) c));
- return lookup;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/JavaDocLine.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/JavaDocLine.java
deleted file mode 100644
index 4eb1490d..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/JavaDocLine.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-/**
- * Javadoc comment line in a comment region.
- *
- * @since 3.0
- */
-public class JavaDocLine extends MultiCommentLine {
-
- /** Line prefix of javadoc start lines */
- public static final String JAVADOC_START_PREFIX= "/**"; //$NON-NLS-1$
-
- /**
- * Creates a new javadoc line.
- *
- * @param region comment region to create the line for
- */
- protected JavaDocLine(final CommentRegion region) {
- super(region);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#formatUpperBorder(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, java.lang.String, int)
- */
- protected void formatUpperBorder(final CommentRange range, final String indentation, final int length) {
-
- final CommentRegion parent= getParent();
-
- if (parent.isSingleLine() && parent.getSize() == 1) {
- parent.logEdit(getStartingPrefix() + CommentRegion.COMMENT_RANGE_DELIMITER, 0, range.getOffset());
- } else
- super.formatUpperBorder(range, indentation, length);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#getStartingPrefix()
- */
- protected String getStartingPrefix() {
- return JAVADOC_START_PREFIX;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/JavaDocRegion.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/JavaDocRegion.java
deleted file mode 100644
index aef5ebc6..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/JavaDocRegion.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.jsdt.core.formatter.CodeFormatter;
-import org.eclipse.wst.jsdt.internal.compiler.parser.ScannerHelper;
-import org.eclipse.wst.jsdt.internal.formatter.CodeFormatterVisitor;
-
-
-/**
- * Javadoc region in a source code document.
- *
- * @since 3.0
- */
-public class JavaDocRegion extends MultiCommentRegion implements IJavaDocTagConstants {
-
- /** The positions of code ranges */
- private final ArrayList fCodePositions= new ArrayList();
-
- /** Should HTML tags be formatted? */
- private final boolean fFormatHtml;
-
- /** Should source code regions be formatted? */
- private final boolean fFormatSource;
-
- /**
- * Creates a new Javadoc region.
- *
- * @param document the document which contains the comment region
- * @param position the position of this comment region in the document
- * @param formatter the given formatter
- */
- public JavaDocRegion(final IDocument document, final Position position, final CodeFormatterVisitor formatter) {
- super(document, position, formatter);
-
- fFormatSource = this.preferences.comment_format_source;
- fFormatHtml = this.preferences.comment_format_html;
- fClear = this.preferences.comment_clear_blank_lines_in_javadoc_comment;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRegion#canFormat(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange)
- */
- protected boolean canFormat(final CommentRange previous, final CommentRange next) {
-
- if (previous != null) {
-
- final boolean isCurrentCode= next.hasAttribute(COMMENT_CODE);
- final boolean isLastCode= previous.hasAttribute(COMMENT_CODE);
-
- final int base= getOffset();
-
- if (!isLastCode && isCurrentCode)
- fCodePositions.add(new Position(base + previous.getOffset()));
- else if (isLastCode && !isCurrentCode)
- fCodePositions.add(new Position(base + next.getOffset() + next.getLength()));
-
- if (previous.hasAttribute(COMMENT_IMMUTABLE) && next.hasAttribute(COMMENT_IMMUTABLE))
- return false;
-
- return true;
- }
- return false;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRegion#formatRegion(java.lang.String, int)
- */
- protected final void formatRegion(final String indentation, final int width) {
-
- super.formatRegion(indentation, width);
-
- if (fFormatSource) {
-
- try {
-
- if (fCodePositions.size() > 0) {
-
- int begin= 0;
- int end= 0;
-
- Position position= null;
-
- final IDocument document= getDocument();
-
- for (int index= fCodePositions.size() - 1; index >= 0;) {
-
- position= (Position)fCodePositions.get(index--);
- begin= position.getOffset();
-
- if (index >= 0) {
- position= (Position)fCodePositions.get(index--);
- end= position.getOffset();
- } else {
- /*
- * Handle missing closing tag
- * see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=57011
- */
- position= null;
- end= getOffset() + getLength() - MultiCommentLine.MULTI_COMMENT_END_PREFIX.trim().length();
- while (end > begin && ScannerHelper.isWhitespace(document.getChar(end - 1)))
- end--;
- }
-
- String snippet= document.get(begin, end - begin);
- snippet= preprocessCodeSnippet(snippet);
- snippet= formatCodeSnippet(snippet);
- snippet= postprocessCodeSnippet(snippet, indentation);
-
- logEdit(snippet, begin - getOffset(), end - begin);
- }
- }
- } catch (BadLocationException e) {
- // Can not happen
- CommentFormatterUtil.log(e);
- }
- }
- }
-
- /**
- * Preprocess a given code snippet.
- *
- * @param snippet the code snippet
- * @return the preprocessed code snippet
- */
- private String preprocessCodeSnippet(String snippet) {
- // strip content prefix
- StringBuffer buffer= new StringBuffer();
- ILineTracker tracker= new DefaultLineTracker();
- String contentPrefix= MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX.trim();
-
- buffer.setLength(0);
- buffer.append(snippet);
- tracker.set(snippet);
- for (int line= tracker.getNumberOfLines() - 1; line > 0; line--) {
- int lineOffset;
- try {
- lineOffset= tracker.getLineOffset(line);
- } catch (BadLocationException e) {
- // Can not happen
- CommentFormatterUtil.log(e);
- return snippet;
- }
- int prefixOffset= buffer.indexOf(contentPrefix, lineOffset);
- if (prefixOffset >= 0 && buffer.substring(lineOffset, prefixOffset).trim().length() == 0)
- buffer.delete(lineOffset, prefixOffset + contentPrefix.length() + 1);
- }
-
- return convertHtml2Java(buffer.toString());
- }
-
- /**
- * Format the given code snippet
- *
- * @param snippet the code snippet
- * @return the formatted code snippet
- */
- private String formatCodeSnippet(String snippet) {
- String lineDelimiter= TextUtilities.getDefaultLineDelimiter(getDocument());
- TextEdit edit= CommentFormatterUtil.format2(CodeFormatter.K_UNKNOWN, snippet, 0, lineDelimiter, this.preferences.getMap());
- if (edit != null)
- snippet= CommentFormatterUtil.evaluateFormatterEdit(snippet, edit, null);
- return snippet;
- }
-
- /**
- * Postprocesses the given code snippet with the given indentation.
- *
- * @param snippet the code snippet
- * @param indentation the indentation
- * @return the postprocessed code snippet
- */
- private String postprocessCodeSnippet(String snippet, String indentation) {
- // patch content prefix
- StringBuffer buffer= new StringBuffer();
- ILineTracker tracker= new DefaultLineTracker();
- String patch= indentation + MultiCommentLine.MULTI_COMMENT_CONTENT_PREFIX;
-
- // remove trailing spaces
- int i= snippet.length();
- while (i > 0 && ' ' == snippet.charAt(i-1))
- i--;
- snippet= snippet.substring(0, i);
-
- buffer.setLength(0);
- String lineDelimiter= getDelimiter();
- if (lineDelimiter != null && snippet.indexOf(lineDelimiter) != 0)
- buffer.append(lineDelimiter);
- buffer.append(convertJava2Html(snippet));
- if (lineDelimiter != null && snippet.lastIndexOf(lineDelimiter) != snippet.length() - lineDelimiter.length())
- buffer.append(lineDelimiter);
- tracker.set(buffer.toString());
-
- for (int line= tracker.getNumberOfLines() - 1; line > 0; line--)
- try {
- buffer.insert(tracker.getLineOffset(line), patch);
- } catch (BadLocationException e) {
- // Can not happen
- CommentFormatterUtil.log(e);
- return snippet;
- }
-
- return buffer.toString();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.MultiCommentRegion#markHtmlRanges()
- */
- protected final void markHtmlRanges() {
-
- markTagRanges(JAVADOC_IMMUTABLE_TAGS, COMMENT_IMMUTABLE, true);
-
- if (fFormatSource)
- markTagRanges(JAVADOC_CODE_TAGS, COMMENT_CODE, false);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.MultiCommentRegion#markHtmlTag(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, java.lang.String)
- */
- protected final void markHtmlTag(final CommentRange range, final char[] token) {
-
- if (range.hasAttribute(COMMENT_HTML)) {
-
- range.markHtmlTag(JAVADOC_IMMUTABLE_TAGS, token, COMMENT_IMMUTABLE, true, true);
- if (fFormatHtml) {
-
- range.markHtmlTag(JAVADOC_SEPARATOR_TAGS, token, COMMENT_SEPARATOR, true, true);
- range.markHtmlTag(JAVADOC_BREAK_TAGS, token, COMMENT_BREAK, false, true);
- range.markHtmlTag(JAVADOC_SINGLE_BREAK_TAG, token, COMMENT_BREAK, true, false);
- range.markHtmlTag(JAVADOC_NEWLINE_TAGS, token, COMMENT_NEWLINE, true, false);
-
- } else
- range.markHtmlTag(JAVADOC_CODE_TAGS, token, COMMENT_SEPARATOR, true, true);
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.MultiCommentRegion#markJavadocTag(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, java.lang.String)
- */
- protected final void markJavadocTag(final CommentRange range, final char[] token) {
-
- range.markPrefixTag(JAVADOC_PARAM_TAGS, COMMENT_TAG_PREFIX, token, COMMENT_PARAMETER);
-
- if (token[0] == JAVADOC_TAG_PREFIX && !range.hasAttribute(COMMENT_PARAMETER))
- range.setAttribute(COMMENT_ROOT);
- }
-
- /**
- * Marks the comment region with the HTML range tag.
- *
- * @param tags the HTML tag which confines the HTML range
- * @param attribute the attribute to set if the comment range is in the
- * HTML range
- * @param html <code>true</code> iff the HTML tags in this HTML range
- * should be marked too, <code>false</code> otherwise
- */
- protected final void markTagRanges(final char[][] tags, final int attribute, final boolean html) {
-
- int level= 0;
- int count= 0;
- char[] token= null;
- CommentRange current= null;
-
- for (int index= 0; index < tags.length; index++) {
-
- level= 0;
- for (final Iterator iterator= getRanges().iterator(); iterator.hasNext();) {
-
- current= (CommentRange)iterator.next();
- count= current.getLength();
-
- if (count > 0 || level > 0) { // PR44035: when inside a tag, mark blank lines as well to get proper snippet formatting
-
- token= getText(current.getOffset(), current.getLength()).toCharArray();
- level= current.markTagRange(token, tags[index], level, attribute, html);
- }
- }
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRegion#canAppend(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine, org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, int, int)
- */
- protected boolean canAppend(CommentLine line, CommentRange previous, CommentRange next, int index, int count) {
- // don't append code sections
- if (next.hasAttribute(COMMENT_CODE | COMMENT_FIRST_TOKEN) && line.getSize() != 0)
- return false;
- return super.canAppend(line, previous, next, index, count);
- }
-
- /**
- * Converts <code>formatted</code> into valid html code suitable to be
- * put inside &lt;pre&gt;&lt;/pre&gt; tags by replacing any html symbols
- * by the relevant entities.
- *
- * @param formatted the formatted java code
- * @return html version of the formatted code
- */
- private String convertJava2Html(String formatted) {
- Java2HTMLEntityReader reader= new Java2HTMLEntityReader(new StringReader(formatted));
- char[] buf= new char[256];
- StringBuffer buffer= new StringBuffer();
- int l;
- try {
- do {
- l= reader.read(buf);
- if (l != -1)
- buffer.append(buf, 0, l);
- } while (l > 0);
- return buffer.toString();
- } catch (IOException e) {
- return formatted;
- }
- }
-
- /**
- * Converts <code>html</code> into java code suitable for formatting
- * by replacing any html entities by their plain text representation.
- *
- * @param html html code, may contain html entities
- * @return plain textified version of <code>html</code>
- */
- private String convertHtml2Java(String html) {
- HTMLEntity2JavaReader reader= new HTMLEntity2JavaReader(new StringReader(html));
- char[] buf= new char[html.length()]; // html2text never gets longer, only shorter!
-
- try {
- int read= reader.read(buf);
- return new String(buf, 0, read);
- } catch (IOException e) {
- return html;
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRegion#createLine()
- * @since 3.1
- */
- protected CommentLine createLine() {
- return new JavaDocLine(this);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/MultiCommentLine.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/MultiCommentLine.java
deleted file mode 100644
index 876e4781..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/MultiCommentLine.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.jsdt.internal.compiler.parser.ScannerHelper;
-
-/**
- * Multi-line comment line in a comment region.
- *
- * @since 3.0
- */
-public class MultiCommentLine extends CommentLine implements ICommentAttributes, IHtmlTagDelimiters, IJavaDocTagConstants {
-
- /** Line prefix of multi-line comment content lines */
- public static final String MULTI_COMMENT_CONTENT_PREFIX= " * "; //$NON-NLS-1$
-
- /** Line prefix of multi-line comment end lines */
- public static final String MULTI_COMMENT_END_PREFIX= " */"; //$NON-NLS-1$
-
- /** Line prefix of multi-line comment content lines */
- public static final String MULTI_COMMENT_START_PREFIX= "/* "; //$NON-NLS-1$
-
- /** The indentation reference of this line */
- private String fReferenceIndentation= ""; //$NON-NLS-1$
-
- /** The javadoc tag lookup. */
- private static final Set fgTagLookup;
-
- static {
- fgTagLookup= new HashSet();
- for (int i= 0; i < JAVADOC_BREAK_TAGS.length; i++) {
- fgTagLookup.add(new String(JAVADOC_BREAK_TAGS[i]));
- }
- for (int i= 0; i < JAVADOC_SINGLE_BREAK_TAG.length; i++) {
- fgTagLookup.add(new String(JAVADOC_SINGLE_BREAK_TAG[i]));
- }
- for (int i= 0; i < JAVADOC_CODE_TAGS.length; i++) {
- fgTagLookup.add(new String(JAVADOC_CODE_TAGS[i]));
- }
- for (int i= 0; i < JAVADOC_IMMUTABLE_TAGS.length; i++) {
- fgTagLookup.add(new String(JAVADOC_IMMUTABLE_TAGS[i]));
- }
- for (int i= 0; i < JAVADOC_NEWLINE_TAGS.length; i++) {
- fgTagLookup.add(new String(JAVADOC_NEWLINE_TAGS[i]));
- }
- for (int i= 0; i < JAVADOC_SEPARATOR_TAGS.length; i++) {
- fgTagLookup.add(new String(JAVADOC_SEPARATOR_TAGS[i]));
- }
- }
-
- /**
- * Creates a new multi-line comment line.
- *
- * @param region comment region to create the line for
- */
- protected MultiCommentLine(final CommentRegion region) {
- super(region);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#adapt(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine)
- */
- protected void adapt(final CommentLine previous) {
-
- if (!hasAttribute(COMMENT_ROOT) && !hasAttribute(COMMENT_PARAMETER) && !previous.hasAttribute(COMMENT_BLANKLINE))
- fReferenceIndentation= previous.getIndentationReference();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#append(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange)
- */
- protected void append(final CommentRange range) {
-
- final MultiCommentRegion parent= (MultiCommentRegion)getParent();
-
- if (range.hasAttribute(COMMENT_PARAMETER))
- setAttribute(COMMENT_PARAMETER);
- else if (range.hasAttribute(COMMENT_ROOT))
- setAttribute(COMMENT_ROOT);
- else if (range.hasAttribute(COMMENT_BLANKLINE))
- setAttribute(COMMENT_BLANKLINE);
-
- final int ranges= getSize();
- if (ranges == 1) {
-
- if (parent.isIndentRoots()) {
-
- final CommentRange first= getFirst();
- final String common= parent.getText(first.getOffset(), first.getLength()) + CommentRegion.COMMENT_RANGE_DELIMITER;
-
- if (hasAttribute(COMMENT_ROOT))
- fReferenceIndentation= common;
- else if (hasAttribute(COMMENT_PARAMETER)) {
- if (parent.isIndentDescriptions())
- fReferenceIndentation= "\t" + common; //$NON-NLS-1$
- else
- fReferenceIndentation= common;
- }
- }
- }
- super.append(range);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#getContentLinePrefix()
- */
- protected String getContentPrefix() {
- return MULTI_COMMENT_CONTENT_PREFIX;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#getEndLinePrefix()
- */
- protected String getEndingPrefix() {
- return MULTI_COMMENT_END_PREFIX;
- }
-
- /**
- * Returns the reference indentation to use for this line.
- *
- * @return the reference indentation for this line
- */
- protected final String getIndentationReference() {
- return fReferenceIndentation;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#getStartLinePrefix()
- */
- protected String getStartingPrefix() {
- return MULTI_COMMENT_START_PREFIX;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#scanLine(int)
- */
- protected void scanLine(final int line) {
-
- final CommentRegion parent= getParent();
- final String start= getStartingPrefix().trim();
- final String end= getEndingPrefix().trim();
- final String content= getContentPrefix().trim();
-
- final int lines= parent.getSize();
- final CommentRange range= getFirst();
-
- int offset= 0;
- int postfix= 0;
-
- String text= parent.getText(range.getOffset(), range.getLength());
- if (line == 0) {
-
- offset= text.indexOf(start);
- if (offset >= 0 && text.substring(0, offset).trim().length() != 0)
- offset= -1;
-
- if (offset >= 0) {
-
- offset += start.length();
- range.trimBegin(offset);
-
- postfix= text.lastIndexOf(end);
- if (postfix >= 0 && text.substring(postfix + end.length()).trim().length() != 0)
- postfix= -1;
-
- if (postfix >= offset)
- // comment ends on same line
- range.setLength(postfix - offset);
- else {
- postfix= text.lastIndexOf(content);
- if (postfix >= 0 && text.substring(postfix + content.length()).trim().length() != 0)
- postfix= -1;
-
- if (postfix >= offset) {
-
- range.setLength(postfix - offset);
- parent.setBorder(BORDER_UPPER);
-
- if (postfix > offset) {
-
- text= parent.getText(range.getOffset(), range.getLength());
- final IRegion region= trimLine(text, content);
-
- range.move(region.getOffset());
- range.setLength(region.getLength());
- }
- }
- }
- }
- } else if (line == lines - 1) {
-
- offset= text.indexOf(content);
- if (offset >= 0 && text.substring(0, offset).trim().length() != 0)
- offset= -1;
- postfix= text.lastIndexOf(end);
- if (postfix >= 0 && text.substring(postfix + end.length()).trim().length() != 0)
- postfix= -1;
-
- if (offset >= 0 && offset == postfix)
- // no content on line, only the comment postfix
- range.setLength(0);
- else {
- if (offset >= 0)
- // omit the content prefix
- range.trimBegin(offset + content.length());
-
- if (postfix >= 0)
- // omit the comment postfix
- range.trimEnd(-end.length());
-
- text= parent.getText(range.getOffset(), range.getLength());
- final IRegion region= trimLine(text, content);
- if (region.getOffset() != 0 || region.getLength() != text.length()) {
-
- range.move(region.getOffset());
- range.setLength(region.getLength());
-
- parent.setBorder(BORDER_UPPER);
- parent.setBorder(BORDER_LOWER);
- }
- }
- } else {
-
- offset= text.indexOf(content);
- if (offset >= 0 && text.substring(0, offset).trim().length() != 0)
- offset= -1;
-
- if (offset >= 0) {
-
- offset += content.length();
- range.trimBegin(offset);
- }
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#tokenizeLine(int)
- */
- protected void tokenizeLine(int line) {
-
- int offset= 0;
- int index= offset;
-
- final CommentRegion parent= getParent();
- final CommentRange range= getFirst();
- final int begin= range.getOffset();
-
- final String content= parent.getText(begin, range.getLength());
- final int length= content.length();
-
- while (offset < length && ScannerHelper.isWhitespace(content.charAt(offset)))
- offset++;
-
- CommentRange result= null;
- if (offset >= length && !parent.isClearLines() && (line > 0 && line < parent.getSize() - 1)) {
-
- result= new CommentRange(begin, 0);
- result.setAttribute(COMMENT_BLANKLINE);
- result.setAttribute(COMMENT_FIRST_TOKEN);
-
- parent.append(result);
- }
-
- int attribute= COMMENT_FIRST_TOKEN | COMMENT_STARTS_WITH_RANGE_DELIMITER;
- while (offset < length) {
-
- while (offset < length && ScannerHelper.isWhitespace(content.charAt(offset))) {
- offset++;
- attribute |= COMMENT_STARTS_WITH_RANGE_DELIMITER;
- }
-
- index= offset;
-
- if (index < length) {
-
- if (content.charAt(index) == HTML_TAG_PREFIX) {
-
- // in order to avoid recognizing any < in a comment, even those which are part of e.g.
- // java source code, we validate the tag content to be one of the recognized
- // tags (structural, breaks, pre, code).
- int tag= ++index;
- while (index < length && content.charAt(index) != HTML_TAG_POSTFIX && content.charAt(index) != HTML_TAG_PREFIX)
- index++;
-
- if (index < length && content.charAt(index) == HTML_TAG_POSTFIX && isValidTag(content.substring(tag, index))) {
- index++;
- attribute |= COMMENT_HTML; // only set html attribute if postfix found
- } else {
- // no tag - do the usual thing from the original offset
- index= tag;
- while (index < length
- && !ScannerHelper.isWhitespace(content.charAt(index))
- && content.charAt(index) != HTML_TAG_PREFIX
- && !content.startsWith(LINK_TAG_PREFIX_STRING, index))
- index++;
- }
-
-
- } else if (content.startsWith(LINK_TAG_PREFIX_STRING, index)) {
-
- while (index < length && content.charAt(index) != LINK_TAG_POSTFIX)
- index++;
-
- if (index < length && content.charAt(index) == LINK_TAG_POSTFIX)
- index++;
-
- attribute |= COMMENT_OPEN | COMMENT_CLOSE;
-
- } else {
-
- while (index < length
- && !ScannerHelper.isWhitespace(content.charAt(index))
- && content.charAt(index) != HTML_TAG_PREFIX
- && !content.startsWith(LINK_TAG_PREFIX_STRING, index))
- index++;
- }
- }
-
- if (index - offset > 0) {
-
- result= new CommentRange(begin + offset, index - offset);
- result.setAttribute(attribute);
-
- parent.append(result);
- offset= index;
- }
-
- attribute= 0;
- }
- }
-
- /**
- * Checks whether <code>tag</code> is a valid tag content (text inside
- * the angular brackets &lt;, &gt;).
- * <p>
- * The algorithm is to see if the tag trimmed of whitespace and an
- * optional slash starts with one of our recognized tags.
- *
- * @param tag the tag to check
- * @return <code>true</code> if <code>tag</code> is a valid tag
- * content
- */
- private boolean isValidTag(String tag) {
- // strip the slash
- if (tag.startsWith("/")) //$NON-NLS-1$
- tag= tag.substring(1, tag.length());
-
- // strip ws
- tag= tag.trim();
-
- // extract first token
- int i= 0;
- while (i < tag.length() && !ScannerHelper.isWhitespace(tag.charAt(i)))
- i++;
- tag= tag.substring(0, i);
-
- // see if it's a tag
- return isTagName(tag.toLowerCase());
- }
-
- /**
- * Checks whether <code>tag</code> is one of the configured tags.
- *
- * @param tag the tag to check
- * @return <code>true</code> if <code>tag</code> is a configured tag
- * name
- */
- private boolean isTagName(String tag) {
- return fgTagLookup.contains(tag);
- }
-
- /**
- * Removes all leading and trailing occurrences from <code>line</code>.
- *
- * @param line the string to remove the occurrences of
- * <code>trimmable</code>
- * @param trimmable the string to remove from <code>line</code>
- * @return the region of the trimmed substring within <code>line</code>
- */
- protected final IRegion trimLine(final String line, final String trimmable) {
-
- final int trim= trimmable.length();
-
- int offset= 0;
- int length= line.length() - trim;
-
- while (line.startsWith(trimmable, offset))
- offset += trim;
-
- while (line.startsWith(trimmable, length))
- length -= trim;
-
- return new Region(offset, length + trim);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/MultiCommentRegion.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/MultiCommentRegion.java
deleted file mode 100644
index eaa7d276..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/MultiCommentRegion.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.wst.jsdt.internal.formatter.CodeFormatterVisitor;
-
-/**
- * Multi-comment region in a source code document.
- *
- * @since 3.0
- */
-public class MultiCommentRegion extends CommentRegion implements IJavaDocTagConstants {
-
- /** Should root tag parameter descriptions be indented after the tag? */
- private final boolean fIndentDescriptions;
-
- /** Should root tag parameter descriptions be indented? */
- private final boolean fIndentRoots;
-
- /** Should description of parameters go to the next line? */
- private final boolean fParameterNewLine;
-
- /** Should root tags be separated from description? */
- private boolean fSeparateRoots;
-
- /**
- * Creates a new multi-comment region.
- *
- * @param document the document which contains the comment region
- * @param position the position of this comment region in the document
- * @param formatter the given formatter
- */
- public MultiCommentRegion(final IDocument document, final Position position, final CodeFormatterVisitor formatter) {
- super(document, position, formatter);
-
- fIndentRoots= this.preferences.comment_indent_root_tags;
- fIndentDescriptions= this.preferences.comment_indent_parameter_description;
- fSeparateRoots= this.preferences.comment_insert_empty_line_before_root_tags;
- fParameterNewLine= this.preferences.comment_insert_new_line_for_parameter;
- fClear = this.preferences.comment_clear_blank_lines_in_block_comment;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRegion#canAppend(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine, org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, int, int)
- */
- protected boolean canAppend(final CommentLine line, final CommentRange previous, final CommentRange next, final int index, int count) {
-
- final boolean blank= next.hasAttribute(COMMENT_BLANKLINE);
-
- // Avoid wrapping punctuation
- if (next.getLength() <= 2 && !blank && isNonAlphaNumeric(next))
- return true;
-
- if (fParameterNewLine && line.hasAttribute(COMMENT_PARAMETER) && line.getSize() > 1)
- return false;
-
- if (previous != null) {
-
- if (index != 0 && (blank || previous.hasAttribute(COMMENT_BLANKLINE) || next.hasAttribute(COMMENT_PARAMETER) || next.hasAttribute(COMMENT_ROOT) || next.hasAttribute(COMMENT_SEPARATOR) || next.hasAttribute(COMMENT_NEWLINE) || previous.hasAttribute(COMMENT_BREAK) || previous.hasAttribute(COMMENT_SEPARATOR)))
- return false;
-
- if (previous.hasAttribute(COMMENT_ROOT))
- return true;
-
- if (next.hasAttribute(COMMENT_IMMUTABLE) && previous.hasAttribute(COMMENT_IMMUTABLE))
- return true;
- }
-
- // always append elements that did not have any range separators
- if (!next.hasAttribute(COMMENT_STARTS_WITH_RANGE_DELIMITER)) {
- return true;
- }
-
- if (fIndentRoots && !line.hasAttribute(COMMENT_ROOT) && !line.hasAttribute(COMMENT_PARAMETER))
- count -= stringToLength(line.getIndentationReference());
-
- // Avoid appending consecutive immutable ranges, which together exceed the line width
- if (next.hasAttribute(COMMENT_IMMUTABLE) && (previous == null || !previous.hasAttribute(COMMENT_IMMUTABLE))) {
- // Breaking the abstraction by directly accessing the list of ranges for looking ahead
- Iterator iter= getRanges().iterator();
- CommentRange current= null;
- while (iter.hasNext() && current != next)
- current= (CommentRange) iter.next();
-
- if (current != null && iter.hasNext()) {
- try {
- int lineNumber= getDocument().getLineOfOffset(getOffset() + current.getOffset());
- CommentRange last= current;
- while (iter.hasNext()) {
- current= (CommentRange) iter.next();
- if (current.hasAttribute(COMMENT_IMMUTABLE) && getDocument().getLineOfOffset(getOffset() + current.getOffset()) == lineNumber)
- last= current;
- else
- break;
- }
- count -= last.getOffset() + last.getLength() - (next.getOffset() + next.getLength());
- } catch (BadLocationException e) {
- // Should not happen
- }
- }
- }
-
- return super.canAppend(line, previous, next, index, count);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRegion#getDelimiter(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine, org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine, org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, java.lang.String)
- */
- protected String getDelimiter(CommentLine predecessor, CommentLine successor, CommentRange previous, CommentRange next, String indentation) {
-
- final String delimiter= super.getDelimiter(predecessor, successor, previous, next, indentation);
-
- if (previous != null) {
-
- // Blank line before <pre> tag
- if (previous.hasAttribute(COMMENT_IMMUTABLE | COMMENT_SEPARATOR) && !next.hasAttribute(COMMENT_CODE) && !successor.hasAttribute(COMMENT_BLANKLINE))
- return delimiter + delimiter;
-
- // Blank line after </pre> tag
- else if (next.hasAttribute(COMMENT_IMMUTABLE | COMMENT_SEPARATOR) && !successor.hasAttribute(COMMENT_BLANKLINE) && !predecessor.hasAttribute(COMMENT_BLANKLINE))
- return delimiter + delimiter;
-
- // Add blank line before first root/parameter tag, if "Blank line before Javadoc tags"
- else if (fSeparateRoots && previous.hasAttribute(COMMENT_PARAGRAPH) && !successor.hasAttribute(COMMENT_BLANKLINE) && !predecessor.hasAttribute(COMMENT_BLANKLINE))
- return delimiter + delimiter;
-
- else if (fIndentRoots && !predecessor.hasAttribute(COMMENT_ROOT) && !predecessor.hasAttribute(COMMENT_PARAMETER) && !predecessor.hasAttribute(COMMENT_BLANKLINE))
- return delimiter + stringToIndent(predecessor.getIndentationReference());
- }
- return delimiter;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRegion#getDelimiter(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange)
- */
- protected String getDelimiter(final CommentRange previous, final CommentRange next) {
- // simply preserve range (~ word) breaks
- if (previous != null && !previous.hasAttribute(COMMENT_STARTS_WITH_RANGE_DELIMITER)) {
- return ""; //$NON-NLS-1$
- } else {
- return super.getDelimiter(previous, next);
- }
- }
-
- /**
- * Should root tag parameter descriptions be indented after the tag?
- *
- * @return <code>true</code> iff the descriptions should be indented
- * after, <code>false</code> otherwise.
- */
- protected final boolean isIndentDescriptions() {
- return fIndentDescriptions;
- }
-
- /**
- * Should root tag parameter descriptions be indented?
- *
- * @return <code>true</code> iff the root tags should be indented,
- * <code>false</code> otherwise.
- */
- protected final boolean isIndentRoots() {
- return fIndentRoots;
- }
-
- /**
- * Marks the comment ranges confined by HTML ranges.
- */
- protected void markHtmlRanges() {
- // Do nothing
- }
-
- /**
- * Marks the comment range with its HTML tag attributes.
- *
- * @param range the comment range to mark
- * @param token token associated with the comment range
- */
- protected void markHtmlTag(final CommentRange range, final char[] token) {
- // Do nothing
- }
-
- /**
- * Marks the comment range with its javadoc tag attributes.
- *
- * @param range the comment range to mark
- * @param token token associated with the comment range
- */
- protected void markJavadocTag(final CommentRange range, final char[] token) {
- range.markPrefixTag(COMMENT_ROOT_TAGS, COMMENT_TAG_PREFIX, token, COMMENT_ROOT);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRegion#markRegion()
- */
- protected void markRegion() {
-
- int count= 0;
- boolean paragraph= false;
-
- char[] token= null;
- CommentRange range= null;
-
- for (final ListIterator iterator= getRanges().listIterator(); iterator.hasNext();) {
-
- range= (CommentRange)iterator.next();
- count= range.getLength();
-
- if (count > 0) {
-
- token= getText(range.getOffset(), count).toLowerCase().toCharArray();
-
- markJavadocTag(range, token);
- if (!paragraph && (range.hasAttribute(COMMENT_ROOT) || range.hasAttribute(COMMENT_PARAMETER))) {
- range.setAttribute(COMMENT_PARAGRAPH);
- paragraph= true;
- }
- markHtmlTag(range, token);
- }
- }
- markHtmlRanges();
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRegion#createLine()
- * @since 3.1
- */
- protected CommentLine createLine() {
- return new MultiCommentLine(this);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/SingleCommentLine.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/SingleCommentLine.java
deleted file mode 100644
index 4f376db3..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/SingleCommentLine.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-/**
- * Single-line comment line in a comment region.
- *
- * @since 3.0
- */
-public class SingleCommentLine extends CommentLine {
-
- /** Line prefix for single line comments */
- public static final String SINGLE_COMMENT_PREFIX= "// "; //$NON-NLS-1$
-
- /** NLS tag prefix */
- private static final String NLS_TAG_PREFIX= "//$NON-NLS-"; //$NON-NLS-1$
-
- /** Is the comment a NLS locale tag sequence? */
- private boolean fLocaleSequence= false;
-
- /**
- * Creates a new single-line comment line.
- *
- * @param region comment region to create the line for
- */
- protected SingleCommentLine(final CommentRegion region) {
- super(region);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#adapt(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine)
- */
- protected void adapt(final CommentLine previous) {
- // Do nothing
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#formatLowerBorder(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, java.lang.String, int)
- */
- protected void formatLowerBorder(final CommentRange range, final String indentation, final int length) {
-
- final int offset= range.getOffset() + range.getLength();
- final CommentRegion parent= getParent();
-
- parent.logEdit(parent.getDelimiter(), offset, parent.getLength() - offset);
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#formatUpperBorder(org.eclipse.wst.jsdt.internal.corext.text.comment.CommentRange, java.lang.String, int)
- */
- protected void formatUpperBorder(final CommentRange range, final String indentation, final int length) {
-
- final CommentRegion parent= getParent();
-
- parent.logEdit(getContentPrefix(), 0, range.getOffset());
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#getContentPrefix()
- */
- protected String getContentPrefix() {
- return SINGLE_COMMENT_PREFIX;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#getEndingPrefix()
- */
- protected String getEndingPrefix() {
- return SINGLE_COMMENT_PREFIX;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#getStartingPrefix()
- */
- protected String getStartingPrefix() {
- return SINGLE_COMMENT_PREFIX;
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#scanLine(int)
- */
- protected void scanLine(final int line) {
-
- final CommentRange range= getFirst();
- final String content= getParent().getText(range.getOffset(), range.getLength());
- final String prefix= getContentPrefix().trim();
-
- final int offset= content.indexOf(prefix);
- if (offset >= 0) {
-
- if (content.startsWith(NLS_TAG_PREFIX))
- fLocaleSequence= true;
-
- range.trimBegin(offset + prefix.length());
- }
- }
-
- /*
- * @see org.eclipse.wst.jsdt.internal.corext.text.comment.CommentLine#tokenizeLine(int)
- */
- protected void tokenizeLine(final int line) {
-
- if (!fLocaleSequence)
- super.tokenizeLine(line);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/SubstitutionTextReader.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/SubstitutionTextReader.java
deleted file mode 100644
index d0a1395d..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/comment/SubstitutionTextReader.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.wst.jsdt.internal.formatter.comment;
-
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.eclipse.wst.jsdt.internal.compiler.parser.ScannerHelper;
-
-/**
- * Reads the text contents from a reader and computes for each character
- * a potential substitution. The substitution may eat more characters than
- * only the one passed into the computation routine.
- */
-public abstract class SubstitutionTextReader extends Reader {
-
- private Reader fReader;
- private boolean fWasWhiteSpace;
- private int fCharAfterWhiteSpace;
-
- /**
- * Tells whether white space characters are skipped.
- */
- private boolean fSkipWhiteSpace= true;
-
- private boolean fReadFromBuffer;
- private StringBuffer fBuffer;
- private int fIndex;
-
-
- protected SubstitutionTextReader(Reader reader) {
- fReader= reader;
- fBuffer= new StringBuffer();
- fIndex= 0;
- fReadFromBuffer= false;
- fCharAfterWhiteSpace= -1;
- fWasWhiteSpace= true;
- }
-
- /**
- * Gets the content as a String
- */
- public String getString() throws IOException {
- StringBuffer buf= new StringBuffer();
- int ch;
- while ((ch= read()) != -1) {
- buf.append((char)ch);
- }
- return buf.toString();
- }
-
- /**
- * Implement to compute the substitution for the given character and
- * if necessary subsequent characters. Use <code>nextChar</code>
- * to read subsequent characters.
- */
- protected abstract String computeSubstitution(int c) throws IOException;
-
- /**
- * Returns the internal reader.
- */
- protected Reader getReader() {
- return fReader;
- }
-
- /**
- * Returns the next character.
- */
- protected int nextChar() throws IOException {
- fReadFromBuffer= (fBuffer.length() > 0);
- if (fReadFromBuffer) {
- char ch= fBuffer.charAt(fIndex++);
- if (fIndex >= fBuffer.length()) {
- fBuffer.setLength(0);
- fIndex= 0;
- }
- return ch;
- } else {
- int ch= fCharAfterWhiteSpace;
- if (ch == -1) {
- ch= fReader.read();
- }
- if (fSkipWhiteSpace && ScannerHelper.isWhitespace((char)ch)) {
- do {
- ch= fReader.read();
- } while (ScannerHelper.isWhitespace((char)ch));
- if (ch != -1) {
- fCharAfterWhiteSpace= ch;
- return ' ';
- }
- } else {
- fCharAfterWhiteSpace= -1;
- }
- return ch;
- }
- }
-
- /*
- * @see Reader#read()
- */
- public int read() throws IOException {
- int c;
- do {
-
- c= nextChar();
- while (!fReadFromBuffer) {
- String s= computeSubstitution(c);
- if (s == null)
- break;
- if (s.length() > 0)
- fBuffer.insert(0, s);
- c= nextChar();
- }
-
- } while (fSkipWhiteSpace && fWasWhiteSpace && (c == ' '));
- fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n');
- return c;
- }
-
- /*
- * @see Reader#read(char[],int,int)
- */
- public int read(char cbuf[], int off, int len) throws IOException {
- int end= off + len;
- for (int i= off; i < end; i++) {
- int ch= read();
- if (ch == -1) {
- if (i == off) {
- return -1;
- } else {
- return i - off;
- }
- }
- cbuf[i]= (char)ch;
- }
- return len;
- }
-
- /*
- * @see java.io.Reader#ready()
- */
- public boolean ready() throws IOException {
- return fReader.ready();
- }
-
- /*
- * @see Reader#close()
- */
- public void close() throws IOException {
- fReader.close();
- }
-
- /*
- * @see Reader#reset()
- */
- public void reset() throws IOException {
- fReader.reset();
- fWasWhiteSpace= true;
- fCharAfterWhiteSpace= -1;
- fBuffer.setLength(0);
- fIndex= 0;
- }
-
- protected final void setSkipWhitespace(boolean state) {
- fSkipWhiteSpace= state;
- }
-
- protected final boolean isSkippingWhitespace() {
- return fSkipWhiteSpace;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/options.properties b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/options.properties
deleted file mode 100644
index 476842b1..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/formatter/options.properties
+++ /dev/null
@@ -1,75 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2007 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
-###############################################################################
-newline.openingBrace.number=1
-newline.openingBrace.category=Newline
-newline.openingBrace.name=I&nsert new line before opening brace
-newline.openingBrace.possibleValues=2|Insert|Do not insert
-newline.openingBrace.description=When Insert, a new line is inserted before an opening brace, otherwise nothing is inserted
-
-newline.controlStatement.number=2
-newline.controlStatement.category=Newline
-newline.controlStatement.name=Insert new &line in control statement
-newline.controlStatement.possibleValues=2|Insert|Do not insert
-newline.controlStatement.description=When Insert, a new line is inserted between } and else, catch, finally
-
-newline.clearAll.number=3
-newline.clearAll.category=Newline
-newline.clearAll.name=Clear all &blank lines
-newline.clearAll.possibleValues=2|Clear|Preserve one
-newline.clearAll.description=When Clear, all blank lines are removed. When Preserve one, only one is kept and all others removed.
-
-newline.elseIf.number=4
-newline.elseIf.category=Newline
-newline.elseIf.name=&Keep else if on the same line
-newline.elseIf.possibleValues=2|Yes|No
-newline.elseIf.description=When Yes, a blank line is inserted between a else and a if when they are contiguous
-
-newline.emptyBlock.number=5
-newline.emptyBlock.category=Newline
-newline.emptyBlock.name=In&sert a new line inside an empty block
-newline.emptyBlock.possibleValues=2|Insert|Do not insert
-newline.emptyBlock.description=When insert, a line break is inserted between contiguous { and }, if } is not followed by a keyword.
-
-line.split.number=6
-line.split.category=Line splitting
-line.split.name=Ma&ximum line length
-line.split.possibleValues=-1
-line.split.description=Enable splitting of long lines (exceeding the configurable length). Length of 0 will disable line splitting
-
-style.compactAssignment.number=7
-style.compactAssignment.category=Style
-style.compactAssignment.name=&Compact assignment
-style.compactAssignment.possibleValues=2|Compact|Normal
-style.compactAssignment.description=Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space is inserted before the assignment operator
-
-style.reuseExistingLayout.number=8
-style.reuseExistingLayout.category=Style
-style.reuseExistingLayout.name=&Reuse existing layout
-style.reuseExistingLayout.possibleValues=2|Reuse|Do not reuse
-style.reuseExistingLayout.description=If the user has formatted his code a certain way, the formatter does not try to reformat it
-
-tabulation.char.number=9
-tabulation.char.category=Style
-tabulation.char.name=Indentation is represented by &tab
-tabulation.char.possibleValues=2|Tab|Spaces
-tabulation.char.description=Either choose to indent with tab characters or spaces
-
-tabulation.size.number=10
-tabulation.size.category=Style
-tabulation.size.name=&Amount of spaces representing a tab
-tabulation.size.possibleValues=-1
-tabulation.size.description=Tabulation size in term of space characters
-
-space.castexpression.number=11
-space.castexpression.category=Style
-space.castexpression.name=&Insert a space in cast expression
-space.castexpression.size.possibleValues=2|Insert|Do not insert
-space.castexpression.description=When insert, a space is added between the closing parenthesis and the expression of the cast expression

Back to the top