diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JDTUtils.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JDTUtils.java index e7955d4ba4..d22cfa4b20 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JDTUtils.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JDTUtils.java @@ -11,7 +11,6 @@ package org.eclipse.jdt.ls.core.internal; import static org.eclipse.core.resources.IResource.DEPTH_ONE; -import static org.eclipse.core.resources.IResource.DEPTH_ZERO; import java.io.File; import java.io.IOException; diff --git a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/JDTUtilsTest.java b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/JDTUtilsTest.java index b82bdf6c05..de7a5d07f3 100644 --- a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/JDTUtilsTest.java +++ b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/JDTUtilsTest.java @@ -30,6 +30,7 @@ import org.apache.commons.io.FileUtils; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; @@ -229,4 +230,21 @@ public void testIsFolder() throws Exception { assertNotNull(JDTUtils.findFile(uriFile.toString())); assertNotNull(JDTUtils.findFolder(uriFolder.toString())); } + + @Test + public void testGetFileOrFolder() throws Exception { + // For: https://github.com/eclipse/eclipse.jdt.ls/issues/1137 + IProject project = WorkspaceHelper.getProject(ProjectsManager.DEFAULT_PROJECT_NAME); + + File dir = new File(project.getLocation().toString(), "/src/org/eclipse/testGetFileOrFolder"); + dir.mkdirs(); + + IResource resource = JDTUtils.getFileOrFolder(dir.toURI().toString()); + assertNotNull(resource); + + IContainer parent = resource.getParent(); + assertTrue(parent instanceof IFolder); + + assertEquals("The parent package should be aware of the newly created child package", parent.members().length, 1); + } }