我正在尝试从Eclipse扩展HTML编辑器,以允许通过验证忽略名为" sly"的特定标记。我已经尝试使用Eclipse扩展点来定义几个验证器,但这还没有成功。
的plugin.xml
<extension id="org.apache.sling.ide.eclipse.sightly.internal.Validator" name="Sightly Validator" point="org.eclipse.wst.validation.validatorV2">
<validator
build="true"
class="org.apache.sling.ide.eclipse.sightly.internal.Validator"
sourceid="org.apache.sling.ide.eclipse.sightly.internal.htmlSyntaxTotalValidator"
manual="true"
version="1"
markerId="org.eclipse.wst.html.core.validationMarker">
<include>
<rules>
<contentType id="org.eclipse.wst.html.core.htmlsource"></contentType>
<fileext caseSensitive="false" ext="html"/>
</rules>
</include>
<group id="org.eclipse.wst.sse.core.structuredModelGroup"/>
</validator>
<extension point="org.eclipse.wst.sse.ui.sourcevalidation">
<validator
scope="total"
class="org.apache.sling.ide.eclipse.sightly.internal.TotalValidator"
id="org.apache.sling.ide.eclipse.sightly.internal.htmlSyntaxTotalValidator">
<contentTypeIdentifier
id="org.eclipse.wst.html.core.htmlsource">
<partitionType id="org.eclipse.wst.html.HTML_DEFAULT"/>
<partitionType id="org.eclipse.wst.html.HTML_DECLARATION"/>
<partitionType id="org.eclipse.wst.html.HTML_COMMENT"/>
<partitionType id="org.eclipse.wst.xml.XML_DEFAULT"/>
<partitionType id="org.eclipse.wst.sse.ST_DEFAULT"/>
</contentTypeIdentifier>
</validator>
</extension>
Java类
public class Validator extends HTMLValidator {
@Override
protected HTMLValidationReporter getReporter(IReporter reporter, IFile file, IDOMModel model) {
return new ValidatorReporter(this, reporter, file, model);
}
}
public class ValidatorReporter extends HTMLValidationReporter {
ValidatorReporter(IValidator owner, IReporter reporter, IFile file, IStructuredModel model) {
super(owner, reporter, file, model);
}
@Override
public void report(ErrorInfo info) {
int targetType = info.getTargetType();
if (targetType == Node.ELEMENT_NODE && info.getState() == 11) {
String name = info.getHint();
if ("sly".equals(name) ) {
return;
}
}
super.report(info);
}
}
}
据我所知,我的调试器被调用,但它们没有覆盖HTML验证器。我可以以某种方式覆盖默认的HTML验证器,还是我要求用户禁用HTML验证?