Java Code Examples for org.eclipse.xtext.util.PolymorphicDispatcher#invoke()

The following examples show how to use org.eclipse.xtext.util.PolymorphicDispatcher#invoke() . 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: AbstractDeclarativeScopeProvider.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected IScope polymorphicFindScopeForReferenceName(EObject context, EReference reference) {
	Predicate<Method> predicate = getPredicate(context, reference);
	PolymorphicDispatcher<IScope> dispatcher = new PolymorphicDispatcher<IScope>(Collections
			.singletonList(this), predicate, errorHandler) {
		@Override
		protected IScope handleNoSuchMethod(Object... params) {
			if (PolymorphicDispatcher.NullErrorHandler.class.equals(errorHandler.getClass()))
				return null;
			return super.handleNoSuchMethod(params);
		}
	};
	EObject current = context;
	IScope scope = null;
	while (scope == null && current != null) {
		scope = dispatcher.invoke(current, reference);
		current = current.eContainer();
	}
	return scope;
}
 
Example 2
Source File: JavaOperationMockup.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public Object execute(ArgumentExpression expression, ExecutionContext context) {
	Operation definition = getOperation(expression);
	List<Object> targets = callbacks;
	if (definition.eContainer() instanceof InterfaceScope) {
		String className = ((InterfaceScope) definition.eContainer()).getName();
		if (className != null) {
			targets = callbacks.stream().filter(c -> className.equals(c.getClass().getSimpleName()))
					.collect(Collectors.toList());
		}
	}
	PolymorphicDispatcher<Object> dispatcher = new PolymorphicDispatcher<Object>(definition.getName(),
			definition.getParameters().size(), definition.getParameters().size(),
			targets.size() > 0 ? targets : callbacks);
	try {
		return dispatcher.invoke(executeArguments(expression.getArguments(), context, definition));
	} catch (Exception ex) {
		throw new WrappedException("Error during invocation of operation '" + definition.getName()
				+ "' with params " + definition.getParameters() + " '", ex);
	}
}
 
Example 3
Source File: PartialStatemachineContentAssistParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 4
Source File: PartialIndentationAwareUiTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 5
Source File: PartialXtendContentAssistParser.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 6
Source File: PartialCheckCfgContentAssistParser.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 7
Source File: PartialPartialContentAssistTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 8
Source File: PartialBuilderTestLanguageContentAssistParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 9
Source File: PartialArithmeticsContentAssistParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 10
Source File: PartialHelloWorldContentAssistParser.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 11
Source File: PartialTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 12
Source File: PartialDomainmodelContentAssistParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 13
Source File: PartialPartialSerializationTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 14
Source File: PartialFileAwareTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 15
Source File: PartialNoJdtTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 16
Source File: PartialPureXbaseContentAssistParser.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 17
Source File: PartialYangContentAssistParser.java    From yang-design-studio with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 18
Source File: PartialTypesContentAssistParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 19
Source File: PartialRenameTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example 20
Source File: PartialN4JSContentAssistParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}