快速修正处理器

标识:
org.eclipse.wst.jsdt.ui.quickFixProcessors

起始版本:
扩展点的起始版本为 3.0。元素 handledMarkerTypes 的起始版本为 3.2。

描述:
此扩展点允许添加快速修正处理器以对 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: type ICompilationUnit; - 要应用快速辅助的编译单元
  • projectNatures: type Collection; - 当前项目的所有项目性质
  • sourceLevel: type 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 表达式。可以使用“and”运算符对 enablement 表达式的子代进行组合。



    <!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)

    >

    此元素用来对带焦点对象的属性状态进行评估。可以使用 org.eclipse.core.expressions.propertyTesters 扩展点来扩展可测试属性集合。如果尚未装入用于执行实际测试的属性测试程序,并且属性 forcePluginActivation 设置为 false,那么测试表达式将返回 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

    >

    此元素用于对带焦点对象执行 equals 检查。如果该对象与 value 属性提供的值相等,那么表达式返回 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。可以使用“and”运算符对 with 表达式的子代进行组合。



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

    <!ATTLIST resolve

    variable CDATA #REQUIRED

    args     CDATA #IMPLIED

    >

    此元素将所要检查以获取其所有子元素的对象更改为由给定变量引用的对象。如果无法解析变量,那么对表达式求值时,表达式将抛出 ExpressionException。可以使用“and”运算符对 resolve 表达式的子代进行组合。



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

    <!ATTLIST adapt

    type CDATA #REQUIRED

    >

    此元素用来使带焦点对象适合于 type 属性指定的类型。如果尚未装入该适配器或者所引用的类型,那么此表达式将返回 EvaluationResult.NOT_LOADED。如果该类型名根本不存在,那么此表达式在求值期间将抛出 ExpressionException。可以使用“and”运算符对 adapt 表达式的子代进行组合。



    <!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。可以使用“and”运算符对 iterate 表达式的子表达式进行组合。



    <!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. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html