use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer in project n4js by eclipse.
the class N4JSEclipseModel method getN4JSSourceContainer.
public Optional<? extends IN4JSSourceContainer> getN4JSSourceContainer(IResource resource) {
N4JSEclipseProject project = getN4JSProject(resource.getProject());
ImmutableList<? extends IN4JSEclipseSourceContainer> containers = project.getSourceContainers();
IPath fullPath = resource.getFullPath();
for (IN4JSEclipseSourceContainer container : containers) {
if (matchPaths(fullPath, container)) {
return Optional.of(container);
}
}
return Optional.absent();
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer in project n4js by eclipse.
the class N4JSToBeBuiltComputer method updateStorage.
@Override
public boolean updateStorage(ToBeBuilt toBeBuilt, IStorage storage, IProgressMonitor monitor) {
if (storage instanceof IFile) {
IFile file = (IFile) storage;
String extension = file.getFileExtension();
// changed archive - schedule contents
if (IN4JSArchive.NFAR_FILE_EXTENSION.equals(extension)) {
IProject project = file.getProject();
String key = project.getName() + "|" + storage.getFullPath().toPortableString();
Set<URI> cachedURIs = knownEntries.remove(key);
if (cachedURIs != null) {
toBeBuilt.getToBeDeleted().addAll(cachedURIs);
}
cachedURIs = Sets.newHashSet();
storageMapper.collectNfarURIs((IFile) storage, cachedURIs);
knownEntries.put(key, cachedURIs);
toBeBuilt.getToBeUpdated().addAll(cachedURIs);
return true;
} else if (IN4JSProject.N4MF_MANIFEST.equals(file.getName())) {
// changed manifest - schedule all resources from source folders
final IN4JSEclipseProject project = eclipseCore.create(file.getProject()).orNull();
if (null != project && project.exists()) {
List<? extends IN4JSEclipseSourceContainer> sourceContainers = project.getSourceContainers();
Set<URI> toBeUpdated = toBeBuilt.getToBeUpdated();
for (IN4JSEclipseSourceContainer sourceContainer : sourceContainers) {
for (URI uri : sourceContainer) {
if (uriValidator.canBuild(uri, new URIBasedStorage(uri))) {
toBeUpdated.add(uri);
}
}
}
}
IProject resourceProject = file.getProject();
String projectName = resourceProject.getName();
Set<URI> toBeDeleted = toBeBuilt.getToBeDeleted();
for (final IResourceDescription description : builderState.getAllResourceDescriptions()) {
URI uri = description.getURI();
if (uri.isPlatformResource()) {
if (projectName.equals(uri.segment(1))) {
toBeDeleted.add(uri);
}
}
}
// still return false because we want to do the normal processing for the manifest file, too
return false;
}
}
return false;
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer in project n4js by eclipse.
the class N4JSEclipseModel method getN4JSSourceContainers.
@Override
public ImmutableList<? extends IN4JSEclipseSourceContainer> getN4JSSourceContainers(N4JSProject project) {
ImmutableList.Builder<IN4JSEclipseSourceContainer> result = ImmutableList.builder();
URI location = project.getLocation();
ProjectDescription description = getProjectDescription(location);
if (description != null) {
List<SourceFragment> sourceFragments = newArrayList(from(description.getSourceFragment()));
sourceFragments.sort((f1, f2) -> f1.compareByFragmentType(f2));
for (SourceFragment sourceFragment : sourceFragments) {
List<String> paths = sourceFragment.getPaths();
for (String p : paths) {
IN4JSEclipseSourceContainer sourceContainer = createProjectN4JSSourceContainer(project, sourceFragment.getSourceFragmentType(), p);
result.add(sourceContainer);
}
}
}
return result.build();
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer in project n4js by eclipse.
the class N4JSEclipseModel method createProjectN4JSSourceContainer.
@Override
protected IN4JSEclipseSourceContainer createProjectN4JSSourceContainer(N4JSProject project, SourceFragmentType type, String relativeLocation) {
N4JSEclipseProject casted = (N4JSEclipseProject) project;
IProject eclipseProject = casted.getProject();
final IContainer container;
if (".".equals(relativeLocation)) {
container = eclipseProject;
} else {
container = eclipseProject.getFolder(relativeLocation);
}
return new EclipseSourceContainer(casted, type, container);
}
Aggregations