eclipse-plugin - Eclipse插件开发:问题视图中没有出现自定义问题标记
问题描述
我正在开发一个 Eclipse 插件,我在其中声明了一个自定义问题标记。它具有org.eclipse.core.resources.problemmarker
其超类型,并且persistent
属性设置为 true。我贡献了一个自定义CategorizedProblem
类,其中getMarkerType
返回我的自定义标记的 id,我将它添加到类中,使用该方法reconcile
的自定义方法中存在问题。还声明了属性下的标记类型:CompilationParticipant
ReconcileContext.putProblems
CompilationParticipant
managedMarker
plugin.xml 的相关部分:
<extension
point="org.eclipse.jdt.core.compilationParticipant">
<compilationParticipant
class="no.tobask.sb4e.FxControllerValidator"
id="FxControllerValidator"
createsProblems="true">
<managedMarker
markerType="no.tobask.sb4e.fxcontrollerproblemmarker">
</managedMarker>
</compilationParticipant>
</extension>
<extension
id="no.tobask.sb4e.fxcontrollerproblemmarker"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<persistent
value="true">
</persistent>
</extension>
来自 CompilationParticipant 的相关代码:
public void reconcile(ReconcileContext context) {
ICompilationUnit clazz = context.getWorkingCopy();
String className = clazz.findPrimaryType().getFullyQualifiedName();
if (documentListener.isAssignedController(className)) {
URL documentLocation = documentListener.getDocument(className);
try {
String fxmlContent = FXOMDocument.readContentFromURL(documentLocation);
FXOMDocument document = new FXOMDocument(fxmlContent, documentLocation, Activator.getClassLoader(),
I18N.getBundle());
CategorizedProblem[] problems = getProblems(context.getAST(AST.JLS11), document);
if (problems != null) {
context.putProblems("no.tobask.sb4e.fxcontrollerproblemmarker", problems);
}
} catch (IOException | JavaModelException e) {
e.printStackTrace();
}
}
}
分类问题:
public class FxControllerProblem extends CategorizedProblem {
List<String> missingIds;
IResource resource;
public FxControllerProblem(List<String> missingIds, IResource resource) {
this.missingIds = missingIds;
this.resource = resource;
}
@Override
public String[] getArguments() {
return missingIds.toArray(new String[0]);
}
@Override
public int getID() {
return 1234;
}
@Override
public String getMessage() {
return "One or more fx:ids from associated FXML document do not have corresponding fields";
}
@Override
public char[] getOriginatingFileName() {
return resource.getName().toCharArray();
}
@Override
public int getSourceEnd() {
return -1;
}
@Override
public int getSourceLineNumber() {
return 1;
}
@Override
public int getSourceStart() {
return 0;
}
@Override
public boolean isError() {
return false;
}
@Override
public boolean isWarning() {
return true;
}
@Override
public void setSourceEnd(int sourceEnd) {
// TODO Auto-generated method stub
}
@Override
public void setSourceLineNumber(int lineNumber) {
// TODO Auto-generated method stub
}
@Override
public void setSourceStart(int sourceStart) {
// TODO Auto-generated method stub
}
@Override
public int getCategoryID() {
return CAT_MEMBER;
}
@Override
public String getMarkerType() {
return "no.tobask.sb4e.fxcontrollerproblemmarker";
}
}
问题是,虽然警告确实在 Java 编辑器中正确显示,但它没有显示在问题视图中。
解决方案
推荐阅读
- api - 如何使用其余 api 删除多个文档?
- r - 如果前一个值已存在于 R 中的数据框中,则迭代循环以提供新值
- react-native - 使用类组件的 React Navigation 5 身份验证流程
- git - Git:在分支结帐/切换时对工作树应用一些(但不是全部)更改
- typescript - 描述参数的泛型类型,可以是少数类型之一
- graphql - 使用 keycloak 身份验证从 GraphQL API 获取
- windows - 如果我键入与搜索字符串长度相同的点,Findstr ERRORLEVEL 返回错误级别
- azure-notificationhub - 通过 Node.js 向通知中心发送推送通知使用了新的 sdk
- javascript - 如何将这些文本框对齐为笔直并相互对齐?
- cordova - InAppBrowser loadstop 触发两次