org.eclipse.xtext.xbase.jvmmodel.ILogicalContainerProvider Java Examples

The following examples show how to use org.eclipse.xtext.xbase.jvmmodel.ILogicalContainerProvider. 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: AbstractExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Compute the simple name for the called feature.
 *
 * @param featureCall the feature call.
 * @param logicalContainerProvider the provider of logicial container.
 * @param featureNameProvider the provider of feature name.
 * @param nullKeyword the null-equivalent keyword.
 * @param thisKeyword the this-equivalent keyword.
 * @param superKeyword the super-equivalent keyword.
 * @param referenceNameLambda replies the reference name or {@code null} if none.
 * @return the simple name.
 */
public static String getCallSimpleName(XAbstractFeatureCall featureCall,
		ILogicalContainerProvider logicalContainerProvider,
		IdentifiableSimpleNameProvider featureNameProvider,
		Function0<? extends String> nullKeyword,
		Function0<? extends String> thisKeyword,
		Function0<? extends String> superKeyword,
		Function1<? super JvmIdentifiableElement, ? extends String> referenceNameLambda) {
	String name = null;
	final JvmIdentifiableElement calledFeature = featureCall.getFeature();
	if (calledFeature instanceof JvmConstructor) {
		final JvmDeclaredType constructorContainer = ((JvmConstructor) calledFeature).getDeclaringType();
		final JvmIdentifiableElement logicalContainer = logicalContainerProvider.getNearestLogicalContainer(featureCall);
		final JvmDeclaredType contextType = ((JvmMember) logicalContainer).getDeclaringType();
		if (contextType == constructorContainer) {
			name = thisKeyword.apply();
		} else {
			name = superKeyword.apply();
		}
	} else if (calledFeature != null) {
		final String referenceName = referenceNameLambda.apply(calledFeature);
		if (referenceName != null) {
			name = referenceName;
		} else if (calledFeature instanceof JvmOperation) {
			name = featureNameProvider.getSimpleName(calledFeature);
		} else {
			name = featureCall.getConcreteSyntaxFeatureName();
		}
	}
	if (name == null) {
		return nullKeyword.apply();
	}
	return name;
}
 
Example #2
Source File: XbaseValidator.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected ILogicalContainerProvider getLogicalContainerProvider() {
	return logicalContainerProvider;
}
 
Example #3
Source File: LogicalContainerAwareReentrantTypeResolver.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected ILogicalContainerProvider getLogicalContainerProvider() {
	return logicalContainerProvider;
}
 
Example #4
Source File: FeatureCallCompiler.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected ILogicalContainerProvider getLogicalContainerProvider() {
	return contextProvider;
}
 
Example #5
Source File: ConstantConditionsInterpreter.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Pure
protected ILogicalContainerProvider getLogicalContainerProvider() {
  return this.logicalContainerProvider;
}
 
Example #6
Source File: AbstractExpressionGenerator.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Change the provider of the logical container.
 *
 * @param provider the logical container provider.
 */
@Inject
public void setLogicalContainerProvider(ILogicalContainerProvider provider) {
	this.contextProvider = provider;
}
 
Example #7
Source File: AbstractExpressionGenerator.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Replies the provider of the logical container.
 *
 * @return the logical container provider.
 */
public ILogicalContainerProvider getLogicalContainerProvider() {
	return this.contextProvider;
}