use of com.intellij.openapi.progress.util.AbstractProgressIndicatorBase in project intellij-community by JetBrains.
the class SkeletonTestTask method runTestOn.
@Override
public void runTestOn(@NotNull final String sdkHome) throws IOException, InvalidSdkException {
final Sdk sdk = createTempSdk(sdkHome, SdkCreationType.SDK_PACKAGES_ONLY);
final File skeletonsPath = new File(PythonSdkType.getSkeletonsPath(PathManager.getSystemPath(), sdk.getHomePath()));
// File with module skeleton
File skeletonFileOrDirectory = new File(skeletonsPath, myModuleNameToBeGenerated);
// Module may be stored in "moduleName.py" or "moduleName/__init__.py"
if (skeletonFileOrDirectory.isDirectory()) {
skeletonFileOrDirectory = new File(skeletonFileOrDirectory, PyNames.INIT_DOT_PY);
} else {
skeletonFileOrDirectory = new File(skeletonFileOrDirectory.getAbsolutePath() + PyNames.DOT_PY);
}
final File skeletonFile = skeletonFileOrDirectory;
if (skeletonFile.exists()) {
// To make sure we do not reuse it
assert skeletonFile.delete() : "Failed to delete file " + skeletonFile;
}
ApplicationManager.getApplication().invokeAndWait(() -> {
// File that uses CLR library
myFixture.copyFileToProject("dotNet/" + mySourceFileToRunGenerationOn, mySourceFileToRunGenerationOn);
// Library itself
myFixture.copyFileToProject("dotNet/PythonLibs.dll", "PythonLibs.dll");
// Another library
myFixture.copyFileToProject("dotNet/SingleNameSpace.dll", "SingleNameSpace.dll");
myFixture.configureByFile(mySourceFileToRunGenerationOn);
}, ModalityState.NON_MODAL);
// This inspection should suggest us to generate stubs
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
PsiDocumentManager.getInstance(myFixture.getProject()).commitAllDocuments();
final String intentionName = PyBundle.message("sdk.gen.stubs.for.binary.modules", myUseQuickFixWithThisModuleOnly);
final IntentionAction intention = myFixture.findSingleIntention(intentionName);
Assert.assertNotNull("No intention found to generate skeletons!", intention);
Assert.assertThat("Intention should be quick fix to run", intention, Matchers.instanceOf(QuickFixWrapper.class));
final LocalQuickFix quickFix = ((QuickFixWrapper) intention).getFix();
Assert.assertThat("Quick fix should be 'generate binary skeletons' fix to run", quickFix, Matchers.instanceOf(GenerateBinaryStubsFix.class));
final Task fixTask = ((GenerateBinaryStubsFix) quickFix).getFixTask(myFixture.getFile());
fixTask.run(new AbstractProgressIndicatorBase());
}
});
FileUtil.copy(skeletonFile, new File(myFixture.getTempDirPath(), skeletonFile.getName()));
if (myExpectedSkeletonFile != null) {
final String actual = StreamUtil.readText(new FileInputStream(skeletonFile), Charset.defaultCharset());
final String skeletonText = StreamUtil.readText(new FileInputStream(new File(getTestDataPath(), myExpectedSkeletonFile)), Charset.defaultCharset());
// TODO: Move to separate method ?
if (!Matchers.equalToIgnoringWhiteSpace(removeGeneratorVersion(skeletonText)).matches(removeGeneratorVersion(actual))) {
throw new FileComparisonFailure("asd", skeletonText, actual, skeletonFile.getAbsolutePath());
}
}
myFixture.configureByFile(skeletonFile.getName());
}
use of com.intellij.openapi.progress.util.AbstractProgressIndicatorBase in project intellij-community by JetBrains.
the class JobUtilTest method checkProgressAndReadAction.
private static void checkProgressAndReadAction(final List<Object> objects, final DaemonProgressIndicator progress, final boolean runInReadAction) throws Throwable {
final AtomicReference<Throwable> exception = new AtomicReference<>();
JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, progress, runInReadAction, o -> {
try {
if (objects.size() <= 1 || JobSchedulerImpl.CORES_COUNT <= JobLauncherImpl.CORES_FORK_THRESHOLD) {
assertTrue(ApplicationManager.getApplication().isDispatchThread());
} else {
}
ProgressIndicator actualIndicator = ProgressManager.getInstance().getProgressIndicator();
if (progress == null) {
assertNotNull(actualIndicator);
assertTrue(actualIndicator instanceof AbstractProgressIndicatorBase);
} else {
assertTrue(actualIndicator instanceof SensitiveProgressWrapper);
ProgressIndicator original = ((SensitiveProgressWrapper) actualIndicator).getOriginalProgressIndicator();
assertSame(progress, original);
}
assertTrue(!runInReadAction || ApplicationManager.getApplication().isReadAccessAllowed());
} catch (Throwable e) {
exception.set(e);
}
return true;
});
if (exception.get() != null)
throw exception.get();
}
Aggregations