use of com.intellij.openapi.progress.Task.Backgroundable in project intellij-community by JetBrains.
the class GenerateBinaryStubsFix method applyFix.
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
final PsiFile file = descriptor.getPsiElement().getContainingFile();
final Backgroundable backgroundable = getFixTask(file);
ProgressManager.getInstance().runProcessWithProgressAsynchronously(backgroundable, new BackgroundableProcessIndicator(backgroundable));
}
use of com.intellij.openapi.progress.Task.Backgroundable in project intellij-community by JetBrains.
the class GenerateBinaryStubsFix method getFixTask.
/**
* Returns fix task that is used to generate stubs
*
* @param fileToRunTaskIn file where task should run
* @return task itself
*/
@NotNull
public Backgroundable getFixTask(@NotNull final PsiFile fileToRunTaskIn) {
final Project project = fileToRunTaskIn.getProject();
final String folder = fileToRunTaskIn.getContainingDirectory().getVirtualFile().getCanonicalPath();
return new Task.Backgroundable(project, "Generating skeletons for binary module", false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
final List<String> assemblyRefs = new ReadAction<List<String>>() {
@Override
protected void run(@NotNull Result<List<String>> result) throws Throwable {
result.setResult(collectAssemblyReferences(fileToRunTaskIn));
}
}.execute().getResultObject();
try {
final PySkeletonRefresher refresher = new PySkeletonRefresher(project, null, mySdk, null, null, folder);
if (needBinaryList(myQualifiedName)) {
if (!generateSkeletonsForList(refresher, indicator, folder))
return;
} else {
//noinspection unchecked
refresher.generateSkeleton(myQualifiedName, "", assemblyRefs, Consumer.EMPTY_CONSUMER);
}
final VirtualFile skeletonDir;
skeletonDir = LocalFileSystem.getInstance().findFileByPath(refresher.getSkeletonsPath());
if (skeletonDir != null) {
skeletonDir.refresh(true, true);
}
} catch (InvalidSdkException e) {
LOG.error(e);
}
}
};
}
Aggregations