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

The following examples show how to use org.eclipse.xtext.Action#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: GrammarElementTitleSwitch.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public String caseAction(Action object) {
	String f = object.getFeature();
	String o = object.getOperator();
	o = (o == null) ? "" : o;
	String result;
	if (showActionAsRuleCall && f != null) {
		result = f + o + new Context2NameFunction().toFunction(null).apply(object) + card(object);
	} else {
		String t = object.getType() != null && object.getType().getClassifier() != null ? object.getType()
				.getClassifier().getName() : "null";
		t = (t == null) ? "" : t;
		f = (f == null) ? "" : "." + f;
		result = "{" + t + f + o + "}" + card(object);
	}
	return addQualified(result, object);
}
 
Example 2
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 3
Source File: XtextProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void completeAction_Feature(EObject model, Assignment assignment, ContentAssistContext context,
		ICompletionProposalAcceptor acceptor) {
	Action action = EcoreUtil2.getContainerOfType(model, Action.class);
	if (action != null && action.getType() != null) {
		EClassifier classifier = action.getType().getClassifier();
		if (classifier instanceof EClass) {
			List<EReference> containments = ((EClass) classifier).getEAllContainments();
			Function<IEObjectDescription, ICompletionProposal> factory = getProposalFactory(grammarAccess.getValidIDRule().getName(), context);
			completeStructuralFeatures(context, factory, acceptor, containments);
		}
	}
	super.completeAction_Feature(model, assignment, context, acceptor);
}
 
Example 4
Source File: CurrentTypeFinder.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Boolean caseAction(Action object) {
	if (object.getType() != null)
		currentType = object.getType().getClassifier();
	return object == stopElement;
}