@Override public void onExecute() { if (ProjectTreeChangeHandler.this.workingQueue.isEmpty()) { return; } List<FileChange> localCopy = new ArrayList<>(ProjectTreeChangeHandler.this.workingQueue.size()); localCopy.addAll(ProjectTreeChangeHandler.this.workingQueue); ProjectTreeChangeHandler.this.workingQueue.clear(); chainPromise = chainPromise .thenPromise( ignored -> { if (localCopy.size() == 1) { return doProcessSingleChange(localCopy.get(0)); } else { return doProcessMultipleChanges(localCopy); } }) .catchErrorPromise(this::onCatchErrorPromise); }
return operation .perform(null) .catchErrorPromise( new Function<PromiseError, Promise<Y>>() { @Override
/** * Returns list of the classpath entries. If the classpath already exist for this project - * returns its otherwise gets classpath from the server. * * @param projectPath path to the project * @return list of the classpath entries */ public Promise<List<ClasspathEntry>> getClasspathEntries(String projectPath) { if (classpath.containsKey(projectPath)) { return classpath.get(projectPath); } else { Promise<List<ClasspathEntry>> result = extensionService .classpathTree(projectPath) .catchErrorPromise( error -> { classpath.remove(projectPath); return promiseProvider.reject(error); }); classpath.put(projectPath, result); return result; } }
derivedPromise.catchErrorPromise( new Function<PromiseError, Promise<Void>>() { @Override
/** * Starts project importing. This method should be called when we want mark project as importing. * * @param sourceStorage information about project location and repository type * @return returns instance of Promise */ protected Promise<Project> startImport(final Path path, SourceStorage sourceStorage) { appContext.addProjectToImporting(path.toString()); return importProject(path, sourceStorage) .then( new Function<Project, Project>() { @Override public Project apply(Project project) throws FunctionException { appContext.removeProjectFromImporting(project.getLocation().toString()); return project; } }) .catchErrorPromise( new Function<PromiseError, Promise<Project>>() { @Override public Promise<Project> apply(PromiseError error) throws FunctionException { appContext.removeProjectFromImporting(path.toString()); throw new IllegalStateException(error.getCause()); } }); }
protected Promise<Container> getNonEmptyPackage(final Container source) { return source .getChildren() .thenPromise( new Function<Resource[], Promise<Container>>() { @Override public Promise<Container> apply(Resource[] children) throws FunctionException { if (children == null || children.length == 0 || children.length > 1) { return promises.resolve(source); } else { final Resource resource = children[0]; if (resource.getResourceType() == FILE) { return promises.resolve(source); } else { return getNonEmptyPackage((Container) resource); } } } }) .catchErrorPromise( new Function<PromiseError, Promise<Container>>() { @Override public Promise<Container> apply(PromiseError arg) throws FunctionException { return promises.resolve(source); } }); } }
.catchErrorPromise( new Function<PromiseError, Promise<Project>>() { @Override
.catchErrorPromise( new Function<PromiseError, Promise<Project>>() { @Override
private Promise<Optional<Resource>> doFindResource(Path path) { return ps.getTree(path.parent(), 1, true) .thenPromise( treeElement -> { Resource resource = null; for (TreeElement nodeElement : treeElement.getChildren()) { ItemReference reference = nodeElement.getNode(); Resource tempResource = newResourceFrom(reference); store.register(tempResource); if (tempResource.isProject()) { inspectProject(tempResource.asProject()); } if (tempResource.getLocation().equals(path)) { resource = tempResource; eventBus.fireEvent( new ResourceChangedEvent(new ResourceDeltaImpl(resource, UPDATED))); } } return promises.resolve(Optional.fromNullable(resource)); }) .catchErrorPromise(error -> promises.resolve(absent())); }
.catchErrorPromise( caught -> { int errorCode = ExceptionUtils.getErrorCode(caught.getCause());
return projectResolver.resolve(project); }) .catchErrorPromise( new Function<PromiseError, Promise<Project>>() { @Override
.move(destination) .thenPromise((Function<Resource, Promise<Void>>) ignored -> promises.resolve(null)) .catchErrorPromise( error -> {
.copy(destination) .thenPromise((Function<Resource, Promise<Void>>) resource1 -> promises.resolve(null)) .catchErrorPromise( error -> {