use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class JavaUtil method resolveFQN.
/**
* Resolves fully qualified name based on base on start point container and end point resource.
* <p/>
* Usually as start point there is a source directory and as end point there is a package fragment or java file.
*
* @param startPoint
* the start point container from which fqn should be resolved
* @param endPoint
* the end point resource to which fqn should be resolved
* @return the resolved fully qualified name
* @throws IllegalArgumentException
* in case if given arguments are invalid. Reason includes:
* <ul>
* <li>Null source folder occurred</li>
* <li>Null resource occurred</li>
* <li>Given base folder is not prefix of checked resource</li>
* </ul>
* @since 4.4.0
*/
public static String resolveFQN(Container startPoint, Resource endPoint) {
checkArgument(startPoint != null, "Null source folder occurred");
checkArgument(endPoint != null, "Null resource occurred");
checkArgument(startPoint.getLocation().isPrefixOf(endPoint.getLocation()), "Given base folder is not prefix of checked resource");
Path path = endPoint.getLocation().removeFirstSegments(startPoint.getLocation().segmentCount());
if (isJavaFile(endPoint)) {
final String ext = ((File) endPoint).getExtension();
if (!isNullOrEmpty(ext)) {
final String name = endPoint.getName();
path = path.removeLastSegments(1).append(name.substring(0, name.length() - ext.length() - 1));
}
}
return path.toString().replace('/', '.');
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class MavenMessagesHandler method computeUniqueHiLevelProjects.
private Set<String> computeUniqueHiLevelProjects(List<String> updatedProjects) {
Set<String> result = new HashSet<>();
for (String project : updatedProjects) {
Path path = new Path(project);
if (path.segmentCount() > 1) {
//TODO maven modules may exists in sub sub directory
path = path.removeLastSegments(1);
}
result.add(path.toString());
}
return result;
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class SourcepathMacroTest method setUp.
@Before
public void setUp() throws Exception {
resources[0] = resource;
when(appContext.getResources()).thenReturn(resources);
when(resource.getRelatedProject()).thenReturn(projectOptional);
when(projectOptional.get()).thenReturn(project);
Map<String, List<String>> attributes = new HashMap<>();
attributes.put(Constants.LANGUAGE, singletonList("java"));
when(project.getAttributes()).thenReturn(attributes);
Path projectPath = Path.valueOf("/name");
when(project.getLocation()).thenReturn(projectPath);
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class SourcepathMacroTest method defaultValueOfSourcepathShouldBeBuilt.
@Test
public void defaultValueOfSourcepathShouldBeBuilt() throws Exception {
List<ClasspathEntryDto> entries = new ArrayList<>();
Set<String> libs = new HashSet<>();
Path projectsRoot = Path.valueOf("/projects");
when(appContext.getProjectsRoot()).thenReturn(projectsRoot);
when(classpathContainer.getClasspathEntries(anyString())).thenReturn(classpathEntriesPromise);
when(classpathResolver.getLibs()).thenReturn(libs);
sourcepathMacro.expand();
verify(classpathEntriesPromise).then(classpathEntriesCapture.capture());
String classpath = classpathEntriesCapture.getValue().apply(entries);
verify(classpathResolver).resolveClasspathEntries(entries);
assertEquals("/projects/name", classpath);
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ClasspathMacroTest method setUp.
@Before
public void setUp() throws Exception {
resources[0] = resource;
when(appContext.getResources()).thenReturn(resources);
when(resource.getRelatedProject()).thenReturn(projectOptional);
when(projectOptional.get()).thenReturn(project);
Map<String, List<String>> attributes = new HashMap<>();
attributes.put(Constants.LANGUAGE, singletonList("java"));
when(project.getAttributes()).thenReturn(attributes);
Path projectPath = Path.valueOf("/name");
when(project.getLocation()).thenReturn(projectPath);
}
Aggregations