|
25 | 25 | import com.jetbrains.php.lang.psi.PhpCodeEditUtil;
|
26 | 26 | import com.jetbrains.php.lang.psi.PhpFile;
|
27 | 27 | import com.jetbrains.php.lang.psi.PhpPsiUtil;
|
28 |
| -import com.jetbrains.php.lang.psi.elements.*; |
29 |
| -import java.util.*; |
| 28 | +import com.jetbrains.php.lang.psi.elements.Method; |
| 29 | +import com.jetbrains.php.lang.psi.elements.PhpClass; |
| 30 | +import com.jetbrains.php.lang.psi.elements.PhpPsiElement; |
30 | 31 | import com.magento.idea.magento2plugin.actions.generation.ImportReferences.PhpClassReferenceResolver;
|
31 | 32 | import com.magento.idea.magento2plugin.actions.generation.data.code.PluginMethodData;
|
32 | 33 | import com.magento.idea.magento2plugin.actions.generation.generator.code.PluginMethodsGenerator;
|
33 | 34 | import com.magento.idea.magento2plugin.actions.generation.util.CodeStyleSettings;
|
34 | 35 | import com.magento.idea.magento2plugin.actions.generation.util.CollectInsertedMethods;
|
35 | 36 | import com.magento.idea.magento2plugin.actions.generation.util.FillTextBufferWithPluginMethods;
|
| 37 | +import com.magento.idea.magento2plugin.bundles.ValidatorBundle; |
36 | 38 | import com.magento.idea.magento2plugin.magento.files.Plugin;
|
37 | 39 | import com.magento.idea.magento2plugin.util.GetPhpClassByFQN;
|
38 | 40 | import com.magento.idea.magento2plugin.util.magento.plugin.GetTargetClassNamesByPluginClassName;
|
|
41 | 43 | import org.jetbrains.annotations.NotNull;
|
42 | 44 | import org.jetbrains.annotations.Nullable;
|
43 | 45 |
|
| 46 | +import javax.swing.*; |
| 47 | +import java.util.*; |
| 48 | + |
44 | 49 | public abstract class PluginGenerateMethodHandlerBase implements LanguageCodeInsightActionHandler {
|
45 | 50 | private CollectInsertedMethods collectInsertedMethods;
|
| 51 | + private ValidatorBundle validatorBundle; |
46 | 52 | public String type;
|
47 | 53 | public FillTextBufferWithPluginMethods fillTextBuffer;
|
48 | 54 |
|
49 | 55 | public PluginGenerateMethodHandlerBase(Plugin.PluginType type) {
|
50 | 56 | this.type = type.toString();
|
51 | 57 | this.fillTextBuffer = FillTextBufferWithPluginMethods.getInstance();
|
52 | 58 | this.collectInsertedMethods = CollectInsertedMethods.getInstance();
|
| 59 | + this.validatorBundle = new ValidatorBundle(); |
53 | 60 | }
|
54 | 61 |
|
55 | 62 | public boolean isValidFor(Editor editor, PsiFile file) {
|
@@ -155,9 +162,17 @@ protected PhpNamedElementNode[] targetMethods(@NotNull PhpClass phpClass, Key<Ob
|
155 | 162 | ArrayList<String> targetClassNames = targetClassesService.execute(currentClass);
|
156 | 163 | for (String targetClassName : targetClassNames) {
|
157 | 164 | PhpClass targetClass = GetPhpClassByFQN.getInstance(phpClass.getProject()).execute(targetClassName);
|
| 165 | + |
| 166 | + if (targetClass == null) { |
| 167 | + String errorMessage = validatorBundle.message("validator.class.targetClassNotFound"); |
| 168 | + JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE); |
| 169 | + continue; |
| 170 | + } |
| 171 | + |
158 | 172 | if (targetClass.isFinal()) {
|
159 | 173 | continue;
|
160 | 174 | }
|
| 175 | + |
161 | 176 | Collection<Method> methods = targetClass.getMethods();
|
162 | 177 | Iterator methodIterator = methods.iterator();
|
163 | 178 |
|
|
0 commit comments