乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      如何在Eclipse中如何自動添加注釋和自定義注釋風(fēng)格

       西北望msm66g9f 2019-06-25
      Java雜記
       

      背景簡介

      豐富的注釋和良好的代碼規(guī)范,對于代碼的閱讀性和可維護(hù)性起著至關(guān)重要的作用。幾乎每個公司對這的要求還是比較嚴(yán)格的,往往會形成自己的一套編碼規(guī)范。但是再實施過程中,如果全靠手動完成,不僅效率低下,還難以保證真正的符合規(guī)范。所以結(jié)合IDE環(huán)境,自動生成注釋,還是很有必要的。今天我們就說一下,如何使用Eclipse給我們提供的自定義代碼模版的功能來作業(yè)。

      設(shè)置注釋模板

      設(shè)置注釋模板的入口:Window->Preference->Java->Code Style->Code Template ,然后展開Comments節(jié)點就是所有需設(shè)置注釋的元素了!

      接下來,對每一個元素逐一介紹:

      文件(Files)注釋標(biāo)簽
      Files標(biāo)簽是對新建的文件的說明,出現(xiàn)在文件最上面

      舉栗子:

      /**   
       * Copyright ? ${year} eSunny Info. Tech Ltd. All rights reserved.
       * 
       * @Package: ${package_name} 
       * @author: ${user}   
       * @date: ${date} ${time} 
       */

      類型(Types)注釋標(biāo)簽(類的注釋)
      Types標(biāo)簽是對類Class的一個說明,出現(xiàn)在類上面

      舉栗子:

       /** 
       * @ClassName: ${type_name} 
       * @Description: ${todo}
       * @author: ${user}
       * @date: ${date} ${time} 
       * ${tags} 
       */

      字段(Fields)注釋標(biāo)簽
      Fields標(biāo)簽是對變量字段的說明

      舉栗子:

      // @Fields ${field} : ${todo}(用一句話描述這個變量表示什么)  

      構(gòu)造函數(shù)(Constructors)標(biāo)簽
      Constructors標(biāo)簽是對類的構(gòu)造函數(shù)的說明

      舉栗子:

      /** 
       * @Title:${enclosing_type}
       * @Description:${todo} 
       * ${tags} 
       */  

      方法(Methods)標(biāo)簽
      Methods標(biāo)簽是對函數(shù)方法的說明

      舉栗子:

      /** 
      * @Title: ${enclosing_method} 
      * @Description: ${todo} 
      * ${tags} ${return_type}
      * @author ${user}
      * @date ${date}${time}
      */ 

      覆蓋方法(Overriding Methods)標(biāo)簽
      Overriding Methods標(biāo)簽是對覆蓋方法的說明

      舉栗子:

      /* (non Javadoc) 
       * @Title: ${enclosing_method}
       * @Description: ${todo}
       * ${tags} 
       * ${see_to_overridden} 
       */ 

      代表方法(Delegate Methods)標(biāo)簽
      舉栗子:

      /**
       * ${tags}
       * ${see_to_target}
       */  

      getter方法標(biāo)簽
      舉栗子:

      /**  
      * @return ${bare_field_name}  
      */  

      setter方法標(biāo)簽
      舉栗子:

      /**  
      * @param ${param} 要設(shè)置的 ${bare_field_name}  
      */  

      以上標(biāo)簽,只需要點擊右側(cè)面板上的按鈕 – 編輯(Edit), 便可修改成自己的注釋!

      如何自動添加注釋

      可通過如下三種方法自動添加注釋:
      (1)輸入“/**”并回車。
      (2)用快捷鍵 Alt+Shift+J(先選中某個方法、類名或變量名)。
      (3)在右鍵菜單中選擇“Source > Generate ElementComment”。

      另外,新建文件或類的時候,怎么自動生成文件(file)的注釋呢?

      只需要勾選Automatically and comments for new methods and types

      導(dǎo)入/導(dǎo)出代碼格式模板

      如果你辛辛苦苦定制好了自己的代碼風(fēng)格,然后換了臺機(jī)器進(jìn)行操作或重裝了Eclipse,是不是要重新配置一遍呢?答案當(dāng)然是No了,Eclipse提供了“導(dǎo)出”和“導(dǎo)入”功能,你可以把自己的模板導(dǎo)出來在其他機(jī)器上使用。

      創(chuàng)建自定義注釋模板
      eclipse自帶一些注釋模板,如日期(@date)、文件名(@ClassName)、作者(@author)等,那么怎么自定義一些注釋模板呢?

      codetemplates.xml模板內(nèi)容,可直接導(dǎo)入eclipse

      /**
      * @Fields field:field:{todo}(用一句話描述這個變量表示什么)
      *//**
      * MIT License
      * Copyright (c) 2018 haihua.liu
      * Permission is hereby granted, free of charge, to any person obtaining a copy
      * of this software and associated documentation files (the “Software”), to deal
      * in the Software without restriction, including without limitation the rights
      * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      * copies of the Software, and to permit persons to whom the Software is
      * furnished to do so, subject to the following conditions:
      * The above copyright notice and this permission notice shall be included in all
      * copies or substantial portions of the Software.
      * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      * SOFTWARE.
      *//**
      * @param paramtheparamthe{bare_field_name} to set
      *//**
      * @return ${bare_field_name}
      *//**
      * @ClassName: ${type_name}
      * @Description: ${todo}(這里用一句話描述這個類的作用)
      * @author ${user}
      * @date ${date}
      *
      * ${tags}
      *//** (非 Javadoc)
      *
      *
      * ${tags}
      * ${see_to_overridden}
      *//**
      * ${tags}
      * ${see_to_target}
      *//**
      * @Title: ${enclosing_method}
      * @Description: ${todo}(這里用一句話描述這個方法的作用)
      * @param ${tags} 參數(shù)
      * @return ${return_type} 返回類型
      * @throws
      */ /**
      * 創(chuàng)建一個新的實例 ${enclosing_type}.
      *
      * ${tags}
      */

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多