Coder Social home page Coder Social logo

Comments (10)

dubreuia avatar dubreuia commented on May 25, 2024

That would be a nice feature. I'm marking that as enhancement. Thanks for the idea, I'll keep you posted.

from intellij-plugin-save-actions.

dorongold avatar dorongold commented on May 25, 2024

+1.
That would be the last thing missing for convincing everybody in my team to switch from eclipse to intellij.

from intellij-plugin-save-actions.

krasa avatar krasa commented on May 25, 2024

I tried to call some methods and it seems to work quite well...

        ApplicationManager.getApplication().invokeLater(new Runnable() {

            @Override
            public void run() {
                new WriteCommandAction.Simple(project) {

                    @Override
                    protected void run() throws Throwable {
                        InspectionManager inspectionManager = InspectionManager.getInstance(project);
                        PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
                        Document document = psiDocumentManager.getDocument(psiFile);
                        psiDocumentManager.commitDocument(document);

                        GlobalInspectionContext context = inspectionManager.createNewGlobalContext(false);
                        LocalCanBeFinal tool = new LocalCanBeFinal();
                        InspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(tool);
                        List<ProblemDescriptor> problemDescriptors = InspectionEngine.runInspectionOnFile(psiFile,
                                toolWrapper, context);
                        for (ProblemDescriptor problemDescriptor : problemDescriptors) {
                            QuickFix[] fixes = problemDescriptor.getFixes();
                            if (fixes != null) {
                                for (QuickFix fix : fixes) {
                                    if (fix != null) {
                                        fix.applyFix(project, problemDescriptor);
                                    }
                                }
                            }
                        }

                        psiDocumentManager.commitDocument(document);
                    }
                }.execute();
            }
        })

from intellij-plugin-save-actions.

dubreuia avatar dubreuia commented on May 25, 2024

Very nice @krasa, I'll try your code ASAP.

The best way to configure that would be to duplicate the "Settings > Editor > Inspections" option table in the save actions options, to enable / disable specific inspections on save... Then reuse your code by looping on the activated inspections and applying them.

from intellij-plugin-save-actions.

krasa avatar krasa commented on May 25, 2024

Yep, that would be ideal.

from intellij-plugin-save-actions.

siedepunkt avatar siedepunkt commented on May 25, 2024

+1 for this enhancement. but applying quick fixes after inspections should be opt-in in settings for various reasons.

from intellij-plugin-save-actions.

dubreuia avatar dubreuia commented on May 25, 2024

I'm currently implementing that one. I'm doing a simple version with only some inspections, so if you want to vote for the one you want, go ahead (there are so many !).

from intellij-plugin-save-actions.

dubreuia avatar dubreuia commented on May 25, 2024

Some inspection IDs I find useful:

  • localCanBeFinal
  • explicitTypeCanBeDiamond
  • unqualifiedFieldAccess
  • suppressAnnotation
  • finalPrivateMethod
  • unnecessarySemicolon
  • fieldCanBeFinal

from intellij-plugin-save-actions.

jaapcoomans avatar jaapcoomans commented on May 25, 2024

+1
I really miss the "Use 'this' qualifier for field/method access" from Eclipse Save Actions! So I'd vote for:

  • unqualifiedFieldAccess
  • unqualifiedMethodAccess

from intellij-plugin-save-actions.

dubreuia avatar dubreuia commented on May 25, 2024

Added in 0.5. Open another issue if you want more inspections, I'll add them incrementally.

from intellij-plugin-save-actions.

Related Issues (20)

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.