use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class JdtToBeBuiltComputer method updateProject.
@Override
public void updateProject(ToBeBuilt toBeBuilt, IProject project, IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 2);
if (progress.isCanceled()) {
throw new OperationCanceledException();
}
if (!project.isAccessible())
return;
IJavaProject javaProject = JavaCore.create(project);
if (javaProject.exists()) {
IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
progress.setWorkRemaining(roots.length);
final Map<String, Long> updated = Maps.newHashMap();
ProjectOrder orderedProjects = workspace.computeProjectOrder(workspace.getRoot().getProjects());
for (final IPackageFragmentRoot root : roots) {
if (progress.isCanceled())
throw new OperationCanceledException();
if (shouldHandle(root) && !isBuiltByUpstream(root, project, orderedProjects.projects)) {
Map<URI, IStorage> rootData = jdtUriMapperExtension.getAllEntries(root);
for (Map.Entry<URI, IStorage> e : rootData.entrySet()) if (uriValidator.canBuild(e.getKey(), e.getValue())) {
toBeBuilt.getToBeDeleted().add(e.getKey());
toBeBuilt.getToBeUpdated().add(e.getKey());
}
}
progress.worked(1);
}
synchronized (modificationStampCache) {
modificationStampCache.projectToModificationStamp.putAll(updated);
}
}
}
use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class WorkspaceProjectsStateTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
uri1 = createFileAndRegisterResource(project1, "file1");
uri2 = createFileAndRegisterResource(project1, "file2");
uri3 = createFileAndRegisterResource(project2, "file3");
Storage2UriMapperImpl mapper = new Storage2UriMapperImpl() {
@Override
public boolean isValidUri(URI uri, IStorage storage) {
return uri != null && !uri.toString().endsWith("/.project");
}
};
mapper.setUriValidator(new UriValidator() {
@Override
public boolean isValid(URI uri, IStorage storage) {
return true;
}
@Override
public boolean isPossiblyManaged(IStorage storage) {
return true;
}
});
projectsState = new WorkspaceProjectsState();
projectsState.setMapper(mapper);
WorkspaceProjectsStateHelper helper = new WorkspaceProjectsStateHelper();
helper.setMapper(mapper);
helper.setWorkspace(ResourcesPlugin.getWorkspace());
projectsState.setHelper(helper);
}
use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class JavaBreakPointProvider method getJavaLineNumber.
private int getJavaLineNumber(final IJavaStratumLineBreakpoint breakpoint) throws CoreException {
ILocationInEclipseResource javaLocation = getJavaLocation(breakpoint);
if (javaLocation == null)
return -1;
IStorage storage = javaLocation.getPlatformResource();
if (storage == null) {
ITextRegionWithLineInformation textRegion = javaLocation.getTextRegion();
if (textRegion == null)
return -1;
return textRegion.getEndLineNumber();
} else {
AbstractEclipseTrace sourceTrace = (AbstractEclipseTrace) traceForStorageProvider.getTraceToSource(storage);
if (sourceTrace == null)
return -1;
AbstractTraceRegion rootTraceRegion = sourceTrace.getRootTraceRegion();
if (rootTraceRegion == null)
return -1;
List<LineMapping> lineMappings = lineMappingProvider.getLineMapping(rootTraceRegion);
if (lineMappings == null) {
return -1;
}
for (LineMapping lineMapping : lineMappings) {
if (lineMapping.sourceStartLine == breakpoint.getLineNumber()) {
return lineMapping.targetEndLine + 1;
}
}
return -1;
}
}
use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class EclipseResourceFileSystemAccess2 method getTraceFile.
/**
* @since 2.3
*/
/* @Nullable */
protected IFile getTraceFile(IFile file) {
IStorage traceFile = fileBasedTraceInformation.getTraceFile(file);
if (traceFile instanceof IFile) {
IFile result = (IFile) traceFile;
syncIfNecessary(result);
return result;
}
return null;
}
use of org.eclipse.core.resources.IStorage in project xtext-eclipse by eclipse.
the class MarkerUpdaterImpl method processDelta.
private void processDelta(Delta delta, /* @Nullable */
ResourceSet resourceSet, IProgressMonitor monitor) throws OperationCanceledException {
URI uri = delta.getUri();
IResourceUIValidatorExtension validatorExtension = getResourceUIValidatorExtension(uri);
IMarkerContributor markerContributor = getMarkerContributor(uri);
CheckMode normalAndFastMode = CheckMode.NORMAL_AND_FAST;
for (Pair<IStorage, IProject> pair : mapper.getStorages(uri)) {
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
if (pair.getFirst() instanceof IFile) {
IFile file = (IFile) pair.getFirst();
if (EXTERNAL_PROJECT_NAME.equals(file.getProject().getName())) {
// skip the marker processing of that file, as the user can't react on any markers anyway.
continue;
}
if (delta.getNew() != null) {
if (resourceSet == null)
throw new IllegalArgumentException("resourceSet may not be null for changed resources.");
Resource resource = resourceSet.getResource(uri, true);
if (validatorExtension != null) {
validatorExtension.updateValidationMarkers(file, resource, normalAndFastMode, monitor);
}
if (markerContributor != null) {
markerContributor.updateMarkers(file, resource, monitor);
}
} else {
if (validatorExtension != null) {
validatorExtension.deleteValidationMarkers(file, normalAndFastMode, monitor);
} else {
deleteAllValidationMarker(file, normalAndFastMode, monitor);
}
if (markerContributor != null) {
markerContributor.deleteMarkers(file, monitor);
} else {
deleteAllContributedMarkers(file, monitor);
}
}
}
}
}
Aggregations