我的目標是擴展eclipse QuickFix組件並自動化解決語法錯誤的過程。基本上,QuickFix組件提供了一個解決方案列表,我的任務是選擇最好的修補程序並將其應用於錯誤代碼。但是,現在我已經被要求在控制檯上打印標記的分辨率。我試圖制定一個教程,我現在有點卡住了。我試着鍛鍊的教程:http://www.informit.com/articles/article.aspx?p=370625&seqNum=21 我首先增加了擴展我的plugin.xml文件從Eclipse插件寫入stdout
<extension point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
markerType="org.eclipse.core.resources.problemmarker"
class="org.eclipse.escript.quickfix.QuickFixer"/>
</extension>
然後我創建了兩個類QuickFixer和QuickFix的。
package quickfixer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator;
class QuickFixer implements IMarkerResolutionGenerator {
public IMarkerResolution[] getResolutions(IMarker arg0) {
try {
Object problem = arg0.getAttribute("Whatsup");
return new IMarkerResolution[] {
new QuickFix("Fix #1 for "+problem),
new QuickFix("Fix #2 for "+problem),
};
} catch(CoreException e) {
return new IMarkerResolution[0];
}
}
}
那麼類的QuickFix:
package quickfixer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IMarkerResolution;
public class QuickFix implements IMarkerResolution {
String label;
QuickFix(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
public void run(IMarker arg0) {
MessageDialog.openInformation(null, "QuickFix Demo",
"This quick-fix is not yet implemented");
System.out.println("Label: " + label);
}
}
我已經成功地糾正我遇到的所有錯誤,然後我已運行該插件。 我一直沒有能夠獲得在控制檯打印出的標籤。任何建議??? ...
我建議改寫你的問題的標題。它與QuickFix沒有任何關係,只是在Eclipse中使用stdout。 – ShiDoiSi
你是如何運行插件的? – ShiDoiSi