use of com.intellij.codeInsight.intention.IntentionAction in project android by JetBrains.
the class AndroidDomTestCase method doTestOnClickQuickfix.
protected final void doTestOnClickQuickfix(VirtualFile file) {
myFixture.configureFromExistingVirtualFile(file);
List<IntentionAction> actions = highlightAndFindQuickFixes(AndroidMissingOnClickHandlerInspection.MyQuickFix.class);
assertEquals(1, actions.size());
IntentionAction action = actions.get(0);
assertInstanceOf(action, AndroidMissingOnClickHandlerInspection.MyQuickFix.class);
WriteCommandAction.runWriteCommandAction(null, () -> ((AndroidMissingOnClickHandlerInspection.MyQuickFix) action).doApplyFix(getProject()));
myFixture.checkResultByFile(myTestFolder + "/onClickIntention.xml");
}
use of com.intellij.codeInsight.intention.IntentionAction in project android by JetBrains.
the class AndroidLayoutDomTest method testOnClickQuickFixIncorrectName.
public void testOnClickQuickFixIncorrectName() throws Throwable {
myFixture.enableInspections(AndroidMissingOnClickHandlerInspection.class);
myFixture.copyFileToProject(myTestFolder + "/OnClickActivityIncorrectName.java", "src/p1/p2/Activity1.java");
VirtualFile file = copyFileToProject("onClickIntentionIncorrectName.xml");
myFixture.configureFromExistingVirtualFile(file);
List<IntentionAction> fixes = highlightAndFindQuickFixes(AndroidMissingOnClickHandlerInspection.MyQuickFix.class);
assertEmpty(fixes);
}
use of com.intellij.codeInsight.intention.IntentionAction in project android by JetBrains.
the class AndroidLayoutDomTest method testOnClickQuickFix1.
public void testOnClickQuickFix1() throws Throwable {
myFixture.enableInspections(AndroidMissingOnClickHandlerInspection.class);
myFixture.copyFileToProject(myTestFolder + "/OnClickActivity.java", "src/p1/p2/Activity1.java");
VirtualFile file = copyFileToProject("onClickIntention.xml");
myFixture.configureFromExistingVirtualFile(file);
List<IntentionAction> fixes = highlightAndFindQuickFixes(AndroidMissingOnClickHandlerInspection.MyQuickFix.class);
assertEmpty(fixes);
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class RegisterExtensionFixProvider method getQuickFixes.
@NotNull
@Override
public IntentionAction[] getQuickFixes(@NotNull PsiElement element) {
if (!(element instanceof PsiIdentifier))
return IntentionAction.EMPTY_ARRAY;
PsiElement parent = element.getParent();
if (!(parent instanceof PsiClass))
return IntentionAction.EMPTY_ARRAY;
PsiClass psiClass = (PsiClass) parent;
if (InheritanceUtil.isInheritor(psiClass, LocalInspectionTool.class.getName())) {
return new IntentionAction[] { new RegisterInspectionFix(psiClass, LocalInspectionEP.LOCAL_INSPECTION) };
}
if (InheritanceUtil.isInheritor(psiClass, GlobalInspectionTool.class.getName())) {
return new IntentionAction[] { new RegisterInspectionFix(psiClass, InspectionEP.GLOBAL_INSPECTION) };
}
ExtensionPointLocator extensionPointLocator = new ExtensionPointLocator(psiClass);
List<ExtensionPointCandidate> candidateList = extensionPointLocator.findSuperCandidates();
if (!candidateList.isEmpty()) {
return new IntentionAction[] { new RegisterExtensionFix(psiClass, candidateList) };
}
return IntentionAction.EMPTY_ARRAY;
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.
the class CreateClassFixTest method runSingle.
@Test
public void runSingle() throws Throwable {
invokeTestRunnable(() -> {
IntentionAction resultAction = null;
final String createAction = QuickFixBundle.message(myCreateClass ? "create.class.text" : "create.interface.text", myTestName);
final List<IntentionAction> actions = myFixture.getAvailableIntentions(getSourceRoot() + "/plugin" + myTestName + ".xml");
for (IntentionAction action : actions) {
if (Comparing.strEqual(action.getText(), createAction)) {
resultAction = action;
break;
}
}
Assert.assertNotNull(resultAction);
myFixture.launchAction(resultAction);
final Project project = myFixture.getProject();
Assert.assertNotNull(JavaPsiFacade.getInstance(project).findClass(myTestName, GlobalSearchScope.allScope(project)));
});
}
Aggregations