Skip to content

Commit 7d12608

Browse files
committed
Fix compile error in CompilationUnitDocumentProviderTest
Fixes: #2840
1 parent ad1a2d4 commit 7d12608

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/CompilationUnitDocumentProviderTest.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,29 @@
1818
import static org.junit.jupiter.api.Assertions.assertNull;
1919
import static org.junit.jupiter.api.Assertions.assertTrue;
2020

21+
import java.io.File;
22+
2123
import org.junit.jupiter.api.AfterEach;
2224
import org.junit.jupiter.api.Test;
2325

2426
import org.eclipse.jdt.testplugin.JavaProjectHelper;
2527

2628
import org.eclipse.core.runtime.CoreException;
29+
import org.eclipse.core.runtime.IPath;
30+
import org.eclipse.core.runtime.NullProgressMonitor;
2731
import org.eclipse.core.runtime.Path;
32+
import org.eclipse.core.runtime.Platform;
33+
import org.eclipse.core.runtime.Plugin;
2834

2935
import org.eclipse.core.resources.IFile;
3036
import org.eclipse.core.resources.IFolder;
3137
import org.eclipse.core.resources.IProject;
38+
import org.eclipse.core.resources.IProjectDescription;
39+
import org.eclipse.core.resources.IWorkspace;
3240
import org.eclipse.core.resources.IWorkspaceRoot;
3341
import org.eclipse.core.resources.ResourcesPlugin;
3442

43+
import org.eclipse.core.filebuffers.tests.FileTool;
3544
import org.eclipse.core.filebuffers.tests.ResourceHelper;
3645

3746
import org.eclipse.ui.IEditorInput;
@@ -104,7 +113,7 @@ public void test2() throws Exception {
104113

105114
@Test
106115
public void test3() throws Exception {
107-
fLinkedProject= ResourceHelper.createLinkedProject("P2", JdtTextTestPlugin.getDefault(), new Path("testResources/folderLinkTarget1"));
116+
fLinkedProject= createLinkedProject("P2", JdtTextTestPlugin.getDefault(), new Path("testResources/folderLinkTarget1"));
108117
assertNotNull(fLinkedProject);
109118
assertTrue(fLinkedProject.exists());
110119

@@ -147,4 +156,23 @@ private void checkFile(IFile file) throws CoreException {
147156
assertNull(provider.getDocument(input));
148157
assertNull(provider.getAnnotationModel(input));
149158
}
159+
160+
private static IProject createLinkedProject(String projectName, Plugin plugin, IPath linkPath) throws CoreException {
161+
IWorkspace workspace= ResourcesPlugin.getWorkspace();
162+
IProject project= workspace.getRoot().getProject(projectName);
163+
164+
IProjectDescription desc= workspace.newProjectDescription(projectName);
165+
File file= FileTool.getFileInPlugin(plugin, linkPath);
166+
IPath projectLocation= IPath.fromOSString(file.getAbsolutePath());
167+
if (Platform.getLocation().equals(projectLocation))
168+
projectLocation= null;
169+
desc.setLocation(projectLocation);
170+
171+
NullProgressMonitor monitor= new NullProgressMonitor();
172+
project.create(desc, monitor);
173+
if (!project.isOpen())
174+
project.open(monitor);
175+
176+
return project;
177+
}
150178
}

0 commit comments

Comments
 (0)