当前位置:网站首页>The configuration and options of save actions are explained in detail, and you won't be confused after reading it

The configuration and options of save actions are explained in detail, and you won't be confused after reading it

2022-07-07 09:20:00 Wow, it's a small dish

Save Actions yes idea A format automation plug-in , Very easy to use , But in setting up Sava Actions Sometimes I'm confused , So I studied the meaning of each option .

My settings

 Insert picture description here
 Insert picture description here

Setup details

General Basic settings

  • Activate save actions on save(before saving each file,performs the configured actions below)
    Format automatically when saving

  • Activate save actions on shortcut
    Automatically format when saving with shortcut keys
    Use scenarios : Received a badly formatted document , You can use this shortcut to automatically format

  • Activate save actions on batch(Code>Save Actions>Execute on multiple files)
    Batch format when saving
    This one didn't work , Because sometimes your formatting settings are different from those of your colleagues , Formatting together will lead to conflict during merging

Formatting Actions Format trigger settings

  • Optimize imports
    Optimize import ( Unused classes are automatically deleted import, This is usually checked )

  • Reformat file
    Reformat the file ( As long as you save the file, it will be automatically formatted )

  • Reformat only change code
    Reformat only when the code changes
    The above two settings are mutually exclusive , intend , Or trigger when the code changes , Or trigger when the file changes
    I usually check the one above , Feel better to use

  • Rerrange fields and methods(configured in “File>Setting>Editor>Code Style>(…)>Arragement”)
    Readjust the scope of fields and methods
    Do not know what that mean? , Never used

Build Actions build Set up

Is in build Settings used in the project , I won't discuss it here

Java Inspection and Quick Fix Specific formatting settings

  • Add final modifier to field
    Add... To the field final Modifier
    I haven't used it. I don't know what it means

  • Add final modifier to local variable or parameter
    Add... To a local variable or parameter final Modifier
    The effect is as follows , All local parameters have been added final Modifier

   public void printStr(final String str1, final String str2, final String str3) {
    
        System.out.println(str1 + str2 + str3);
    }

I won't check this option , Because sometimes the formal parameters will change

  • Add final modifier to local variable or parameter except if it is implicit
    Add to a non implicit local variable or parameter final Modifier
    I don't quite understand what this non implicit means

  • Add static modifier to methods
    Add... To the method static Modifier
    The effect is as follows , Don't check

    public static void testStatic(String str) {
    
        System.out.println(str);
    }
  • Add this to field access
    Use of fields plus “this” The pointer
    You can check it or not , Look at personal usage habits .

  • Add this to method access
    Method use plus this
    The meaning is similar to that of the above option , You can check it or not , Look at the code habit

  • Add class qualifier to static member access
    Static member access adds a class qualifier
    That is, static methods access static variables , Will automatically add classes . Variable name , Can point

  • Add class qualifier to static member access outside declaring class
    Declare static member access outside the class and add a class qualifier
    I don't quite understand what the class outside this declaration means , Anyway, they are mutually exclusive with the one above

  • Add missing @Override annotions
    Add missing @Override annotation
    Can tick

  • Add blocks to if/while/for statements
    to if/while/for Add braces to the statement

    public String judgeIt(int a) throws Exception {
    
        if (a == 3) {
    
            return "yes";
        }
        throw new Exception();
    }
  • Remove blocks from if/while/for statements
    to if/while/for Statement to remove braces
    public String judgeIt(int a) throws Exception {
    
        if (a == 3) return "yes";
        throw new Exception();
    }

I'll check the one below , As if java6 If there is no other code in the future , Can directly return, It's cool

  • Remove unnessary this to field and method
    Remove unnecessary... From a field or method “this”
    Personal habits , I don't like to use this, So I'll check this

-Remove final from private method
Private methods remove final keyword

    private final String getStr(final String str) {
    //  After setting final Keywords will be removed when saving 
        return str;
    }

In fact, I personally don't know why private methods should be added in front of final keyword , If there is java The great God with a better foundation saw my article , Please tell me by comment or private letter ~

  • Remove explicit generic type for diamond
    Remove angle brackets for explicit generic types
    I don't know what that means , There is no tick

  • Remove unused suppress warning annotation
    Remove useless Suppress Warning

  • Remove unnecessary semicolon
    Remove unnecessary semicolons

  • Change visibility of field or method to lower access
    Change the visibility of a field or method to reduce access
    I don't know that either ...

原网站

版权声明
本文为[Wow, it's a small dish]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130626221093.html