| Summary: | [M2x IDE Integration] Simplfy the implementation of org.eclipse.sphinx.xtendxpand.util.XtendXpandUtil.getUnderlyingFile(String, ResourceLoader) method & Add JUnit and Integration tests for testing this method | ||
|---|---|---|---|
| Product: | [Automotive] Sphinx | Reporter: | Idrissa Dieng <idydieng> |
| Component: | Core | Assignee: | Idrissa Dieng <idydieng> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | ali.akar82, idydieng, r.sezestre, stephaneberle9 |
| Version: | 0.7.0 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
(In reply to comment #0) > - a linked file (located outsite of the workspace), > - a file containing in a linked folder (located outsite of the workspace), > - a file located in the workspace. Some JavaDoc should be added explaining these facts. > IFileStore fileStore = EFS.getStore(resourceURL.toURI()); > if (fileStore != null) { > IFile[] files = > workspaceRoot.findFilesForLocationURI(fileStore.toURI()); Are you sure that we need the EFS.getStore() thing? We could try to pass the result of resourceURL.toURI() directly to workspaceRoot.findFilesForLocationURI(). (In reply to comment #1) > (In reply to comment #0) > > - a linked file (located outsite of the workspace), > > - a file containing in a linked folder (located outsite of the workspace), > > - a file located in the workspace. > > Some JavaDoc should be added explaining these facts. > > > IFileStore fileStore = EFS.getStore(resourceURL.toURI()); > > if (fileStore != null) { > > IFile[] files = > > workspaceRoot.findFilesForLocationURI(fileStore.toURI()); > > Are you sure that we need the EFS.getStore() thing? We could try to pass the > result of resourceURL.toURI() directly to > workspaceRoot.findFilesForLocationURI(). yes you're right just following code is need: IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // Gets all files that are mapped in the current workspace to the given URI. The file search result // include files located in the current workspace and also linked files or files contained in a linked // folder that were located outside of the workspace. IFile[] files = workspaceRoot.findFilesForLocationURI(resourceURL.toURI()); Fixed but I leave the bug open until the availablity of JUnit and Integration tests for org.eclipse.sphinx.xtendxpand.util.XtendXpandUtil#getUnderlyingFile(String, ResourceLoader) method. The JUnit test case for XtendXpandUtil#getUnderlyingFile(String, ResourceLoader) method should be added for getting the underlying for following cases: (1) linked file (located outsite of the current workspace) (2) file located in the workspace. Steps to do for (2): * Copy the resource to be linked into working directory (using the org.eclipse.sphinx.testutils.TestFileAccessor.createWorkingCopyOfInputFile(String) method) * Creates a linked file (from working directory) into transformXtendProject project * Call XtendXpandUtil#getUnderlyingFile(String, ResourceLoader) method and verify if every thing (e.g., path ect.) is OK Fixed as bug description and comments Mass-closing Resolved tickets |
The implementation of the org.eclipse.sphinx.xtendxpand.util.XtendXpandUtil.getUnderlyingFile(String, ResourceLoader) method should be simply in order to manage in the same way: - a linked file (located outsite of the workspace), - a file containing in a linked folder (located outsite of the workspace), - a file located in the workspace. The nemwly code is: public static IFile getUnderlyingFile(String qualifiedName, ResourceLoader resourceLoader) { Assert.isNotNull(resourceLoader); URL resourceURL = resourceLoader.getResource(qualifiedName); if (resourceURL != null) { try { IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // Checks whether there given file store points to a file in the workspace IFileStore fileStore = EFS.getStore(resourceURL.toURI()); if (fileStore != null) { IFile[] files = workspaceRoot.findFilesForLocationURI(fileStore.toURI()); if (files != null && files.length > 0) { // Returns the first workspace file that match return files[0]; } } } catch (Exception ex) { // Ignore exception } } return null; } We shoul add also JUnit and Integration tests for testing this method.