快速修正程式處理器

ID:
org.eclipse.wst.jsdt.ui.quickFixProcessors

自:
自 3.0 版開始的延伸點。自 3.2 版開始的元素 handledMarkerTypes。

說明:
這個延伸點可新增「快速修正程式」處理器,對 JavaScript 問題提供新的「快速修正程式」。

自 3.2 版開始,延伸可指定可處理的問題標記類型。只會取得這些類型的問題來處理。如果未指定要處理的標記類型,處理器只會取得 org.eclipse.wst.jsdt.core.problem、 org.eclipse.wst.jsdt.core.buildpath_problem 和 org.eclipse.wst.jsdt.core.task 類型的問題(相容於 3.2 版以前的行為)。

這個延伸點支援 enablement 標示。測試的內容如下:

  • compilationUnit: ICompilationUnit 類型;套用快速輔助的編譯單元
  • projectNatures: Collection 類型;現行專案的所有專案本質
  • sourceLevel: String 類型;現行專案的程式碼標準
  • 配置標記:

    <!ELEMENT extension (quickFixProcessor+)>

    <!ATTLIST extension

    point CDATA #REQUIRED

    id    CDATA #IMPLIED

    name  CDATA #IMPLIED

    >


    <!ELEMENT quickFixProcessor (enablement? , handledMarkerTypes*)>

    <!ATTLIST quickFixProcessor

    id                  CDATA #REQUIRED

    name                CDATA #IMPLIED

    class               CDATA #REQUIRED

    requiredSourceLevel CDATA #IMPLIED

    >


    <!ELEMENT handledMarkerTypes (markerType+)>

    指定此快速修正程式處理器可處理的問題的標記類型。如果未指定要處理的標記類型,處理器會取得 org.eclipse.wst.jsdt.core.problem、org.eclipse.wst.jsdt.core.buildpath_problem 和 org.eclipse.wst.jsdt.core.task 類型的問題。



    <!ELEMENT markerType EMPTY>

    <!ATTLIST markerType

    id CDATA #REQUIRED

    >


    <!ELEMENT enablement (not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

    一般的根元素。這個元素可用於延伸點內定義其 enablement 表示式。enablement 表示式的子項是使用 "and" 運算子來組合。



    <!ELEMENT not (not | and | or | instanceof | test | systemTest | equals | count | with | resolve | adapt | iterate | reference)>

    這個元素代表 NOT 運算,以算出它的子元素表示式的結果。



    <!ELEMENT and (not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

    這個元素代表 AND 運算,以算出它的所有子元素表示式的結果。



    <!ELEMENT or (not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

    這個元素代表 OR 運算,以算出它的所有子元素表示式的結果。



    <!ELEMENT instanceof EMPTY>

    <!ATTLIST instanceof

    value CDATA #REQUIRED

    >

    這個元素是用來執行焦點物件的 instanceof 檢查。如果物件類型是屬性值指定的類型的子類型,則這個表示式傳回 EvaluationResult.TRUE。 否則傳回 EvaluationResult.FALSE。



    <!ELEMENT test EMPTY>

    <!ATTLIST test

    property              CDATA #REQUIRED

    args                  CDATA #IMPLIED

    value                 CDATA #IMPLIED

    forcePluginActivation (true | false)

    >

    這個元素是用來評估焦點物件的內容狀態。testable 內容集可使用 org.eclipse.core.expressions.propertyTesters 延伸點加以延伸。如果尚未載入要執行實際測試的內容測試程式,且 forcePluginActivation 屬性設為 false,則 test 表示式會傳回 EvaluationResult.NOT_LOADED。 如果 forcePluginActivation 設為 true,而且用來評估這個表示式的評估環境定義支援外掛程式啟動,則評估這項內容會導致定義此測試程式的外掛程式啟動。



    <!ELEMENT systemTest EMPTY>

    <!ATTLIST systemTest

    property CDATA #REQUIRED

    value    CDATA #REQUIRED

    >

    呼叫 System.getProperty 方法來測試系統內容,並比較其結果與透過 value 屬性指定的值。



    <!ELEMENT equals EMPTY>

    <!ATTLIST equals

    value CDATA #REQUIRED

    >

    這個元素是用來執行焦點物件的相等檢查。如果物件等於屬性值提供的值,則表示式傳回 EvaluationResult.TRUE。否則傳回 EvaluationResult.FALSE。



    <!ELEMENT count EMPTY>

    <!ATTLIST count

    value CDATA #REQUIRED

    >

    這個元素是用來測試集合中的元素數目。



    <!ELEMENT with (not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

    <!ATTLIST with

    variable CDATA #REQUIRED

    >

    這個元素將要檢查其所有子元素的物件變更為給定變數所參照的物件。如果無法解析變數,則表示式在評估時會擲出 ExpressionException。with 表示式的子項是使用 "and" 運算子來組合。



    <!ELEMENT resolve (not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

    <!ATTLIST resolve

    variable CDATA #REQUIRED

    args     CDATA #IMPLIED

    >

    這個元素將要檢查其所有子元素的物件變更為給定變數所參照的物件。如果無法解析變數,則表示式在評估時會擲出 ExpressionException。resolve 表示式的子項是使用 "and" 運算子來組合。



    <!ELEMENT adapt (not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

    <!ATTLIST adapt

    type CDATA #REQUIRED

    >

    這個元素是用來調整焦點物件,使它成為屬性類型指定的類型。如果配接器或參照的類型尚未載入,表示式會傳回 EvaluationResult.NOT_LOADED。 如果類型名稱根本不存在,它會在評估期間擲出 ExpressionException。adapt 表示式的子項是使用 "and" 運算子來組合。



    <!ELEMENT iterate (not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>

    <!ATTLIST iterate

    operator (or|and)

    ifEmpty  (true | false)

    >

    這個元素是用來反覆運算 java.util.Collection 類型的變數,或是配合 org.eclipse.core.expressions.IIterable 的變數。如果焦點物件不是上述其中之一,則在評估表示式時,會擲出含有 ExpressionStatus 的 CoreException。iterate 表示式的子表示式是使用 "and" 運算子來組合。



    <!ELEMENT reference EMPTY>

    <!ATTLIST reference

    definitionId IDREF #REQUIRED

    >

    這個元素是用來參照 org.eclipse.core.expressions.definitions 延伸點的表示式。將使用現行評估環境定義,在現行表示式元素內評估表示式定義。



    範例:
    下列是快速修正程式處理器要素項的範例:

    
     <extension point="org.eclipse.wst.jsdt.ui.quickFixProcessors">
      <quickFixProcessor
       id="AdvancedQuickFixProcessor"
       name="Advanced Quick Fix Processor"
       requiredSourceLevel="1.5"
       class="com.example.AdvancedQuickFixProcessor">
       <handledMarkerTypes>
          <markerType id="org.eclipse.myplugin.audits"/>
       </handledMarkerTypes>
           <enablement> 
          <with variable="projectNatures">
             <iterate operator="or">
                <equals value="org.eclipse.wst.jsdt.core.javanature"/>
                      </iterate>
                   </with>
           </enablement> 
      </quickFixProcessor>
        </extension>

    API 資訊:
    提供的類別必須實作 org.eclipse.wst.jsdt.ui.text.java.IQuickFixProcessor


    Copyright © 2007 IBM Corporation and others.
    All rights reserved.本程式與隨附的資料依照 Elipse Public License 1.0 版此次發行所隨附的條款而提供,可以在以下網址取得:http://www.eclipse.org/legal/epl-v10.html