use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.
the class NfarStorageMapper method initializeCache.
@Override
public void initializeCache() {
Optional<? extends IN4JSEclipseProject> projectOpt = null;
IN4JSEclipseProject n4jsProject = null;
for (IProject project : workspace.getRoot().getProjects()) {
projectOpt = eclipseCore.create(project);
if (projectOpt.isPresent()) {
n4jsProject = projectOpt.get();
if (n4jsProject.exists()) {
updateCache(n4jsProject);
}
}
}
Listener listener = new Listener();
workspace.addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.
the class NfarStorageMapper method collectNfarURIs.
public void collectNfarURIs(IProject project, Set<URI> target) {
Optional<? extends IN4JSEclipseProject> projectOpt = eclipseCore.create(project);
if (projectOpt.isPresent()) {
IN4JSEclipseProject n4jsProject = projectOpt.get();
Set<URI> archives = knownLibArchives.get(n4jsProject.getLocation());
if (archives != null) {
for (URI archiveURI : archives) {
Set<URI> entries = knownEntries.get(archiveURI);
if (entries != null) {
target.addAll(entries);
}
}
}
}
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.
the class N4MFProjectDependencyStrategy method getProjectDependencies.
@Override
public List<IProject> getProjectDependencies(final IProject project) {
final IN4JSEclipseProject n4Project = core.create(project).orNull();
if (null != n4Project) {
// This covers project dependencies, tests (if any), required REs and required RLs and APIs.
final Collection<? extends IN4JSEclipseProject> dependencies = n4Project.getDependenciesAndImplementedApis();
// This is for the provided runtime libraries.
final Collection<IN4JSEclipseProject> providedRuntimeLibs = from(n4Project.getProvidedRuntimeLibraries()).filter(IN4JSEclipseProject.class).toList();
// This is for the extended RE, if specified.
final IN4JSSourceContainerAware srcContainerAware = n4Project.getExtendedRuntimeEnvironment().orNull();
final IN4JSEclipseProject extendedRE = srcContainerAware instanceof IN4JSEclipseProject ? (IN4JSEclipseProject) srcContainerAware : null;
int projectCount = dependencies.size() + providedRuntimeLibs.size();
if (null != extendedRE) {
projectCount++;
}
final IProject[] projects = new IProject[projectCount];
int i = 0;
for (final IN4JSEclipseProject dependency : dependencies) {
projects[i++] = dependency.getProject();
}
for (final IN4JSEclipseProject providedRuntimeLib : providedRuntimeLibs) {
projects[i++] = providedRuntimeLib.getProject();
}
if (null != extendedRE) {
projects[i] = extendedRE.getProject();
}
return from(asList(projects)).filter(p -> !(p instanceof ExternalProject)).toList();
} else {
return emptyList();
}
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.
the class TestResultsView method onDoubleClick.
/**
* Invoked when user double-clicks a result node in the UI.
*/
protected void onDoubleClick() {
final ISelection selection = testTreeViewer.getSelection();
final ResultNode resultNode = (ResultNode) ((IStructuredSelection) selection).getFirstElement();
if (resultNode == null) {
return;
}
TestElement testElement = resultNode.getElement();
if (testElement instanceof TestCase) {
final URI testCaseURI = ((TestCase) testElement).getURI();
if (testCaseURI == null) {
return;
}
final IN4JSEclipseProject project = core.findProject(testCaseURI).orNull();
if (null != project && project.exists()) {
final URI moduleLocation = testCaseURI.trimFragment();
final String[] projectRelativeSegments = moduleLocation.deresolve(project.getLocation()).segments();
final String path = Joiner.on(SEPARATOR).join(copyOfRange(projectRelativeSegments, 1, projectRelativeSegments.length));
final IFile module = project.getProject().getFile(path);
if (null != module && module.isAccessible()) {
uriOpener.open(testCaseURI, true);
} else {
openError(getShell(), "Cannot open editor", "Test class not found in selected project.");
}
} else {
openError(getShell(), "Cannot open editor", "The container project not found in the workspace.");
}
}
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.
the class NfarStorageMapper method collectNfarURIs.
public void collectNfarURIs(IFile nfarArchive, Set<URI> target) {
URI archiveURI = URI.createPlatformResourceURI(nfarArchive.getFullPath().toString(), true);
Set<URI> entries = knownEntries.get(archiveURI);
if (entries != null) {
target.addAll(entries);
} else if (nfarArchive.exists()) {
Optional<? extends IN4JSEclipseProject> projectOpt = eclipseCore.create(nfarArchive.getProject());
if (projectOpt.isPresent()) {
IN4JSEclipseProject n4jsProject = projectOpt.get();
if (n4jsProject.exists()) {
updateCache(n4jsProject);
}
entries = knownEntries.get(archiveURI);
if (entries != null) {
target.addAll(entries);
} else {
// project exists but archive is not on the project path - we have to scan it nevertheless
Optional<? extends IN4JSEclipseArchive> archive = eclipseCore.findArchive(archiveURI);
if (archive.isPresent()) {
traverseArchive(archive.get(), target);
}
}
}
}
}
Aggregations