/** * Update a part of the text. */ @Override public void updateText(final String text, final int offset, final int replaceLength) { this.clearCachedServiceResults(); this.resource.update(offset, replaceLength, text); this.refreshText(); }
/** * @since 2.4 */ protected void doReconcile(IRegion region) { if (resource == null) { if (log.isDebugEnabled()) log.debug("Resource is null in XtextReconcilerUnitOfWork."); return; } if (log.isDebugEnabled()) log.debug("Preparing reconciliation."); try { if (!(region instanceof ReconcilerReplaceRegion)) { throw new IllegalArgumentException("Region to be reconciled must be a ReplaceRegion"); } ReconcilerReplaceRegion replaceRegionToBeProcessed = (ReconcilerReplaceRegion) region; if (log.isTraceEnabled()) { log.trace("Parsing replace region '" + replaceRegionToBeProcessed + "'."); } resource.update(replaceRegionToBeProcessed.getOffset(), replaceRegionToBeProcessed.getLength(), replaceRegionToBeProcessed.getText()); resource.setModificationStamp(replaceRegionToBeProcessed.getModificationStamp()); } catch (RuntimeException exc) { log.error("Parsing in reconciler failed.", exc); throw exc; } } }
@Override public void reloadAllModelsOfType(final String modelType) { synchronized (resourceSet) { // Make a copy to avoid ConcurrentModificationException List<Resource> resourceListCopy = new ArrayList<Resource>(resourceSet.getResources()); for (Resource resource : resourceListCopy) { if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) { if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) { XtextResource xtextResource = (XtextResource) resource; // It's not sufficient to discard the derived state. // The quick & dirts solution is to reparse the whole resource. // We trigger this by dummy updating the resource. logger.debug("Refreshing resource '{}'", resource.getURI().lastSegment()); xtextResource.update(1, 0, ""); notifyListeners(resource.getURI().lastSegment(), EventType.MODIFIED); } } } } }
@Override public void reloadAllModelsOfType(final String modelType) { synchronized (resourceSet) { // Make a copy to avoid ConcurrentModificationException List<Resource> resourceListCopy = new ArrayList<Resource>(resourceSet.getResources()); for (Resource resource : resourceListCopy) { if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) { if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) { XtextResource xtextResource = (XtextResource) resource; // It's not sufficient to discard the derived state. // The quick & dirts solution is to reparse the whole resource. // We trigger this by dummy updating the resource. logger.debug("Refreshing resource '{}'", resource.getURI().lastSegment()); xtextResource.update(1, 0, ""); notifyListeners(resource.getURI().lastSegment(), EventType.MODIFIED); } } } } }