Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2011-01-27 12:07:40 +0000
committerStephan Herrmann2011-01-27 12:07:40 +0000
commit192b65f5566cc0d0af77a6afc4b664c3d09389d4 (patch)
tree2b4378a83ce7bb4c6f0d54f45ab12699030a7a4e /org.eclipse.jdt.core.tests.model
parentc6f6284655ee0dd0c8582ebff467efb2fd1b02e4 (diff)
downloadorg.eclipse.objectteams-192b65f5566cc0d0af77a6afc4b664c3d09389d4.tar.gz
org.eclipse.objectteams-192b65f5566cc0d0af77a6afc4b664c3d09389d4.tar.xz
org.eclipse.objectteams-192b65f5566cc0d0af77a6afc4b664c3d09389d4.zip
updated test plug-ins to v_B35 for 3.7M5
Diffstat (limited to 'org.eclipse.jdt.core.tests.model')
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java116
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java6
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java12
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java35
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java10
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java3560
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterMassiveRegressionTests.java113
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java127
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java149
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java13
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java38
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java6
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java60
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor2.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java6
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java272
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java13
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Converter/src/test0720/A.java14
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Converter15/src/test0348/AnnotatedInterfaceWithStringDefault.java5
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Converter15/src/test0348/TestAnnotationWithStringDefault.java19
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/Formatter/test488/A_out.java4
27 files changed, 4145 insertions, 459 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
index d332a066a..f104b03f1 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -47,7 +47,7 @@ public class ASTConverter15Test extends ConverterTestSetup {
}
static {
-// TESTS_NUMBERS = new int[] { 345, 346 };
+// TESTS_NUMBERS = new int[] { 348 };
// TESTS_RANGE = new int[] { 325, -1 };
// TESTS_NAMES = new String[] {"test0204"};
}
@@ -3967,7 +3967,7 @@ public class ASTConverter15Test extends ConverterTestSetup {
Statement statement = (Statement) statements.get(0);
assertEquals("Not a constructor invocation", ASTNode.CONSTRUCTOR_INVOCATION, statement.getNodeType());
ConstructorInvocation constructorInvocation = (ConstructorInvocation) statement;
- checkSourceRange(constructorInvocation, "x.<String> this();", source);
+ checkSourceRange(constructorInvocation, "x.<String> this();", source, true/*expectMalformed*/);
assertTrue("Node is not malformed", isMalformed(constructorInvocation));
}
@@ -9669,7 +9669,7 @@ public class ASTConverter15Test extends ConverterTestSetup {
assertTrue("Not a recovered binding", binding3.isRecovered());
final IJavaElement javaElement = binding3.getJavaElement();
assertNotNull("No java element", javaElement);
- assertEquals("Not a compilation unit", IJavaElement.COMPILATION_UNIT, javaElement.getElementType());
+ assertEquals("Not a compilation unit", IJavaElement.TYPE, javaElement.getElementType());
assertNotNull("No parent", javaElement.getParent());
}
@@ -11156,4 +11156,110 @@ public class ASTConverter15Test extends ConverterTestSetup {
assertEquals("Wrong constant value", "a", constantValue);
}
-} \ No newline at end of file
+ /*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=333360
+ */
+ public void test0347() throws JavaModelException {
+ this.workingCopy = getWorkingCopy("/Converter15/src/test0347/X.java", true/*resolve*/);
+ String contents =
+ "package test0347;\n" +
+ "public class X implements One</*start*/Outer<Integer>.Inner<Double>[]/*end*/> {\n" +
+ "}\n" +
+ "interface One<T> {}\n" +
+ "class Outer<T> {\n" +
+ " public class Inner<S> {}\n" +
+ "}";
+ ArrayType type = (ArrayType) buildAST(
+ contents,
+ this.workingCopy);
+ assertNotNull("No annotation", type);
+ ITypeBinding binding = type.resolveBinding();
+ assertNotNull("No binding", binding);
+ assertEquals("Wrong qualified name", "test0347.Outer<java.lang.Integer>.Inner<java.lang.Double>[]", binding.getQualifiedName());
+ Type componentType = type.getComponentType();
+ binding = componentType.resolveBinding();
+ assertNotNull("No binding", binding);
+ assertEquals("Wrong qualified name", "test0347.Outer<java.lang.Integer>.Inner<java.lang.Double>", binding.getQualifiedName());
+ assertTrue("Not parameterized", componentType.isParameterizedType());
+ ParameterizedType parameterizedType = (ParameterizedType) componentType;
+ Type type2 = parameterizedType.getType();
+ assertTrue("Not qualified", type2.isQualifiedType());
+ QualifiedType qualifiedType = (QualifiedType) type2;
+ binding = qualifiedType.resolveBinding();
+ assertNotNull("No binding", binding);
+ assertEquals("Wrong qualified name", "test0347.Outer<java.lang.Integer>.Inner<java.lang.Double>", binding.getQualifiedName());
+ Type qualifier = qualifiedType.getQualifier();
+ assertTrue("Not parameterized", qualifier.isParameterizedType());
+ binding = qualifier.resolveBinding();
+ assertNotNull("No binding", binding);
+ assertEquals("Wrong qualified name", "test0347.Outer<java.lang.Integer>", binding.getQualifiedName());
+ parameterizedType = (ParameterizedType) qualifier;
+ type2 = parameterizedType.getType();
+ assertTrue("Not simple type", type2.isSimpleType());
+ binding = type2.resolveBinding();
+ assertNotNull("No binding", binding);
+ assertEquals("Wrong qualified name", "test0347.Outer<java.lang.Integer>", binding.getQualifiedName());
+ }
+ // issues with annotation default values
+ public void _test0348() throws JavaModelException {
+ ICompilationUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0348", "AnnotatedInterfaceWithStringDefault.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ IType type = sourceUnit.getType("AnnotatedInterfaceWithStringDefault");//$NON-NLS-1$
+ //ICompilationUnit sourceUnit2 = getCompilationUnit("Converter15" , "src", "test0348", "TestAnnotationWithStringDefault.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ //IType type2 = sourceUnit2.getType("TestAnnotationWithStringDefault");//$NON-NLS-1$
+
+ assertNotNull("Should not be null", type);
+ ASTParser parser= ASTParser.newParser(AST.JLS3);
+ parser.setProject(type.getJavaProject());
+ IBinding[] bindings= parser.createBindings(new IJavaElement[] { type }, null);
+ if (bindings.length == 1 && bindings[0] instanceof ITypeBinding) {
+ ITypeBinding typeBinding= (ITypeBinding) bindings[0];
+ IAnnotationBinding[] annotations = typeBinding.getAnnotations();
+ for (int i = 0, max = annotations.length; i < max; i++) {
+ IAnnotationBinding annotation = annotations[i];
+ IMemberValuePairBinding[] allMemberValuePairs = annotation.getAllMemberValuePairs();
+ for (int j = 0, max2 = allMemberValuePairs.length; j < max2; j++) {
+ IMemberValuePairBinding memberValuePair = allMemberValuePairs[j];
+ Object defaultValue = memberValuePair.getValue();
+ System.out.println(defaultValue);
+ assertNotNull("no default value", defaultValue);
+ }
+ }
+ }
+ }
+
+ /*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=334119
+ * Ensures that dollar in a type name is not confused as the starting of member type
+ */
+ public void test0349() throws JavaModelException {
+ this.workingCopy = getWorkingCopy("/Converter15/src/p/X$Y.java", true/*resolve*/);
+ ASTNode node = buildAST(
+ "package p;\n" +
+ "/*start*/public class X$Y {\n" +
+ "}/*end*/",
+ this.workingCopy,
+ false);
+ IBinding binding = ((TypeDeclaration) node).resolveBinding();
+ assertBindingKeyEquals(
+ "Lp/X$Y;", // should not be Lp/X$Y-X$Y;
+ binding.getKey());
+ }
+
+ /*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=334119
+ * Ensures that dollar in a type name is not confused as the starting of member type
+ */
+ public void test0348b() throws JavaModelException {
+ this.workingCopy = getWorkingCopy("/Converter15/src/p/X$.java", true/*resolve*/);
+ ASTNode node = buildAST(
+ "package p;\n" +
+ "/*start*/public class X$ {\n" +
+ "}/*end*/",
+ this.workingCopy,
+ false);
+ IBinding binding = ((TypeDeclaration) node).resolveBinding();
+ assertBindingKeyEquals(
+ "Lp/X$;", // should not be Lp/X$~X$;
+ binding.getKey());
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java
index 8f45c715d..451c687b8 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java
@@ -6943,7 +6943,7 @@ public class ASTConverterAST3Test extends ConverterTestSetup {
"public void fails() {\n" + //$NON-NLS-1$
" foo()\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
- checkSourceRange(methodDeclaration, expectedSource, source);
+ checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/);
Block block = methodDeclaration.getBody();
expectedSource =
"{\n" + //$NON-NLS-1$
@@ -6999,7 +6999,7 @@ public class ASTConverterAST3Test extends ConverterTestSetup {
"public void fails() {\n" + //$NON-NLS-1$
" foo()\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
- checkSourceRange(methodDeclaration, expectedSource, source);
+ checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/);
Block block = methodDeclaration.getBody();
expectedSource =
"{\n" + //$NON-NLS-1$
@@ -8182,7 +8182,7 @@ public class ASTConverterAST3Test extends ConverterTestSetup {
" z\n" + //$NON-NLS-1$
" }\n" + //$NON-NLS-1$
"}"; //$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
+ checkSourceRange(node, expectedSource, source, true/*expectMalformed*/);
int methodEndPosition = node.getStartPosition() + node.getLength();
node = getASTNode(compilationUnit, 0);
assertNotNull("not null", node); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java
index c23f585f5..f34c99b78 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -35,7 +35,7 @@ public class ASTConverterTest extends ConverterTestSetup {
}
static {
-// TESTS_NUMBERS = new int[] { 305 };
+// TESTS_NUMBERS = new int[] { 339 };
}
public static Test suite() {
return buildModelTestSuite(ASTConverterTest.class);
@@ -7116,7 +7116,7 @@ public class ASTConverterTest extends ConverterTestSetup {
"public void fails() {\n" + //$NON-NLS-1$
" foo()\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
- checkSourceRange(methodDeclaration, expectedSource, source);
+ checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/);
Block block = methodDeclaration.getBody();
expectedSource =
"{\n" + //$NON-NLS-1$
@@ -7171,7 +7171,7 @@ public class ASTConverterTest extends ConverterTestSetup {
"public void fails() {\n" + //$NON-NLS-1$
" foo()\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
- checkSourceRange(methodDeclaration, expectedSource, source);
+ checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/);
Block block = methodDeclaration.getBody();
expectedSource =
"{\n" + //$NON-NLS-1$
@@ -8350,7 +8350,7 @@ public class ASTConverterTest extends ConverterTestSetup {
" z\n" + //$NON-NLS-1$
" }\n" + //$NON-NLS-1$
"}"; //$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
+ checkSourceRange(node, expectedSource, source, true /*expectMalformed*/);
int methodEndPosition = node.getStartPosition() + node.getLength();
node = getASTNode(compilationUnit, 0);
assertNotNull("not null", node); //$NON-NLS-1$
@@ -8561,7 +8561,7 @@ public class ASTConverterTest extends ConverterTestSetup {
String compiler_compliance = null;
try {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0344", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- preferences = new InstanceScope().getNode(JavaCore.PLUGIN_ID);
+ preferences = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);
pb_assert = preferences.get(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, "");
compiler_source = preferences.get(JavaCore.COMPILER_SOURCE, "");
compiler_compliance = preferences.get(JavaCore.COMPILER_COMPLIANCE, "");
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java
index aeee05e53..e1aa54fdd 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java
@@ -1908,7 +1908,7 @@ public class ASTConverterTest2 extends ConverterTestSetup {
assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
assertTrue("Is a constructor", !methodDeclaration.isConstructor());
- checkSourceRange(methodDeclaration, "private void foo(){", source);
+ checkSourceRange(methodDeclaration, "private void foo(){", source, true/*expectMalformed*/);
node = getASTNode(compilationUnit, 0, 1);
assertNotNull("No node", node);
assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
@@ -3125,7 +3125,7 @@ public class ASTConverterTest2 extends ConverterTestSetup {
assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration declaration = (MethodDeclaration) node;
assertTrue("A constructor", !declaration.isConstructor());
- checkSourceRange(declaration, "public method(final int parameter);", source);
+ checkSourceRange(declaration, "public method(final int parameter);", source, true/*expectMalformed*/);
}
/**
@@ -3143,7 +3143,7 @@ public class ASTConverterTest2 extends ConverterTestSetup {
assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration declaration = (MethodDeclaration) node;
assertTrue("A constructor", !declaration.isConstructor());
- checkSourceRange(declaration, "public method(final int parameter) { }", source);
+ checkSourceRange(declaration, "public method(final int parameter) { }", source, true/*expectMalformed*/);
}
/**
@@ -3280,7 +3280,7 @@ public class ASTConverterTest2 extends ConverterTestSetup {
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration declaration = (MethodDeclaration) node;
assertTrue("Not a constructor", declaration.isConstructor());
- checkSourceRange(declaration, "public A();", source);
+ checkSourceRange(declaration, "public A();", source, true /*expectMalformed*/);
}
/**
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
index cb22e3f13..626a77f93 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -122,7 +122,7 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
static {
// TESTS_NAMES = new String[] {"test0602"};
// TESTS_RANGE = new int[] { 713, -1 };
-// TESTS_NUMBERS = new int[] { 719 };
+// TESTS_NUMBERS = new int[] { 504, 505, 512, 720 };
}
public static Test suite() {
return buildModelTestSuite(ASTConverterTestAST3_2.class);
@@ -1988,7 +1988,7 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
assertTrue("Is a constructor", !methodDeclaration.isConstructor());
- checkSourceRange(methodDeclaration, "private void foo(){", source);
+ checkSourceRange(methodDeclaration, "private void foo(){", source, true/*expectMalformed*/);
node = getASTNode(compilationUnit, 0, 1);
assertNotNull("No node", node);
assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
@@ -3203,7 +3203,7 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration declaration = (MethodDeclaration) node;
assertTrue("A constructor", !declaration.isConstructor());
- checkSourceRange(declaration, "public method(final int parameter);", source);
+ checkSourceRange(declaration, "public method(final int parameter);", source, true/*expectMalformed*/);
}
/**
@@ -3221,7 +3221,7 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration declaration = (MethodDeclaration) node;
assertTrue("A constructor", !declaration.isConstructor());
- checkSourceRange(declaration, "public method(final int parameter) { }", source);
+ checkSourceRange(declaration, "public method(final int parameter) { }", source, true/*expectMalformed*/);
}
/**
@@ -3358,7 +3358,7 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration declaration = (MethodDeclaration) node;
assertTrue("Not a constructor", declaration.isConstructor());
- checkSourceRange(declaration, "public A();", source);
+ checkSourceRange(declaration, "public A();", source, true/*expectMalformed*/);
}
/**
@@ -5493,7 +5493,7 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
node = getASTNode(compilationUnit, 0, 0);
assertEquals("wrong type", ASTNode.FIELD_DECLARATION, node.getNodeType());
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "d String[][]", source.toCharArray());
+ checkSourceRange(fieldDeclaration, "d String[][]", source.toCharArray(), true/*expectMalformed*/);
Type type = fieldDeclaration.getType();
assertTrue("Not a simple type", type.isSimpleType());
List fragments = fieldDeclaration.fragments();
@@ -7243,7 +7243,7 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
List fragments = fieldDeclaration.fragments();
assertEquals("wrong size", 1, fragments.size());
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- checkSourceRange(fragment, "s = {\"\",,,", source);
+ checkSourceRange(fragment, "s = {\"\",,,", source, true/*expectMalformed*/);
assertTrue("Not initializer", fragment.getInitializer() == null);
assertTrue("Not a malformed node", isMalformed(fragment));
}
@@ -9161,6 +9161,7 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
assertTrue("Not a recovered binding", typeBinding.isRecovered());
IJavaElement javaElement = typeBinding.getJavaElement();
assertNotNull("No java element", javaElement);
+ assertEquals("Wrong java element type", IJavaElement.TYPE, javaElement.getElementType());
assertTrue("Javalement exists", !javaElement.exists());
IPackageBinding packageBinding = typeBinding.getPackage();
assertNotNull("No package", packageBinding);
@@ -9293,6 +9294,7 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
assertTrue("Not a recovered binding", typeBinding.isRecovered());
IJavaElement javaElement = typeBinding.getJavaElement();
assertNotNull("No java element", javaElement);
+ assertEquals("Wrong java element type", IJavaElement.TYPE, javaElement.getElementType());
assertTrue("Java element exists", !javaElement.exists());
IPackageBinding packageBinding = typeBinding.getPackage();
assertNotNull("No package", packageBinding);
@@ -10556,4 +10558,21 @@ public class ASTConverterTestAST3_2 extends ConverterTestSetup {
}
}
}
+ /**
+ * http://bugs.eclipse.org/bugs/show_bug.cgi?id=47396
+ */
+ public void test0720() throws JavaModelException {
+ ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0720", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ char[] source = sourceUnit.getSource().toCharArray();
+ ASTNode result = runConversion(AST.JLS3, sourceUnit, true);
+ assertTrue("not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); //$NON-NLS-1$
+ CompilationUnit unit = (CompilationUnit) result;
+ assertEquals("Wrong number of problems", 1, unit.getProblems().length); //$NON-NLS-1$
+ ASTNode node = getASTNode(unit, 1, 0);
+ assertNotNull(node);
+ assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
+ MethodDeclaration declaration = (MethodDeclaration) node;
+ assertTrue("A constructor", !declaration.isConstructor());
+ checkSourceRange(declaration, "public void method(final int parameter) { }", source, true/*expectMalformed*/);
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java
index 3b9e81746..a74c9ab71 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -559,6 +559,9 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
}
protected void checkSourceRange(ASTNode node, String expectedContents, char[] source) {
+ checkSourceRange(node, expectedContents, source, false);
+ }
+ protected void checkSourceRange(ASTNode node, String expectedContents, char[] source, boolean expectMalformed) {
assertNotNull("The node is null", node); //$NON-NLS-1$
assertTrue("The node(" + node.getClass() + ").getLength() == 0", node.getLength() != 0); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("The node.getStartPosition() == -1", node.getStartPosition() != -1); //$NON-NLS-1$
@@ -568,6 +571,11 @@ public abstract class ConverterTestSetup extends AbstractASTTests {
System.arraycopy(source, start, actualContents, 0, length);
String actualContentsString = new String(actualContents);
assertSourceEquals("Unexpected source", Util.convertToIndependantLineDelimiter(expectedContents), Util.convertToIndependantLineDelimiter(actualContentsString));
+ if (expectMalformed) {
+ assertTrue("Is not malformed", isMalformed(node));
+ } else {
+ assertFalse("Is malformed", isMalformed(node));
+ }
}
protected boolean isMalformed(ASTNode node) {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index a920ae73d..7c27719ce 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Ray V. (voidstar@gmail.com) - Contribution for bug 282988
*******************************************************************************/
package org.eclipse.jdt.core.tests.formatter;
@@ -1242,7 +1243,8 @@ public void testBug198074_c1() throws JavaModelException {
"public class Test {\n" +
"\n" +
" String foo(boolean enabled) {\n" +
- " if (enabled) {\n" +
+ " if (enabled)\n" +
+ " {\n" +
" // we need x\n" +
" // we need a select\n" +
" return \"select x \"\n" +
@@ -1272,7 +1274,8 @@ public void testBug198074_c1b() throws JavaModelException {
"public class Test {\n" +
"\n" +
" String foo(boolean enabled) {\n" +
- " if (enabled) {\n" +
+ " if (enabled)\n" +
+ " {\n" +
" // we need x\n" +
" // we need a select\n" +
" return \"select x \"\n" +
@@ -1897,8 +1900,8 @@ public void testBug281655() throws JavaModelException {
formatSource(source,
"@MessageDriven(mappedName = \"filiality/SchedulerMQService\",\n" +
" activationConfig = {\n" +
- " @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" +
- " propertyValue = \"0/10 * * * * ?\")\n" +
+ " @ActivationConfigProperty(propertyName = \"cronTrigger\",\n" +
+ " propertyValue = \"0/10 * * * * ?\")\n" +
" })\n" +
"@RunAs(\"admin\")\n" +
"@ResourceAdapter(\"quartz-ra.rar\")\n" +
@@ -2621,8 +2624,10 @@ public void testBug286601() throws JavaModelException {
" }\n" +
"}\n";
formatSource(source,
- "public class Test {\n" +
- " public void aMethod() {\n" +
+ "public class Test\n" +
+ "{\n" +
+ " public void aMethod()\n" +
+ " {\n" +
" Object anObject = new Object()\n" +
" {\n" +
" boolean aVariable;\n" +
@@ -2689,8 +2694,10 @@ public void testBug286601c() {
" }\n" +
"}\n";
formatSource(source,
- "public class Test {\n" +
- " public void aMethod() {\n" +
+ "public class Test\n" +
+ "{\n" +
+ " public void aMethod()\n" +
+ " {\n" +
" Object anObject = new Object()\n" +
" {\n" +
" boolean aVariable;\n" +
@@ -2721,398 +2728,232 @@ public void testBug286601d() {
" }\n" +
"}\n";
formatSource(source,
- "public class Test {\n" +
- " public void aMethod() {\n" +
- " Object anObject = new Object() /* comment */\n" +
- " {\n" +
- " boolean aVariable;\n" +
- "\n" +
- " void foo() /* comment */\n" +
- " {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n"
- );
-}
-public void testBug286601e() {
- this.formatterPrefs.join_wrapped_lines = false;
- setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
- String source =
"public class Test\n" +
"{\n" +
- " public void build(String href) {\n" +
- " // set the href on the related topic\n" +
- " if (href == null)\n" +
- " setHref(\"\"); //$NON-NLS-1$\n" +
- " else {\n" +
- " if (!href.equals(\"\") // no empty link //$NON-NLS-1$\n" +
- " && !href.startsWith(\"/\") // no help url //$NON-NLS-1$\n" +
- " && href.indexOf(\':\') == -1) // no other protocols\n" +
- " {\n" +
- " setHref(\"/test/\" + href); //$NON-NLS-1$ //$NON-NLS-2$\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n";
- formatSource(source,
- "public class Test\n" +
- "{\n" +
- " public void build(String href)\n" +
+ " public void aMethod()\n" +
" {\n" +
- " // set the href on the related topic\n" +
- " if (href == null)\n" +
- " setHref(\"\"); //$NON-NLS-1$\n" +
- " else\n" +
+ " Object anObject = new Object() /* comment */\n" +
" {\n" +
- " if (!href.equals(\"\") // no empty link //$NON-NLS-1$\n" +
- " && !href.startsWith(\"/\") // no help url //$NON-NLS-1$\n" +
- " && href.indexOf(\':\') == -1) // no other protocols\n" +
- " {\n" +
- " setHref(\"/test/\" + href); //$NON-NLS-1$ //$NON-NLS-2$\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n"
- );
-}
-public void testBug286601f() {
- this.formatterPrefs.join_wrapped_lines = false;
- setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
- String source =
- "public class Test\n" +
- "{\n" +
- " \n" +
- " private AntModel getAntModel(final File buildFile) {\n" +
- " AntModel model= new AntModel(XMLCore.getDefault(), doc, null, new LocationProvider(null) {\n" +
- " /* (non-Javadoc)\n" +
- " * @see org.eclipse.ant.internal.ui.editor.outline.ILocationProvider#getLocation()\n" +
- " */\n" +
- " public IPath getLocation() {\n" +
- " return new Path(buildFile.getAbsolutePath());\n" +
- " }\n" +
- " });\n" +
- " model.reconcile(null);\n" +
- " return model;\n" +
- " }\n" +
- "}\n";
- formatSource(source,
- "public class Test\n" +
- "{\n" +
- "\n" +
- " private AntModel getAntModel(final File buildFile)\n" +
- " {\n" +
- " AntModel model = new AntModel(XMLCore.getDefault(), doc, null,\n" +
- " new LocationProvider(null)\n" +
- " {\n" +
- " /*\n" +
- " * (non-Javadoc)\n" +
- " * \n" +
- " * @see\n" +
- " * org.eclipse.ant.internal.ui.editor.outline.ILocationProvider\n" +
- " * #getLocation()\n" +
- " */\n" +
- " public IPath getLocation()\n" +
- " {\n" +
- " return new Path(buildFile.getAbsolutePath());\n" +
- " }\n" +
- " });\n" +
- " model.reconcile(null);\n" +
- " return model;\n" +
- " }\n" +
- "}\n"
- );
-}
-public void testBug286601g() {
- this.formatterPrefs.join_wrapped_lines = false;
- String source =
- "package massive;\n" +
- "\n" +
- "public class X05\n" +
- "{\n" +
- "\n" +
- " public void foo() throws NullPointerException {\n" +
- "\n" +
- " Object body = new Object() {\n" +
- " public void run(StringBuffer monitor) throws IllegalArgumentException {\n" +
- " IResourceVisitor visitor = new IResourceVisitor() {\n" +
- " public boolean visit(String resource) throws IllegalArgumentException {\n" +
- " return true;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "\n" +
- "}\n" +
- "interface IResourceVisitor {\n" +
- "}\n";
- formatSource(source,
- "package massive;\n" +
- "\n" +
- "public class X05 {\n" +
- "\n" +
- " public void foo() throws NullPointerException {\n" +
- "\n" +
- " Object body = new Object() {\n" +
- " public void run(StringBuffer monitor)\n" +
- " throws IllegalArgumentException {\n" +
- " IResourceVisitor visitor = new IResourceVisitor() {\n" +
- " public boolean visit(String resource)\n" +
- " throws IllegalArgumentException {\n" +
- " return true;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "\n" +
- "}\n" +
- "\n" +
- "interface IResourceVisitor {\n" +
- "}\n"
- );
-}
-public void testBug286601h() {
- this.formatterPrefs.join_wrapped_lines = false;
- setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
- String source =
- "package massive;\n" +
- "\n" +
- "public class X05\n" +
- "{\n" +
- "\n" +
- " public void foo() throws NullPointerException {\n" +
- "\n" +
- " Object body = new Object() {\n" +
- " public void run(StringBuffer monitor) throws IllegalArgumentException {\n" +
- " IResourceVisitor visitor = new IResourceVisitor() {\n" +
- " public boolean visit(String resource) throws IllegalArgumentException {\n" +
- " return true;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "\n" +
- "}\n" +
- "interface IResourceVisitor {\n" +
- "}\n";
- formatSource(source,
- "package massive;\n" +
- "\n" +
- "public class X05\n" +
- "{\n" +
- "\n" +
- " public void foo() throws NullPointerException\n" +
- " {\n" +
+ " boolean aVariable;\n" +
"\n" +
- " Object body = new Object()\n" +
- " {\n" +
- " public void run(StringBuffer monitor)\n" +
- " throws IllegalArgumentException\n" +
+ " void foo() /* comment */\n" +
" {\n" +
- " IResourceVisitor visitor = new IResourceVisitor()\n" +
- " {\n" +
- " public boolean visit(String resource)\n" +
- " throws IllegalArgumentException\n" +
- " {\n" +
- " return true;\n" +
- " }\n" +
- " };\n" +
" }\n" +
" };\n" +
" }\n" +
- "\n" +
- "}\n" +
- "\n" +
- "interface IResourceVisitor\n" +
- "{\n" +
- "}\n"
- );
-}
-public void testBug286601i1() {
- this.formatterPrefs.join_wrapped_lines = false;
- this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE;
- setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
- String source =
- "package massive;\n" +
- "\n" +
- "public class X06a {\n" +
- "\n" +
- " \n" +
- " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" +
- " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" +
- " /* Comment 1 */\n" +
- " /* Comment 2 */ { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" +
- " /* Comment 3 */ { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
- " };\n" +
- "\n" +
- "}\n";
- formatSource(source,
- "package massive;\n" +
- "\n" +
- "public class X06a\n" +
- "{\n" +
- "\n" +
- " // Table to merge access modes for condition statements (e.g branch[x] ||\n" +
- " // branch[y]).\n" +
- " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" +
- " {\n" +
- " /* Comment 1 */\n" +
- " /* Comment 2 */{ \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" +
- " /* Comment 3 */{ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
- " };\n" +
- "\n" +
"}\n"
);
}
-public void testBug286601i2() {
+public void testBug286601_massive_01() {
this.formatterPrefs.join_wrapped_lines = false;
- this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE;
- this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE;
setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
String source =
- "package massive;\n" +
- "\n" +
- "public class X06a {\n" +
- "\n" +
- " \n" +
- " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" +
- " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" +
- " /* Comment 1 */\n" +
- " /* Comment 2 */ { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" +
- " /* Comment 3 */ { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
- " };\n" +
- "\n" +
+ "package massive;\n" +
+ "public class X01 {\n" +
+ " public void build(String href) {\n" +
+ " // set the href on the related topic\n" +
+ " if (href == null)\n" +
+ " setHref(\"\"); //$NON-NLS-1$\n" +
+ " else {\n" +
+ " if (!href.equals(\"\") // no empty link //$NON-NLS-1$\n" +
+ " && !href.startsWith(\"/\") // no help url //$NON-NLS-1$\n" +
+ " && href.indexOf(\':\') == -1) // no other protocols\n" +
+ " {\n" +
+ " setHref(\"/test/\" + href); //$NON-NLS-1$ //$NON-NLS-2$\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " private void setHref(String string)\n" +
+ " {\n" +
+ " \n" +
+ " }\n" +
"}\n";
formatSource(source,
- "package massive;\n" +
- "\n" +
- "public class X06a\n" +
- "{\n" +
- "\n" +
- " // Table to merge access modes for condition statements (e.g branch[x] ||\n" +
- " // branch[y]).\n" +
- " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" +
- " {\n" +
- " /* Comment 1 */\n" +
- " /* Comment 2 */{ \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" +
- " /* Comment 3 */{ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
- " };\n" +
- "\n" +
+ "package massive;\n" +
+ "\n" +
+ "public class X01\n" +
+ "{\n" +
+ " public void build(String href)\n" +
+ " {\n" +
+ " // set the href on the related topic\n" +
+ " if (href == null)\n" +
+ " setHref(\"\"); //$NON-NLS-1$\n" +
+ " else\n" +
+ " {\n" +
+ " if (!href.equals(\"\") // no empty link //$NON-NLS-1$\n" +
+ " && !href.startsWith(\"/\") // no help url //$NON-NLS-1$\n" +
+ " && href.indexOf(\':\') == -1) // no other protocols\n" +
+ " {\n" +
+ " setHref(\"/test/\" + href); //$NON-NLS-1$ //$NON-NLS-2$\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " private void setHref(String string)\n" +
+ " {\n" +
+ "\n" +
+ " }\n" +
"}\n"
);
}
-public void testBug286601j1() {
+public void testBug286601_massive_02() {
this.formatterPrefs.join_wrapped_lines = false;
- this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE;
setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
String source =
- "package massive;\n" +
- "\n" +
- "public class X06b {\n" +
- "\n" +
- " \n" +
- " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" +
- " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" +
- " { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" +
- " { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
- " };\n" +
- "\n" +
+ "package massive;\n" +
+ "\n" +
+ "public class X02\n" +
+ "{\n" +
+ " \n" +
+ " private AntModel getAntModel(final File buildFile) {\n" +
+ " AntModel model= new AntModel(XMLCore.getDefault(), doc, null, new LocationProvider(null) {\n" +
+ " /* (non-Javadoc)\n" +
+ " * @see org.eclipse.ant.internal.ui.editor.outline.ILocationProvider#getLocation()\n" +
+ " */\n" +
+ " public IPath getLocation() {\n" +
+ " return new Path(buildFile.getAbsolutePath());\n" +
+ " }\n" +
+ " });\n" +
+ " model.reconcile(null);\n" +
+ " return model;\n" +
+ " }\n" +
"}\n";
formatSource(source,
- "package massive;\n" +
- "\n" +
- "public class X06b\n" +
- "{\n" +
- "\n" +
- " // Table to merge access modes for condition statements (e.g branch[x] ||\n" +
- " // branch[y]).\n" +
- " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" +
- " {\n" +
- " { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" +
- " { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
- " };\n" +
- "\n" +
+ "package massive;\n" +
+ "\n" +
+ "public class X02\n" +
+ "{\n" +
+ "\n" +
+ " private AntModel getAntModel(final File buildFile)\n" +
+ " {\n" +
+ " AntModel model = new AntModel(XMLCore.getDefault(), doc, null,\n" +
+ " new LocationProvider(null)\n" +
+ " {\n" +
+ " /*\n" +
+ " * (non-Javadoc)\n" +
+ " * \n" +
+ " * @see\n" +
+ " * org.eclipse.ant.internal.ui.editor.outline.ILocationProvider\n" +
+ " * #getLocation()\n" +
+ " */\n" +
+ " public IPath getLocation()\n" +
+ " {\n" +
+ " return new Path(buildFile.getAbsolutePath());\n" +
+ " }\n" +
+ " });\n" +
+ " model.reconcile(null);\n" +
+ " return model;\n" +
+ " }\n" +
"}\n"
);
}
-public void testBug286601j2() {
+public void testBug286601_massive_03() {
this.formatterPrefs.join_wrapped_lines = false;
- this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE;
- this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE;
- setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
String source =
- "package massive;\n" +
- "\n" +
- "public class X06b {\n" +
- "\n" +
- " \n" +
- " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" +
- " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" +
- " { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" +
- " { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
- " };\n" +
- "\n" +
+ "package massive;\n" +
+ "\n" +
+ "public class X03\n" +
+ "{\n" +
+ "\n" +
+ " public void foo() throws NullPointerException {\n" +
+ "\n" +
+ " Object body = new Object() {\n" +
+ " public void run(StringBuffer monitor) throws IllegalArgumentException {\n" +
+ " IResourceVisitor visitor = new IResourceVisitor() {\n" +
+ " public boolean visit(String resource) throws IllegalArgumentException {\n" +
+ " return true;\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "\n" +
+ "}\n" +
+ "interface IResourceVisitor {\n" +
"}\n";
formatSource(source,
- "package massive;\n" +
- "\n" +
- "public class X06b\n" +
- "{\n" +
- "\n" +
- " // Table to merge access modes for condition statements (e.g branch[x] ||\n" +
- " // branch[y]).\n" +
- " private static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" +
- " {\n" +
- " { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" +
- " { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
- " };\n" +
- "\n" +
+ "package massive;\n" +
+ "\n" +
+ "public class X03\n" +
+ "{\n" +
+ "\n" +
+ " public void foo() throws NullPointerException {\n" +
+ "\n" +
+ " Object body = new Object() {\n" +
+ " public void run(StringBuffer monitor)\n" +
+ " throws IllegalArgumentException {\n" +
+ " IResourceVisitor visitor = new IResourceVisitor() {\n" +
+ " public boolean visit(String resource)\n" +
+ " throws IllegalArgumentException {\n" +
+ " return true;\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "\n" +
+ "}\n" +
+ "\n" +
+ "interface IResourceVisitor {\n" +
"}\n"
);
}
-public void testBug286601k() {
+public void testBug286601_wksp_03b() {
this.formatterPrefs.join_wrapped_lines = false;
- this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE;
- this.formatterPrefs.alignment_for_expressions_in_array_initializer = DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE;
setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
String source =
- "package massive;\n" +
- "\n" +
- "public class X07 {\n" +
- " private MinimizedFileSystemElement selectFiles(final Object rootFileSystemObject, final IImportStructureProvider structureProvider) {\n" +
- "\n" +
- " BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {\n" +
- " public void run() {\n" +
- " //Create the root element from the supplied file system object\n" +
- " }\n" +
- " });\n" +
- "\n" +
- " return null;\n" +
- " }\n" +
+ "package massive;\n" +
+ "\n" +
+ "public class X03\n" +
+ "{\n" +
+ "\n" +
+ " public void foo() throws NullPointerException {\n" +
+ "\n" +
+ " Object body = new Object() {\n" +
+ " public void run(StringBuffer monitor) throws IllegalArgumentException {\n" +
+ " IResourceVisitor visitor = new IResourceVisitor() {\n" +
+ " public boolean visit(String resource) throws IllegalArgumentException {\n" +
+ " return true;\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "\n" +
+ "}\n" +
+ "interface IResourceVisitor {\n" +
"}\n";
formatSource(source,
- "package massive;\n" +
- "\n" +
- "public class X07\n" +
- "{\n" +
- " private MinimizedFileSystemElement selectFiles(\n" +
- " final Object rootFileSystemObject,\n" +
- " final IImportStructureProvider structureProvider)\n" +
- " {\n" +
- "\n" +
- " BusyIndicator.showWhile(getShell().getDisplay(), new Runnable()\n" +
- " {\n" +
- " public void run()\n" +
- " {\n" +
- " // Create the root element from the supplied file system object\n" +
- " }\n" +
- " });\n" +
- "\n" +
- " return null;\n" +
- " }\n" +
+ "package massive;\n" +
+ "\n" +
+ "public class X03\n" +
+ "{\n" +
+ "\n" +
+ " public void foo() throws NullPointerException\n" +
+ " {\n" +
+ "\n" +
+ " Object body = new Object()\n" +
+ " {\n" +
+ " public void run(StringBuffer monitor)\n" +
+ " throws IllegalArgumentException\n" +
+ " {\n" +
+ " IResourceVisitor visitor = new IResourceVisitor()\n" +
+ " {\n" +
+ " public boolean visit(String resource)\n" +
+ " throws IllegalArgumentException\n" +
+ " {\n" +
+ " return true;\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "\n" +
+ "}\n" +
+ "\n" +
+ "interface IResourceVisitor\n" +
+ "{\n" +
"}\n"
);
}
@@ -7019,14 +6860,14 @@ public void testBug313524_wksp1_02() throws JavaModelException {
" MessageFormat\n" +
" .format(InternalAntMessages\n" +
" .getString(\"InternalAntRunner.Buildfile__{0}_does_not_exist_!_1\"), //$NON-NLS-1$\n" +
- " new String[] { buildFile.getAbsolutePath() }));\n" +
+ " new String[] { buildFile.getAbsolutePath() }));\n" +
" }\n" +
" if (!buildFile.isFile()) {\n" +
" throw new BuildException(\n" +
" MessageFormat\n" +
" .format(InternalAntMessages\n" +
" .getString(\"InternalAntRunner.Buildfile__{0}_is_not_a_file_1\"), //$NON-NLS-1$\n" +
- " new String[] { buildFile.getAbsolutePath() }));\n" +
+ " new String[] { buildFile.getAbsolutePath() }));\n" +
" }\n" +
" }\n" +
"}\n"
@@ -7263,6 +7104,50 @@ public void testBug313524_wksp1_12() throws JavaModelException {
}
/**
+ * @bug 317039: [formatter] Code Formatter fails on inner class source indentation
+ * @test Ensure formatter is stable when 'Never Join Lines' preference is checked
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=317039"
+ */
+public void testBug317039_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "public class X01\n" +
+ " {\n" +
+ "\n" +
+ " public void innerThread()\n" +
+ " {\n" +
+ "\n" +
+ " new Thread(new Runnable()\n" +
+ " {\n" +
+ " @Override\n" +
+ " public void run()\n" +
+ " {\n" +
+ " // TODO Auto-generated method stub\n" +
+ " }\n" +
+ " }).start();\n" +
+ " }\n" +
+ " }\n";
+ formatSource(source,
+ "public class X01\n" +
+ "{\n" +
+ "\n" +
+ " public void innerThread()\n" +
+ " {\n" +
+ "\n" +
+ " new Thread(new Runnable()\n" +
+ " {\n" +
+ " @Override\n" +
+ " public void run()\n" +
+ " {\n" +
+ " // TODO Auto-generated method stub\n" +
+ " }\n" +
+ " }).start();\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+
+/**
* @bug 320754: [formatter] formatter:off/on tags does not work correctly
* @test Ensure disabling/enabling tags work properly around annotations
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=320754"
@@ -7628,4 +7513,2953 @@ public void testBug328362() throws Exception {
"}\n"
);
}
+
+/**
+ * @bug 330313: [formatter] 'Never join already wrapped lines' formatter option does correctly indent
+ * @test Ensure that indentation is correct when 'Never join already wrapped lines' is set
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=330313"
+ */
+public void testBug330313() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "public class Test {\n" +
+ " private void helper2(\n" +
+ " boolean[] booleans) {\n" +
+ " if (booleans[0]) {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "public class Test {\n" +
+ " private void helper2(\n" +
+ " boolean[] booleans) {\n" +
+ " if (booleans[0]) {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313a() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "public class Test {\n" +
+ " private void helper2(\n" +
+ " boolean[] booleans) {\n" +
+ " if (booleans[0]) {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source);
+}
+public void testBug330313b() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "public class Test {\n" +
+ " private void helper2(\n" +
+ " boolean[] booleans) {\n" +
+ " if (booleans[0]) {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "public class Test {\n" +
+ " private void helper2(\n" +
+ " boolean[] booleans) {\n" +
+ " if (booleans[0]) {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313c() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "public class Test {\n" +
+ " private void helper2(\n" +
+ "boolean[] booleans) {\n" +
+ " if (booleans[0]) {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "public class Test {\n" +
+ " private void helper2(\n" +
+ " boolean[] booleans) {\n" +
+ " if (booleans[0]) {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313d() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "public class Test {\n" +
+ " private void helper2(\n" +
+ " boolean[] booleans) {\n" +
+ " if (booleans[0]) {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "public class Test {\n" +
+ " private void helper2(\n" +
+ " boolean[] booleans) {\n" +
+ " if (booleans[0]) {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_regression_187a() {
+ String source =
+ "import java.io.File;\n" +
+ "\n" +
+ "public class RegressionTest_187 {\n" +
+ "\n" +
+ " private String createC42PDFCommandLine(String documentName) {\n" +
+ " return (Registry.getConvertToolPath() + File.separator +\n" +
+ " Registry.getConvertToolName() +\n" +
+ " \" -o \" + _workingDir + File.separator + documentName +\n" +
+ " \" -l \" + _workingDir + File.separator + _fileList);\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "import java.io.File;\n" +
+ "\n" +
+ "public class RegressionTest_187 {\n" +
+ "\n" +
+ " private String createC42PDFCommandLine(String documentName) {\n" +
+ " return (Registry.getConvertToolPath() + File.separator\n" +
+ " + Registry.getConvertToolName() + \" -o \" + _workingDir\n" +
+ " + File.separator + documentName + \" -l \" + _workingDir\n" +
+ " + File.separator + _fileList);\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_regression_187b() {
+ String source =
+ "import java.io.File;\n" +
+ "\n" +
+ "public class RegressionTest_187 {\n" +
+ "\n" +
+ " private String createC42PDFCommandLine(String documentName) {\n" +
+ " return (Registry.getConvertToolPath() + File.separator +\n" +
+ " Registry.getConvertToolName() +\n" +
+ " (\" -o \" + _workingDir + File.separator + documentName +\n" +
+ " (\" -l \" + _workingDir + File.separator + _fileList)));\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "import java.io.File;\n" +
+ "\n" +
+ "public class RegressionTest_187 {\n" +
+ "\n" +
+ " private String createC42PDFCommandLine(String documentName) {\n" +
+ " return (Registry.getConvertToolPath() + File.separator\n" +
+ " + Registry.getConvertToolName() + (\" -o \" + _workingDir\n" +
+ " + File.separator + documentName + (\" -l \" + _workingDir\n" +
+ " + File.separator + _fileList)));\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+//static { TESTS_PREFIX = "testBug330313_wksp1"; }
+public void testBug330313_wksp1_01_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ "\n" +
+ " protected String getPrefixFromDocument(String aDocumentText, int anOffset) {\n" +
+ " int startOfWordToken = anOffset;\n" +
+ " \n" +
+ " char token= \'a\';\n" +
+ " if (startOfWordToken > 0) {\n" +
+ " token= aDocumentText.charAt(startOfWordToken - 1);\n" +
+ " }\n" +
+ " \n" +
+ " while (startOfWordToken > 0 \n" +
+ " && (Character.isJavaIdentifierPart(token) \n" +
+ " || \'.\' == token\n" +
+ " || \'-\' == token\n" +
+ " || \';\' == token)\n" +
+ " && !(\'$\' == token)) {\n" +
+ " startOfWordToken--;\n" +
+ " if (startOfWordToken == 0) {\n" +
+ " break; //word goes right to the beginning of the doc\n" +
+ " }\n" +
+ " token= aDocumentText.charAt(startOfWordToken - 1);\n" +
+ " }\n" +
+ " return \"\";\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ "\n" +
+ " protected String getPrefixFromDocument(String aDocumentText, int anOffset) {\n" +
+ " int startOfWordToken = anOffset;\n" +
+ "\n" +
+ " char token = \'a\';\n" +
+ " if (startOfWordToken > 0) {\n" +
+ " token = aDocumentText.charAt(startOfWordToken - 1);\n" +
+ " }\n" +
+ "\n" +
+ " while (startOfWordToken > 0\n" +
+ " && (Character.isJavaIdentifierPart(token)\n" +
+ " || \'.\' == token\n" +
+ " || \'-\' == token\n" +
+ " || \';\' == token)\n" +
+ " && !(\'$\' == token)) {\n" +
+ " startOfWordToken--;\n" +
+ " if (startOfWordToken == 0) {\n" +
+ " break; // word goes right to the beginning of the doc\n" +
+ " }\n" +
+ " token = aDocumentText.charAt(startOfWordToken - 1);\n" +
+ " }\n" +
+ " return \"\";\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_02_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X02 {\n" +
+ " public void testMethod(String currentTokenVal,\n" +
+ " int[][] expectedTokenSequencesVal,\n" +
+ " String[] tokenImageVal\n" +
+ " )\n" +
+ " {\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X02 {\n" +
+ " public void testMethod(String currentTokenVal,\n" +
+ " int[][] expectedTokenSequencesVal,\n" +
+ " String[] tokenImageVal\n" +
+ " )\n" +
+ " {\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_03_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X03 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " if (declaringClass.isNestedType()){\n" +
+ " NestedTypeBinding nestedType = (NestedTypeBinding) declaringClass;\n" +
+ " this.scope.extraSyntheticArguments = nestedType.syntheticOuterLocalVariables();\n" +
+ " scope.computeLocalVariablePositions(// consider synthetic arguments if any\n" +
+ " nestedType.enclosingInstancesSlotSize + 1,\n" +
+ " codeStream);\n" +
+ " argSlotSize += nestedType.enclosingInstancesSlotSize;\n" +
+ " argSlotSize += nestedType.outerLocalVariablesSlotSize;\n" +
+ " } else {\n" +
+ " scope.computeLocalVariablePositions(1, codeStream);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X03 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " if (declaringClass.isNestedType()) {\n" +
+ " NestedTypeBinding nestedType = (NestedTypeBinding) declaringClass;\n" +
+ " this.scope.extraSyntheticArguments = nestedType\n" +
+ " .syntheticOuterLocalVariables();\n" +
+ " scope.computeLocalVariablePositions(// consider synthetic arguments\n" +
+ " // if any\n" +
+ " nestedType.enclosingInstancesSlotSize + 1,\n" +
+ " codeStream);\n" +
+ " argSlotSize += nestedType.enclosingInstancesSlotSize;\n" +
+ " argSlotSize += nestedType.outerLocalVariablesSlotSize;\n" +
+ " } else {\n" +
+ " scope.computeLocalVariablePositions(1, codeStream);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_04() {
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X04 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " for (;;) {\n" +
+ " if (act <= NUM_RULES) { // reduce action\n" +
+ " tempStackTop--;\n" +
+ " } else if (act < ACCEPT_ACTION || // shift action\n" +
+ " act > ERROR_ACTION) { // shift-reduce action\n" +
+ " if (indx == MAX_DISTANCE)\n" +
+ " return indx;\n" +
+ " indx++;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X04 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " for (;;) {\n" +
+ " if (act <= NUM_RULES) { // reduce action\n" +
+ " tempStackTop--;\n" +
+ " } else if (act < ACCEPT_ACTION || // shift action\n" +
+ " act > ERROR_ACTION) { // shift-reduce action\n" +
+ " if (indx == MAX_DISTANCE)\n" +
+ " return indx;\n" +
+ " indx++;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_04_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X04 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " for (;;) {\n" +
+ " if (act <= NUM_RULES) { // reduce action\n" +
+ " tempStackTop--;\n" +
+ " } else if (act < ACCEPT_ACTION || // shift action\n" +
+ " act > ERROR_ACTION) { // shift-reduce action\n" +
+ " if (indx == MAX_DISTANCE)\n" +
+ " return indx;\n" +
+ " indx++;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X04 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " for (;;) {\n" +
+ " if (act <= NUM_RULES) { // reduce action\n" +
+ " tempStackTop--;\n" +
+ " } else if (act < ACCEPT_ACTION || // shift action\n" +
+ " act > ERROR_ACTION) { // shift-reduce action\n" +
+ " if (indx == MAX_DISTANCE)\n" +
+ " return indx;\n" +
+ " indx++;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_05_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X05 {\n" +
+ "\n" +
+ " private void foo() {\n" +
+ " setBuildFileLocation.invoke(runner, new Object[] { buildFileLocation });\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X05\n" +
+ "{\n" +
+ "\n" +
+ " private void foo()\n" +
+ " {\n" +
+ " setBuildFileLocation.invoke(runner, new Object[]\n" +
+ " { buildFileLocation });\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_06_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X06 {\n" +
+ "\n" +
+ " public void foo(Object index) {\n" +
+ "\n" +
+ " try {\n" +
+ " index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/);\n" +
+ " }\n" +
+ " finally {}\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X06\n" +
+ "{\n" +
+ "\n" +
+ " public void foo(Object index)\n" +
+ " {\n" +
+ "\n" +
+ " try\n" +
+ " {\n" +
+ " index = this.manager.getIndexForUpdate(this.containerPath, true, /*\n" +
+ " * reuse\n" +
+ " * index\n" +
+ " * file\n" +
+ " */\n" +
+ " true /* create if none */);\n" +
+ " } finally\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_07() {
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X07 {\n" +
+ "\n" +
+ "static final long[] jjtoToken = {\n" +
+ " 0x7fbfecffL, \n" +
+ "};\n" +
+ "static final long[] jjtoSkip = {\n" +
+ " 0x400000L, \n" +
+ "};\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X07 {\n" +
+ "\n" +
+ " static final long[] jjtoToken = { 0x7fbfecffL, };\n" +
+ " static final long[] jjtoSkip = { 0x400000L, };\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_07_bnl() {
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X07 {\n" +
+ "\n" +
+ "static final long[] jjtoToken = {\n" +
+ " 0x7fbfecffL, \n" +
+ "};\n" +
+ "static final long[] jjtoSkip = {\n" +
+ " 0x400000L, \n" +
+ "};\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X07\n" +
+ "{\n" +
+ "\n" +
+ " static final long[] jjtoToken =\n" +
+ " { 0x7fbfecffL, };\n" +
+ " static final long[] jjtoSkip =\n" +
+ " { 0x400000L, };\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_07_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X07 {\n" +
+ "\n" +
+ "static final long[] jjtoToken = {\n" +
+ " 0x7fbfecffL, \n" +
+ "};\n" +
+ "static final long[] jjtoSkip = {\n" +
+ " 0x400000L, \n" +
+ "};\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X07 {\n" +
+ "\n" +
+ " static final long[] jjtoToken = {\n" +
+ " 0x7fbfecffL,\n" +
+ " };\n" +
+ " static final long[] jjtoSkip = {\n" +
+ " 0x400000L,\n" +
+ " };\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_07_njl_bnl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X07 {\n" +
+ "\n" +
+ "static final long[] jjtoToken = {\n" +
+ " 0x7fbfecffL, \n" +
+ "};\n" +
+ "static final long[] jjtoSkip = {\n" +
+ " 0x400000L, \n" +
+ "};\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X07\n" +
+ "{\n" +
+ "\n" +
+ " static final long[] jjtoToken =\n" +
+ " {\n" +
+ " 0x7fbfecffL,\n" +
+ " };\n" +
+ " static final long[] jjtoSkip =\n" +
+ " {\n" +
+ " 0x400000L,\n" +
+ " };\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_08_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X08 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " MinimizedFileSystemElement dummyParent =\n" +
+ " new MinimizedFileSystemElement(\"\", null, true);//$NON-NLS-1$\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X08 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " MinimizedFileSystemElement dummyParent =\n" +
+ " new MinimizedFileSystemElement(\"\", null, true);//$NON-NLS-1$\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// testCompare1159_1: org.eclipse.debug.internal.ui.DebugUIPropertiesAdapterFactory
+public void testBug330313_wksp1_09_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X09 {\n" +
+ " public Class[] getAdapterList() {\n" +
+ " return new Class[] {\n" +
+ " IWorkbenchAdapter.class\n" +
+ " };\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X09 {\n" +
+ " public Class[] getAdapterList() {\n" +
+ " return new Class[] {\n" +
+ " IWorkbenchAdapter.class\n" +
+ " };\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// testCompare1723_1: org.eclipse.jdt.internal.compiler.ast.DoubleLiteral
+public void testBug330313_wksp1_10_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X10 {\n" +
+ "\n" +
+ "public void computeConstant() {\n" +
+ "\n" +
+ " if (true)\n" +
+ " { //only a true 0 can be made of zeros\n" +
+ " //2.00000000000000000e-324 is illegal .... \n" +
+ " }}\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X10 {\n" +
+ "\n" +
+ " public void computeConstant() {\n" +
+ "\n" +
+ " if (true)\n" +
+ " { // only a true 0 can be made of zeros\n" +
+ " // 2.00000000000000000e-324 is illegal ....\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// testCompare1794_1: org.eclipse.jdt.internal.compiler.ast.ClassFile
+public void testBug330313_wksp1_11_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X11 {\n" +
+ " X11() {\n" +
+ " accessFlags\n" +
+ " &= ~(\n" +
+ " AccStrictfp\n" +
+ " | AccProtected\n" +
+ " | AccPrivate\n" +
+ " | AccStatic\n" +
+ " | AccSynchronized\n" +
+ " | AccNative);\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X11 {\n" +
+ " X11() {\n" +
+ " accessFlags &= ~(\n" +
+ " AccStrictfp\n" +
+ " | AccProtected\n" +
+ " | AccPrivate\n" +
+ " | AccStatic\n" +
+ " | AccSynchronized\n" +
+ " | AccNative);\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// rg.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlFormatter.java
+public void testBug330313_wksp1_12() {
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X12 {\n" +
+ "\n" +
+ " private static Document createDocument(String string, Position[] positions) throws IllegalArgumentException {\n" +
+ " Document doc= new Document(string);\n" +
+ " try {\n" +
+ " if (positions != null) {\n" +
+ " doc.addPositionUpdater(new DefaultPositionUpdater(POS_CATEGORY) {\n" +
+ " protected boolean notDeleted() {\n" +
+ " if (fOffset < fPosition.offset && (fPosition.offset + fPosition.length < fOffset + fLength)) {\n" +
+ " return false;\n" +
+ " }\n" +
+ " return true;\n" +
+ " }\n" +
+ " });\n" +
+ " }\n" +
+ " } catch (BadPositionCategoryException cannotHappen) {\n" +
+ " // can not happen: category is correctly set up\n" +
+ " }\n" +
+ " return doc;\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X12 {\n" +
+ "\n" +
+ " private static Document createDocument(String string, Position[] positions)\n" +
+ " throws IllegalArgumentException {\n" +
+ " Document doc = new Document(string);\n" +
+ " try {\n" +
+ " if (positions != null) {\n" +
+ " doc.addPositionUpdater(new DefaultPositionUpdater(POS_CATEGORY) {\n" +
+ " protected boolean notDeleted() {\n" +
+ " if (fOffset < fPosition.offset\n" +
+ " && (fPosition.offset + fPosition.length < fOffset\n" +
+ " + fLength)) {\n" +
+ " return false;\n" +
+ " }\n" +
+ " return true;\n" +
+ " }\n" +
+ " });\n" +
+ " }\n" +
+ " } catch (BadPositionCategoryException cannotHappen) {\n" +
+ " // can not happen: category is correctly set up\n" +
+ " }\n" +
+ " return doc;\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_12_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X12 {\n" +
+ "\n" +
+ " private static Document createDocument(String string, Position[] positions) throws IllegalArgumentException {\n" +
+ " Document doc= new Document(string);\n" +
+ " try {\n" +
+ " if (positions != null) {\n" +
+ " doc.addPositionUpdater(new DefaultPositionUpdater(POS_CATEGORY) {\n" +
+ " protected boolean notDeleted() {\n" +
+ " if (fOffset < fPosition.offset && (fPosition.offset + fPosition.length < fOffset + fLength)) {\n" +
+ " return false;\n" +
+ " }\n" +
+ " return true;\n" +
+ " }\n" +
+ " });\n" +
+ " }\n" +
+ " } catch (BadPositionCategoryException cannotHappen) {\n" +
+ " // can not happen: category is correctly set up\n" +
+ " }\n" +
+ " return doc;\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X12 {\n" +
+ "\n" +
+ " private static Document createDocument(String string, Position[] positions)\n" +
+ " throws IllegalArgumentException {\n" +
+ " Document doc = new Document(string);\n" +
+ " try {\n" +
+ " if (positions != null) {\n" +
+ " doc.addPositionUpdater(new DefaultPositionUpdater(POS_CATEGORY) {\n" +
+ " protected boolean notDeleted() {\n" +
+ " if (fOffset < fPosition.offset\n" +
+ " && (fPosition.offset + fPosition.length < fOffset\n" +
+ " + fLength)) {\n" +
+ " return false;\n" +
+ " }\n" +
+ " return true;\n" +
+ " }\n" +
+ " });\n" +
+ " }\n" +
+ " } catch (BadPositionCategoryException cannotHappen) {\n" +
+ " // can not happen: category is correctly set up\n" +
+ " }\n" +
+ " return doc;\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from org.eclipse.ant.ui/org/eclipse/core/internal/dtree/NodeInfo.java
+public void testBug330313_wksp1_13() {
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X13 {\n" +
+ "\n" +
+ " public boolean isEmptyDelta() {\n" +
+ " return (this.getType() == AbstractDataTreeNode.T_NO_DATA_DELTA_NODE && this.getNamesOfChildren().length == 0 && this.getNamesOfDeletedChildren().length == 0);\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X13 {\n" +
+ "\n" +
+ " public boolean isEmptyDelta() {\n" +
+ " return (this.getType() == AbstractDataTreeNode.T_NO_DATA_DELTA_NODE\n" +
+ " && this.getNamesOfChildren().length == 0 && this\n" +
+ " .getNamesOfDeletedChildren().length == 0);\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_13_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X13 {\n" +
+ "\n" +
+ " public boolean isEmptyDelta() {\n" +
+ " return (this.getType() == AbstractDataTreeNode.T_NO_DATA_DELTA_NODE && this.getNamesOfChildren().length == 0 && this.getNamesOfDeletedChildren().length == 0);\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X13 {\n" +
+ "\n" +
+ " public boolean isEmptyDelta() {\n" +
+ " return (this.getType() == AbstractDataTreeNode.T_NO_DATA_DELTA_NODE\n" +
+ " && this.getNamesOfChildren().length == 0 && this\n" +
+ " .getNamesOfDeletedChildren().length == 0);\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from org.eclipse.jdt.core/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
+public void testBug330313_wksp1_14() {
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X14 {\n" +
+ " public void foo() {\n" +
+ " if (true) {\n" +
+ " if (((bits & DepthMASK) != 0)\n" +
+ " && (fieldBinding.isPrivate() // private access\n" +
+ " || (fieldBinding.isProtected() // implicit protected access\n" +
+ " && fieldBinding.declaringClass.getPackage() \n" +
+ " != currentScope.enclosingSourceType().getPackage()))) {\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X14 {\n" +
+ " public void foo() {\n" +
+ " if (true) {\n" +
+ " if (((bits & DepthMASK) != 0) && (fieldBinding.isPrivate() // private\n" +
+ " // access\n" +
+ " || (fieldBinding.isProtected() // implicit protected access\n" +
+ " && fieldBinding.declaringClass.getPackage() != currentScope\n" +
+ " .enclosingSourceType().getPackage()))) {\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_14_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X14 {\n" +
+ " public void foo() {\n" +
+ " if (true) {\n" +
+ " if (((bits & DepthMASK) != 0)\n" +
+ " && (fieldBinding.isPrivate() // private access\n" +
+ " || (fieldBinding.isProtected() // implicit protected access\n" +
+ " && fieldBinding.declaringClass.getPackage() \n" +
+ " != currentScope.enclosingSourceType().getPackage()))) {\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X14 {\n" +
+ " public void foo() {\n" +
+ " if (true) {\n" +
+ " if (((bits & DepthMASK) != 0)\n" +
+ " && (fieldBinding.isPrivate() // private access\n" +
+ " || (fieldBinding.isProtected() // implicit protected access\n" +
+ " && fieldBinding.declaringClass.getPackage()\n" +
+ " != currentScope.enclosingSourceType().getPackage()))) {\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from org.eclipse.jdt.core/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
+public void testBug330313_wksp1_15_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X15 {\n" +
+ " public void foo() {\n" +
+ " if (true) {\n" +
+ " if (fieldBinding.declaringClass != this.actualReceiverType\n" +
+ " && !this.actualReceiverType.isArrayType() \n" +
+ " && fieldBinding.declaringClass != null\n" +
+ " && fieldBinding.constant == NotAConstant\n" +
+ " && ((currentScope.environment().options.targetJDK >= ClassFileConstants.JDK1_2 \n" +
+ " && !fieldBinding.isStatic()\n" +
+ " && fieldBinding.declaringClass.id != T_Object) // no change for Object fields (if there was any)\n" +
+ " || !fieldBinding.declaringClass.canBeSeenBy(currentScope))){\n" +
+ " this.codegenBinding = currentScope.enclosingSourceType().getUpdatedFieldBinding(fieldBinding, (ReferenceBinding)this.actualReceiverType);\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X15 {\n" +
+ " public void foo() {\n" +
+ " if (true) {\n" +
+ " if (fieldBinding.declaringClass != this.actualReceiverType\n" +
+ " && !this.actualReceiverType.isArrayType()\n" +
+ " && fieldBinding.declaringClass != null\n" +
+ " && fieldBinding.constant == NotAConstant\n" +
+ " && ((currentScope.environment().options.targetJDK >= ClassFileConstants.JDK1_2\n" +
+ " && !fieldBinding.isStatic()\n" +
+ " && fieldBinding.declaringClass.id != T_Object) // no\n" +
+ " // change\n" +
+ " // for\n" +
+ " // Object\n" +
+ " // fields\n" +
+ " // (if\n" +
+ " // there\n" +
+ " // was\n" +
+ " // any)\n" +
+ " || !fieldBinding.declaringClass\n" +
+ " .canBeSeenBy(currentScope))) {\n" +
+ " this.codegenBinding = currentScope.enclosingSourceType()\n" +
+ " .getUpdatedFieldBinding(fieldBinding,\n" +
+ " (ReferenceBinding) this.actualReceiverType);\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case 1941_1 (extracted from org.eclipse.jdt.core/org/eclipse/jdt/internal/compiler/ast/Parser.java)
+public void testBug330313_wksp1_16() {
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X16 {\n" +
+ "void foo() {\n" +
+ " // recovery\n" +
+ " if (this.currentElement != null) {\n" +
+ " if (!(this.currentElement instanceof RecoveredType)\n" +
+ " && (this.currentToken == TokenNameDOT\n" +
+ " //|| declaration.modifiers != 0\n" +
+ " || (this.scanner.getLineNumber(declaration.type.sourceStart)\n" +
+ " != this.scanner.getLineNumber((int) (namePosition >>> 32))))){\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X16 {\n" +
+ " void foo() {\n" +
+ " // recovery\n" +
+ " if (this.currentElement != null) {\n" +
+ " if (!(this.currentElement instanceof RecoveredType)\n" +
+ " && (this.currentToken == TokenNameDOT\n" +
+ " // || declaration.modifiers != 0\n" +
+ " || (this.scanner\n" +
+ " .getLineNumber(declaration.type.sourceStart) != this.scanner\n" +
+ " .getLineNumber((int) (namePosition >>> 32))))) {\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_16_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X16 {\n" +
+ "void foo() {\n" +
+ " // recovery\n" +
+ " if (this.currentElement != null) {\n" +
+ " if (!(this.currentElement instanceof RecoveredType)\n" +
+ " && (this.currentToken == TokenNameDOT\n" +
+ " //|| declaration.modifiers != 0\n" +
+ " || (this.scanner.getLineNumber(declaration.type.sourceStart)\n" +
+ " != this.scanner.getLineNumber((int) (namePosition >>> 32))))){\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X16 {\n" +
+ " void foo() {\n" +
+ " // recovery\n" +
+ " if (this.currentElement != null) {\n" +
+ " if (!(this.currentElement instanceof RecoveredType)\n" +
+ " && (this.currentToken == TokenNameDOT\n" +
+ " // || declaration.modifiers != 0\n" +
+ " || (this.scanner\n" +
+ " .getLineNumber(declaration.type.sourceStart)\n" +
+ " != this.scanner\n" +
+ " .getLineNumber((int) (namePosition >>> 32))))) {\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case 1872_1 (extracted from org.eclipse.jdt.core/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java)
+public void testBug330313_wksp1_17_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X17 {\n" +
+ " void foo() {\n" +
+ " if ((currentMethodScope = this.methodScope())\n" +
+ " != outerLocalVariable.declaringScope.methodScope()) {\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X17 {\n" +
+ " void foo() {\n" +
+ " if ((currentMethodScope = this.methodScope())\n" +
+ " != outerLocalVariable.declaringScope.methodScope()) {\n" +
+ " return;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case 1964_1 (extracted from org.eclipse.jdt.core/org/eclipse/jdt/core/dom/ASTMatcher.java)
+public void testBug330313_wksp1_18_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X18 {\n" +
+ " public boolean foo() {\n" +
+ " return (\n" +
+ " safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())\n" +
+ " && safeSubtreeListMatch(node.modifiers(), o.modifiers())\n" +
+ " && safeSubtreeMatch(node.getName(), o.getName())\n" +
+ " && safeSubtreeListMatch(node.arguments(), o.arguments())\n" +
+ " && safeSubtreeListMatch(\n" +
+ " node.bodyDeclarations(),\n" +
+ " o.bodyDeclarations()));\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X18 {\n" +
+ " public boolean foo() {\n" +
+ " return (safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())\n" +
+ " && safeSubtreeListMatch(node.modifiers(), o.modifiers())\n" +
+ " && safeSubtreeMatch(node.getName(), o.getName())\n" +
+ " && safeSubtreeListMatch(node.arguments(), o.arguments())\n" +
+ " && safeSubtreeListMatch(\n" +
+ " node.bodyDeclarations(),\n" +
+ " o.bodyDeclarations()));\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_19_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X19 {\n" +
+ " public boolean foo() {\n" +
+ " return (\n" +
+ " safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())\n" +
+ " && safeSubtreeListMatch(node.modifiers(), o.modifiers())\n" +
+ " && safeSubtreeMatch(node.getName(), o.getName())\n" +
+ " && safeSubtreeListMatch(node.superInterfaceTypes(), o.superInterfaceTypes())\n" +
+ " && safeSubtreeListMatch(\n" +
+ " node.bodyDeclarations(),\n" +
+ " o.bodyDeclarations()));\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X19 {\n" +
+ " public boolean foo() {\n" +
+ " return (safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())\n" +
+ " && safeSubtreeListMatch(node.modifiers(), o.modifiers())\n" +
+ " && safeSubtreeMatch(node.getName(), o.getName())\n" +
+ " && safeSubtreeListMatch(node.superInterfaceTypes(),\n" +
+ " o.superInterfaceTypes())\n" +
+ " && safeSubtreeListMatch(\n" +
+ " node.bodyDeclarations(),\n" +
+ " o.bodyDeclarations()));\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractDebugView.java
+public void testBug330313_wksp1_20_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X20 {\n" +
+ "\n" +
+ " static final String decode(String entity) {\n" +
+ " if (true) {\n" +
+ " if (entity.charAt(2) == \'X\' || entity.charAt(2) == \'x\') {\n" +
+ " }\n" +
+ " Character c =\n" +
+ " new Character((char)Integer.parseInt(entity.substring(start), radix));\n" +
+ " return c.toString();\n" +
+ " }\n" +
+ " return \"\";\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X20 {\n" +
+ "\n" +
+ " static final String decode(String entity) {\n" +
+ " if (true) {\n" +
+ " if (entity.charAt(2) == \'X\' || entity.charAt(2) == \'x\') {\n" +
+ " }\n" +
+ " Character c =\n" +
+ " new Character((char) Integer.parseInt(\n" +
+ " entity.substring(start), radix));\n" +
+ " return c.toString();\n" +
+ " }\n" +
+ " return \"\";\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from org.apache.lucene/src/org/apache/lucene/demo/html/Entities.java
+public void testBug330313_wksp1_21_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X21 {\n" +
+ " public boolean isAvailable() {\n" +
+ " return !(getViewer() == null || getViewer().getControl() == null || getViewer().getControl().isDisposed());\n" +
+ " } \n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X21 {\n" +
+ " public boolean isAvailable() {\n" +
+ " return !(getViewer() == null || getViewer().getControl() == null || getViewer()\n" +
+ " .getControl().isDisposed());\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from differences noticed with patch v27.txt
+public void testBug330313_wksp1_22_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X22 {\n" +
+ " public boolean foo() {\n" +
+ " return (\n" +
+ " (node.isInterface() == o.isInterface())\n" +
+ " && safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())\n" +
+ " && safeSubtreeMatch(node.getName(), o.getName())\n" +
+ " && safeSubtreeListMatch(node.bodyDeclarations(), o.bodyDeclarations()));\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X22 {\n" +
+ " public boolean foo() {\n" +
+ " return ((node.isInterface() == o.isInterface())\n" +
+ " && safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())\n" +
+ " && safeSubtreeMatch(node.getName(), o.getName())\n" +
+ " && safeSubtreeListMatch(node.bodyDeclarations(),\n" +
+ " o.bodyDeclarations()));\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_23_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X23 {\n" +
+ " void foo() {\n" +
+ " boolean wasError = IMarker.SEVERITY_ERROR\n" +
+ " == pb.getAttribute(IMarker.SEVERITY,\n" +
+ " IMarker.SEVERITY_ERROR);\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source );
+}
+public void testBug330313_wksp1_24_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X24 {\n" +
+ "\n" +
+ " protected boolean canRunEvaluation() {\n" +
+ " // NOTE similar to #canStep, except a quiet suspend state is OK\n" +
+ " try {\n" +
+ " return isSuspendedQuiet() || (isSuspended()\n" +
+ " && !(isPerformingEvaluation() || isInvokingMethod())\n" +
+ " && !isStepping()\n" +
+ " && getTopStackFrame() != null\n" +
+ " && !getJavaDebugTarget().isPerformingHotCodeReplace());\n" +
+ " } catch (DebugException e) {\n" +
+ " return false;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source );
+}
+public void testBug330313_wksp1_25_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X25 {\n" +
+ "\n" +
+ " void unloadIcon(ImageData icon) {\n" +
+ " int sizeImage = (((icon.width * icon.depth + 31) / 32 * 4) +\n" +
+ " ((icon.width + 31) / 32 * 4)) * icon.height;\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source );
+}
+public void testBug330313_wksp1_26_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X26 {\n" +
+ "\n" +
+ "void foo() {\n" +
+ " for (int i = 0; i < data.length; i++) {\n" +
+ " byte s = data[i];\n" +
+ " sourceData[i] = (byte)(((s & 0x80) >> 7) |\n" +
+ " ((s & 0x40) >> 5) |\n" +
+ " ((s & 0x20) >> 3) |\n" +
+ " ((s & 0x10) >> 1) |\n" +
+ " ((s & 0x08) << 1) |\n" +
+ " ((s & 0x04) << 3) |\n" +
+ " ((s & 0x02) << 5) |\n" +
+ " ((s & 0x01) << 7));\n" +
+ " }\n" +
+ "}\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X26 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " for (int i = 0; i < data.length; i++) {\n" +
+ " byte s = data[i];\n" +
+ " sourceData[i] = (byte) (((s & 0x80) >> 7) |\n" +
+ " ((s & 0x40) >> 5) |\n" +
+ " ((s & 0x20) >> 3) |\n" +
+ " ((s & 0x10) >> 1) |\n" +
+ " ((s & 0x08) << 1) |\n" +
+ " ((s & 0x04) << 3) |\n" +
+ " ((s & 0x02) << 5) |\n" +
+ " ((s & 0x01) << 7));\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_27_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X27 {\n" +
+ " private void foo() {\n" +
+ "\n" +
+ " if (_VerificationResult.getVerificationCode()\n" +
+ " == IVerificationResult.TYPE_ENTRY_SIGNED_UNRECOGNIZED\n" +
+ " || _VerificationResult.getVerificationCode()\n" +
+ " == IVerificationResult.TYPE_ENTRY_SIGNED_RECOGNIZED) {\n" +
+ " // Group box\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X27 {\n" +
+ " private void foo() {\n" +
+ "\n" +
+ " if (_VerificationResult.getVerificationCode()\n" +
+ " == IVerificationResult.TYPE_ENTRY_SIGNED_UNRECOGNIZED\n" +
+ " || _VerificationResult.getVerificationCode()\n" +
+ " == IVerificationResult.TYPE_ENTRY_SIGNED_RECOGNIZED) {\n" +
+ " // Group box\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_28_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X28 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " if (fieldBinding.declaringClass != lastReceiverType\n" +
+ " && !lastReceiverType.isArrayType() \n" +
+ " && fieldBinding.declaringClass != null\n" +
+ " && fieldBinding.constant == NotAConstant\n" +
+ " && ((currentScope.environment().options.targetJDK >= ClassFileConstants.JDK1_2\n" +
+ " && (fieldBinding != this.binding || this.indexOfFirstFieldBinding > 1 || !fieldBinding.isStatic())\n" +
+ " && fieldBinding.declaringClass.id != T_Object)\n" +
+ " || !(useDelegate\n" +
+ " ? new CodeSnippetScope(currentScope).canBeSeenByForCodeSnippet(fieldBinding.declaringClass, (ReferenceBinding) this.delegateThis.type)\n" +
+ " : fieldBinding.declaringClass.canBeSeenBy(currentScope)))){\n" +
+ " // code\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X28 {\n" +
+ "\n" +
+ " void foo() {\n" +
+ " if (fieldBinding.declaringClass != lastReceiverType\n" +
+ " && !lastReceiverType.isArrayType()\n" +
+ " && fieldBinding.declaringClass != null\n" +
+ " && fieldBinding.constant == NotAConstant\n" +
+ " && ((currentScope.environment().options.targetJDK >= ClassFileConstants.JDK1_2\n" +
+ " && (fieldBinding != this.binding\n" +
+ " || this.indexOfFirstFieldBinding > 1 || !fieldBinding\n" +
+ " .isStatic())\n" +
+ " && fieldBinding.declaringClass.id != T_Object)\n" +
+ " || !(useDelegate\n" +
+ " ? new CodeSnippetScope(currentScope)\n" +
+ " .canBeSeenByForCodeSnippet(\n" +
+ " fieldBinding.declaringClass,\n" +
+ " (ReferenceBinding) this.delegateThis.type)\n" +
+ " : fieldBinding.declaringClass\n" +
+ " .canBeSeenBy(currentScope)))) {\n" +
+ " // code\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_29_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X29 {\n" +
+ "\n" +
+ " boolean foo() {\n" +
+ " return (pack != null && otherpack != null && isSamePackage(pack, otherpack));\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X29 {\n" +
+ "\n" +
+ " boolean foo() {\n" +
+ " return (pack != null && otherpack != null && isSamePackage(pack,\n" +
+ " otherpack));\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_30_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X30 {\n" +
+ " private boolean isInTypeNestedInInputType(ASTNode node, TypeDeclaration inputType){\n" +
+ " return (isInAnonymousTypeInsideInputType(node, inputType) ||\n" +
+ " isInLocalTypeInsideInputType(node, inputType) ||\n" +
+ " isInNonStaticMemberTypeInsideInputType(node, inputType));\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X30 {\n" +
+ " private boolean isInTypeNestedInInputType(ASTNode node,\n" +
+ " TypeDeclaration inputType) {\n" +
+ " return (isInAnonymousTypeInsideInputType(node, inputType) ||\n" +
+ " isInLocalTypeInsideInputType(node, inputType) || isInNonStaticMemberTypeInsideInputType(\n" +
+ " node, inputType));\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_31_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X31 {\n" +
+ " void foo(int i) {\n" +
+ " if (true) {\n" +
+ " switch (i) {\n" +
+ " case 0:\n" +
+ " if (!((offset == (hashable.length - 1)) && !has95 && hasOneOf(meta63, hashable, offset - 2, 2) && !hasOneOf(meta64, hashable, offset - 4, 2)))\n" +
+ " buffer.append(\'R\');\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X31 {\n" +
+ " void foo(int i) {\n" +
+ " if (true) {\n" +
+ " switch (i) {\n" +
+ " case 0:\n" +
+ " if (!((offset == (hashable.length - 1)) && !has95\n" +
+ " && hasOneOf(meta63, hashable, offset - 2, 2) && !hasOneOf(\n" +
+ " meta64, hashable, offset - 4, 2)))\n" +
+ " buffer.append(\'R\');\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_32_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X32 {\n" +
+ " public boolean equals(Object object) {\n" +
+ " TextAttribute a= (TextAttribute) object;\n" +
+ " return (a.style == style && equals(a.foreground, foreground) && equals(a.background, background));\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X32 {\n" +
+ " public boolean equals(Object object) {\n" +
+ " TextAttribute a = (TextAttribute) object;\n" +
+ " return (a.style == style && equals(a.foreground, foreground) && equals(\n" +
+ " a.background, background));\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from differences noticed with patch v29.txt
+public void testBug330313_wksp1_33() {
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X33 {\n" +
+ " void foo() {\n" +
+ " if(inMetaTag &&\n" +
+ " ( t1.image.equalsIgnoreCase(\"name\") ||\n" +
+ " t1.image.equalsIgnoreCase(\"HTTP-EQUIV\")\n" +
+ " )\n" +
+ " && t2 != null)\n" +
+ " {\n" +
+ " currentMetaTag=t2.image.toLowerCase();\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X33 {\n" +
+ " void foo() {\n" +
+ " if (inMetaTag\n" +
+ " && (t1.image.equalsIgnoreCase(\"name\") || t1.image\n" +
+ " .equalsIgnoreCase(\"HTTP-EQUIV\")) && t2 != null) {\n" +
+ " currentMetaTag = t2.image.toLowerCase();\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_33_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X33 {\n" +
+ " void foo() {\n" +
+ " if(inMetaTag &&\n" +
+ " ( t1.image.equalsIgnoreCase(\"name\") ||\n" +
+ " t1.image.equalsIgnoreCase(\"HTTP-EQUIV\")\n" +
+ " )\n" +
+ " && t2 != null)\n" +
+ " {\n" +
+ " currentMetaTag=t2.image.toLowerCase();\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X33 {\n" +
+ " void foo() {\n" +
+ " if (inMetaTag &&\n" +
+ " (t1.image.equalsIgnoreCase(\"name\") ||\n" +
+ " t1.image.equalsIgnoreCase(\"HTTP-EQUIV\")\n" +
+ " )\n" +
+ " && t2 != null)\n" +
+ " {\n" +
+ " currentMetaTag = t2.image.toLowerCase();\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_34_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X34 {\n" +
+ " private boolean compareMarkers(ResourceInfo oldElement, ResourceInfo newElement) {\n" +
+ " boolean bothNull = oldElement.getMarkers(false) == null && newElement.getMarkers(false) == null;\n" +
+ " return bothNull || oldElement.getMarkerGenerationCount() == newElement.getMarkerGenerationCount();\n" +
+ " }\n" +
+ " private boolean compareSync(ResourceInfo oldElement, ResourceInfo newElement) {\n" +
+ " return oldElement.getSyncInfoGenerationCount() == newElement.getSyncInfoGenerationCount();\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X34 {\n" +
+ " private boolean compareMarkers(ResourceInfo oldElement,\n" +
+ " ResourceInfo newElement) {\n" +
+ " boolean bothNull = oldElement.getMarkers(false) == null\n" +
+ " && newElement.getMarkers(false) == null;\n" +
+ " return bothNull\n" +
+ " || oldElement.getMarkerGenerationCount() == newElement\n" +
+ " .getMarkerGenerationCount();\n" +
+ " }\n" +
+ "\n" +
+ " private boolean compareSync(ResourceInfo oldElement, ResourceInfo newElement) {\n" +
+ " return oldElement.getSyncInfoGenerationCount() == newElement\n" +
+ " .getSyncInfoGenerationCount();\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from differences noticed with patch v30.txt
+public void testBug330313_wksp1_35_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X35 {\n" +
+ " void foo() {\n" +
+ " if (true) {\n" +
+ " if (20+lineNum*printGC.getFontMetrics().getHeight() > printer.getClientArea().height) {\n" +
+ " //\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X35 {\n" +
+ " void foo() {\n" +
+ " if (true) {\n" +
+ " if (20 + lineNum * printGC.getFontMetrics().getHeight() > printer\n" +
+ " .getClientArea().height) {\n" +
+ " //\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from differences noticed with patch v32.txt
+public void testBug330313_wksp1_36_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X36 {\n" +
+ " public static boolean isRuntimeException(ITypeBinding thrownException) {\n" +
+ " if (thrownException == null || thrownException.isPrimitive() || thrownException.isArray())\n" +
+ " return false;\n" +
+ " return findTypeInHierarchy(thrownException, \"java.lang.RuntimeException\") != null; //$NON-NLS-1$\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X36 {\n" +
+ " public static boolean isRuntimeException(ITypeBinding thrownException) {\n" +
+ " if (thrownException == null || thrownException.isPrimitive()\n" +
+ " || thrownException.isArray())\n" +
+ " return false;\n" +
+ " return findTypeInHierarchy(thrownException,\n" +
+ " \"java.lang.RuntimeException\") != null; //$NON-NLS-1$\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_37_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X37 {\n" +
+ " void foo() {\n" +
+ " if (true) {\n" +
+ " if (ignoreQuickDiffPrefPage && (info.getAnnotationType().equals(\"org.eclipse.ui.workbench.texteditor.quickdiffChange\") //$NON-NLS-1$\n" +
+ " || (info.getAnnotationType().equals(\"org.eclipse.ui.workbench.texteditor.quickdiffAddition\")) //$NON-NLS-1$\n" +
+ " || (info.getAnnotationType().equals(\"org.eclipse.ui.workbench.texteditor.quickdiffDeletion\")) //$NON-NLS-1$\n" +
+ " )) \n" +
+ " continue;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X37 {\n" +
+ " void foo() {\n" +
+ " if (true) {\n" +
+ " if (ignoreQuickDiffPrefPage\n" +
+ " && (info.getAnnotationType()\n" +
+ " .equals(\"org.eclipse.ui.workbench.texteditor.quickdiffChange\") //$NON-NLS-1$\n" +
+ " || (info.getAnnotationType()\n" +
+ " .equals(\"org.eclipse.ui.workbench.texteditor.quickdiffAddition\")) //$NON-NLS-1$\n" +
+ " || (info.getAnnotationType()\n" +
+ " .equals(\"org.eclipse.ui.workbench.texteditor.quickdiffDeletion\")) //$NON-NLS-1$\n" +
+ " ))\n" +
+ " continue;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Test case extracted from differences noticed with patch v33.txt
+public void testBug330313_wksp1_38_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X38 {\n" +
+ " void foo(boolean condition) {\n" +
+ " if (condition)\n" +
+ " {\n" +
+ " // block 1\n" +
+ " }\n" +
+ " else\n" +
+ " {\n" +
+ " // block 2\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source );
+}
+public void testBug330313_wksp1_39_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X39 {\n" +
+ "/**\n" +
+ " * <pre>\n" +
+ " * RadioGroupFieldEditor editor= new RadioGroupFieldEditor(\n" +
+ " * \"GeneralPage.DoubleClick\", resName, 1,\n" +
+ " * new String[][] {\n" +
+ " * {\"Open Browser\", \"open\"},\n" +
+ " * {\"Expand Tree\", \"expand\"}\n" +
+ " * },\n" +
+ " * parent); \n" +
+ " * </pre>\n" +
+ " */\n" +
+ "public void foo() {\n" +
+ "}\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X39 {\n" +
+ " /**\n" +
+ " * <pre>\n" +
+ " * RadioGroupFieldEditor editor = new RadioGroupFieldEditor(\n" +
+ " * &quot;GeneralPage.DoubleClick&quot;, resName, 1,\n" +
+ " * new String[][] {\n" +
+ " * { &quot;Open Browser&quot;, &quot;open&quot; },\n" +
+ " * { &quot;Expand Tree&quot;, &quot;expand&quot; }\n" +
+ " * },\n" +
+ " * parent);\n" +
+ " * </pre>\n" +
+ " */\n" +
+ " public void foo() {\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_40_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X40 {\n" +
+ " protected final static String[][] TABLE= new String[][] {\n" +
+ " /*INACTIVE*/ /*PARTLY_ACTIVE */ /*ACTIVE */\n" +
+ " /* INACTIVE */ { \"INACTIVE\", \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\" },\n" +
+ " /* PARTLY_ACTIVE*/ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\" },\n" +
+ " /* ACTIVE */ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\", \"ACTIVE\"}\n" +
+ " };\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X40 {\n" +
+ " protected final static String[][] TABLE = new String[][] {\n" +
+ " /* INACTIVE *//* PARTLY_ACTIVE *//* ACTIVE */\n" +
+ " /* INACTIVE */{ \"INACTIVE\", \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\" },\n" +
+ " /* PARTLY_ACTIVE */{ \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\",\n" +
+ " \"PARTLY_ACTIVE\" },\n" +
+ " /* ACTIVE */{ \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\", \"ACTIVE\" }\n" +
+ " };\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_41_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X41 {\n" +
+ " static final int [][] TABLE = {\n" +
+ " \n" +
+ " /* First */\n" +
+ " {1, 2},\n" +
+ " {3, 4},\n" +
+ " {5, 6},\n" +
+ "// {7????, 8},\n" +
+ "\n" +
+ " /* Second */ \n" +
+ "// {11, 12},\n" +
+ "// {13, 14},\n" +
+ "// {15, 16},\n" +
+ " \n" +
+ " \n" +
+ " /* Third */\n" +
+ " {21, 22},\n" +
+ " {23, 24},\n" +
+ " {25, 26},\n" +
+ "// {27????, 28},\n" +
+ "\n" +
+ " /* Others */\n" +
+ " {31, 32},\n" +
+ " {33, 34},\n" +
+ " {35, 36},\n" +
+ "// {37????, 38},\n" +
+ " \n" +
+ " };\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X41 {\n" +
+ " static final int[][] TABLE = {\n" +
+ "\n" +
+ " /* First */\n" +
+ " { 1, 2 },\n" +
+ " { 3, 4 },\n" +
+ " { 5, 6 },\n" +
+ " // {7????, 8},\n" +
+ "\n" +
+ " /* Second */\n" +
+ " // {11, 12},\n" +
+ " // {13, 14},\n" +
+ " // {15, 16},\n" +
+ "\n" +
+ " /* Third */\n" +
+ " { 21, 22 },\n" +
+ " { 23, 24 },\n" +
+ " { 25, 26 },\n" +
+ " // {27????, 28},\n" +
+ "\n" +
+ " /* Others */\n" +
+ " { 31, 32 },\n" +
+ " { 33, 34 },\n" +
+ " { 35, 36 },\n" +
+ " // {37????, 38},\n" +
+ "\n" +
+ " };\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_42_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X42 {\n" +
+ " static final byte[][] DashList = {\n" +
+ " { }, // SWT.LINE_SOLID\n" +
+ " { 10, 4 }, // SWT.LINE_DASH\n" +
+ " { 2, 2 }, // SWT.LINE_DOT\n" +
+ " { 10, 4, 2, 4 }, // SWT.LINE_DASHDOT\n" +
+ " { 10, 4, 2, 4, 2, 4 } // SWT.LINE_DASHDOTDOT\n" +
+ " };\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X42 {\n" +
+ " static final byte[][] DashList = {\n" +
+ " {}, // SWT.LINE_SOLID\n" +
+ " { 10, 4 }, // SWT.LINE_DASH\n" +
+ " { 2, 2 }, // SWT.LINE_DOT\n" +
+ " { 10, 4, 2, 4 }, // SWT.LINE_DASHDOT\n" +
+ " { 10, 4, 2, 4, 2, 4 } // SWT.LINE_DASHDOTDOT\n" +
+ " };\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_43_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X43 {\n" +
+ " Cloneable clone;\n" +
+ "X43() {\n" +
+ " this.clone = new Cloneable() {\n" +
+ " void foo(int x) {\n" +
+ " switch (x) {\n" +
+ " case 1:\n" +
+ " case 2:\n" +
+ " if (true) break;\n" +
+ " // FALL THROUGH\n" +
+ " case 3:\n" +
+ " case 4:\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ " };\n" +
+ "}\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X43 {\n" +
+ " Cloneable clone;\n" +
+ "\n" +
+ " X43() {\n" +
+ " this.clone = new Cloneable() {\n" +
+ " void foo(int x) {\n" +
+ " switch (x) {\n" +
+ " case 1:\n" +
+ " case 2:\n" +
+ " if (true)\n" +
+ " break;\n" +
+ " // FALL THROUGH\n" +
+ " case 3:\n" +
+ " case 4:\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_44_njl() {
+ // TODO Could be improved to put the all array statements at the same indentation...
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X44 {\n" +
+ " String foo() {\n" +
+ " return Policy.bind(\"CVSAnnotateBlock.6\", new Object[] { //$NON-NLS-1$\n" +
+ " user,\n" +
+ " revision,\n" +
+ " String.valueOf(delta),\n" +
+ " line\n" +
+ " });\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X44 {\n" +
+ " String foo() {\n" +
+ " return Policy.bind(\"CVSAnnotateBlock.6\", new Object[] { //$NON-NLS-1$\n" +
+ " user,\n" +
+ " revision,\n" +
+ " String.valueOf(delta),\n" +
+ " line\n" +
+ " });\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_45_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X45 {\n" +
+ " private String[][] TABLE = {\n" +
+ " {\"COL_REVISION\", \"COL_DATE\", \"COL_AUTHOR\", \"COL_COMMENT\", \"COL_TAGS\"}, /* revision */ \n" +
+ " {\"COL_TAGS\", \"COL_REVISION\", \"COL_DATE\", \"COL_AUTHOR\", \"COL_COMMENT\"}, /* tags */\n" +
+ " {\"COL_DATE\", \"COL_REVISION\", \"COL_AUTHOR\", \"COL_COMMENT\", \"COL_TAGS\"}, /* date */\n" +
+ " {\"COL_AUTHOR\", \"COL_REVISION\", \"COL_DATE\", \"COL_COMMENT\", \"COL_TAGS\"}, /* author */\n" +
+ " {\"COL_COMMENT\", \"COL_REVISION\", \"COL_DATE\", \"COL_AUTHOR\", \"COL_TAGS\"} /* comment */\n" +
+ " };\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X45 {\n" +
+ " private String[][] TABLE = {\n" +
+ " { \"COL_REVISION\", \"COL_DATE\", \"COL_AUTHOR\", \"COL_COMMENT\",\n" +
+ " \"COL_TAGS\" }, /* revision */\n" +
+ " { \"COL_TAGS\", \"COL_REVISION\", \"COL_DATE\", \"COL_AUTHOR\",\n" +
+ " \"COL_COMMENT\" }, /* tags */\n" +
+ " { \"COL_DATE\", \"COL_REVISION\", \"COL_AUTHOR\", \"COL_COMMENT\",\n" +
+ " \"COL_TAGS\" }, /* date */\n" +
+ " { \"COL_AUTHOR\", \"COL_REVISION\", \"COL_DATE\", \"COL_COMMENT\",\n" +
+ " \"COL_TAGS\" }, /* author */\n" +
+ " { \"COL_COMMENT\", \"COL_REVISION\", \"COL_DATE\", \"COL_AUTHOR\",\n" +
+ " \"COL_TAGS\" } /* comment */\n" +
+ " };\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_46_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X46 {\n" +
+ " void foo() {\n" +
+ " if (getActive() == StackPresentation.AS_ACTIVE_NOFOCUS) {\n" +
+ " drawGradient(\n" +
+ " colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR), \n" +
+ " new Color [] {\n" +
+ " colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START) \n" +
+ " }, \n" +
+ " new int [0],\n" +
+ " true); \n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X46 {\n" +
+ " void foo() {\n" +
+ " if (getActive() == StackPresentation.AS_ACTIVE_NOFOCUS) {\n" +
+ " drawGradient(\n" +
+ " colorRegistry\n" +
+ " .get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR),\n" +
+ " new Color[] {\n" +
+ " colorRegistry\n" +
+ " .get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START)\n" +
+ " },\n" +
+ " new int[0],\n" +
+ " true);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_47_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X47 {\n" +
+ " void foo(int x) {\n" +
+ " switch (x) {\n" +
+ " case 0 :\n" +
+ " // case 0\n" +
+ " break;\n" +
+ " case 3 :\n" +
+ " // case 3\n" +
+ " break;\n" +
+ " //case -1 :\n" +
+ " // internal failure: trying to load variable not supposed to be generated\n" +
+ " // break;\n" +
+ " default :\n" +
+ " // default\n" +
+ " }\n" +
+ " // last comment\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X47 {\n" +
+ " void foo(int x) {\n" +
+ " switch (x) {\n" +
+ " case 0:\n" +
+ " // case 0\n" +
+ " break;\n" +
+ " case 3:\n" +
+ " // case 3\n" +
+ " break;\n" +
+ " // case -1 :\n" +
+ " // internal failure: trying to load variable not supposed to be\n" +
+ " // generated\n" +
+ " // break;\n" +
+ " default:\n" +
+ " // default\n" +
+ " }\n" +
+ " // last comment\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_48_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X48 {\n" +
+ " void foo(int x) {\n" +
+ " switch (x) {\n" +
+ " case 0 :\n" +
+ " // case 0\n" +
+ " break;\n" +
+ " case 3 :\n" +
+ " // case 3\n" +
+ " break;\n" +
+ " //case -1 :\n" +
+ " // internal failure: trying to load variable not supposed to be generated\n" +
+ " // break;\n" +
+ " }\n" +
+ " // last comment\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X48 {\n" +
+ " void foo(int x) {\n" +
+ " switch (x) {\n" +
+ " case 0:\n" +
+ " // case 0\n" +
+ " break;\n" +
+ " case 3:\n" +
+ " // case 3\n" +
+ " break;\n" +
+ " // case -1 :\n" +
+ " // internal failure: trying to load variable not supposed to be\n" +
+ " // generated\n" +
+ " // break;\n" +
+ " }\n" +
+ " // last comment\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_49_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X49 {\n" +
+ " void foo(int i) {\n" +
+ " if (true) {\n" +
+ " if (true) {\n" +
+ " this.foundTaskPositions[this.foundTaskCount] = new int[] { i, i + tagLength - 1 };\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X49 {\n" +
+ " void foo(int i) {\n" +
+ " if (true) {\n" +
+ " if (true) {\n" +
+ " this.foundTaskPositions[this.foundTaskCount] = new int[] { i,\n" +
+ " i + tagLength - 1 };\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_50_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X50 {\n" +
+ "private void deployCodeSnippetClassIfNeeded(IRequestor requestor) {\n" +
+ " if (this.codeSnippetBinary == null) {\n" +
+ " // Deploy CodeSnippet class (only once)\n" +
+ " requestor.acceptClassFiles(\n" +
+ " new ClassFile[] {\n" +
+ " new ClassFile() {\n" +
+ " public byte[] getBytes() {\n" +
+ " return getCodeSnippetBytes();\n" +
+ " }\n" +
+ " public char[][] getCompoundName() {\n" +
+ " return EvaluationConstants.ROOT_COMPOUND_NAME;\n" +
+ " }\n" +
+ " }\n" +
+ " }, \n" +
+ " null);\n" +
+ " }\n" +
+ "}\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X50 {\n" +
+ " private void deployCodeSnippetClassIfNeeded(IRequestor requestor) {\n" +
+ " if (this.codeSnippetBinary == null) {\n" +
+ " // Deploy CodeSnippet class (only once)\n" +
+ " requestor.acceptClassFiles(\n" +
+ " new ClassFile[] {\n" +
+ " new ClassFile() {\n" +
+ " public byte[] getBytes() {\n" +
+ " return getCodeSnippetBytes();\n" +
+ " }\n" +
+ "\n" +
+ " public char[][] getCompoundName() {\n" +
+ " return EvaluationConstants.ROOT_COMPOUND_NAME;\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " null);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_51_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X51 {\n" +
+ "\n" +
+ "protected void addAllSourceFiles(final ArrayList sourceFiles) throws CoreException {\n" +
+ " for (int i = 0, l = sourceLocations.length; i < l; i++) {\n" +
+ " sourceLocation.sourceFolder.accept(\n" +
+ " new IResourceProxyVisitor() {\n" +
+ " public boolean visit(IResourceProxy proxy) throws CoreException {\n" +
+ " IResource resource = null;\n" +
+ " switch(proxy.getType()) {\n" +
+ " case IResource.FILE :\n" +
+ " if (exclusionPatterns != null || inclusionPatterns != null) {\n" +
+ " resource = proxy.requestResource();\n" +
+ " if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false;\n" +
+ " }\n" +
+ " if (org.eclipse.jdt.internal.compiler.util.Util.isJavaFileName(proxy.getName())) {\n" +
+ " if (resource == null)\n" +
+ " resource = proxy.requestResource();\n" +
+ " sourceFiles.add(new SourceFile((IFile) resource, sourceLocation));\n" +
+ " }\n" +
+ " return false;\n" +
+ " case IResource.FOLDER :\n" +
+ " if (exclusionPatterns != null && inclusionPatterns == null) {\n" +
+ " // if there are inclusion patterns then we must walk the children\n" +
+ " resource = proxy.requestResource();\n" +
+ " if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false;\n" +
+ " }\n" +
+ " if (isAlsoProject && isExcludedFromProject(proxy.requestFullPath())) return false;\n" +
+ " }\n" +
+ " return true;\n" +
+ " }\n" +
+ " },\n" +
+ " IResource.NONE\n" +
+ " );\n" +
+ " notifier.checkCancel();\n" +
+ " }\n" +
+ "}\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X51 {\n" +
+ "\n" +
+ " protected void addAllSourceFiles(final ArrayList sourceFiles)\n" +
+ " throws CoreException {\n" +
+ " for (int i = 0, l = sourceLocations.length; i < l; i++) {\n" +
+ " sourceLocation.sourceFolder.accept(\n" +
+ " new IResourceProxyVisitor() {\n" +
+ " public boolean visit(IResourceProxy proxy)\n" +
+ " throws CoreException {\n" +
+ " IResource resource = null;\n" +
+ " switch (proxy.getType()) {\n" +
+ " case IResource.FILE:\n" +
+ " if (exclusionPatterns != null\n" +
+ " || inclusionPatterns != null) {\n" +
+ " resource = proxy.requestResource();\n" +
+ " if (Util.isExcluded(resource,\n" +
+ " inclusionPatterns,\n" +
+ " exclusionPatterns))\n" +
+ " return false;\n" +
+ " }\n" +
+ " if (org.eclipse.jdt.internal.compiler.util.Util\n" +
+ " .isJavaFileName(proxy.getName())) {\n" +
+ " if (resource == null)\n" +
+ " resource = proxy.requestResource();\n" +
+ " sourceFiles.add(new SourceFile(\n" +
+ " (IFile) resource, sourceLocation));\n" +
+ " }\n" +
+ " return false;\n" +
+ " case IResource.FOLDER:\n" +
+ " if (exclusionPatterns != null\n" +
+ " && inclusionPatterns == null) {\n" +
+ " // if there are inclusion patterns then we\n" +
+ " // must walk the children\n" +
+ " resource = proxy.requestResource();\n" +
+ " if (Util.isExcluded(resource,\n" +
+ " inclusionPatterns,\n" +
+ " exclusionPatterns))\n" +
+ " return false;\n" +
+ " }\n" +
+ " if (isAlsoProject\n" +
+ " && isExcludedFromProject(proxy\n" +
+ " .requestFullPath()))\n" +
+ " return false;\n" +
+ " }\n" +
+ " return true;\n" +
+ " }\n" +
+ " },\n" +
+ " IResource.NONE\n" +
+ " );\n" +
+ " notifier.checkCancel();\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_52_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X52 {\n" +
+ " protected FastSyncInfoFilter getKnownFailureCases() {\n" +
+ " return new OrSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " // Conflicting additions of files will fail\n" +
+ " new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.ADDITION),\n" +
+ " new FastSyncInfoFilter() {\n" +
+ " public boolean select(SyncInfo info) {\n" +
+ " return info.getLocal().getType() == IResource.FILE;\n" +
+ " }\n" +
+ " }\n" +
+ " }),\n" +
+ " // Conflicting changes of files will fail if the local is not managed\n" +
+ " // or is an addition\n" +
+ " new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE),\n" +
+ " new FastSyncInfoFilter() {\n" +
+ " public boolean select(SyncInfo info) {\n" +
+ " if (info.getLocal().getType() == IResource.FILE) {\n" +
+ " try {\n" +
+ " ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)info.getLocal());\n" +
+ " byte[] syncBytes = cvsFile.getSyncBytes();\n" +
+ " return (syncBytes == null || ResourceSyncInfo.isAddition(syncBytes));\n" +
+ " } catch (CVSException e) {\n" +
+ " CVSUIPlugin.log(e);\n" +
+ " // Fall though and try to update\n" +
+ " }\n" +
+ " }\n" +
+ " return false;\n" +
+ " }\n" +
+ " }\n" +
+ " }),\n" +
+ " // Conflicting changes involving a deletion on one side will aways fail\n" +
+ " new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE),\n" +
+ " new FastSyncInfoFilter() {\n" +
+ " public boolean select(SyncInfo info) {\n" +
+ " IResourceVariant remote = info.getRemote();\n" +
+ " IResourceVariant base = info.getBase();\n" +
+ " if (info.getLocal().exists()) {\n" +
+ " // local != base and no remote will fail\n" +
+ " return (base != null && remote == null);\n" +
+ " } else {\n" +
+ " // no local and base != remote\n" +
+ " return (base != null && remote != null && !base.equals(remote));\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }),\n" +
+ " // Conflicts where the file type is binary will work but are not merged\n" +
+ " // so they should be skipped\n" +
+ " new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " FastSyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE),\n" +
+ " new FastSyncInfoFilter() {\n" +
+ " public boolean select(SyncInfo info) {\n" +
+ " IResource local = info.getLocal();\n" +
+ " if (local.getType() == IResource.FILE) {\n" +
+ " try {\n" +
+ " ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)local);\n" +
+ " byte[] syncBytes = file.getSyncBytes();\n" +
+ " if (syncBytes != null) {\n" +
+ " return ResourceSyncInfo.isBinary(syncBytes);\n" +
+ " }\n" +
+ " } catch (CVSException e) {\n" +
+ " // There was an error obtaining or interpreting the sync bytes\n" +
+ " // Log it and skip the file\n" +
+ " CVSProviderPlugin.log(e);\n" +
+ " return true;\n" +
+ " }\n" +
+ " }\n" +
+ " return false;\n" +
+ " }\n" +
+ " }\n" +
+ " }),\n" +
+ " // Outgoing changes may not fail but they are skipped as well\n" +
+ " new SyncInfoDirectionFilter(SyncInfo.OUTGOING)\n" +
+ " });\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X52 {\n" +
+ " protected FastSyncInfoFilter getKnownFailureCases() {\n" +
+ " return new OrSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " // Conflicting additions of files will fail\n" +
+ " new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " FastSyncInfoFilter.getDirectionAndChangeFilter(\n" +
+ " SyncInfo.CONFLICTING, SyncInfo.ADDITION),\n" +
+ " new FastSyncInfoFilter() {\n" +
+ " public boolean select(SyncInfo info) {\n" +
+ " return info.getLocal().getType() == IResource.FILE;\n" +
+ " }\n" +
+ " }\n" +
+ " }),\n" +
+ " // Conflicting changes of files will fail if the local is not\n" +
+ " // managed\n" +
+ " // or is an addition\n" +
+ " new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " FastSyncInfoFilter.getDirectionAndChangeFilter(\n" +
+ " SyncInfo.CONFLICTING, SyncInfo.CHANGE),\n" +
+ " new FastSyncInfoFilter() {\n" +
+ " public boolean select(SyncInfo info) {\n" +
+ " if (info.getLocal().getType() == IResource.FILE) {\n" +
+ " try {\n" +
+ " ICVSFile cvsFile = CVSWorkspaceRoot\n" +
+ " .getCVSFileFor((IFile) info\n" +
+ " .getLocal());\n" +
+ " byte[] syncBytes = cvsFile\n" +
+ " .getSyncBytes();\n" +
+ " return (syncBytes == null || ResourceSyncInfo\n" +
+ " .isAddition(syncBytes));\n" +
+ " } catch (CVSException e) {\n" +
+ " CVSUIPlugin.log(e);\n" +
+ " // Fall though and try to update\n" +
+ " }\n" +
+ " }\n" +
+ " return false;\n" +
+ " }\n" +
+ " }\n" +
+ " }),\n" +
+ " // Conflicting changes involving a deletion on one side will\n" +
+ " // aways fail\n" +
+ " new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " FastSyncInfoFilter.getDirectionAndChangeFilter(\n" +
+ " SyncInfo.CONFLICTING, SyncInfo.CHANGE),\n" +
+ " new FastSyncInfoFilter() {\n" +
+ " public boolean select(SyncInfo info) {\n" +
+ " IResourceVariant remote = info.getRemote();\n" +
+ " IResourceVariant base = info.getBase();\n" +
+ " if (info.getLocal().exists()) {\n" +
+ " // local != base and no remote will fail\n" +
+ " return (base != null && remote == null);\n" +
+ " } else {\n" +
+ " // no local and base != remote\n" +
+ " return (base != null && remote != null && !base\n" +
+ " .equals(remote));\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }),\n" +
+ " // Conflicts where the file type is binary will work but are not\n" +
+ " // merged\n" +
+ " // so they should be skipped\n" +
+ " new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" +
+ " FastSyncInfoFilter.getDirectionAndChangeFilter(\n" +
+ " SyncInfo.CONFLICTING, SyncInfo.CHANGE),\n" +
+ " new FastSyncInfoFilter() {\n" +
+ " public boolean select(SyncInfo info) {\n" +
+ " IResource local = info.getLocal();\n" +
+ " if (local.getType() == IResource.FILE) {\n" +
+ " try {\n" +
+ " ICVSFile file = CVSWorkspaceRoot\n" +
+ " .getCVSFileFor((IFile) local);\n" +
+ " byte[] syncBytes = file.getSyncBytes();\n" +
+ " if (syncBytes != null) {\n" +
+ " return ResourceSyncInfo\n" +
+ " .isBinary(syncBytes);\n" +
+ " }\n" +
+ " } catch (CVSException e) {\n" +
+ " // There was an error obtaining or\n" +
+ " // interpreting the sync bytes\n" +
+ " // Log it and skip the file\n" +
+ " CVSProviderPlugin.log(e);\n" +
+ " return true;\n" +
+ " }\n" +
+ " }\n" +
+ " return false;\n" +
+ " }\n" +
+ " }\n" +
+ " }),\n" +
+ " // Outgoing changes may not fail but they are skipped as well\n" +
+ " new SyncInfoDirectionFilter(SyncInfo.OUTGOING)\n" +
+ " });\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp1_53_njl_bnl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X53 {\n" +
+ " static final short[][][] BLACK_CODE = {\n" +
+ " /* 9 bits */\n" +
+ " {{24, 15}},\n" +
+ " /* 10 bits */\n" +
+ " {{8, 18}, {15, 64}, {23, 16}, {24, 17}, {55, 0}},\n" +
+ " /* 11 bits */\n" +
+ " {/* EOL */{0, -1}, {8, 1792}, {23, 24}, {24, 25}, {40, 23}, {55, 22}, {103, 19},\n" +
+ " {104, 20}, {108, 21}, {12, 1856}, {13, 1920}},\n" +
+ " };\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X53\n" +
+ "{\n" +
+ " static final short[][][] BLACK_CODE =\n" +
+ " {\n" +
+ " /* 9 bits */\n" +
+ " {\n" +
+ " { 24, 15 } },\n" +
+ " /* 10 bits */\n" +
+ " {\n" +
+ " { 8, 18 },\n" +
+ " { 15, 64 },\n" +
+ " { 23, 16 },\n" +
+ " { 24, 17 },\n" +
+ " { 55, 0 } },\n" +
+ " /* 11 bits */\n" +
+ " {/* EOL */\n" +
+ " { 0, -1 },\n" +
+ " { 8, 1792 },\n" +
+ " { 23, 24 },\n" +
+ " { 24, 25 },\n" +
+ " { 40, 23 },\n" +
+ " { 55, 22 },\n" +
+ " { 103, 19 },\n" +
+ " { 104, 20 },\n" +
+ " { 108, 21 },\n" +
+ " { 12, 1856 },\n" +
+ " { 13, 1920 } },\n" +
+ " };\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp2_01 () {
+ String source =
+ "package wksp2;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ "\n" +
+ " static final Object[][] contents = {\n" +
+ " // comment\n" +
+ " { \"STR1\",\n" +
+ " // comment\n" +
+ " new String[] { \"STR\", // comment\n" +
+ " \"STR\", // comment\n" +
+ " \"STR\"} // comment\n" +
+ " }\n" +
+ "\n" +
+ " };\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp2;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ "\n" +
+ " static final Object[][] contents = {\n" +
+ " // comment\n" +
+ " { \"STR1\",\n" +
+ " // comment\n" +
+ " new String[] { \"STR\", // comment\n" +
+ " \"STR\", // comment\n" +
+ " \"STR\" } // comment\n" +
+ " }\n" +
+ "\n" +
+ " };\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_wksp3_X01_njl() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ String source =
+ "package wksp3;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ " private static final String foo[][] = {\n" +
+ " // line 1\n" +
+ " // line 2\n" +
+ " {\"A\", \"B\", \"C\", \"D\", \"E\"} // comment\n" +
+ " };\n" +
+ "}\n";
+ formatSource(source ,
+ "package wksp3;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ " private static final String foo[][] = {\n" +
+ " // line 1\n" +
+ " // line 2\n" +
+ " { \"A\", \"B\", \"C\", \"D\", \"E\" } // comment\n" +
+ " };\n" +
+ "}\n"
+ );
+}
+// Test cases added from bug 286601
+public void testBug330313_b286601_04() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = Alignment.M_ONE_PER_LINE_SPLIT;
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package b286601;\n" +
+ "\n" +
+ "public class X04 {\n" +
+ "\n" +
+ " \n" +
+ " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" +
+ " private static final int[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" +
+ " /* UNUSED READ READ_POTENTIAL WRTIE WRITE_POTENTIAL UNKNOWN */\n" +
+ " /* UNUSED */ { UNUSED, READ_POTENTIAL, READ_POTENTIAL, WRITE_POTENTIAL, WRITE_POTENTIAL, UNKNOWN },\n" +
+ " /* READ */ { READ_POTENTIAL, READ, READ_POTENTIAL, UNKNOWN, UNKNOWN, UNKNOWN },\n" +
+ " /* READ_POTENTIAL */ { READ_POTENTIAL, READ_POTENTIAL, READ_POTENTIAL, UNKNOWN, UNKNOWN, UNKNOWN },\n" +
+ " /* WRITE */ { WRITE_POTENTIAL, UNKNOWN, UNKNOWN, WRITE, WRITE_POTENTIAL, UNKNOWN },\n" +
+ " /* WRITE_POTENTIAL */ { WRITE_POTENTIAL, UNKNOWN, UNKNOWN, WRITE_POTENTIAL, WRITE_POTENTIAL, UNKNOWN },\n" +
+ " /* UNKNOWN */ { UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN }\n" +
+ " };\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package b286601;\n" +
+ "\n" +
+ "public class X04\n" +
+ "{\n" +
+ "\n" +
+ " // Table to merge access modes for condition statements (e.g branch[x] ||\n" +
+ " // branch[y]).\n" +
+ " private static final int[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" +
+ " {\n" +
+ " /* UNUSED READ READ_POTENTIAL WRTIE WRITE_POTENTIAL UNKNOWN */\n" +
+ " /* UNUSED */{\n" +
+ " UNUSED,\n" +
+ " READ_POTENTIAL,\n" +
+ " READ_POTENTIAL,\n" +
+ " WRITE_POTENTIAL,\n" +
+ " WRITE_POTENTIAL,\n" +
+ " UNKNOWN },\n" +
+ " /* READ */{\n" +
+ " READ_POTENTIAL,\n" +
+ " READ,\n" +
+ " READ_POTENTIAL,\n" +
+ " UNKNOWN,\n" +
+ " UNKNOWN,\n" +
+ " UNKNOWN },\n" +
+ " /* READ_POTENTIAL */{\n" +
+ " READ_POTENTIAL,\n" +
+ " READ_POTENTIAL,\n" +
+ " READ_POTENTIAL,\n" +
+ " UNKNOWN,\n" +
+ " UNKNOWN,\n" +
+ " UNKNOWN },\n" +
+ " /* WRITE */{\n" +
+ " WRITE_POTENTIAL,\n" +
+ " UNKNOWN,\n" +
+ " UNKNOWN,\n" +
+ " WRITE,\n" +
+ " WRITE_POTENTIAL,\n" +
+ " UNKNOWN },\n" +
+ " /* WRITE_POTENTIAL */{\n" +
+ " WRITE_POTENTIAL,\n" +
+ " UNKNOWN,\n" +
+ " UNKNOWN,\n" +
+ " WRITE_POTENTIAL,\n" +
+ " WRITE_POTENTIAL,\n" +
+ " UNKNOWN },\n" +
+ " /* UNKNOWN */{ UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN }\n" +
+ // Should be slip but that has been broken since 3.4.2 (i.e. 3.3.2 is OK)
+// " /* UNKNOWN */{\n" +
+// " UNKNOWN,\n" +
+// " UNKNOWN,\n" +
+// " UNKNOWN,\n" +
+// " UNKNOWN,\n" +
+// " UNKNOWN,\n" +
+// " UNKNOWN }\n" +
+ " };\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_b286601_05() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = Alignment.M_ONE_PER_LINE_SPLIT;
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package b286601;\n" +
+ "\n" +
+ "public class X05 {\n" +
+ "\n" +
+ " \n" +
+ " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" +
+ " static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" +
+ " { \"UNUSED\", \"READ_POTENTIAL\", \"READ_POTENTIAL\", \"WRITE_POTENTIAL\", \"WRITE_POTENTIAL\", \"UNKNOWN\" },\n" +
+ " { \"READ_POTENTIAL\", \"READ\", \"READ_POTENTIAL\", \"UNKNOWN\", \"UNKNOWN\", \"UNKNOWN\" },\n" +
+ " };\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package b286601;\n" +
+ "\n" +
+ "public class X05\n" +
+ "{\n" +
+ "\n" +
+ " // Table to merge access modes for condition statements (e.g branch[x] ||\n" +
+ " // branch[y]).\n" +
+ " static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" +
+ " {\n" +
+ " {\n" +
+ " \"UNUSED\",\n" +
+ " \"READ_POTENTIAL\",\n" +
+ " \"READ_POTENTIAL\",\n" +
+ " \"WRITE_POTENTIAL\",\n" +
+ " \"WRITE_POTENTIAL\",\n" +
+ " \"UNKNOWN\" },\n" +
+ " {\n" +
+ " \"READ_POTENTIAL\",\n" +
+ " \"READ\",\n" +
+ " \"READ_POTENTIAL\",\n" +
+ " \"UNKNOWN\",\n" +
+ " \"UNKNOWN\",\n" +
+ " \"UNKNOWN\" },\n" +
+ " };\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_b286601_06() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = Alignment.M_ONE_PER_LINE_SPLIT;
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package b286601;\n" +
+ "\n" +
+ "public class X06 {\n" +
+ "\n" +
+ " \n" +
+ " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" +
+ " static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" +
+ " /* Comment 1 */\n" +
+ " /* Comment 2 */ { \"UNUSED\", \"READ_POTENTIAL\", \"READ_POTENTIAL\", \"WRITE_POTENTIAL\", \"WRITE_POTENTIAL\", \"UNKNOWN\" },\n" +
+ " /* Comment 3 */ { \"READ_POTENTIAL\", \"READ\", \"READ_POTENTIAL\", \"UNKNOWN\", \"UNKNOWN\", \"UNKNOWN\" },\n" +
+ " };\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package b286601;\n" +
+ "\n" +
+ "public class X06\n" +
+ "{\n" +
+ "\n" +
+ " // Table to merge access modes for condition statements (e.g branch[x] ||\n" +
+ " // branch[y]).\n" +
+ " static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" +
+ " {\n" +
+ " /* Comment 1 */\n" +
+ " /* Comment 2 */{\n" +
+ " \"UNUSED\",\n" +
+ " \"READ_POTENTIAL\",\n" +
+ " \"READ_POTENTIAL\",\n" +
+ " \"WRITE_POTENTIAL\",\n" +
+ " \"WRITE_POTENTIAL\",\n" +
+ " \"UNKNOWN\" },\n" +
+ " /* Comment 3 */{\n" +
+ " \"READ_POTENTIAL\",\n" +
+ " \"READ\",\n" +
+ " \"READ_POTENTIAL\",\n" +
+ " \"UNKNOWN\",\n" +
+ " \"UNKNOWN\",\n" +
+ " \"UNKNOWN\" },\n" +
+ " };\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_b286601_07() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE;
+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = Alignment.M_ONE_PER_LINE_SPLIT;
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package b286601;\n" +
+ "\n" +
+ "public class X07 {\n" +
+ "\n" +
+ " \n" +
+ " // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). \n" +
+ " static final String[][] ACCESS_MODE_CONDITIONAL_TABLE= {\n" +
+ " /* Comment 1 */\n" +
+ " /* Comment 2 */ { \"1234567890123456789012345678901234567890\", \"1234567890123456789012345678901234567890\" },\n" +
+ " /* Comment 3 */ { \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
+ " };\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package b286601;\n" +
+ "\n" +
+ "public class X07\n" +
+ "{\n" +
+ "\n" +
+ " // Table to merge access modes for condition statements (e.g branch[x] ||\n" +
+ " // branch[y]).\n" +
+ " static final String[][] ACCESS_MODE_CONDITIONAL_TABLE =\n" +
+ " {\n" +
+ " /* Comment 1 */\n" +
+ " /* Comment 2 */{\n" +
+ " \"1234567890123456789012345678901234567890\",\n" +
+ " \"1234567890123456789012345678901234567890\" },\n" +
+ " /* Comment 3 */{\n" +
+ " \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\",\n" +
+ " \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" +
+ " };\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug330313_b286601_08() {
+ this.formatterPrefs.join_wrapped_lines = false;
+ this.formatterPrefs.alignment_for_expressions_in_array_initializer = Alignment.M_ONE_PER_LINE_SPLIT;
+ setUpBracesPreferences(DefaultCodeFormatterConstants.NEXT_LINE);
+ String source =
+ "package b286601;\n" +
+ "\n" +
+ "public class X08 {\n" +
+ " private MinimizedFileSystemElement selectFiles(final Object rootFileSystemObject, final IImportStructureProvider structureProvider) {\n" +
+ "\n" +
+ " BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {\n" +
+ " public void run() {\n" +
+ " //Create the root element from the supplied file system object\n" +
+ " }\n" +
+ " });\n" +
+ "\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package b286601;\n" +
+ "\n" +
+ "public class X08\n" +
+ "{\n" +
+ " private MinimizedFileSystemElement selectFiles(\n" +
+ " final Object rootFileSystemObject,\n" +
+ " final IImportStructureProvider structureProvider)\n" +
+ " {\n" +
+ "\n" +
+ " BusyIndicator.showWhile(getShell().getDisplay(), new Runnable()\n" +
+ " {\n" +
+ " public void run()\n" +
+ " {\n" +
+ " // Create the root element from the supplied file system object\n" +
+ " }\n" +
+ " });\n" +
+ "\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+
+/**
+ * @bug 332818: [formatter] Java formatter, Blank Lines tab, only 1st line indented when multiple lines is set
+ * @test Ensure that the indentation is set on all blank lines
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=332818"
+ */
+public void testBug332818() throws Exception {
+ this.formatterPrefs.indent_empty_lines = true;
+ this.formatterPrefs.number_of_empty_lines_to_preserve = 99;
+ String source =
+ "public class Test {\n" +
+ "\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " private String f1;\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "\n" +
+ " \n" +
+ " private String f2;\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "}\n";
+ formatSource(source,
+ "public class Test {\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " private String f1;\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " private String f2;\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "}\n"
+ );
+}
+
+/**
+ * @bug 332877: [formatter] line comment wrongly put on a new line
+ * @test Ensure that the comment on last enum constant is not wrongly put on a new line
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=332877"
+ */
+public void testBug332877() throws Exception {
+ String source =
+ "public enum Environment {\n" +
+ " PROD, // Production level environments\n" +
+ " STAGING // Staging\n" +
+ "}\n";
+ formatSource(source,
+ "public enum Environment {\n" +
+ " PROD, // Production level environments\n" +
+ " STAGING // Staging\n" +
+ "}\n"
+ );
+}
+
+/**
+ * @bug 282988: [formatter] Option to align single-line comments in a column
+ * @test Ensure that with line comment formatting turned off comment alignment doesn't change
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988"
+ */
+public void testBug282988() throws Exception {
+ this.formatterPrefs.comment_preserve_white_space_between_code_and_line_comments = true;
+ String source =
+ "package test;\n" +
+ "\n" +
+ "public class FormatterError {\n" +
+ " public void storeSomething(java.nio.ByteBuffer buffer) throws Exception {\n" +
+ " buffer.clear();\n" +
+ " buffer.putLong(0); // backlink to previous version of this object\n" +
+ " buffer.putInt(1); // version identifier\n" +
+ " buffer.flip(); // prepare to write\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package test;\n" +
+ "\n" +
+ "public class FormatterError {\n" +
+ " public void storeSomething(java.nio.ByteBuffer buffer) throws Exception {\n" +
+ " buffer.clear();\n" +
+ " buffer.putLong(0); // backlink to previous version of this object\n" +
+ " buffer.putInt(1); // version identifier\n" +
+ " buffer.flip(); // prepare to write\n" +
+ " }\n" +
+ "}\n"
+ );
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterMassiveRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterMassiveRegressionTests.java
index 72d6a5497..63757e2a4 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterMassiveRegressionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterMassiveRegressionTests.java
@@ -418,7 +418,7 @@ public static Test suite() {
protected static Test suite(File inputDir, String profile, Map directories) {
String name = "FormatterMassiveRegressionTests on "+inputDir.getName();
- if (profile == null || profile.length() == 0) {
+ if (profile != null && profile.length() > 0) {
name += " " + profile;
}
TestSuite suite = new Suite(name);
@@ -566,19 +566,19 @@ private static String buildProfileString() {
String separator = "";
if (JOIN_LINES != null) {
buffer.append("join_lines="+JOIN_LINES);
- separator = ", ";
+ separator = ",";
}
if (NO_COMMENTS) {
- buffer.append(separator+"no_comments");
- separator = ", ";
+ buffer.append(separator+"no_comments=true");
+ separator = ",";
}
if (BRACES != null) {
buffer.append(separator+"braces="+BRACES);
- separator = ", ";
+ separator = ",";
}
if (PRESERVED_LINES != -1) {
buffer.append(separator+"preserved_lines="+PRESERVED_LINES);
- separator = ", ";
+ separator = ",";
}
builtProfile = buffer.toString();
}
@@ -659,15 +659,13 @@ private static void initDirectories(File inputDir, int profiles, boolean verify)
MAINTENANCE = true;
} else if (token.equals("list")) {
LIST = true;
- } else if (token.equals("tmp")) {
- if (JDT_CORE_HEAD) {
- TEMP_OUTPUT = "HEAD";
- }
+ } else {
+ TEMP_OUTPUT = token;
}
}
setOutputDir(inputDir, outputDir, profiles);
if (CLEAN) {
- if (PATCH_BUG != null || (TEMP_OUTPUT == null && JDT_CORE_HEAD)) {
+ if ((PATCH_BUG != null || JDT_CORE_HEAD) && TEMP_OUTPUT == null) {
System.err.println("Reference can only be updated using a version (i.e. with a closed buildnotes_jdt-core.html)!");
System.exit(1);
}
@@ -705,51 +703,55 @@ private static void initDirectories(File inputDir, int profiles, boolean verify)
private static void setLogDir(File inputDir, int profiles, boolean verify) throws CoreException {
// Compute log dir
- File logDir = new File(System.getProperty("logDir"));
- if (!logDir.exists()) {
- if (!logDir.mkdirs()) {
- System.err.println("Cannot create specified log directory: "+logDir+"!!!");
+ File rootLogDir = new File(System.getProperty("logDir"));
+ if (!rootLogDir.exists()) {
+ if (!rootLogDir.mkdirs()) {
+ System.err.println("Cannot create specified log directory: "+rootLogDir+"!!!");
return;
}
}
// Compute log sub-directories depending on version
- logDir = new File(logDir, ECLIPSE_VERSION);
+ rootLogDir = new File(rootLogDir, ECLIPSE_VERSION);
+ String subRootDir;
if (PATCH_BUG != null) {
- logDir = new File(logDir, "tests");
- logDir = new File(logDir, PATCH_BUG);
- logDir = new File(logDir, PATCH_VERSION);
+ rootLogDir = new File(rootLogDir, "tests");
+ rootLogDir = new File(rootLogDir, PATCH_BUG);
+ subRootDir = PATCH_VERSION;
} else if (JDT_CORE_HEAD) {
- logDir = new File(logDir, "HEAD");
+ subRootDir = "HEAD";
} else {
- logDir = new File(logDir, ECLIPSE_MILESTONE);
- logDir = new File(logDir, JDT_CORE_VERSION);
+ rootLogDir = new File(rootLogDir, ECLIPSE_MILESTONE);
+ subRootDir = JDT_CORE_VERSION;
}
// Compute log sub-directories depending on profiles
+ List subDirs = new ArrayList();
if (profiles > 0) {
- logDir = new File(logDir, "profiles");
- logDir = setProfilesDir(profiles, logDir);
+ subDirs.add("profiles");
+ setProfilesDir(profiles, subDirs);
}
if (FILES_FILTER_KIND > 0) {
- logDir = new File(new File(logDir, "filter"), FILES_FILTER.replace('?', '_').replace('*', '%'));
+ subDirs.add("filter");
+ subDirs.add(FILES_FILTER.replace('?', '_').replace('*', '%'));
}
// Create log stream
- logDir.mkdirs();
+ File logDir = createDir(new File (rootLogDir, subRootDir), subDirs);
String filePrefix = inputDir.getName().replaceAll("\\.", "");
String logFileName = filePrefix+".txt";
LOG_FILE = new File(logDir, logFileName);
if (verify && LOG_FILE.exists()) {
- File saveDir = new File(logDir, "save");
- saveDir.mkdir();
+ File saveDir = new File(new File(rootLogDir, "save"), subRootDir);
+ saveDir.mkdirs();
int i=0;
while (true) {
- String newFileName = filePrefix+"_";
- if (i<10) newFileName += "0";
- newFileName += i+".txt";
- File renamedFile = new File(saveDir, newFileName);
+ String dirN = Integer.toString(i);
+ if (i<10) dirN = "0" + dirN;
+ saveDir = new File(saveDir, dirN);
+ logDir = createDir(saveDir, subDirs);
+ File renamedFile = new File(logDir, logFileName);
if (LOG_FILE.renameTo(renamedFile)) break;
i++;
}
@@ -768,7 +770,22 @@ private static void setLogDir(File inputDir, int profiles, boolean verify) throw
// LOG_BUFFER = new StringBuffer();
}
+private static File createDir(File rootDir, List subDirs) {
+ File dir = rootDir;
+ for (int i=0, s=subDirs.size(); i<s; i++) {
+ dir = new File (dir, (String) subDirs.get(i));
+ }
+ dir.mkdirs();
+ return dir;
+}
+
private static File setProfilesDir(int profiles, File dir) {
+ List subDirs = new ArrayList();
+ setProfilesDir(profiles, subDirs);
+ return createDir(dir, subDirs);
+}
+
+private static void setProfilesDir(int profiles, List subDirs) {
String joinLines = null;
switch (profiles & PROFILE_JOIN_LINES_MASK) {
case PROFILE_NEVER_JOIN_LINES:
@@ -782,10 +799,11 @@ private static File setProfilesDir(int profiles, File dir) {
break;
}
if (joinLines != null) {
- dir = new File(new File(dir, "join_lines"), joinLines);
+ subDirs.add("join_lines");
+ subDirs.add(joinLines);
}
if ((profiles & PROFILE_NO_COMMENTS) != 0) {
- dir = new File(dir, "no_comments");
+ subDirs.add("no_comments");
}
String braces = null;
switch (profiles & PROFILE_BRACES_MASK) {
@@ -800,13 +818,14 @@ private static File setProfilesDir(int profiles, File dir) {
break;
}
if (braces != null) {
- dir = new File(new File(dir, "braces"), braces);
+ subDirs.add("braces");
+ subDirs.add(braces);
}
if ((profiles & PROFILE_PRESERVED_LINES_MASK) != 0) {
int lines = (profiles & PROFILE_PRESERVED_LINES_MASK) >> 5;
- dir = new File(new File(dir, "preserved_lines"), Integer.toString(lines));
+ subDirs.add("preserved_lines");
+ subDirs.add(Integer.toString(lines));
}
- return dir;
}
private static void appendProfiles(int profiles, StringBuffer buffer) {
@@ -876,7 +895,10 @@ private static void setOutputDir(File inputDir, String dir, int profiles) {
// Add the temporary output if any
if (TEMP_OUTPUT != null) {
- OUTPUT_DIR = new File(OUTPUT_DIR, TEMP_OUTPUT);
+ StringTokenizer tokenizer = new StringTokenizer(TEMP_OUTPUT, "/");
+ while (tokenizer.hasMoreTokens()) {
+ OUTPUT_DIR = new File(OUTPUT_DIR, tokenizer.nextToken());
+ }
}
// Compute output sub-directories depending on profiles
@@ -1135,9 +1157,18 @@ public void setUpSuite() throws Exception {
}
// Dump the version
- File versionFile = new Path(OUTPUT_DIR.getPath()).append("version.txt").toFile();
- OUTPUT_DIR.mkdirs();
- Util.writeToFile(JDT_CORE_VERSION, versionFile.getAbsolutePath());
+ if (CLEAN) {
+ File versionFile = new Path(OUTPUT_DIR.getPath()).append("version.txt").toFile();
+ OUTPUT_DIR.mkdirs();
+ String version = JDT_CORE_VERSION;
+ if (TEMP_OUTPUT != null) {
+ version += " + " + TEMP_OUTPUT;
+ if (PATCH_BUG != null) {
+ version += " " + PATCH_VERSION + " of " + PATCH_BUG;
+ }
+ }
+ Util.writeToFile(version, versionFile.getAbsolutePath());
+ }
// Init time measuring
TIME_MEASURES = new TimeMeasuring();
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
index 1dbd24007..43c062cb7 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Brock Janiczak - Contribution for bug 150741
+ * Ray V. (voidstar@gmail.com) - Contribution for bug 282988
*******************************************************************************/
package org.eclipse.jdt.core.tests.formatter;
@@ -61,8 +62,8 @@ public class FormatterRegressionTests extends AbstractJavaModelTests {
Map formatterOptions;
static {
-// TESTS_NUMBERS = new int[] { 730 };
-// TESTS_RANGE = new int[] { 730, -1 };
+// TESTS_NUMBERS = new int[] { 736 };
+// TESTS_RANGE = new int[] { 734, -1 };
}
public static Test suite() {
return buildModelTestSuite(FormatterRegressionTests.class);
@@ -10981,4 +10982,124 @@ public void test733() {
"}"
);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988
+public void test734() {
+ this.formatterPrefs = null;
+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE);
+ String source =
+ "package p;\n" +
+ "\n" +
+ "public class Comment {\n" +
+ " public static void main(String[] args) {\n" +
+ " // internal indentation\n" +
+ " int i = 1; // tabs\n" +
+ " int j = 2; // spaces\n" +
+ " int k = 3; // mixed tabs and spaces\n" +
+ " System.out.print(i); /* does not affect block comments */\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package p;\n" +
+ "\n" +
+ "public class Comment {\n" +
+ " public static void main(String[] args) {\n" +
+ " // internal indentation\n" +
+ " int i = 1; // tabs\n" +
+ " int j = 2; // spaces\n" +
+ " int k = 3; // mixed tabs and spaces\n" +
+ " System.out.print(i); /* does not affect block comments */\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988
+public void test735() {
+ this.formatterPrefs = null;
+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE);
+ String source =
+ "package p;\n" +
+ "\n" +
+ "public class Comment {\n" +
+ " public static void main(String[] args) {\n" +
+ " // internal indentation\n" +
+ " int i = 1; // tabs\n" +
+ " int j = 2; // spaces\n" +
+ " int k = 3; // mixed tabs and spaces\n" +
+ " System.out.print(i); /* does not affect block comments */\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package p;\n" +
+ "\n" +
+ "public class Comment {\n" +
+ " public static void main(String[] args) {\n" +
+ " // internal indentation\n" +
+ " int i = 1; // tabs\n" +
+ " int j = 2; // spaces\n" +
+ " int k = 3; // mixed tabs and spaces\n" +
+ " System.out.print(i); /* does not affect block comments */\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988
+public void test736() {
+ this.formatterPrefs = null;
+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.TRUE);
+ String source =
+ "package p;\n" +
+ "\n" +
+ "public class Comment {\n" +
+ " public static void main(String[] args) {\n" +
+ " // internal indentation\n" +
+ " int i = 1;// tabs\n" +
+ " int j = 2;// spaces\n" +
+ " int k = 3;// mixed tabs and spaces\n" +
+ " System.out.print(i); /* does not affect block comments */\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package p;\n" +
+ "\n" +
+ "public class Comment {\n" +
+ " public static void main(String[] args) {\n" +
+ " // internal indentation\n" +
+ " int i = 1;// tabs\n" +
+ " int j = 2;// spaces\n" +
+ " int k = 3;// mixed tabs and spaces\n" +
+ " System.out.print(i); /* does not affect block comments */\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=282988
+public void test737() {
+ this.formatterPrefs = null;
+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE);
+ String source =
+ "package p;\n" +
+ "\n" +
+ "public class Comment {\n" +
+ " public static void main(String[] args) {\n" +
+ " // internal indentation\n" +
+ " int i = 1;// tabs\n" +
+ " int j = 2;// spaces\n" +
+ " int k = 3;// mixed tabs and spaces\n" +
+ " System.out.print(i); /* does not affect block comments */\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package p;\n" +
+ "\n" +
+ "public class Comment {\n" +
+ " public static void main(String[] args) {\n" +
+ " // internal indentation\n" +
+ " int i = 1;// tabs\n" +
+ " int j = 2;// spaces\n" +
+ " int k = 3;// mixed tabs and spaces\n" +
+ " System.out.print(i); /* does not affect block comments */\n" +
+ " }\n" +
+ "}\n"
+ );
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
index 8596b7c1e..55c3979a1 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java
index 4b28e6405..32d5b962c 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -43,7 +43,7 @@ public class AttachedJavadocTests extends ModifyingResourceTests {
private static final String DEFAULT_DOC_FOLDER = "doc";
static {
-// TESTS_NAMES = new String[] { "test010" };
+// TESTS_NAMES = new String[] { "testBug334652_4" };
// TESTS_NUMBERS = new int[] { 24 };
// TESTS_RANGE = new int[] { 169, 180 };
}
@@ -783,4 +783,149 @@ public class AttachedJavadocTests extends ModifyingResourceTests {
this.project.setOptions(options);
}
}
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652
+ public void testBug334652() throws CoreException, IOException {
+ IClasspathEntry[] entries = this.project.getRawClasspath();
+
+ try {
+ IClasspathAttribute attribute =
+ JavaCore.newClasspathAttribute(
+ IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
+ "jar:platform:/resource/AttachedJavadocProject/bug334652_doc.zip!/NoJavaDocForInnerClass/doc");
+ IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652.jar"), null, null, null, new IClasspathAttribute[] { attribute}, false);
+ this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
+ this.project.getResolvedClasspath(false);
+
+ IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652.jar"));
+ final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$InnerFinalException.class").getType();
+ IMethod method = type.getMethod("InnerFinalException", new String[] { "Lcom.test.PublicAbstractClass;", "Ljava.lang.String;", "Ljava.lang.String;"});
+ assertNotNull(method);
+ assertTrue("Does not exist", method.exists());
+
+ String javadoc = method.getAttachedJavadoc(null);
+ assertNotNull(javadoc);
+ assertEquals("Wrong contents", "<H3>\r\n" +
+ "PublicAbstractClass.InnerFinalException</H3>\r\n" +
+ "<PRE>\r\n" +
+ "public <B>PublicAbstractClass.InnerFinalException</B>(java.lang.String&nbsp;property,\r\n" +
+ " java.lang.String&nbsp;msg)</PRE>\r\n" +
+ "<DL>\r\n" +
+ "<DD>javadoc for InnerFinalException(String property, String msg)\r\n" +
+ "<P>\r\n" +
+ "<DL>\r\n" +
+ "<DT><B>Parameters:</B><DD><CODE>property</CODE> - the property argument<DD><CODE>msg</CODE> - the message argument</DL>\r\n" +
+ "</DL>\r\n", javadoc);
+ } finally {
+ this.project.setRawClasspath(entries, null);
+ }
+ }
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652
+ public void testBug334652_2() throws CoreException, IOException {
+ IClasspathEntry[] entries = this.project.getRawClasspath();
+
+ try {
+ IClasspathAttribute attribute =
+ JavaCore.newClasspathAttribute(
+ IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
+ "jar:platform:/resource/AttachedJavadocProject/bug334652(2)_doc.zip!/doc");
+ IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652(2).jar"), null, null, null, new IClasspathAttribute[] { attribute}, false);
+ this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
+ this.project.getResolvedClasspath(false);
+
+ IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652(2).jar"));
+ final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$InnerFinalException.class").getType();
+ IMethod method = type.getMethod("InnerFinalException", new String[] { "Ljava.lang.String;", "Ljava.lang.String;"});
+ assertNotNull(method);
+ assertTrue("Does not exist", method.exists());
+
+ String javadoc = method.getAttachedJavadoc(null);
+ assertNotNull(javadoc);
+ assertEquals("Wrong contents", "<H3>\r\n" +
+ "PublicAbstractClass.InnerFinalException</H3>\r\n" +
+ "<PRE>\r\n" +
+ "public <B>PublicAbstractClass.InnerFinalException</B>(java.lang.String&nbsp;property,\r\n" +
+ " java.lang.String&nbsp;msg)</PRE>\r\n" +
+ "<DL>\r\n" +
+ "<DD>javadoc for InnerFinalException(String property, String msg)\r\n" +
+ "<P>\r\n" +
+ "<DL>\r\n" +
+ "<DT><B>Parameters:</B><DD><CODE>property</CODE> - the property argument<DD><CODE>msg</CODE> - the message argument</DL>\r\n" +
+ "</DL>\r\n", javadoc);
+ } finally {
+ this.project.setRawClasspath(entries, null);
+ }
+ }
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652
+ public void testBug334652_3() throws CoreException, IOException {
+ IClasspathEntry[] entries = this.project.getRawClasspath();
+
+ try {
+ IClasspathAttribute attribute =
+ JavaCore.newClasspathAttribute(
+ IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
+ "jar:platform:/resource/AttachedJavadocProject/bug334652(3)_doc.zip!/doc");
+ IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652(3).jar"), null, null, null, new IClasspathAttribute[] { attribute}, false);
+ this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
+ this.project.getResolvedClasspath(false);
+
+ IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652(3).jar"));
+ final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$A$InnerFinalException.class").getType();
+ IMethod method = type.getMethod("InnerFinalException", new String[] { "Lcom.test.PublicAbstractClass$A;", "Ljava.lang.String;", "Ljava.lang.String;"});
+ assertNotNull(method);
+ assertTrue("Does not exist", method.exists());
+
+ String javadoc = method.getAttachedJavadoc(null);
+ assertNotNull(javadoc);
+ assertEquals("Wrong contents",
+ "<H3>\r\n" +
+ "PublicAbstractClass.A.InnerFinalException</H3>\r\n" +
+ "<PRE>\r\n" +
+ "public <B>PublicAbstractClass.A.InnerFinalException</B>(java.lang.String&nbsp;property,\r\n" +
+ " java.lang.String&nbsp;msg)</PRE>\r\n" +
+ "<DL>\r\n" +
+ "<DD>javadoc for InnerFinalException(String property, String msg)\r\n" +
+ "<P>\r\n" +
+ "<DL>\r\n" +
+ "<DT><B>Parameters:</B><DD><CODE>property</CODE> - the property argument<DD><CODE>msg</CODE> - the message argument</DL>\r\n" +
+ "</DL>\r\n", javadoc);
+ } finally {
+ this.project.setRawClasspath(entries, null);
+ }
+ }
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652
+ public void testBug334652_4() throws CoreException, IOException {
+ IClasspathEntry[] entries = this.project.getRawClasspath();
+
+ try {
+ IClasspathAttribute attribute =
+ JavaCore.newClasspathAttribute(
+ IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
+ "jar:platform:/resource/AttachedJavadocProject/bug334652(4)_doc.zip!/doc");
+ IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652(4).jar"), null, null, null, new IClasspathAttribute[] { attribute}, false);
+ this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
+ this.project.getResolvedClasspath(false);
+
+ IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652(4).jar"));
+ final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$A$InnerFinalException.class").getType();
+ IMethod method = type.getMethod("InnerFinalException", new String[] { "Lcom.test.PublicAbstractClass$A;", "Ljava.lang.String;", "Ljava.lang.String;"});
+ assertNotNull(method);
+ assertTrue("Does not exist", method.exists());
+
+ String javadoc = method.getAttachedJavadoc(null);
+ assertNotNull(javadoc);
+ assertEquals("Wrong contents", "<H3>\r\n" +
+ "PublicAbstractClass.A.InnerFinalException</H3>\r\n" +
+ "<PRE>\r\n" +
+ "public <B>PublicAbstractClass.A.InnerFinalException</B>(java.lang.String&nbsp;property,\r\n" +
+ " java.lang.String&nbsp;msg)</PRE>\r\n" +
+ "<DL>\r\n" +
+ "<DD>javadoc for InnerFinalException(String property, String msg)\r\n" +
+ "<P>\r\n" +
+ "<DL>\r\n" +
+ "<DT><B>Parameters:</B><DD><CODE>property</CODE> - the property argument<DD><CODE>msg</CODE> - the message argument</DL>\r\n" +
+ "</DL>\r\n", javadoc);
+ } finally {
+ this.project.setRawClasspath(entries, null);
+ }
+ }
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java
index f319d03a9..6ce4b3450 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BindingKeyTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * Copyright (c) 2005, 2011 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
@@ -20,6 +20,7 @@ public class BindingKeyTests extends AbstractJavaModelTests {
static {
// TESTS_PREFIX = "testInvalidCompilerOptions";
// TESTS_NAMES = new String[] { "test028"};
+// TESTS_NUMBERS = new int[] { 56 };
}
public BindingKeyTests(String name) {
@@ -628,4 +629,14 @@ public class BindingKeyTests extends AbstractJavaModelTests {
public void test055() {
assertFalse("Should not be a raw type", new BindingKey("Ltest/ZZ<Ljava/lang/Object>;").isRawType());
}
+
+ /*
+ * Ensures that the type arguments for a parameterized type binding key are correct for secondary type
+ */
+ public void test056() {
+ assertBindingKeyTypeArgumentsEqual(
+ "[LOuter<Ljava.lang.Integer;>.Inner<Ljava.lang.Double;>;\n",
+ "LNullBinding~One<[LNullBinding~Outer<Ljava/lang/Integer;>.Inner<Ljava/lang/Double;>;>;"
+ );
+ }
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java
index 95e447f57..3d6983d93 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -1034,6 +1034,40 @@ public void testContainerInitializer25() throws CoreException {
}
}
+
+/*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=327471
+ * [java.io.EOFException at java.io.DataInputStream.readInt(Unknown Source)]
+ * This test ensures that there is no exception on a restart of eclipse after
+ * the project is closed after the workspace save
+ */
+public void testContainerInitializer26() throws CoreException {
+ try {
+ createProject("P1");
+ createFile("/P1/lib.jar", "");
+ ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1/lib.jar"}));
+ IJavaProject p2 = createJavaProject(
+ "P2",
+ new String[] {},
+ new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"},
+ "");
+ ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1"}));
+
+ waitForAutoBuild();
+ getWorkspace().save(true/*full save*/, null/*no progress*/);
+ p2.getProject().close(null); // close the project after the save and before the shutdown
+ JavaModelManager.getJavaModelManager().shutdown();
+
+ startLogListening();
+ simulateRestart();
+ assertLogEquals(""); // no error should be logged
+
+ } finally {
+ stopLogListening();
+ deleteProject("P1");
+ deleteProject("P2");
+ }
+}
public void testVariableInitializer01() throws CoreException {
try {
createProject("P1");
@@ -1533,7 +1567,7 @@ public void testUserLibraryInitializer1() throws Exception {
IFile srcFile = createFile("/p61872/swtsrc.zip", "");
// Modify user library
- IEclipsePreferences preferences = new InstanceScope().getNode(JavaCore.PLUGIN_ID);
+ IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);
String propertyName = JavaModelManager.CP_USERLIBRARY_PREFERENCES_PREFIX+"SWT";
StringBuffer propertyValue = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<userlibrary systemlibrary=\"false\" version=\"1\">\r\n<archive");
String jarFullPath = getWorkspaceRoot().getLocation().append(jarFile.getFullPath()).toString();
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
index 75b687188..c23f6bf7d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -285,7 +285,7 @@ public void test232816b() throws Exception {
initializer.requestClasspathContainerUpdate(containerPath.append(libraryName), null, containerSuggestion);
// Modify user library
- IEclipsePreferences preferences = new InstanceScope().getNode(JavaCore.PLUGIN_ID);
+ IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);
String propertyName = JavaModelManager.CP_USERLIBRARY_PREFERENCES_PREFIX+"SomeUserLibrary";
StringBuffer propertyValue = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<userlibrary systemlibrary=\"false\" version=\"1\">\r\n<archive");
//String jarFullPath = getWorkspaceRoot().getLocation().append(jarFile.getFullPath()).toString();
@@ -5956,7 +5956,7 @@ public void testBug276373() throws Exception {
UserLibraryClasspathContainer containerSuggestion = new UserLibraryClasspathContainer(libraryName);
initializer.requestClasspathContainerUpdate(containerPath.append(libraryName), null, containerSuggestion);
- IEclipsePreferences preferences = new InstanceScope().getNode(JavaCore.PLUGIN_ID);
+ IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);
String propertyName = JavaModelManager.CP_USERLIBRARY_PREFERENCES_PREFIX+"TestUserLibrary";
StringBuffer propertyValue = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<userlibrary systemlibrary=\"false\" version=\"1\">\r\n<archive");
propertyValue.append(" path=\"" + libJar.getAbsolutePath());
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
index f9ddb76ca..80c519323 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -21893,4 +21893,62 @@ public void test325481b() throws JavaModelException {
COMPLETION_PROJECT.setOptions(options);
}
}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=332268
+// To verify that we DO get proposals for static fields that have not yet been declared
+// inside a field declaration statement, iff current field is not static
+public void testBug332268a() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ "package test;"+
+ "public class Test {\n" +
+ " int myVar1 = 1;\n" +
+ " int myVar2 = 1;\n" +
+ " int myVar3 = myVar;\n" +
+ " int myVar4 = 1;\n" +
+ " static int myVar5 = 1;\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "int myVar3 = myVar";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+ assertResults(
+ "myVar1[FIELD_REF]{myVar1, Ltest.Test;, I, myVar1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
+ "myVar2[FIELD_REF]{myVar2, Ltest.Test;, I, myVar2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
+ "myVar5[FIELD_REF]{myVar5, Ltest.Test;, I, myVar5, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}",
+ requestor.getResults());
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=332268
+// To verify that we do not get proposals for static fields that have not yet been declared
+// inside a field declaration statement, if current field is static
+public void testBug332268b() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ "package test;"+
+ "public class Test {\n" +
+ " static int myVar1 = 1;\n" +
+ " int myVar2 = 1;\n" +
+ " static int myVar3 = myVar;\n" +
+ " int myVar4 = 1;\n" +
+ " static int myVar5 = 1;\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "int myVar3 = myVar";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+ assertResults(
+ "myVar1[FIELD_REF]{myVar1, Ltest.Test;, I, myVar1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}",
+ requestor.getResults());
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java
index 4f54f59a6..1aa1bc2bb 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -184,7 +184,7 @@ public class CompletionTestsRequestor extends CompletionRequestor {
protected String[] quickSort(String[] collection, int left, int right) {
int original_left = left;
int original_right = right;
- String mid = collection[ (left + right) / 2];
+ String mid = collection[left + ((right - left)/2)];
do {
while (mid.compareTo(collection[left]) > 0)
// s[left] >= mid
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor2.java
index 8c0be97bb..f5b8188d5 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 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
@@ -492,7 +492,7 @@ public class CompletionTestsRequestor2 extends CompletionRequestor {
protected CompletionProposal[] quickSort(CompletionProposal[] collection, int left, int right) {
int original_left = left;
int original_right = right;
- CompletionProposal mid = collection[ (left + right) / 2];
+ CompletionProposal mid = collection[left + ((right - left)/2)];
do {
while (compare(mid, collection[left]) > 0)
// s[left] >= mid
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java
index f52560481..c9368c8dd 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -135,7 +135,7 @@ public class EncodingTests extends ModifyingResourceTests {
public void testCreateCompilationUnitAndImportContainer() throws Exception {
String savedEncoding = null;
String resourcesPluginId = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
- IEclipsePreferences preferences = new InstanceScope().getNode(resourcesPluginId);
+ IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(resourcesPluginId);
try {
savedEncoding = preferences.get(ResourcesPlugin.PREF_ENCODING, "");
String encoding = "UTF-8";
@@ -926,7 +926,7 @@ public class EncodingTests extends ModifyingResourceTests {
public void testBug255501() throws Exception {
String savedEncoding = null;
String resourcesPluginId = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
- IEclipsePreferences preferences = new InstanceScope().getNode(resourcesPluginId);
+ IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(resourcesPluginId);
try {
savedEncoding = preferences.get(ResourcesPlugin.PREF_ENCODING, "");
JavaCore.getOptions(); // force options to be cached
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java
index 2956e61d3..98527516d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
index 4ccd86885..c88974f36 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -8792,6 +8792,7 @@ public void testBug185452() throws CoreException {
"lib/b166348.jar pack [No source]\n" +
"lib/b166348.jar test [No source]\n" +
"lib/b317264 b317264\n" +
+ "lib/b327654 b327654\n" +
"lib/b86293.jar [No source]\n" +
"lib/b87627.jar [No source]\n" +
"lib/b87627.jar b87627 [No source]\n" +
@@ -12578,4 +12579,273 @@ public void testBug329727() throws CoreException, IOException {
deleteFile("/JavaSearchBugs/bug329727.jar");
}
}
+
+/**
+ * @bug 327654: FUP of bug 317264: Refactoring is impossible with commons-lang.jar is in the path
+ * @test types in enum package should not be reported for 1.5 projects
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=327654"
+ */
+public void testBug327654() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5");
+ addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b327654/commons-lang.jar"), null, null));
+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS;
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask);
+
+ waitUntilIndexesReady();
+ TypeNameMatchCollector collector = new TypeNameMatchCollector();
+ new SearchEngine().searchAllTypeNames(
+ "org.apache.commons.lang.enum".toCharArray(),
+ SearchPattern.R_EXACT_MATCH,
+ "".toCharArray(),
+ SearchPattern.R_PREFIX_MATCH,
+ IJavaSearchConstants.TYPE,
+ scope,
+ collector,
+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+ null);
+ assertSearchResults("Unexpected search results!", "", collector);
+ } finally {
+ deleteProject(project);
+ }
+}
+/**
+ * @bug 325418: [search] Search for method declarations returns spurious potential matches for anonymous classes
+ * @test search of method declarations of binary anonymous classes using
+ * enclosing method's type variables should yield correct results.
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=325418"
+ */
+public void testBug325418a() throws Exception {
+ try
+ {
+ IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib325418.jar","JCL15_LIB"}, "","1.5");
+ org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
+ "p325418/Test.java",
+ "package p325418;\n" +
+ "public class Test{\n"+
+ " public <T> T foo() {\n"+
+ " return new Inner<T>() {T run() { return null; }}.run();\n"+
+ " }\n"+
+ "}\n"+
+ "abstract class Inner <T> {\n"+
+ " abstract T run();\n"+
+ "}\n"
+ }, p.getProject().getLocation().append("lib325418.jar").toOSString(), "1.5");
+ refresh(p);
+ //addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b325418.jar"), null, null));
+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask);
+ search("Inner.run()", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector);
+ assertSearchResults("Unexpected search results!",
+ "lib325418.jar T p325418.Inner.run() [No source] EXACT_MATCH\n" +
+ "lib325418.jar T p325418.<anonymous>.run() [No source] EXACT_MATCH",
+ this.resultCollector);
+ } finally {
+ deleteProject("P");
+ }
+}
+// local named class instead of anonymous class
+public void testBug325418b() throws Exception {
+ try
+ {
+ IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib325418.jar","JCL15_LIB"}, "","1.5");
+ org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
+ "p325418/Test.java",
+ "package p325418;\n" +
+ "public class Test {\n" +
+ " public <T> T foo() {\n" +
+ " class ExtendsInner extends Inner<T> {\n" +
+ " T run() { return null; } \n" +
+ " } \n" +
+ " return null; \n" +
+ " } \n" +
+ "} \n" +
+ "abstract class Inner <T> {\n" +
+ " abstract T run();\n" +
+ "}"
+ }, p.getProject().getLocation().append("lib325418.jar").toOSString(), "1.5");
+ refresh(p);
+ //addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b325418.jar"), null, null));
+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask);
+ search("Inner.run", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector);
+ assertSearchResults("Unexpected search results!",
+ "lib325418.jar T p325418.Inner.run() [No source] EXACT_MATCH\n" +
+ "lib325418.jar T p325418.ExtendsInner.run() [No source] EXACT_MATCH",
+ this.resultCollector);
+ } finally {
+ deleteProject("P");
+ }
+}
+// should work good even if both the inner type and the enclosing methods have type variables
+public void testBug325418c() throws Exception {
+ try
+ {
+ IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib325418.jar","JCL15_LIB"}, "","1.5");
+ org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
+ "p325418/Test.java",
+ "package p325418;\n" +
+ "public class Test {\n" +
+ " public <T> T foo() {\n" +
+ " class ExtendsInner<U> extends Inner<T, U> {\n" +
+ " T run() { return null; } \n" +
+ " T run(U obj) { return null; } \n" +
+ " } \n" +
+ " return null; \n" +
+ " } \n" +
+ "} \n" +
+ "abstract class Inner <T, U> {\n" +
+ " abstract T run();\n" +
+ " abstract T run(U obj);\n" +
+ "}"
+ }, p.getProject().getLocation().append("lib325418.jar").toOSString(), "1.5");
+ refresh(p);
+ //addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b325418.jar"), null, null));
+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask);
+ search("Inner.run", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector);
+ assertSearchResults("Unexpected search results!",
+ "lib325418.jar T p325418.Inner.run() [No source] EXACT_MATCH\n" +
+ "lib325418.jar T p325418.Inner.run(U) [No source] EXACT_MATCH\n" +
+ "lib325418.jar T p325418.ExtendsInner.run() [No source] EXACT_MATCH\n" +
+ "lib325418.jar T p325418.ExtendsInner.run(U) [No source] EXACT_MATCH",
+ this.resultCollector);
+ } finally {
+ deleteProject("P");
+ }
+}
+// should work good even if the enclosing method having type variables is more than one level
+public void testBug325418d() throws Exception {
+ try
+ {
+ IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib325418.jar","JCL15_LIB"}, "","1.5");
+ org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
+ "p325418/Test.java",
+ "package p325418;\n" +
+ "public class Test {\n" +
+ " public <T> T foo() {\n" +
+ " class Inner {\n" +
+ " T run() {\n" +
+ " return new TwoLevelInner<T>() {T run() { return null; }}.run();\n" +
+ " }\n" +
+ " }\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "abstract class TwoLevelInner <T> {\n" +
+ " abstract T run();\n" +
+ "}\n"
+ }, p.getProject().getLocation().append("lib325418.jar").toOSString(), "1.5");
+ refresh(p);
+ //addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b325418.jar"), null, null));
+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask);
+ search("TwoLevelInner.run", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope, this.resultCollector);
+ assertSearchResults("Unexpected search results!",
+ "lib325418.jar T p325418.<anonymous>.run() [No source] EXACT_MATCH\n" +
+ "lib325418.jar T p325418.TwoLevelInner.run() [No source] EXACT_MATCH",
+ this.resultCollector);
+ } finally {
+ deleteProject("P");
+ }
+}
+
+/**
+ * @bug 324189: [search] Method Search returns false results
+ * @test Search for Worker.run() should not return results like TestWorker
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324189"
+ */
+public void testBug324189a() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b324189/X.java",
+ "package b324189;\n" +
+ "public class TestWorker{\n" +
+ " public void run() {}\n" +
+ "class AWorker {\n" +
+ " public void run() {}\n" +
+ "}\n"+
+ "}\n"
+ );
+ search("Worker.run()", METHOD, DECLARATIONS);
+ assertSearchResults("");
+}
+
+// Worker in the default package should be in the result
+public void testBug324189b() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Worker.java",
+ "public class Worker{\n" +
+ " public void run() {}\n" +
+ "}\n"
+ );
+ search("Worker.run()", METHOD, DECLARATIONS);
+ assertSearchResults("src/Worker.java void Worker.run() [run] EXACT_MATCH");
+}
+// bWorker in the package name should also not be in the search result
+public void testBug324189c() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/bWorker/X.java",
+ "package bWorker;\n" +
+ "public class X{\n" +
+ " public void run() {}\n" +
+ "}"
+ );
+ search("Worker.X.run()", METHOD, DECLARATIONS);
+ assertSearchResults("");
+}
+// TestWorker in a class file also should not be in the search result
+public void testBug324189d() throws CoreException, IOException {
+ String libPath = getExternalResourcePath("lib324189.jar");
+ try {
+ // Create project and external jar file
+ Util.createJar(
+ new String[] {
+ "b324189/TestWorker.java",
+ "package b324189;\n" +
+ "public class TestWorker{\n" +
+ " public void run() {}\n" +
+ "class Worker{\n" +
+ " public void run() {}\n" +
+ "}\n"+
+ "}",
+ "b324189/Worker.java",
+ "package b324189;\n" +
+ "public class Worker{\n" +
+ " public void run() {}\n" +
+ "}"
+ },
+ new HashMap(),
+ libPath);
+ IJavaProject javaProject = createJavaProject("P", new String[0], new String[] {libPath}, "");
+ waitUntilIndexesReady();
+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ;
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }, mask);
+ this.resultCollector.showSelection();
+ search("Worker.run()", METHOD, DECLARATIONS, scope);
+ assertSearchResults(
+ getExternalPath() + "lib324189.jar void b324189.TestWorker$Worker.run() EXACT_MATCH\n" +
+ getExternalPath() + "lib324189.jar void b324189.Worker.run() EXACT_MATCH"
+ );
+ } finally {
+ deleteExternalFile(libPath);
+ deleteProject("P");
+ }
+}
+// Test the special case in comment 20 of bug 324189
+public void testBug324189e() throws CoreException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b324189/A.java",
+ "package b324189;\n" +
+ "public class A{\n" +
+ " public void run() {}\n" +
+ "}\n"+
+ "class AnotherA {" +
+ " public void run() {} \n" +
+ " }\n"
+ );
+ search("A.run()", METHOD, DECLARATIONS);
+ assertSearchResults("src/b324189/A.java void b324189.A.run() [run] EXACT_MATCH");
+}
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java
index 44a4953ae..3222bb9c2 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MementoTests.java
@@ -92,7 +92,7 @@ public void setUpSuite() throws Exception {
"1.4");
this.createJavaProject(
"P",
- new String[] {"src"},
+ new String[] {"src", "!"},
new String[] {
getExternalJCLPathString(),
"/P/lib",
@@ -794,4 +794,15 @@ public void testTypeParameter2() {
"=P/src<p{X.java[X~foo]T",
typeParameter);
}
+/*
+ * Test that a package fragment root name starting with '!' can be reconstructed from
+ * the handle identifier.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=331821
+ */
+public void testBug331821() throws JavaModelException {
+ IPackageFragmentRoot root = getPackageFragmentRoot("P", "!");
+ String handleIdentifier = root.getHandleIdentifier();
+ IPackageFragmentRoot newRoot = (IPackageFragmentRoot) JavaCore.create(handleIdentifier);
+ assertEquals(root, newRoot);
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java
index eca154a56..611995e92 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/OptionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -632,7 +632,7 @@ public void testBug125360() throws CoreException, BackingStoreException {
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=131707"
*/
public void testBug131707() throws CoreException {
- IEclipsePreferences defaultPreferences = new DefaultScope().getNode(JavaCore.PLUGIN_ID);
+ IEclipsePreferences defaultPreferences = DefaultScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);
try {
defaultPreferences.put("org.eclipse.jdt.core.classpathVariable.MY_DEFAULT_LIB", "c:\\temp\\lib.jar");
simulateExitRestart();
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java
index e609caa17..a417b59d4 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/src/test0720/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/src/test0720/A.java
new file mode 100644
index 000000000..0b96904ef
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter/src/test0720/A.java
@@ -0,0 +1,14 @@
+package test0720;
+
+public class A
+{
+ public A()
+ {
+
+ }
+
+}
+interface B
+{
+ public void method(final int parameter) { }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter15/src/test0348/AnnotatedInterfaceWithStringDefault.java b/org.eclipse.jdt.core.tests.model/workspace/Converter15/src/test0348/AnnotatedInterfaceWithStringDefault.java
new file mode 100644
index 000000000..fd1a2e1de
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter15/src/test0348/AnnotatedInterfaceWithStringDefault.java
@@ -0,0 +1,5 @@
+package test0348;
+
+@TestAnnotationWithStringDefault
+public interface AnnotatedInterfaceWithStringDefault {
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter15/src/test0348/TestAnnotationWithStringDefault.java b/org.eclipse.jdt.core.tests.model/workspace/Converter15/src/test0348/TestAnnotationWithStringDefault.java
new file mode 100644
index 000000000..4c8cb429e
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter15/src/test0348/TestAnnotationWithStringDefault.java
@@ -0,0 +1,19 @@
+package test0348;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface TestAnnotationWithStringDefault {
+ String emptyString() default "";
+ String string() default "string";
+
+ @TestAnnotationWithStringDefault
+ public static class Annotated {}
+
+ @TestAnnotationWithStringDefault
+ public interface AnnotatedInterface {}
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test488/A_out.java b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test488/A_out.java
index 5c2b20aa6..be3d2d0b3 100644
--- a/org.eclipse.jdt.core.tests.model/workspace/Formatter/test488/A_out.java
+++ b/org.eclipse.jdt.core.tests.model/workspace/Formatter/test488/A_out.java
@@ -4,14 +4,14 @@ public class A {
case VALUE0 :
doCase0();
break;
- case VALUE1 :{
+ case VALUE1 : {
doCase1();
break;
}
case VALUE2 :
doCase2();
break;
- default :{
+ default : {
doDefault();
}
}

Back to the top