}
@Override
public String getText(Object element) {
if (element instanceof IExplainTreeNode) {
IExplainTreeNode debugNode = (IExplainTreeNode) element;
TypeSystem ts = debugNode.getTypeSystem();
if (element instanceof RuleElementMatchesNode) {
Type type = ts.getType(ExplainConstants.RULE_ELEMENT_MATCHES_TYPE);
FeatureStructure fs = debugNode.getFeatureStructure();
Feature f = type.getFeatureByBaseName(ExplainConstants.ELEMENT);
Feature fanchor = type.getFeatureByBaseName(ExplainConstants.RULE_ANCHOR);
if (f != null && fanchor != null) {
String v = fs.getStringValue(f);
String ruleAnchor = fs.getBooleanValue(fanchor) ? "'" : "";
return ruleAnchor + v;
}
} else if (element instanceof RuleElementMatchNode) {
FeatureStructure fs = debugNode.getFeatureStructure();
if (fs instanceof AnnotationFS) {
String s = ((AnnotationFS) fs).getCoveredText();
s = s.replaceAll("[\\n\\r]", "");
return s;
}
} else if (element instanceof ConditionNode) {
Type type = ts.getType(ExplainConstants.EVAL_CONDITION_TYPE);
FeatureStructure fs = debugNode.getFeatureStructure();
Feature f = type.getFeatureByBaseName(ExplainConstants.ELEMENT);
if (f != null) {
String v = fs.getStringValue(f);
return v;
}