Git Product home page Git Product logo

intellij-generateallsetmethod's Introduction

intellij-generateAllSetMethod

GitHub release Jetbrains Plugins Version
Downloads Downloads last month

  • generate setter default values when cursor on local variable setter

  • generate converter when cursor in method methodConveter

  • generate List Set Map return value ListImplement Installation


support following product build version > 141

  • Android Studio
  • IntelliJ IDEA
  • IntelliJ IDEA Community Edition

using IDE plugin system

  • Preferences(Settings) > Plugins > Browse repositories... > find"GenerateAllSetter" > Install Plugin

Manual:

  • downloadlastest plugin zip -> Preferences(Settings) > Plugins > Install plugin from disk...

restart IDE.

contribute

  • import the project to Intellij
  • add a gradle task runIde
  • change the code and run the task to see the change

my other plugins

intellij-generateallsetmethod's People

Contributors

axesipov avatar binarywang avatar gejun123456 avatar gudqs7 avatar icodelife avatar pisecespeng avatar zhumengzhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

intellij-generateallsetmethod's Issues

Formatting

Hi. This is a convenient plugin. I am pointing issue with generated code.

For example, generated line for class Foo would be

Foo name= new Foo() instead of

Foo name = Foo(). It's missing a space before =.

I reckon that the problem is here.

Fix would really save additional step of manual formatting or hitting shortcut for formatter.

作者,我根据工作中的使用对插件有些改进想法,并愿意参与开发

昨天把代码拉下来后已经编译通过,目前完成了无参数使用this来赋值的逻辑,也就是支持构造方法。后续想要改进:

  1. 在变量上触发赋值时也根据入参+this来尝试赋值(我在业务开发中有太多中间类的转换了)
  2. 多参数入参及this属性遍历查找相似的赋值
  3. 支持Lombok Builder(只考虑支持Lombok的Builder格式,Builder模式变种太多而目前基本lombok一统江山了)
  4. 名字匹配不要求字符串完全一致,而是使用去除非字母符号然后字符串转为小写来匹配

想请问作者有什么功能是考虑接受的吗?有的话可以一起沟通,刚刚尝试写插件,很多类不熟悉,可以请教下大佬,我也可以贡献一定代码。

只生成父类属性的setter方法

IDEA 版本:2019.3.3
插件版本:2.4

感谢辛勤付出!
现在遇到这个问题,生成的 setter 没有当前类声明的属性的 setter,只有父类属性的 setter。

NPE

IJ 2016.3.4
Plugin 1.0.0

The error occurs randomly

null
java.lang.NullPointerException
	at com.bruce.intellijplugin.generatesetter.utils.PsiToolUtils.extractParamInfo(PsiToolUtils.java:36)
	at com.bruce.intellijplugin.generatesetter.GenerateAllSetterAction.isAvailable(GenerateAllSetterAction.java:381)
	at com.intellij.codeInsight.intention.PsiElementBaseIntentionAction.isAvailable(PsiElementBaseIntentionAction.java:64)
	at com.intellij.codeInsight.intention.impl.config.IntentionActionWrapper.isAvailable(IntentionActionWrapper.java:59)
	at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.availableFor(ShowIntentionActionsHandler.java:132)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.a(ShowIntentionsPass.java:312)
	at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.chooseBetweenHostAndInjected(ShowIntentionActionsHandler.java:157)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getActionsToShow(ShowIntentionsPass.java:311)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.a(ShowIntentionsPass.java:243)
	at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.doCollectInformation(ShowIntentionsPass.java:219)
	at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:70)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:433)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1061)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.b(PassExecutorService.java:426)
	at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:568)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:519)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.c(PassExecutorService.java:425)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:405)
	at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:155)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

修改plugin

之前我有给作者发过一份Email,想提出了想自动添加上注释,但是迟迟没有收到回复,今天我把代码拉取下来进行查看,折腾了许久,想自己动手,结果发现maven源不存在,作者请更新一下代码哦

Add generation for "this"

If you for example want to write a copy constructor, it would be nice if you can use the plugin.
Currently you would have to do MyClass instance = this; to use the plugin.

not available on return types of methods in

Problem seen in 2.3 (I think it worked in 2.1)
If I have a new method:

private SubscriptionFile convertFromFile(final File file) {
        return null;
    }

where File and SubscriptionFile has the same members.
I used to be able to place the cursor on return type and get the "generate all setters" context option . The result would be:

private SubscriptionFile convertFromFile(final File file) {
        SubscriptionFile subscriptionFile = new SubscriptionFile();
        subscriptionFile.setX(file.getX());
        subscriptionFile.setY(file.getY());
        subscriptionFile.setZ(file.getZ());
        return subscriptionFile;
        return null;
    }

Where I have to remove the return null; line
I particularly liked the automatic matching of the setter and getter methods.

But this no longer works. Is it supposed to?

Anyone has trouble in MacOSX?

IDEA 2017.3.2 Ultimate Edition
OS: High Sierra
I install this plug-in and restart Intellij
but I press alt + enter, nothing happened...
then I check the "preference"->"keymap"->"plugin"
can't find anything about this plug in.
any one could give me some tips ? many thanks
really like to use this wonderful plug in

maps is not imported

when two field has different type, like string and integer, create a basic converter for them.

Add selector for disabling default values for setters

Adding any default values in setters may lead to error when programmer forget replace value in one of setters. Instead it would be useful to generate setters without values. All of this setters will be highlighted as error while it not filled - wonderful anti error indicator.

Support configuring type conversion

The objects that we are mapping don't always have the same types of fields.
For example, sometimes it's needed to perform type conversions:

  1. from UUID to String
  2. from Date/LocalDate to Long
  3. between enum types

Would be best if such mappings would be configurable either in project properties (settings) or using some configuration file (whatever is easier)

Generate get methods

Please also consider generating get methods.

Use case: I have a class with >30 fields (don't ask..) and I want to write a unit test that verify stuff. To do that I will write
assertThat(myObject.getXXXX()).isEqualTo(...);
It would help a lot if I could generate all get calls. Then the next step would simple to "column selection mode" and add 'assertThat( ).isEqualTo()' around them.

Please add JUnit 5 support

"assert all getters" generates a long "assertThat(xx.getxx()).isEqualTo();" list.
"assertThat" is not anymore in JUnit 5.

Please use something dependent on the getter return type or simply use
"assertEquals(xx expected, xx actual)"

Support configurable setter prefix

Plugin is great and it works with setter that starts with name set. On the other hand I got a Builder to a class and would be great to have all builder with* methods calls generated as well.

Small request on the naming..

Hi there, is it possible to fix the "generate all setter" to "Generate all setters"

generateallsetters

Sorry for my small OCD problem, absolutely love the plugin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.