Skip to content

Commit 11a9bf1

Browse files
committed
refactor: directly use Path in test instead of converting to File first
1 parent e3113b1 commit 11a9bf1

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/outline/OutlineContentTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void testExternalFile(@TempDir Path tempDir) throws CoreException, IOExce
6060

6161
MockLanguageServer.INSTANCE.setDocumentSymbols(symbolCow);
6262

63-
final var editor = (ITextEditor) TestUtils.openExternalFileInEditor(testFile.toFile());
63+
final var editor = (ITextEditor) TestUtils.openExternalFileInEditor(testFile);
6464

6565
final var outlinePage = (CNFOutlinePage) new EditorToOutlineAdapterFactory().getAdapter(editor, IContentOutlinePage.class);
6666
final var shell = new Shell(editor.getEditorSite().getWorkbenchWindow().getShell());
@@ -90,7 +90,7 @@ public void testExternalFileOpenedOnFileStore(@TempDir Path tempDir) throws Core
9090

9191
MockLanguageServer.INSTANCE.setDocumentSymbols(symbolCow);
9292

93-
final var editor = (ITextEditor) TestUtils.openExternalFileOnFileStore(testFile.toFile());
93+
final var editor = (ITextEditor) TestUtils.openExternalFileOnFileStore(testFile);
9494

9595
final var outlinePage = (CNFOutlinePage) new EditorToOutlineAdapterFactory().getAdapter(editor, IContentOutlinePage.class);
9696
final var shell = new Shell(editor.getEditorSite().getWorkbenchWindow().getShell());

org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/outline/OutlineViewerInputTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void testDocumentURIAbsolutePathForExternalFile(@TempDir Path tempDir) th
6262
var tempFile = Files.writeString(tempDir.resolve("externalTest.lspt"), "external file content for testing absolute paths");
6363

6464
// Open the external file in an editor
65-
var editor = (ITextEditor) TestUtils.openExternalFileInEditor(tempFile.toFile());
65+
var editor = (ITextEditor) TestUtils.openExternalFileInEditor(tempFile);
6666
var document = LSPEclipseUtils.getDocument(editor);
6767

6868
// Create OutlineViewerInput and verify documentURI

org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/utils/TestUtils.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import static org.junit.jupiter.api.Assertions.assertTrue;
1616

1717
import java.io.ByteArrayInputStream;
18-
import java.io.File;
1918
import java.io.IOException;
2019
import java.nio.file.Files;
2120
import java.nio.file.Path;
@@ -101,20 +100,20 @@ public static List<IEditorReference> splitActiveEditor() {
101100
return List.of(page.getEditorReferences());
102101
}
103102

104-
public static IEditorPart openExternalFileInEditor(File file) throws PartInitException {
103+
public static IEditorPart openExternalFileInEditor(Path file) throws PartInitException {
105104
IWorkbenchWindow workbenchWindow = UI.getActiveWindow();
106105
IWorkbenchPage page = workbenchWindow.getActivePage();
107-
IEditorPart part = IDE.openEditor(page, file.toURI(), "org.eclipse.ui.genericeditor.GenericEditor", false);
106+
IEditorPart part = IDE.openEditor(page, file.toUri(), "org.eclipse.ui.genericeditor.GenericEditor", false);
108107
if (part != null) {
109108
part.setFocus();
110109
}
111110
return part;
112111
}
113112

114-
public static IEditorPart openExternalFileOnFileStore(File file) throws PartInitException {
113+
public static IEditorPart openExternalFileOnFileStore(Path file) throws PartInitException {
115114
IWorkbenchWindow workbenchWindow = UI.getActiveWindow();
116115
IWorkbenchPage page = workbenchWindow.getActivePage();
117-
IFileStore fileStore = EFS.getLocalFileSystem().getStore(file.toURI());
116+
IFileStore fileStore = EFS.getLocalFileSystem().getStore(file.toUri());
118117
IEditorPart part = IDE.openEditorOnFileStore(page, fileStore);
119118
if (part != null) {
120119
part.setFocus();

0 commit comments

Comments
 (0)