Search in sources :

Example 1 with CoarseGrainedChangeEvent

use of org.eclipse.xtext.resource.impl.CoarseGrainedChangeEvent in project xtext-eclipse by eclipse.

the class ProjectClasspathChangeListener method elementChanged.

@Override
public void elementChanged(ElementChangedEvent event) {
    if (workspace != null && workspace.isAutoBuilding()) {
        try {
            if (event.getDelta() != null) {
                Set<IJavaProject> javaProjects = getJavaProjectsWithClasspathChange(event.getDelta());
                if (!javaProjects.isEmpty()) {
                    Set<IProject> projects = FluentIterable.from(javaProjects).filter(Predicates.notNull()).transform(IJavaProject::getProject).toSet();
                    dirtyStateManager.notifyListeners(new CoarseGrainedChangeEvent());
                    Set<IProject> mutableProjects = Sets.newLinkedHashSet(projects);
                    for (IProject project : projects) {
                        mutableProjects.addAll(projectDependencyGraph.getDependentXtextProjects(project));
                    }
                    scheduleBuildIfNecessary(mutableProjects);
                }
            }
        } catch (WrappedException e) {
            log.error(e.getCause().getMessage(), e.getCause());
        } catch (RuntimeException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : CoarseGrainedChangeEvent(org.eclipse.xtext.resource.impl.CoarseGrainedChangeEvent) WrappedException(org.eclipse.emf.common.util.WrappedException) IJavaProject(org.eclipse.jdt.core.IJavaProject) IProject(org.eclipse.core.resources.IProject)

Example 2 with CoarseGrainedChangeEvent

use of org.eclipse.xtext.resource.impl.CoarseGrainedChangeEvent in project xtext-eclipse by eclipse.

the class DirtyStateAwareResourceDescriptions method dirtyDescriptionsChanged.

public void dirtyDescriptionsChanged(IResourceDescription.Event event) {
    if (event instanceof CoarseGrainedChangeEvent) {
        notifyListeners(event);
        return;
    }
    ResourceDescriptionChangeEvent changeEvent = new ResourceDescriptionChangeEvent(Iterables.transform(event.getDeltas(), new Function<IResourceDescription.Delta, IResourceDescription.Delta>() {

        @Override
        public IResourceDescription.Delta apply(IResourceDescription.Delta from) {
            IResourceDescription.Delta result = from;
            if (from.getNew() == null) {
                result = createDelta(from.getOld(), globalDescriptions.getResourceDescription(from.getUri()));
            } else if (from.getOld() == null) {
                result = createDelta(globalDescriptions.getResourceDescription(from.getUri()), from.getNew());
            }
            return result;
        }
    }));
    notifyListeners(changeEvent);
}
Also used : CoarseGrainedChangeEvent(org.eclipse.xtext.resource.impl.CoarseGrainedChangeEvent) Function(com.google.common.base.Function) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) ChangedResourceDescriptionDelta(org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) ResourceDescriptionChangeEvent(org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent)

Aggregations

CoarseGrainedChangeEvent (org.eclipse.xtext.resource.impl.CoarseGrainedChangeEvent)2 Function (com.google.common.base.Function)1 IProject (org.eclipse.core.resources.IProject)1 WrappedException (org.eclipse.emf.common.util.WrappedException)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)1 ChangedResourceDescriptionDelta (org.eclipse.xtext.resource.impl.ChangedResourceDescriptionDelta)1 ResourceDescriptionChangeEvent (org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent)1