Java Code Examples for org.eclipse.xtext.resource.IResourceDescription.Delta#getUri()
The following examples show how to use
org.eclipse.xtext.resource.IResourceDescription.Delta#getUri() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: N4JSMarkerUpdater.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void updateMarkers(Delta delta, /* @Nullable */ ResourceSet resourceSet, IProgressMonitor monitor) throws OperationCanceledException { URI uri = delta.getUri(); Iterable<Pair<IStorage, IProject>> pairs = mapper.getStorages(uri); if (resourceSet != null && pairs.iterator().hasNext()) { Pair<IStorage, IProject> pair = pairs.iterator().next(); IStorage storage = pair.getFirst(); if (!(storage instanceof IFile)) { updateMarkersForExternalLibraries(delta, resourceSet, monitor); return; } } super.updateMarkers(delta, resourceSet, monitor); }
Example 2
Source File: XBuildManager.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** Update this build manager's state after the resources represented by the given deltas have been built. */ protected void recordBuildProgress(List<IResourceDescription.Delta> newlyBuiltDeltas, boolean didGenerate) { for (Delta delta : newlyBuiltDeltas) { URI uri = delta.getUri(); this.dirtyFiles.remove(uri); this.deletedFiles.remove(uri); if (didGenerate) { this.dirtyFilesAwaitingGeneration.remove(uri); this.deletedFilesAwaitingGeneration.remove(uri); } else { // a resource was built while doGenerate==false, so mark it as awaiting generation if (delta.getNew() != null) { this.deletedFilesAwaitingGeneration.remove(uri); this.dirtyFilesAwaitingGeneration.add(uri); } else { this.dirtyFilesAwaitingGeneration.remove(uri); this.deletedFilesAwaitingGeneration.add(uri); } } } mergeWithUnreportedDeltas(newlyBuiltDeltas); }
Example 3
Source File: ProjectStateHolder.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** Updates the index state, file hashes and validation issues */ public void updateProjectState(XBuildRequest request, XBuildResult result, IProjectConfig projectConfig) { HashMap<URI, HashedFileContent> newFileContents = new HashMap<>(uriToHashedFileContents); for (Delta delta : result.getAffectedResources()) { URI uri = delta.getUri(); storeHash(newFileContents, uri); } for (URI deletedFile : request.getResultDeleteFiles()) { newFileContents.remove(deletedFile); } setIndexState(result.getIndexState()); mergeValidationIssues(request.getResultIssues()); uriToHashedFileContents = newFileContents; if (request.isGeneratorEnabled() && !result.getAffectedResources().isEmpty()) { writeProjectState(projectConfig); } }
Example 4
Source File: CheckExtensionGenerator.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Add an extension to the <code>plugin.xml</code> file. * * @param context * build context * @param delta * resource delta * @param monitor * progress monitor * @throws CoreException * the core exception */ public void changePluginXmlFile(final IBuildContext context, final Delta delta, final IProgressMonitor monitor) throws CoreException { URI uri = delta.getUri(); CheckCatalog catalog = projectHelper.getCatalog(context, uri); if (catalog == null) { throw new CoreException(new Status(IStatus.ERROR, Activator.getPluginId(), IStatus.ERROR, "No Catalog found", null)); //$NON-NLS-1$ } IFile file = getPluginFile(uri); if (!validPluginFile(file)) { createNewFile(catalog, file, monitor); } else { if (!catalogValidates(catalog)) { removeExtensions(file, catalog, monitor); } else { updateExtensions(file, catalog, monitor); // TODO improve by only updating the manifest if the validator extension has changed.. } } mergeManifest(catalog, monitor); }
Example 5
Source File: BuilderUtil.java From n4js with Eclipse Public License 1.0 | 5 votes |
/***/ public static String print(ImmutableList<Delta> deltas) { int i = 1; String buff = "Deltas : \n"; for (Delta delta : deltas) { buff += "Delta " + i + "[" + delta.getUri() + "]: {\n"; buff += " old : " + toString(delta.getOld()) + "\n"; buff += " new : " + toString(delta.getNew()) + "\n"; buff += "}\n\n"; i++; } return buff; }
Example 6
Source File: N4JSMarkerUpdater.java From n4js with Eclipse Public License 1.0 | 5 votes |
private void updateMarkersForExternalLibraries(Delta delta, ResourceSet resourceSet, IProgressMonitor monitor) { URI uri = delta.getUri(); if (n4jsCore.isNoValidate(uri)) { return; } Resource resource = resourceSet.getResource(uri, true); IResourceValidator validator = getValidator(resource); IN4JSProject prj = n4jsCore.findProject(uri).orNull(); CancelIndicator cancelIndicator = getCancelIndicator(monitor); if (prj != null && prj.isExternal() && prj.exists() && prj instanceof N4JSEclipseProject && uri.isFile()) { // transform file uri in workspace iResource IFile file = URIUtils.convertFileUriToPlatformFile(uri); if (file != null && resource != null) { List<Issue> list = validator.validate(resource, CheckMode.NORMAL_AND_FAST, cancelIndicator); if (SHOW_ONLY_EXTERNAL_ERRORS) { for (Iterator<Issue> iter = list.iterator(); iter.hasNext();) { if (iter.next().getSeverity() != Severity.ERROR) { iter.remove(); } } } try { validatorExtension.createMarkers(file, resource, list); } catch (CoreException e) { e.printStackTrace(); } } } }
Example 7
Source File: BuilderUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public static String print(ImmutableList<Delta> deltas) { int i = 1; String buff = "Deltas : \n"; for (Delta delta : deltas) { buff+= "Delta "+i+"["+delta.getUri()+"]: {\n"; buff+= " old : "+toString(delta.getOld())+"\n"; buff+= " new : "+toString(delta.getNew())+"\n"; buff+= "}\n\n"; i++; } return buff; }
Example 8
Source File: AbstractCachingResourceDescriptionManager.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** {@inheritDoc} */ @Override public boolean isAffected(final Collection<Delta> deltas, final IResourceDescription candidate, final IResourceDescriptions context) { // NOPMD(NPathComplexity) final Collection<Delta> filteredDeltas = getInterestingDeltas(deltas); if (filteredDeltas.isEmpty()) { return false; } final List<IContainer> containers = getContainerManager().getVisibleContainers(candidate, context); for (final Delta delta : filteredDeltas) { final URI deltaURI = delta.getUri();// NOPMD - potentially could be lost due to call on getNew() after // deleted resources are no longer visible resources so we test them, too. if (delta.getNew() == null && isReferencedBy(delta, candidate, context)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(candidate.getURI() + " is affected by " + delta.getUri()); //$NON-NLS-1$ } return true; } for (IContainer container : containers) { if (container.getResourceDescription(deltaURI) != null) { if (isReferencedBy(delta, candidate, context)) { if (LOGGER.isDebugEnabled()) { // NOPMD AvoidDeeplyNestedIfStmts LOGGER.debug(candidate.getURI() + " is affected by " + delta.getUri()); //$NON-NLS-1$ } return true; } break; } } } return false; }
Example 9
Source File: MarkerUpdaterImpl.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
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())) { // if the file is found via the source attachment of a classpath entry, which happens // in case of running a test IDE with bundles from the workspace of the development IDE // (the workspace bundles' bin folder is linked to the classpath of bundles in the test IDE), // 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); } } } } }
Example 10
Source File: GamlMarkerUpdater.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public void updateMarkers(final Delta delta, final ResourceSet resourceSet, final IProgressMonitor monitor) throws OperationCanceledException { final URI uri = delta.getUri(); final IResourceUIValidatorExtension validatorExtension = getResourceUIValidatorExtension(uri); final IMarkerContributor markerContributor = getMarkerContributor(uri); final CheckMode normalAndFastMode = CheckMode.NORMAL_AND_FAST; for (final Pair<IStorage, IProject> pair : mapper.getStorages(uri)) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } if (pair.getFirst() instanceof IFile) { final IFile file = (IFile) pair.getFirst(); if (delta.getNew() != null) { if (resourceSet == null) { throw new IllegalArgumentException( "resourceSet may not be null for changed resources."); } final Resource resource = resourceSet.getResource(uri, true); if (validatorExtension != null) { validatorExtension.updateValidationMarkers(file, resource, normalAndFastMode, monitor); } if (markerContributor != null) { markerContributor.updateMarkers(file, resource, monitor); } // GAMA.getGui().getMetaDataProvider().storeMetadata(file, // info.getInfo(resource, file.getModificationStamp()), // true); } 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); } } } } }