Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2020-02-28 03:38:39 -0500
committerManoj Palat2020-02-28 03:53:26 -0500
commit02f2318239f4f57725187ac1964724baf9231ca2 (patch)
tree1e5f57ff50241168c2693b9794390adfd94b94a1
parent93b7413003d18d7935ee495d0d7167bdca4aa0e1 (diff)
downloadeclipse.jdt.core-I20200228-1800.tar.gz
eclipse.jdt.core-I20200228-1800.tar.xz
eclipse.jdt.core-I20200228-1800.zip
Bug 543073 - The CompilationUnitSorter.sort() throws on level = 11 inX20200229-0700X20200228-1900X20200228-0700X20200228-0520I20200229-0600I20200228-1800
4.10 Change-Id: I9d59929fa2fee1c3b8dc47322233dd38bf74313b Signed-off-by: Manoj Palat <manpalat@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java28
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java5
2 files changed, 31 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java
index 679e6a0e0b..5a41713730 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -1920,6 +1920,32 @@ public void test029() throws CoreException {
deleteFile("/P/src/X.java");
}
}
+@SuppressWarnings("deprecation")
+public void testBug543073_001() throws CoreException {
+ try {
+ this.createFile(
+ "/P/src/X.java",
+ "public enum X {\n" +
+ " Z, A, C, B;\n" +
+ "}"
+ );
+ String expectedResult =
+ "public enum X {\n" +
+ " Z, A, C, B;\n" +
+ "}";
+ sortUnit(AST_INTERNAL_JLS10, this.getCompilationUnit("/P/src/X.java"), expectedResult, false, new Comparator() {
+ public int compare(Object o1, Object o2) {
+ BodyDeclaration bodyDeclaration1 = (BodyDeclaration) o1;
+ BodyDeclaration bodyDeclaration2 = (BodyDeclaration) o2;
+ final int sourceStart1 = ((Integer) bodyDeclaration1.getProperty(CompilationUnitSorter.RELATIVE_ORDER)).intValue();
+ final int sourceStart2 = ((Integer) bodyDeclaration2.getProperty(CompilationUnitSorter.RELATIVE_ORDER)).intValue();
+ return sourceStart1 - sourceStart2;
+ }
+ });
+ } finally {
+ deleteFile("/P/src/X.java");
+ }
+}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=113722
public void test030() throws CoreException {
try {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java
index c4a942990e..19b2f07f23 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -57,6 +57,9 @@ public final class CompilationUnitSorter {
case AST.JLS8 :
case AST.JLS9 :
case AST.JLS10 :
+ case AST.JLS11 :
+ case AST.JLS12 :
+ case AST.JLS13 :
break;
default :
throw new IllegalArgumentException();

Back to the top