diff --git a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/actions/OnEventChangeSignatureDialog.java b/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/actions/OnEventChangeSignatureDialog.java
deleted file mode 100644
index 5c742202a4b..00000000000
--- a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/actions/OnEventChangeSignatureDialog.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.facebook.litho.intellij.actions;
-
-import com.facebook.litho.annotations.Param;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.fileTypes.LanguageFileType;
-import com.intellij.openapi.fileTypes.StdFileTypes;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiAnnotation;
-import com.intellij.psi.PsiCodeFragment;
-import com.intellij.psi.PsiDocumentManager;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiElementFactory;
-import com.intellij.psi.PsiEllipsisType;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiModifier;
-import com.intellij.psi.PsiModifierList;
-import com.intellij.psi.PsiNameHelper;
-import com.intellij.psi.PsiParameter;
-import com.intellij.psi.PsiParameterList;
-import com.intellij.psi.PsiType;
-import com.intellij.psi.PsiTypeCodeFragment;
-import com.intellij.psi.PsiWhiteSpace;
-import com.intellij.psi.util.PsiTypesUtil;
-import com.intellij.refactoring.BaseRefactoringProcessor;
-import com.intellij.refactoring.RefactoringBundle;
-import com.intellij.refactoring.changeSignature.CallerChooserBase;
-import com.intellij.refactoring.changeSignature.ChangeSignatureDialogBase;
-import com.intellij.refactoring.changeSignature.JavaChangeSignatureDialog;
-import com.intellij.refactoring.changeSignature.JavaMethodDescriptor;
-import com.intellij.refactoring.changeSignature.JavaParameterTableModel;
-import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
-import com.intellij.refactoring.changeSignature.ParameterTableModelItemBase;
-import com.intellij.refactoring.ui.JavaComboBoxVisibilityPanel;
-import com.intellij.refactoring.ui.VisibilityPanelBase;
-import com.intellij.refactoring.util.RefactoringMessageUtil;
-import com.intellij.ui.EditorTextField;
-import com.intellij.ui.ToolbarDecorator;
-import com.intellij.ui.treeStructure.Tree;
-import com.intellij.util.Consumer;
-import com.intellij.util.ui.table.EditorTextFieldJBTableRowRenderer;
-import com.intellij.util.ui.table.JBTableRow;
-import com.intellij.util.ui.table.JBTableRowEditor;
-import com.intellij.util.ui.table.JBTableRowRenderer;
-import java.awt.BorderLayout;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Dialog similar to the {@link JavaChangeSignatureDialog} with differences specific to Litho
- * OnEvent method:
- *
- *
- * - Visibility is fixed
- *
- Return type is fixed
- *
- No default value option for parameters
- *
- No error on absence of default value
- *
- No additional tab for exceptions
- *
- No Preview and Refactor buttons
- *
- */
-final class OnEventChangeSignatureDialog
- extends ChangeSignatureDialogBase<
- ParameterInfoImpl,
- PsiMethod,
- String,
- JavaMethodDescriptor,
- ParameterTableModelItemBase,
- JavaParameterTableModel> {
-
- private final Map nameToParameter = new HashMap<>();
- private PsiMethod newMethod;
-
- /** @param method is used to fill the chooser table. It will not be modified. */
- OnEventChangeSignatureDialog(Project project, PsiMethod method, PsiElement context) {
- super(project, new OnEventMethodDescriptor(method), false, context);
- // Save initial method parameters
- PsiParameter[] parameters = method.getParameterList().getParameters();
- for (PsiParameter parameter : parameters) {
- nameToParameter.put(parameter.getName(), parameter);
- }
- }
-
- @Nullable
- PsiMethod getMethod() {
- return newMethod;
- }
-
- @Override
- protected JPanel createParametersPanel(boolean hasTabsInDialog) {
- super.createParametersPanel(hasTabsInDialog);
- return ToolbarDecorator.createDecorator(myParametersList.getTable()).createPanel();
- }
-
- @Override
- protected boolean isListTableViewSupported() {
- return true;
- }
-
- @Override
- protected ParametersListTable createParametersListTable() {
- return new OnEventParametersListTable();
- }
-
- @Override
- protected LanguageFileType getFileType() {
- return StdFileTypes.JAVA;
- }
-
- @Override
- protected VisibilityPanelBase createVisibilityControl() {
- return new JavaComboBoxVisibilityPanel();
- }
-
- @NotNull
- @Override
- protected JavaParameterTableModel createParametersInfoModel(JavaMethodDescriptor descriptor) {
- final PsiParameterList parameterList = descriptor.getMethod().getParameterList();
- return new JavaParameterTableModel(parameterList, myDefaultValueContext, this);
- }
-
- @Nullable
- @Override
- protected BaseRefactoringProcessor createRefactoringProcessor() {
- return null;
- }
-
- @Nullable
- @Override
- protected PsiCodeFragment createReturnTypeCodeFragment() {
- return null;
- }
-
- @Nullable
- @Override
- protected CallerChooserBase createCallerChooser(
- String s, Tree tree, Consumer> consumer) {
- return null;
- }
-
- @NotNull
- @Override
- protected Action[] createActions() {
- return new Action[] {getOKAction()};
- }
-
- @Override
- protected void invokeRefactoring(BaseRefactoringProcessor processor) {
- closeOKAction();
- }
-
- @Override
- protected String calculateSignature() {
- return doCalculateSignature(myMethod.getMethod());
- }
-
- @Nullable
- @Override
- protected String validateAndCommitData() {
- return validateAndCreateMethod();
- }
-
- /**
- * @return either an error message or null if no errors are found. This method has side effect of
- * creating a new PsiMethod with chosen fields and method name.
- */
- @Nullable
- private String validateAndCreateMethod() {
- String methodName = getMethodName();
- if (!PsiNameHelper.getInstance(myProject).isIdentifier(methodName)) {
- return RefactoringMessageUtil.getIncorrectIdentifierMessage(methodName);
- }
-
- final PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
- final PsiMethod oldMethod = myMethod.getMethod();
- final PsiMethod newMethod = factory.createMethod(methodName, oldMethod.getReturnType());
-
- final List> tableModelItems =
- myParametersTableModel.getItems();
- final PsiParameterList parameterList = newMethod.getParameterList();
- for (final ParameterTableModelItemBase item : tableModelItems) {
- final String parameterName = item.parameter.getName();
- if (!PsiNameHelper.getInstance(myProject).isIdentifier(parameterName)) {
- return RefactoringMessageUtil.getIncorrectIdentifierMessage(parameterName);
- }
-
- final PsiType parameterType;
- try {
- parameterType = ((PsiTypeCodeFragment) item.typeCodeFragment).getType();
- } catch (PsiTypeCodeFragment.TypeSyntaxException e) {
- return RefactoringBundle.message(
- "changeSignature.wrong.type.for.parameter",
- item.typeCodeFragment.getText(),
- parameterName);
- } catch (PsiTypeCodeFragment.NoTypeException e) {
- return RefactoringBundle.message(
- "changeSignature.no.type.for.parameter", "return", parameterName);
- }
- if (PsiTypesUtil.hasUnresolvedComponents(parameterType)) {
- return RefactoringBundle.message("changeSignature.cannot.resolve.parameter.type");
- }
- if (parameterType instanceof PsiEllipsisType) {
- return "Don`t use varargs type for " + parameterName;
- }
-
- PsiParameter parameter =
- getInitialMethodParameter(parameterName, parameterType.getPresentableText());
- if (parameter == null) {
- parameter = factory.createParameter(parameterName, parameterType);
- final PsiModifierList parameterModifierList = parameter.getModifierList();
- if (parameterModifierList == null) {
- continue;
- }
- parameterModifierList.addAnnotation(Param.class.getName());
- }
- parameterList.add(parameter);
- }
- // TODO T39429594: Context should be not removable
- // TODO T39429594: Extract createMethod logic into Utility class
- // TODO T39429594: Check for duplicate parameter names
-
- final PsiModifierList modifierList = newMethod.getModifierList();
- for (PsiElement modifier : oldMethod.getModifierList().getChildren()) {
- modifierList.add(modifier);
- }
- modifierList.setModifierProperty(PsiModifier.PACKAGE_LOCAL, true);
-
- this.newMethod = newMethod;
-
- return null;
- }
-
- private String doCalculateSignature(PsiMethod method) {
- // This method could be called when object has not been fully constructed
- if (nameToParameter == null) {
- return "";
- }
- final StringBuilder buffer = new StringBuilder();
- final PsiModifierList modifierList = method.getModifierList();
-
- // New line after annotation
- final PsiElement[] modifiers = modifierList.getChildren();
- for (int i = 0, size = modifiers.length; i < size; i++) {
- final PsiElement modifier = modifiers[i];
- if (modifier instanceof PsiWhiteSpace) {
- continue;
- }
- buffer.append(modifier.getText());
- if (i == 0 && modifier instanceof PsiAnnotation) {
- buffer.append("\n");
- } else {
- buffer.append(" ");
- }
- }
-
- final PsiType returnType = method.getReturnType();
- if (returnType != null) {
- buffer.append(returnType.getPresentableText()).append(" ");
- }
- buffer.append(getMethodName()).append("(");
-
- final int lineBreakIdx = buffer.lastIndexOf("\n");
- final String indent =
- StringUtil.repeatSymbol(
- ' ', lineBreakIdx >= 0 ? buffer.length() - lineBreakIdx - 1 : buffer.length());
-
- final List> currentTableItems =
- myParametersTableModel.getItems();
-
- for (int i = 0; i < currentTableItems.size(); i++) {
- final ParameterTableModelItemBase item = currentTableItems.get(i);
- if (i > 0) {
- buffer.append(",");
- buffer.append("\n");
- buffer.append(indent);
- }
- final String itemName = item.parameter.getName();
- final String itemType = item.typeCodeFragment.getText();
- final PsiParameter parameter = getInitialMethodParameter(itemName, itemType);
- if (parameter != null) {
- for (PsiElement annotation : parameter.getAnnotations()) {
- buffer.append(annotation.getText()).append(" ");
- }
- } else {
- buffer.append("@").append(Param.class.getSimpleName()).append(" ");
- }
- buffer.append(itemType).append(" ").append(itemName);
- }
-
- buffer.append(")");
-
- return buffer.toString();
- }
-
- /** @return parameter from initial method if name and type match any, null otherwise. */
- @Nullable
- // Package-private to be accessed from the inner class.
- PsiParameter getInitialMethodParameter(String name, String type) {
- final PsiParameter parameter = nameToParameter.get(name);
- if (parameter == null) {
- return null;
- }
- if (parameter.getType().getPresentableText().equals(type)) {
- return parameter;
- }
- return null;
- }
-
- /** Java Method Descriptor that doesn't allow to modify return type or change visibility. */
- private static class OnEventMethodDescriptor extends JavaMethodDescriptor {
- OnEventMethodDescriptor(PsiMethod method) {
- super(method);
- }
-
- @Override
- public boolean canChangeVisibility() {
- return false;
- }
-
- @Override
- public ReadWriteOption canChangeReturnType() {
- return ReadWriteOption.None;
- }
- }
-
- /**
- * Table that has not-modifiable fields for initial parameters. Implementation mostly copied from
- * the {@link JavaChangeSignatureDialog}.
- */
- private class OnEventParametersListTable extends ParametersListTable {
- private final EditorTextFieldJBTableRowRenderer myRowRenderer =
- new EditorTextFieldJBTableRowRenderer(
- getProject(), OnEventChangeSignatureDialog.this.getFileType(), myDisposable) {
- @Override
- protected String getText(JTable table, int row) {
- ParameterTableModelItemBase item = getRowItem(row);
- final String typeText = item.typeCodeFragment.getText();
- final String separator =
- StringUtil.repeatSymbol(' ', getTypesMaxLength() - typeText.length() + 1);
- return " " + (typeText + separator + item.parameter.getName());
- }
- };
-
- int getTypesMaxLength() {
- int len = 0;
- for (ParameterTableModelItemBase item :
- myParametersTableModel.getItems()) {
- final String text = item.typeCodeFragment == null ? null : item.typeCodeFragment.getText();
- len = Math.max(len, text == null ? 0 : text.length());
- }
- return len;
- }
-
- @Override
- protected boolean isRowEditable(int row) {
- // If table parameter is an initial method parameter, than it's not editable.
- if (row == 0) {
- stopEditing();
- }
- final List> currentTableItems =
- myParametersTableModel.getItems();
- if (row > currentTableItems.size()) {
- return true;
- }
- final ParameterInfoImpl parameterInfo = currentTableItems.get(row).parameter;
- final PsiParameter initialMethodParameter =
- getInitialMethodParameter(parameterInfo.getName(), parameterInfo.getTypeText());
- return initialMethodParameter == null;
- }
-
- @Override
- protected JBTableRowRenderer getRowRenderer(int row) {
- return myRowRenderer;
- }
-
- @NotNull
- @Override
- protected JBTableRowEditor getRowEditor(
- final ParameterTableModelItemBase item) {
- return new JBTableRowEditor() {
- private EditorTextField myTypeEditor;
- private EditorTextField myNameEditor;
-
- @Override
- public void prepareEditor(JTable table, int row) {
- setLayout(new BorderLayout());
- final Document document =
- PsiDocumentManager.getInstance(getProject()).getDocument(item.typeCodeFragment);
- myTypeEditor = new EditorTextField(document, getProject(), getFileType());
- myTypeEditor.addDocumentListener(mySignatureUpdater);
- myTypeEditor.setPreferredWidth(getTable().getWidth() / 2);
- myTypeEditor.addDocumentListener(new RowEditorChangeListener(0));
- add(createLabeledPanel("Type:", myTypeEditor), BorderLayout.WEST);
-
- myNameEditor = new EditorTextField(item.parameter.getName(), getProject(), getFileType());
- myNameEditor.addDocumentListener(mySignatureUpdater);
- myNameEditor.addDocumentListener(new RowEditorChangeListener(1));
- add(createLabeledPanel("Name:", myNameEditor), BorderLayout.CENTER);
- }
-
- @Override
- public JBTableRow getValue() {
- return column -> {
- switch (column) {
- case 0:
- return item.typeCodeFragment;
- case 1:
- return myNameEditor.getText().trim();
- case 2:
- return item.defaultValueCodeFragment;
- case 3:
- return false;
- }
- return null;
- };
- }
-
- @Override
- public JComponent getPreferredFocusedComponent() {
- return myTypeEditor.getFocusTarget();
- }
-
- @Override
- public JComponent[] getFocusableComponents() {
- return new JComponent[] {myTypeEditor.getFocusTarget(), myNameEditor.getFocusTarget()};
- }
- };
- }
-
- @Override
- protected boolean isRowEmpty(int row) {
- final ParameterInfoImpl parameter = getRowItem(row).parameter;
- return StringUtil.isEmpty(parameter.getName()) && StringUtil.isEmpty(parameter.getTypeText());
- }
- }
-}
diff --git a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/actions/OnEventGenerateAction.java b/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/actions/OnEventGenerateAction.java
deleted file mode 100644
index 2cc61dac9c0..00000000000
--- a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/actions/OnEventGenerateAction.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.facebook.litho.intellij.actions;
-
-import com.facebook.litho.intellij.LithoPluginUtils;
-import com.facebook.litho.intellij.completion.OnEventGenerateUtils;
-import com.facebook.litho.intellij.extensions.EventLogger;
-import com.facebook.litho.intellij.logging.LithoLoggerProvider;
-import com.intellij.codeInsight.CodeInsightActionHandler;
-import com.intellij.codeInsight.generation.ClassMember;
-import com.intellij.codeInsight.generation.GenerateMembersHandlerBase;
-import com.intellij.codeInsight.generation.GenerationInfo;
-import com.intellij.codeInsight.generation.PsiGenerationInfo;
-import com.intellij.codeInsight.generation.PsiMethodMember;
-import com.intellij.codeInsight.generation.actions.BaseGenerateAction;
-import com.intellij.ide.util.TreeJavaClassChooserDialog;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.util.IncorrectOperationException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Generates a method handling Litho event in the Litho Spec.
- * https://fblitho.com/docs/events-overview
- */
-public class OnEventGenerateAction extends BaseGenerateAction {
-
- public interface EventChooser {
- PsiClass choose(PsiClass context, Project project);
- }
-
- public interface OnEventRefactorer {
- PsiMethod changeSignature(Project project, PsiMethod originalOnEventMethod, PsiClass context);
- }
-
- public interface OnEventGeneratedListener {
- void onGenerated(PsiMethod onEvent);
- }
-
- public static CodeInsightActionHandler createHandler(
- EventChooser eventChooser, OnEventGeneratedListener onEventGeneratedListener) {
- return new OnEventGenerateHandler(
- eventChooser,
- (project, originalOnEventMethod, context) -> {
- if (ApplicationManager.getApplication().isUnitTestMode()) {
- return originalOnEventMethod;
- }
- final OnEventChangeSignatureDialog onEventMethodSignatureChooser =
- new OnEventChangeSignatureDialog(project, originalOnEventMethod, context);
- onEventMethodSignatureChooser.show();
- return onEventMethodSignatureChooser.getMethod();
- },
- onEventGeneratedListener);
- }
-
- public OnEventGenerateAction() {
- super(
- createHandler(
- (context, project) -> {
- // Choose event to generate method for
- final TreeJavaClassChooserDialog chooseEventDialog =
- new TreeJavaClassChooserDialog(
- "Choose Event",
- project,
- GlobalSearchScope.allScope(project),
- LithoPluginUtils::isEvent,
- context /* Any initial class */);
- chooseEventDialog.show();
- return chooseEventDialog.getSelected();
- },
- onEventMethod ->
- LithoLoggerProvider.getEventLogger()
- .log(EventLogger.EVENT_ON_EVENT_GENERATION + ".success")));
- }
-
- @Override
- public void update(AnActionEvent e) {
- // Applies visibility of the Generate Action group
- super.update(e);
- final PsiFile file = e.getData(CommonDataKeys.PSI_FILE);
- if (!LithoPluginUtils.isLithoSpec(file)) {
- e.getPresentation().setEnabledAndVisible(false);
- }
- }
-
- /**
- * Generates Litho event method. Prompts the user for additional data: choose Event class and
- * method signature customisation.
- *
- * @see com.facebook.litho.intellij.completion.MethodGenerateHandler
- */
- static class OnEventGenerateHandler extends GenerateMembersHandlerBase {
- private final EventChooser eventChooser;
- private final OnEventGeneratedListener onEventGeneratedListener;
- private final OnEventRefactorer onEventRefactorer;
-
- OnEventGenerateHandler(
- EventChooser eventChooser,
- OnEventRefactorer onEventRefactorer,
- OnEventGeneratedListener onEventGeneratedListener) {
- super("");
- this.eventChooser = eventChooser;
- this.onEventGeneratedListener = onEventGeneratedListener;
- this.onEventRefactorer = onEventRefactorer;
- }
-
- /** @return method based on user choice. */
- @Override
- protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) {
- return Optional.ofNullable(eventChooser.choose(aClass, project))
- .map(
- eventClass ->
- OnEventGenerateUtils.createOnEventMethod(
- aClass, eventClass, Collections.emptyList()))
- .map(
- customMethod -> {
- OnEventGenerateUtils.addComment(aClass, customMethod);
- onEventGeneratedListener.onGenerated(customMethod);
- return new ClassMember[] {new PsiMethodMember(customMethod)};
- })
- .orElse(ClassMember.EMPTY_ARRAY);
- }
-
- @Override
- protected GenerationInfo[] generateMemberPrototypes(PsiClass psiClass, ClassMember classMember)
- throws IncorrectOperationException {
- return generateMemberPrototypes(psiClass, new ClassMember[] {classMember})
- .toArray(GenerationInfo.EMPTY_ARRAY);
- }
-
- /** @return a list of objects to insert into generated code. */
- @NotNull
- @Override
- protected List extends GenerationInfo> generateMemberPrototypes(
- PsiClass aClass, ClassMember[] members) throws IncorrectOperationException {
- final List prototypes = new ArrayList<>();
- for (ClassMember member : members) {
- if (member instanceof PsiMethodMember) {
- PsiMethodMember methodMember = (PsiMethodMember) member;
- prototypes.add(new PsiGenerationInfo<>(methodMember.getElement()));
- }
- }
- return prototypes;
- }
-
- @Override
- protected ClassMember[] getAllOriginalMembers(PsiClass psiClass) {
- return ClassMember.EMPTY_ARRAY;
- }
- }
-}
diff --git a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/AddArgumentFix.java b/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/AddArgumentFix.java
index 2ee4c6bf926..16cc13e6e45 100644
--- a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/AddArgumentFix.java
+++ b/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/AddArgumentFix.java
@@ -25,7 +25,6 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiCall;
-import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementFactory;
import com.intellij.psi.PsiExpressionList;
@@ -84,20 +83,6 @@ static IntentionAction createAddMethodCallFix(
return new AddArgumentFix(originalMethodCall, newArgumentList, fixDescription);
}
- /**
- * Creates new fix, that generates OnEvent method and adds static method call as an argument to
- * the originalMethodCall.
- */
- static IntentionAction createNewMethodCallFix(
- PsiMethodCallExpression originalMethodCall,
- String clsName,
- PsiClass event,
- PsiClass parentLayoutSpec) {
- String fixDescription = "Create new " + getCapitalizedMethoName(originalMethodCall);
- return new OnEventCreateFix(
- originalMethodCall, clsName, event, parentLayoutSpec, fixDescription);
- }
-
static String getCapitalizedMethoName(PsiMethodCallExpression methodCall) {
return StringUtil.capitalize(methodCall.getMethodExpression().getReferenceName());
}
diff --git a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/MethodCallAnnotator.java b/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/MethodCallAnnotator.java
index dec4f052ade..8dc3f08a12b 100644
--- a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/MethodCallAnnotator.java
+++ b/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/MethodCallAnnotator.java
@@ -110,11 +110,6 @@ private static void addEventHandlerFix(
.collect(Collectors.toList());
final PsiClass event = PsiSearchUtils.getInstance().findClass(project, eventQualifiedName);
- if (event != null) {
- fixes.add(
- AddArgumentFix.createNewMethodCallFix(
- methodCall, componentQualifiedName, event, parentCls));
- }
AnnotatorUtils.addError(holder, error, fixes);
}
diff --git a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/OnEventCreateFix.java b/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/OnEventCreateFix.java
deleted file mode 100644
index 6ebdee60fd9..00000000000
--- a/litho-intellij-plugin/src/main/java/com/facebook/litho/intellij/inspections/OnEventCreateFix.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.facebook.litho.intellij.inspections;
-
-import com.facebook.litho.intellij.actions.OnEventGenerateAction;
-import com.facebook.litho.intellij.extensions.EventLogger;
-import com.facebook.litho.intellij.logging.LithoLoggerProvider;
-import com.intellij.codeInsight.intention.HighPriorityAction;
-import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
-import com.intellij.openapi.application.Application;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.TransactionGuard;
-import com.intellij.openapi.command.WriteCommandAction;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiCall;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiMethod;
-import com.intellij.util.IncorrectOperationException;
-import java.util.Optional;
-import java.util.concurrent.atomic.AtomicReference;
-import org.jetbrains.annotations.Nls;
-
-/** Fix generates new OnEvent method, and replaces argument list in the given method call. */
-class OnEventCreateFix extends BaseIntentionAction implements HighPriorityAction {
- private final PsiClass event;
- private final PsiCall methodCall;
- private final String clsName;
- private final PsiClass layoutCls;
-
- OnEventCreateFix(
- PsiCall methodCall,
- String clsName,
- PsiClass event,
- PsiClass layoutSpecToUpdate,
- String fixDescription) {
- this.event = event;
- this.clsName = clsName;
- this.methodCall = methodCall;
- this.layoutCls = layoutSpecToUpdate;
- setText(fixDescription);
- }
-
- @Nls(capitalization = Nls.Capitalization.Sentence)
- @Override
- public String getFamilyName() {
- return MethodCallAnnotator.FIX_FAMILY_NAME;
- }
-
- @Override
- public boolean isAvailable(Project project, Editor editor, PsiFile file) {
- // Copied from PermuteArgumentsFix
- return !project.isDisposed()
- && methodCall.isValid()
- && methodCall.getManager().isInProject(methodCall)
- && methodCall.getArgumentList() != null;
- }
-
- @Override
- public void invoke(Project project, Editor editor, PsiFile file)
- throws IncorrectOperationException {
- final AtomicReference eventMethodRef = new AtomicReference<>();
- final Runnable generateOnEvent =
- () ->
- OnEventGenerateAction.createHandler(
- (context, eventProject) -> event, eventMethodRef::set)
- .invoke(project, editor, file);
- final Runnable updateArgumentList =
- () ->
- Optional.ofNullable(eventMethodRef.get())
- .map(
- eventMethod ->
- AddArgumentFix.createArgumentList(
- methodCall,
- clsName,
- eventMethod.getName(),
- JavaPsiFacade.getInstance(project).getElementFactory()))
- .ifPresent(argumentList -> methodCall.getArgumentList().replace(argumentList));
- final Runnable action =
- () -> {
- TransactionGuard.getInstance().submitTransactionAndWait(generateOnEvent);
- WriteCommandAction.runWriteCommandAction(project, updateArgumentList);
- LithoLoggerProvider.getEventLogger().log(EventLogger.EVENT_FIX_EVENT_HANDLER + ".new");
- };
- final Application application = ApplicationManager.getApplication();
- if (application.isUnitTestMode()) {
- action.run();
- } else {
- application.invokeLater(action);
- }
- }
-}
diff --git a/litho-intellij-plugin/src/main/resources/META-INF/plugin.xml b/litho-intellij-plugin/src/main/resources/META-INF/plugin.xml
index 26355180c1e..fd053cd9089 100644
--- a/litho-intellij-plugin/src/main/resources/META-INF/plugin.xml
+++ b/litho-intellij-plugin/src/main/resources/META-INF/plugin.xml
@@ -131,14 +131,6 @@
/>
-
-
-
-