Search in sources :

Example 6 with IJavaElementDelta

use of org.eclipse.jdt.core.IJavaElementDelta in project che by eclipse.

the class JavaModelOperation method addReconcileDelta.

/*
     * Registers the given reconcile delta with the Java Model Manager.
     */
protected void addReconcileDelta(ICompilationUnit workingCopy, IJavaElementDelta delta) {
    HashMap reconcileDeltas = JavaModelManager.getJavaModelManager().getDeltaProcessor().reconcileDeltas;
    org.eclipse.jdt.internal.core.JavaElementDelta previousDelta = (org.eclipse.jdt.internal.core.JavaElementDelta) reconcileDeltas.get(workingCopy);
    if (previousDelta != null) {
        IJavaElementDelta[] children = delta.getAffectedChildren();
        for (int i = 0, length = children.length; i < length; i++) {
            org.eclipse.jdt.internal.core.JavaElementDelta child = (org.eclipse.jdt.internal.core.JavaElementDelta) children[i];
            previousDelta.insertDeltaTree(child.getElement(), child);
        }
        // since it is the result of the last reconcile operation
        if ((delta.getFlags() & IJavaElementDelta.F_AST_AFFECTED) != 0) {
            previousDelta.changedAST(delta.getCompilationUnitAST());
        }
    } else {
        reconcileDeltas.put(workingCopy, delta);
    }
}
Also used : HashMap(java.util.HashMap) IJavaElementDelta(org.eclipse.jdt.core.IJavaElementDelta) IJavaElementDelta(org.eclipse.jdt.core.IJavaElementDelta)

Example 7 with IJavaElementDelta

use of org.eclipse.jdt.core.IJavaElementDelta in project che by eclipse.

the class JavaSearchScope method processDelta.

/*
     * @see AbstractSearchScope#processDelta(IJavaElementDelta)
     */
public void processDelta(IJavaElementDelta delta, int eventType) {
    switch(delta.getKind()) {
        case IJavaElementDelta.CHANGED:
            IJavaElementDelta[] children = delta.getAffectedChildren();
            for (int i = 0, length = children.length; i < length; i++) {
                IJavaElementDelta child = children[i];
                processDelta(child, eventType);
            }
            break;
        case IJavaElementDelta.REMOVED:
            IJavaElement element = delta.getElement();
            if (this.encloses(element)) {
                if (this.elements != null) {
                    this.elements.remove(element);
                }
                String path = null;
                switch(element.getElementType()) {
                    case IJavaElement.JAVA_PROJECT:
                        path = ((IJavaProject) element).getProject().getFullPath().toString();
                        break;
                    case IJavaElement.PACKAGE_FRAGMENT_ROOT:
                        path = ((IPackageFragmentRoot) element).getPath().toString();
                        break;
                    default:
                        return;
                }
                for (int i = 0; i < this.pathsCount; i++) {
                    if (this.relativePaths[i].equals(path)) {
                        this.relativePaths[i] = null;
                        rehash();
                        break;
                    }
                }
            }
            break;
    }
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) IJavaElementDelta(org.eclipse.jdt.core.IJavaElementDelta) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Example 8 with IJavaElementDelta

use of org.eclipse.jdt.core.IJavaElementDelta in project che by eclipse.

the class SearchResultUpdater method elementChanged.

public void elementChanged(ElementChangedEvent event) {
    //long t0= System.currentTimeMillis();
    IJavaElementDelta delta = event.getDelta();
    Set<IAdaptable> removedElements = new HashSet<IAdaptable>();
    Set<IAdaptable> potentiallyRemovedElements = new HashSet<IAdaptable>();
    collectRemoved(potentiallyRemovedElements, removedElements, delta);
    if (removedElements.size() > 0)
        handleRemoved(removedElements);
    if (potentiallyRemovedElements.size() > 0)
        handleRemoved(potentiallyRemovedElements);
//System.out.println(this+"handled delta in: "+(System.currentTimeMillis()-t0));
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) IJavaElementDelta(org.eclipse.jdt.core.IJavaElementDelta) HashSet(java.util.HashSet)

Aggregations

IJavaElementDelta (org.eclipse.jdt.core.IJavaElementDelta)8 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 IResourceDelta (org.eclipse.core.resources.IResourceDelta)2 IElementChangedListener (org.eclipse.jdt.core.IElementChangedListener)2 IJavaElement (org.eclipse.jdt.core.IJavaElement)2 IResource (org.eclipse.core.resources.IResource)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)1 AbstractSearchScope (org.eclipse.jdt.internal.core.search.AbstractSearchScope)1 JavaWorkspaceScope (org.eclipse.jdt.internal.core.search.JavaWorkspaceScope)1