Skip to content

Commit e0066d6

Browse files
snjezadatho7561
authored andcommitted
Test case for PR #1139
Signed-off-by: Snjezana Peco <[email protected]>
1 parent d79b0e9 commit e0066d6

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package test;
2+
3+
import java.io.ByteArrayInputStream;
4+
5+
public class OtherClass {
6+
public void test(ByteArrayInputStream baos) {
7+
}
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package test;
2+
3+
import java.io.ByteArrayInputStream;
4+
5+
public class TestUnusedImport {
6+
7+
/**
8+
* {@link OtherClass#test(ByteArrayInputStream)}
9+
*/
10+
void method() {
11+
}
12+
}

org.eclipse.jdt.core.tests.javac/src/org/eclipse/jdt/core/tests/javac/RegressionTests.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void cleanUp() throws Exception {
8282
@Test
8383
public void testCheckBuild() throws Exception {
8484
project.build(IncrementalProjectBuilder.FULL_BUILD, null);
85-
assertEquals(Set.of("A.class", "B.class", "pack"),
85+
assertEquals(Set.of("A.class", "B.class", "pack", "test"),
8686
new HashSet<>(Arrays.asList(new File(project.getLocation().toFile(), "bin").list())));
8787
assertArrayEquals(new String[] { "Packaged.class" },
8888
new File(project.getLocation().toFile(), "bin/pack").list());
@@ -142,6 +142,7 @@ public void testBuildMultipleOutputDirectories2() throws Exception {
142142
}
143143

144144
// https://github.com/eclipse-jdtls/eclipse-jdt-core-incubator/issues/955
145+
@SuppressWarnings("restriction")
145146
@Test
146147
public void testlombok() throws Exception {
147148
Assume.assumeTrue("javac is not set, skip it", CompilationUnit.DOM_BASED_OPERATIONS);
@@ -157,6 +158,18 @@ public void testlombok() throws Exception {
157158
assertArrayEquals(new IProblem[0], dom.getProblems());
158159
}
159160

161+
// https://github.com/eclipse-jdtls/eclipse-jdt-core-incubator/issues/1140
162+
@Test
163+
public void testUnusedImport() throws Exception {
164+
ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.CLEAN_BUILD, null);
165+
ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
166+
waitForBackgroundJobs();
167+
ICompilationUnit unit = (ICompilationUnit)JavaCore.create(project).findElement(Path.fromOSString("test/TestUnusedImport.java"));
168+
unit.becomeWorkingCopy(null);
169+
var dom = unit.reconcile(AST.getJLSLatest(), true, unit.getOwner(), null);
170+
assertArrayEquals(new IProblem[0], dom.getProblems());
171+
}
172+
160173
static IProject importProject(String locationInBundle) throws URISyntaxException, IOException, CoreException {
161174
File file = new File(FileLocator.toFileURL(RegressionTests.class.getResource("/" + locationInBundle + "/.project")).toURI());
162175
IPath dotProjectPath = Path.fromOSString(file.getAbsolutePath());

0 commit comments

Comments
 (0)