public void processResourceDelta( final IResourceDelta[] rDeltas, final ICElement element, Set<IResource> handled) { if (rDeltas != null) { for (IResourceDelta rd : rDeltas) { final int rdkind = rd.getKind(); if (rdkind != IResourceDelta.ADDED) { IResource res = rd.getResource(); if (!handled.add(res)) { continue; } if (res instanceof IFile) { switch (rdkind) { case IResourceDelta.CHANGED: if ((rd.getFlags() & IResourceDelta.CONTENT) != 0) { fChanged.add(new PotentialTranslationUnit(element, (IFile) res)); } break; case IResourceDelta.REMOVED: fRemoved.add(new PotentialTranslationUnit(element, (IFile) res)); break; } } } processResourceDelta( rd.getAffectedChildren(IResourceDelta.CHANGED | IResourceDelta.REMOVED), element, handled); } } }
public boolean visit(IResourceDelta delta) { if (delta.getResource().getType() != IResource.FILE) { return true; } int deltaKind = delta.getKind(); if (deltaKind == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) { URI platformURI = URI.createPlatformResourceURI(delta.getFullPath().toString(), true); Resource changedResource = resourceSet.getResource(platformURI, false); if (changedResource != null) { changedResource.unload(); com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.IRezeptTextResource currentResource = getResource(); if (changedResource.equals(currentResource)) { // reload the resource displayed in the editor resourceSet.getResource(currentResource.getURI(), true); } if (currentResource != null && currentResource.getErrors().isEmpty()) { EcoreUtil.resolveAll(currentResource); } // reset the selected element in outline and properties by text position if (highlighting != null) { highlighting.updateEObjectSelection(); } } } return true; }
public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); if (!(resource instanceof IFile) || !resource.getName().endsWith(".java") || !resource.exists()) { return true; } monitor.subTask(resource.getName()); switch (delta.getKind()) { case IResourceDelta.ADDED: check(resource, architecture, true); monitor.worked(1); break; case IResourceDelta.REMOVED: delete(resource); monitor.worked(1); break; case IResourceDelta.CHANGED: check(resource, architecture, true); monitor.worked(1); break; } /* return true to continue visiting children */ return true; }
/** * Visits the given resource delta that corresponds to a file. * * @param delta The given resource delta * @param file The file concerning by this delta * @return <code>true</code> if the resource delta's children should be visited; <code>false * </code> if they should be skipped. * @exception CoreException if the visit fails for some reason. */ protected boolean visitFile(IResourceDelta delta, IFile currentFile) throws CoreException { // By default, we do not visit the resource delta's children boolean visitChildren = false; final Option<ModelingProject> optionalModelingProject = ModelingProject.asModelingProject(currentFile.getProject()); if (optionalModelingProject.some()) { if (IResourceDelta.REMOVED == delta.getKind()) { if (optionalModelingProject.get().isValid()) { // Check that this IFile is not the main representations // file of this project if (optionalModelingProject.get().isMainRepresentationsFile(currentFile)) { mainRepresentationsFileToDelete.add(currentFile); } } else if (new FileQuery(currentFile).isSessionResourceFile()) { // If the project is not valid and the deleted file is a // representations file, validate the project again. optionalModelingProject .get() .getMainRepresentationsFileURI(new NullProgressMonitor(), true, false); } } else if (IResourceDelta.ADDED == delta.getKind()) { // Check that the corresponding project does not already // have a main representations file if (SiriusUtil.SESSION_RESOURCE_EXTENSION.equals(currentFile.getFileExtension())) { if (optionalModelingProject.get().isValid()) { representationsFileToAddOnValidModelingProject.add(currentFile); } } } } return visitChildren; }
@Override public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); if (delta == null) { return; } IEditorInput input = getEditorInput(); IPath localPath = null; if (input instanceof IPathEditorInput) { localPath = ((IPathEditorInput) input).getPath(); } if (localPath == null) { return; } localPath = ContentUtils.convertPathToWorkspacePath(localPath); delta = delta.findMember(localPath); if (delta == null) { return; } if (delta.getKind() == IResourceDelta.CHANGED) { // Refresh editor DBeaverUI.asyncExec( new Runnable() { @Override public void run() { loadImage(); } }); } }
@Override protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException { IProject project = getProject(); if (project == null) return null; if ((kind == INCREMENTAL_BUILD) || (kind == AUTO_BUILD)) { IResourceDelta delta = getDelta(project); if (delta == null) { project.accept(new PDDLVisitor()); } else { delta.accept(new PDDLVisitor()); } } else if (kind == FULL_BUILD) { project.accept(new PDDLVisitor()); } else if (kind == CLEAN_BUILD) { IPDDLNature nature = PDDLNature.getPDDLNature(project); if (nature != null) { IPDDLProjectIndex index = nature.getPDDLProjectIndex(); if (index != null) index.clear(); } } return null; }
// ------------------------------------------------------------------------- // I N S T A N C E M E T H O D S // ------------------------------------------------------------------------- @Override public String toString() { String typeString = getNotificationTypePhrase(); String resourceType = " "; // $NON-NLS-1$ if (delta != null && delta.getResource() != null) { if (delta.getResource() instanceof IProject) { resourceType = " Project Notification: "; // $NON-NLS-1$ } else if (delta.getResource() instanceof IFile) { resourceType = " File Notification: "; // $NON-NLS-1$ } else if (delta.getResource() instanceof IFolder) { resourceType = " Folder Notification: "; // $NON-NLS-1$ } } StringBuffer toString = new StringBuffer(typeString); toString.append(resourceType); toString.append(" on "); // $NON-NLS-1$ toString.append(getNotifier()); toString.append("\nisPreAutoBuild = " + isPreAutoBuild()); // $NON-NLS-1$ toString.append("\nisPostAutoBuild = " + isPostAutoBuild()); // $NON-NLS-1$ toString.append("\nisAutoBuild = " + isAutoBuild()); // $NON-NLS-1$ toString.append("\nisRename = " + isRename()); // $NON-NLS-1$ toString.append("\nisClose = " + isClose()); // $NON-NLS-1$ toString.append("\nisOpen = " + isOpen()); // $NON-NLS-1$ toString.append("\nisFile = " + isFile()); // $NON-NLS-1$ toString.append("\nisFolder = " + isFolder()); // $NON-NLS-1$ toString.append("\nisProject = " + isProject()); // $NON-NLS-1$ toString.append("\nisPostChange = " + isPostChange()); // $NON-NLS-1$ return toString.toString(); }
@Override public synchronized void resourceChanged(IResourceChangeEvent event) { IResource res = event.getResource(); if (!(res instanceof IProject)) return; String name = res.getName(); IResourceDelta delta = event.getDelta(); if (delta == null) return; int kind = delta.getKind(); if (configs.containsKey(name)) { if (kind == IResourceDelta.REMOVED) { configs.remove(name); tmpConfigs.remove(name); } else if (kind == IResourceDelta.CHANGED) { int flags = delta.getFlags(); if ((flags & IResourceDelta.MOVED_TO) != 0) { IPath path = delta.getMovedToPath(); Map<String, IAConfiguration> cfgs = configs.get(name); String newName = path.lastSegment(); configs.remove(name); configs.put(newName, cfgs); Map<String, IAConfiguration> tmpcfgs = tmpConfigs.get(name); tmpConfigs.remove(name); tmpConfigs.put(newName, tmpcfgs); } } } }
@Override protected final IProject[] build( int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor) throws CoreException { if (!validateProject()) { // Project who invoked the builder is not supported return new IProject[0]; } getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); if (kind == IncrementalProjectBuilder.FULL_BUILD) { initialize(); clean(monitor); build(monitor); } else { IResourceDelta delta = getDelta(getProject()); // if (delta == null) DeltaFileVisitor visitor = new DeltaFileVisitor(); delta.accept(visitor, IResourceDelta.ADDED | IResourceDelta.CHANGED); // { if (visitor.isSourceFound()) { initialize(); build(monitor); } // } else // { // incrementalBuild(delta, monitor); // } } endBuild(monitor); return new IProject[] {getProject()}; }
/** {@inheritDoc} */ @Override public void resourceChanged(IResourceChangeEvent pEvent) { if (IResourceChangeEvent.POST_CHANGE == pEvent.getType()) { // Extract all the additions among the changes IResourceDelta delta = pEvent.getDelta(); IResourceDelta[] added = delta.getAffectedChildren(); // In all the added resources, process the projects for (int i = 0, length = added.length; i < length; i++) { IResourceDelta addedi = added[i]; // Get the project IResource resource = addedi.getResource(); IProject project = resource.getProject(); if (ProjectsManager.getProject(project.getName()) == null && project.isOpen()) { ProjectAdderJob job = new ProjectAdderJob(project); job.schedule(); } } } else if (IResourceChangeEvent.PRE_DELETE == pEvent.getType()) { // detect UNO IDL project about to be deleted IResource removed = pEvent.getResource(); if (ProjectsManager.getProject(removed.getName()) != null) { ProjectsManager.removeProject(removed.getName()); } } else if (IResourceChangeEvent.PRE_CLOSE == pEvent.getType()) { IResource res = pEvent.getResource(); if (res != null && ProjectsManager.getProject(res.getName()) != null) { // Project about to be closed: remove for the available uno projects ProjectsManager.removeProject(res.getName()); } } }
protected IResourceDelta createSaveDelta() throws CoreException { IResourceDelta javaResource = mock(IResourceDelta.class); when(javaResource.getFullPath()).thenReturn(new Path("a.java")); javaResource.accept((IResourceDeltaVisitor) anyObject()); return createResourceDelta(project, new IResourceDelta[] {javaResource}); }
private void processResourceDelta(WorkingSetDelta result, IResourceDelta delta) { IResource resource = delta.getResource(); int type = resource.getType(); int index = result.indexOf(resource); int kind = delta.getKind(); int flags = delta.getFlags(); if (kind == IResourceDelta.CHANGED && type == IResource.PROJECT && index != -1) { if ((flags & IResourceDelta.OPEN) != 0) { result.set(index, resource); } } if (index != -1 && kind == IResourceDelta.REMOVED) { if ((flags & IResourceDelta.MOVED_TO) != 0) { result.set( index, ResourcesPlugin.getWorkspace().getRoot().findMember(delta.getMovedToPath())); } else { result.remove(index); } } // Don't dive into closed or opened projects if (projectGotClosedOrOpened(resource, kind, flags)) { return; } IResourceDelta[] children = delta.getAffectedChildren(); for (int i = 0; i < children.length; i++) { processResourceDelta(result, children[i]); } }
protected boolean checkForClassFileChanges( IResourceDelta binaryDelta, ClasspathMultiDirectory md, int segmentCount) throws CoreException { IResource resource = binaryDelta.getResource(); // remember that if inclusion & exclusion patterns change then a full build is done boolean isExcluded = (md.exclusionPatterns != null || md.inclusionPatterns != null) && Util.isExcluded(resource, md.inclusionPatterns, md.exclusionPatterns); switch (resource.getType()) { case IResource.FOLDER: if (isExcluded && md.inclusionPatterns == null) return true; // no need to go further with this delta since its children cannot be // included IResourceDelta[] children = binaryDelta.getAffectedChildren(); for (int i = 0, l = children.length; i < l; i++) if (!checkForClassFileChanges(children[i], md, segmentCount)) return false; return true; case IResource.FILE: if (!isExcluded && org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(resource.getName())) { // perform full build if a managed class file has been changed IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension(); if (this.newState.isKnownType(typePath.toString())) { if (JavaBuilder.DEBUG) System.out.println( "MUST DO FULL BUILD. Found change to class file " + typePath); // $NON-NLS-1$ return false; } return true; } } return true; }
private Set<String> getResourcesToBuild( final int kind, @SuppressWarnings("rawtypes") final Map args, final IProject project) throws CoreException { Set<BuildResource> result = Sets.newHashSet(); final IProgressMonitor submon = new NullProgressMonitor(); // new SubProgressMonitor(monitor, 10); submon.beginTask("retrieving resources to build", IProgressMonitor.UNKNOWN); if (kind == FULL_BUILD) { result = helper.getAffectedResources(args, project, submon); } else { final IResourceDelta delta = getDelta(project); final Path path = new Path(".settings/org.erlide.core.prefs"); if (delta.findMember(path) != null) { ErlLogger.info("project configuration changed: doing full rebuild"); result = helper.getAffectedResources(args, project, submon); } else { result = helper.getAffectedResources(args, delta, submon); } } if (BuilderHelper.isDebugging()) { ErlLogger.debug( "Will compile %d resource(s): %s", Integer.valueOf(result.size()), result.toString()); } submon.done(); final Set<String> paths = new HashSet<String>(); for (final BuildResource res : result) { paths.add(res.getResource().getLocation().toPortableString()); } return paths; }
protected void incrementalBuild(IResourceDelta delta, final IProgressMonitor monitor) { int deltaKind = delta.getKind(); if (deltaKind == IResourceDelta.REMOVED) { return; } // final boolean[] buildCSS = new boolean[1]; try { delta.accept( new IResourceDeltaVisitor() { public boolean visit(IResourceDelta delta) { final IResource resource = delta.getResource(); IPath fullResourcePath = resource.getFullPath(); for (String segment : fullResourcePath.segments()) { if ("_diffs".equals(segment)) // $NON-NLS-1$ { // IDE-110 IDE-648 final IWebProject webproject = LiferayCore.create(IWebProject.class, getProject()); if (webproject != null && webproject.getDefaultDocrootFolder() != null) { IFolder webappRoot = webproject.getDefaultDocrootFolder(); if (webappRoot != null) { IFolder diffs = webappRoot.getFolder(new Path("_diffs")); // $NON-NLS-1$ if (diffs != null && diffs.exists() && diffs.getFullPath().isPrefixOf(fullResourcePath)) { applyDiffsDeltaToDocroot(delta, diffs.getParent(), monitor); return false; } } } } else if ("build.xml".equals(segment)) // IDE-828 //$NON-NLS-1$ { IPath relPath = resource.getProjectRelativePath(); if (relPath != null && relPath.segmentCount() == 1) { try { compileTheme(resource.getProject()); } catch (CoreException e) { ThemeCore.logError("Error compiling theme.", e); // $NON-NLS-1$ } } } } return true; // visit children too } }); } catch (CoreException e) { ThemeCore.logError(e); } }
private void handleChange(IResourceDelta delta) { if ((delta.getFlags() & IResourceDelta.REPLACED) != 0) { // A replace was added in place of a removed resource handleAdded(delta); } else if (delta.getResource().getType() == IResource.FILE) { ensureResourceCovered(delta.getResource(), changedRoots); } }
private void handleMove(IResourceDelta delta) { if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) { ensureResourceCovered(delta.getResource(), movedRoots); } else if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) { IResource source = createSourceResource(delta); ensureResourceCovered(source, movedRoots); } }
/* * (non-Javadoc) * * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) */ public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); try { delta.accept(this); } catch (CoreException e) { e.printStackTrace(); } }
private void handleAdded(IResourceDelta delta) { if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) { handleMove(delta); } else if ((delta.getFlags() & IResourceDelta.COPIED_FROM) != 0) { handleCopy(delta); } else { ensureResourceCovered(delta.getResource(), addedRoots); } }
private void handleRemoved(IResourceDelta delta) { if ((delta.getFlags() & IResourceDelta.OPEN) != 0) { closedProjects.add(delta.getResource()); } else if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) { handleMove(delta); } else { ensureResourceCovered(delta.getResource(), removedRoots); } }
/* * (non-Javadoc) * * @see * org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org * .eclipse.core.resources.IResourceChangeEvent) */ public void resourceChanged(final IResourceChangeEvent event) { final IResourceDelta delta = event.getDelta(); try { if (delta != null) { // ErlLogger.debug("change " + event.toString()); delta.accept(this); } } catch (final CoreException e) { ErlLogger.warn(e); } }
@Override public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); if (delta != null) { final IPath serverPropertiesFullPath = serverProject.getFullPath().append(SERVER_PROPERTIES); if (delta.findMember(serverPropertiesFullPath) != null) { serverChanged(); } } }
@Override public void resourceChanged(IResourceChangeEvent e) { IResourceDelta delta = e.getDelta(); try { if (delta != null && isInstalled) { delta.accept(this); } } catch (CoreException x) { log.warn("Error handling resourceChanged", x); } }
public boolean visit(IResourceDelta delta) { // only interested in changed resources (not added or removed) if (delta.getKind() != IResourceDelta.REMOVED) { return true; } IResource resource = delta.getResource(); if (resource.getType() == IResource.FILE && CALSourcePathMapper.CAL_FILE_EXTENSION.equalsIgnoreCase(resource.getFileExtension())) { removedCalFileFound = true; } return true; }
@Override public boolean visit(IResourceDelta delta, IProgressMonitor monitor) throws CoreException { if (delta.getKind() == IResourceDelta.CHANGED) { IResource resource = delta.getResource(); if (resource.getType() == IResource.FILE) { if (DartCore.isHTMLLikeFileName(resource.getName())) { processHtml((IFile) resource); } } } return true; }
public void resourceChanged(IResourceChangeEvent e) { IResourceDelta delta = e.getDelta(); IResource resource = getResource(); if (delta != null && resource != null) { IResourceDelta child = delta.findMember(resource.getFullPath()); if (child != null) { IMarkerDelta[] deltas = child.getMarkerDeltas(); if (deltas.length > 0) { forceReconciling(false); } } } }
static boolean isRemove(IResourceDelta delta) { int kind = delta.getKind(); if (IResourceDelta.REMOVED == kind) { return true; } if (IResourceDelta.CHANGED == kind && delta.getResource() instanceof IContainer) { return true; } return false; }
@Override public boolean visit(IResourceDelta delta) throws CoreException { IResource res = delta.getResource(); if (res instanceof IProject && delta.getKind() == IResourceDelta.CHANGED) { IProject project = (IProject) res; if (!project.isAccessible()) { // only track open C projects return false; } } checkInvalidate(delta, res); return true; }
/** * For any change to the encoding file or any resource with encoding set, just discard the cache * for the corresponding project. */ public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); if (delta == null) return; IResourceDelta[] projectDeltas = delta.getAffectedChildren(); // process each project in the delta Set projectsToSave = new HashSet(); for (int i = 0; i < projectDeltas.length; i++) // nothing to do if a project has been added/removed/moved if (projectDeltas[i].getKind() == IResourceDelta.CHANGED && (projectDeltas[i].getFlags() & IResourceDelta.OPEN) == 0) processEntryChanges(projectDeltas[i], projectsToSave); fJob.addChanges(projectsToSave); }
public boolean visit(IResourceDelta delta) throws CoreException { switch (delta.getKind()) { case IResourceDelta.ADDED: case IResourceDelta.REMOVED: collect(delta.getResource()); break; case IResourceDelta.CHANGED: if ((delta.getFlags() & (IResourceDelta.CONTENT | IResourceDelta.REPLACED)) != 0) collect(delta.getResource()); break; } return true; }