mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Javafx: "Wrap field with JavaFx property" intention - use ArtifactManager's modification tracker for caching presence of JavaFX artifacts (IDEA-102430)
This commit is contained in:
+5
-18
@@ -1,34 +1,21 @@
|
||||
package org.jetbrains.plugins.javaFX;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.javaFX.fxml.AbstractJavaFXTestCase;
|
||||
|
||||
/**
|
||||
* Same as the base test, but detects the presence of JavaFX using imports and FXMLs, not artifacts
|
||||
* @author Pavel.Dolgov
|
||||
*/
|
||||
public class JavaFxFieldToPropertyNoArtifactTest extends JavaFxFieldToPropertyTest {
|
||||
public static final DefaultLightProjectDescriptor JAVA_FX_DESCRIPTOR_NO_ARTIFACT = new DefaultLightProjectDescriptor() {
|
||||
@Override
|
||||
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
AbstractJavaFXTestCase.addJavaFxJarAsLibrary(module, model);
|
||||
super.configureModule(module, model, contentEntry);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void setUpModule() {
|
||||
super.setUpModule();
|
||||
}
|
||||
|
||||
public void testArtifactPresenceFieldToProperty() throws Exception {
|
||||
final IntentionAction intentionAction = getIntentionAction(getTestName(false) + ".java");
|
||||
// no artifact, no fxml, no javafx.* imports: the intention shoudn't be available
|
||||
assertNull(intentionAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isArtifactNeeded() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -35,7 +35,9 @@ public class JavaFxFieldToPropertyTest extends DaemonAnalyzerTestCase {
|
||||
protected void setUpModule() {
|
||||
super.setUpModule();
|
||||
AbstractJavaFXTestCase.addJavaFxJarAsLibrary(getModule());
|
||||
ArtifactManager.getInstance(getProject()).addArtifact("fake-javafx", JavaFxApplicationArtifactType.getInstance(), null);
|
||||
if (isArtifactNeeded()) {
|
||||
ArtifactManager.getInstance(getProject()).addArtifact("fake-javafx", JavaFxApplicationArtifactType.getInstance(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public void testIntFieldToProperty() throws Exception {
|
||||
@@ -98,6 +100,10 @@ public class JavaFxFieldToPropertyTest extends DaemonAnalyzerTestCase {
|
||||
return findIntentionAction(infos, actionName, editor, file);
|
||||
}
|
||||
|
||||
protected boolean isArtifactNeeded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
|
||||
@@ -69,9 +69,9 @@ public class JavaFxModuleUtil {
|
||||
private static boolean hasJavaFxArtifacts(@NotNull Project project) {
|
||||
return CachedValuesManager.getManager(project).getCachedValue(
|
||||
project, () -> {
|
||||
final Collection<? extends Artifact> artifacts =
|
||||
ArtifactManager.getInstance(project).getArtifactsByType(JavaFxApplicationArtifactType.getInstance());
|
||||
return CachedValueProvider.Result.create(!artifacts.isEmpty(), ProjectRootManager.getInstance(project));
|
||||
final ArtifactManager artifactManager = ArtifactManager.getInstance(project);
|
||||
final Collection<? extends Artifact> artifacts = artifactManager.getArtifactsByType(JavaFxApplicationArtifactType.getInstance());
|
||||
return CachedValueProvider.Result.create(!artifacts.isEmpty(), artifactManager.getModificationTracker());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user