Skip to content

Fixed plugin generation for complex non primitive types #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import com.jetbrains.php.lang.psi.elements.Method;
import com.jetbrains.php.lang.psi.elements.PhpClass;
import com.jetbrains.php.lang.psi.elements.PhpPsiElement;
import com.magento.idea.magento2plugin.actions.generation.ImportReferences.PhpClassReferenceResolver;
import com.magento.idea.magento2plugin.actions.generation.data.code.PluginMethodData;
import com.magento.idea.magento2plugin.actions.generation.generator.code.PluginMethodsGenerator;
import com.magento.idea.magento2plugin.actions.generation.references.PhpClassReferenceResolver;
import com.magento.idea.magento2plugin.actions.generation.util.CodeStyleSettings;
import com.magento.idea.magento2plugin.actions.generation.util.CollectInsertedMethods;
import com.magento.idea.magento2plugin.actions.generation.util.FillTextBufferWithPluginMethods;
Expand Down Expand Up @@ -72,7 +72,7 @@ public abstract class PluginGenerateMethodHandlerBase implements LanguageCodeIns
*/
public PluginGenerateMethodHandlerBase(final Plugin.PluginType type) {
this.type = type.toString();
this.fillTextBuffer = FillTextBufferWithPluginMethods.getInstance();
this.fillTextBuffer = new FillTextBufferWithPluginMethods();
this.collectInsertedMethods = CollectInsertedMethods.getInstance();
this.validatorBundle = new ValidatorBundle();
this.commonBundle = new CommonBundle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import com.jetbrains.php.lang.psi.elements.Method;
import com.jetbrains.php.lang.psi.elements.PhpClass;
import com.jetbrains.php.lang.psi.elements.PhpPsiElement;
import com.magento.idea.magento2plugin.actions.generation.ImportReferences.PhpClassReferenceResolver;
import com.magento.idea.magento2plugin.actions.generation.data.PluginFileData;
import com.magento.idea.magento2plugin.actions.generation.data.code.PluginMethodData;
import com.magento.idea.magento2plugin.actions.generation.generator.code.PluginMethodsGenerator;
import com.magento.idea.magento2plugin.actions.generation.generator.util.DirectoryGenerator;
import com.magento.idea.magento2plugin.actions.generation.generator.util.FileFromTemplateGenerator;
import com.magento.idea.magento2plugin.actions.generation.references.PhpClassReferenceResolver;
import com.magento.idea.magento2plugin.actions.generation.util.CodeStyleSettings;
import com.magento.idea.magento2plugin.actions.generation.util.CollectInsertedMethods;
import com.magento.idea.magento2plugin.actions.generation.util.FillTextBufferWithPluginMethods;
Expand All @@ -46,10 +46,9 @@
import javax.swing.JOptionPane;
import org.jetbrains.annotations.NotNull;

@SuppressWarnings({
"PMD.ExcessiveImports"
})
@SuppressWarnings({"PMD.ExcessiveImports"})
public class PluginClassGenerator extends FileGenerator {

private final PluginFileData pluginFileData;
private final Project project;
private final ValidatorBundle validatorBundle;
Expand All @@ -74,7 +73,7 @@ public PluginClassGenerator(
this.directoryGenerator = DirectoryGenerator.getInstance();
this.fileFromTemplateGenerator = new FileFromTemplateGenerator(project);
this.getFirstClassOfFile = GetFirstClassOfFile.getInstance();
this.fillTextBuffer = FillTextBufferWithPluginMethods.getInstance();
this.fillTextBuffer = new FillTextBufferWithPluginMethods();
this.collectInsertedMethods = CollectInsertedMethods.getInstance();
this.pluginFileData = pluginFileData;
this.project = project;
Expand All @@ -86,8 +85,10 @@ public PluginClassGenerator(
* Generate plugin.
*
* @param actionName String
*
* @return PsiFile
*/
@Override
public PsiFile generate(final String actionName) {
final PsiFile[] pluginFile = {null};
WriteCommandAction.runWriteCommandAction(project, () -> {
Expand Down Expand Up @@ -227,6 +228,7 @@ private PhpClass createPluginClass(final String actionName) {
return getFirstClassOfFile.execute((PhpFile) pluginFile);
}

@Override
protected void fillAttributes(final Properties attributes) {
attributes.setProperty("NAME", pluginFileData.getPluginClassName());
attributes.setProperty("NAMESPACE", pluginFileData.getNamespace());
Expand Down
Loading