@Test public void createAddMethodCallFix() { testHelper.getPsiClass( classes -> { PsiClass cls = classes.get(0); PsiMethodCallExpression call = PsiTreeUtil.findChildOfType(cls, PsiMethodCallExpression.class); Project project = testHelper.getFixture().getProject(); PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory(); Editor editor = mock(Editor.class); when(editor.getCaretModel()).thenReturn(mock(CaretModel.class)); IntentionAction fix = AddArgumentFix.createAddMethodCallFix(call, "ClassName", "methodName", factory); assertThat(call.getArgumentList().getExpressions()[0].getText()) .isNotEqualTo("ClassName.methodName()"); fix.invoke(project, editor, testHelper.getFixture().getFile()); assertThat(call.getArgumentList().getExpressions()[0].getText()) .isEqualTo("ClassName.methodName()"); return true; }, "RequiredPropAnnotatorTest.java"); }
static IntentionAction createAddMethodCallFix( PsiMethodCallExpression originalMethodCall, String clsName, String methodName, PsiElementFactory elementFactory) { PsiExpressionList newArgumentList = createArgumentList(originalMethodCall.getContext(), clsName, methodName, elementFactory); String fixDescription = "Add ." + methodName + "() " + getCapitalizedMethoName(originalMethodCall); return new AddArgumentFix(originalMethodCall, newArgumentList, fixDescription); }
AddArgumentFix extends BaseIntentionAction implements HighPriorityAction { static IntentionAction createAddMethodCallFix( PsiMethodCallExpression originalMethodCall, String clsName, String methodName, PsiElementFactory elementFactory) { PsiExpressionList newArgumentList = createArgumentList(originalMethodCall.getContext(), clsName, methodName, elementFactory); String fixDescription = "Add ." + methodName + "() " + getCapitalizedMethoName(originalMethodCall); return new AddArgumentFix(originalMethodCall, newArgumentList, fixDescription); } }
AddArgumentFix extends BaseIntentionAction implements HighPriorityAction { static IntentionAction createAddMethodCallFix( PsiMethodCallExpression originalMethodCall, String clsName, String methodName, PsiElementFactory elementFactory) { PsiExpressionList newArgumentList = createArgumentList(originalMethodCall.getContext(), clsName, methodName, elementFactory); String fixDescription = "Add ." + methodName + "() " + getCapitalizedMethoName(originalMethodCall); return new AddArgumentFix(originalMethodCall, newArgumentList, fixDescription); } private  AddArgumentFix(
      PsiCall originalCall, PsiExpressionList newArgumentList, String description); }
AddArgumentFix extends BaseIntentionAction implements HighPriorityAction { static IntentionAction createAddMethodCallFix( PsiMethodCallExpression originalMethodCall, String clsName, String methodName, PsiElementFactory elementFactory) { PsiExpressionList newArgumentList = createArgumentList(originalMethodCall.getContext(), clsName, methodName, elementFactory); String fixDescription = "Add ." + methodName + "() " + getCapitalizedMethoName(originalMethodCall); return new AddArgumentFix(originalMethodCall, newArgumentList, fixDescription); } private  AddArgumentFix(
      PsiCall originalCall, PsiExpressionList newArgumentList, String description); @Nls(capitalization = Nls.Capitalization.Sentence) @Override String getFamilyName(); @Override boolean isAvailable(Project project, Editor editor, PsiFile file); @Override void invoke(Project project, Editor editor, PsiFile file); }
AddArgumentFix extends BaseIntentionAction implements HighPriorityAction { static IntentionAction createAddMethodCallFix( PsiMethodCallExpression originalMethodCall, String clsName, String methodName, PsiElementFactory elementFactory) { PsiExpressionList newArgumentList = createArgumentList(originalMethodCall.getContext(), clsName, methodName, elementFactory); String fixDescription = "Add ." + methodName + "() " + getCapitalizedMethoName(originalMethodCall); return new AddArgumentFix(originalMethodCall, newArgumentList, fixDescription); } private  AddArgumentFix(
      PsiCall originalCall, PsiExpressionList newArgumentList, String description); @Nls(capitalization = Nls.Capitalization.Sentence) @Override String getFamilyName(); @Override boolean isAvailable(Project project, Editor editor, PsiFile file); @Override void invoke(Project project, Editor editor, PsiFile file);  }