Java Code Examples for org.eclipse.xtext.CrossReference#getType()

The following examples show how to use org.eclipse.xtext.CrossReference#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrammarAccessUtil.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
private static List<String> getSingleElementDescription(AbstractElement ele) {
	if (ele instanceof Keyword)
		return Collections.singletonList(((Keyword) ele).getValue());
	else if (ele instanceof Assignment)
		return Collections.singletonList(((Assignment) ele).getFeature());
	else if (ele instanceof RuleCall)
		return Collections.singletonList(((RuleCall) ele).getRule()
				.getName());
	else if (ele instanceof Action) {
		Action a = (Action) ele;
		ArrayList<String> r = new ArrayList<String>();
		if (a.getType() != null && a.getType().getClassifier() != null)
			r.add(a.getType().getClassifier().getName());
		if (a.getFeature() != null && !"".equals(a.getFeature()))
			r.add(a.getFeature());
		return r;
	} else if (ele instanceof CrossReference) {
		CrossReference cr = (CrossReference) ele;
		if (cr.getType() != null && cr.getType().getClassifier() != null)
			return Collections.singletonList(cr.getType().getClassifier()
					.getName());
	} else if (ele instanceof EnumLiteralDeclaration) {
		EnumLiteralDeclaration decl = (EnumLiteralDeclaration) ele;
		return Collections.singletonList(decl.getEnumLiteral().getName());
	}
	return Collections.emptyList();
}
 
Example 2
Source File: XtextLabelProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private String getLabel(CrossReference ref) {
	TypeRef type = ref.getType();
	String typeName = getClassifierName(type);
	if (ref.getTerminal() instanceof RuleCall)
		return "[" + typeName + "|" + getLabel((RuleCall) ref.getTerminal()) + "]";
	return "[" + typeName + "|..]";
}
 
Example 3
Source File: GrammarElementTitleSwitch.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected String addCrossRef(String result, AbstractElement ele) {
	if (!showAssignment)
		return result;
	CrossReference cr = GrammarUtil.containingCrossReference(ele);
	if (cr == null)
		return result;
	String name = cr.getType() != null && cr.getType().getClassifier() != null ? cr.getType().getClassifier()
			.getName() : "null";
	return "[" + name + "|" + result + "]";
}