use of com.intellij.openapi.application.ReadAction in project intellij-community by JetBrains.
the class ArtifactCompilerUtil method createOutputToArtifactMap.
public static MultiMap<String, Artifact> createOutputToArtifactMap(final Project project) {
final MultiMap<String, Artifact> result = MultiMap.create(FileUtil.PATH_HASHING_STRATEGY);
new ReadAction() {
protected void run(@NotNull final Result r) {
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
String outputPath = artifact.getOutputFilePath();
if (!StringUtil.isEmpty(outputPath)) {
result.putValue(outputPath, artifact);
}
}
}
}.execute();
return result;
}
use of com.intellij.openapi.application.ReadAction 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);
}
}
};
}
use of com.intellij.openapi.application.ReadAction in project android by JetBrains.
the class GradleSyncTest method shouldUseLibrary.
@Test
public void shouldUseLibrary() throws IOException {
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
Project project = ideFrame.getProject();
// Make sure the library was added.
LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
String libraryName = "org.apache.http.legacy-" + TestUtils.getLatestAndroidPlatform();
Library library = libraryTable.getLibraryByName(libraryName);
// Verify that the library has the right j
VirtualFile[] jarFiles = library.getFiles(CLASSES);
assertThat(jarFiles).asList().hasSize(1);
VirtualFile jarFile = jarFiles[0];
assertEquals("org.apache.http.legacy.jar", jarFile.getName());
// Verify that the module depends on the library
Module appModule = ideFrame.getModule("app");
AtomicBoolean dependencyFound = new AtomicBoolean();
new ReadAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(appModule).getModifiableModel();
try {
for (OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (orderEntry instanceof LibraryOrderEntry) {
LibraryOrderEntry libraryDependency = (LibraryOrderEntry) orderEntry;
if (libraryDependency.getLibrary() == library) {
dependencyFound.set(true);
}
}
}
} finally {
modifiableModel.dispose();
}
}
}.execute();
assertTrue("Module app should depend on library '" + library.getName() + "'", dependencyFound.get());
}
use of com.intellij.openapi.application.ReadAction in project android by JetBrains.
the class IdeFrameFixture method parseBuildFileForModule.
@NotNull
public GradleBuildModelFixture parseBuildFileForModule(@NotNull String moduleName) {
Module module = getModule(moduleName);
VirtualFile buildFile = getGradleBuildFile(module);
Ref<GradleBuildModel> buildModelRef = new Ref<>();
new ReadAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
buildModelRef.set(GradleBuildModel.parseBuildFile(buildFile, getProject()));
}
}.execute();
return new GradleBuildModelFixture(buildModelRef.get());
}
Aggregations