Java Code Examples for org.eclipse.xtext.xbase.XAbstractFeatureCall#getConcreteSyntaxFeatureName()

The following examples show how to use org.eclipse.xtext.xbase.XAbstractFeatureCall#getConcreteSyntaxFeatureName() . 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: AbstractConstantExpressionsInterpreter.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected String getOperator(final XAbstractFeatureCall call) {
  String _switchResult = null;
  Resource _eResource = call.eResource();
  final Resource res = _eResource;
  boolean _matched = false;
  if (res instanceof StorageAwareResource) {
    boolean _isLoadedFromStorage = ((StorageAwareResource)res).isLoadedFromStorage();
    if (_isLoadedFromStorage) {
      _matched=true;
      QualifiedName _operator = this.operatorMapping.getOperator(QualifiedName.create(call.getFeature().getSimpleName()));
      String _string = null;
      if (_operator!=null) {
        _string=_operator.toString();
      }
      return _string;
    }
  }
  if (!_matched) {
    _switchResult = call.getConcreteSyntaxFeatureName();
  }
  return _switchResult;
}
 
Example 2
Source File: AbstractExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Get the string representation of an operator.
 *
 * @param call the call to the operator feature.
 * @return the string representation of the operator or {@code null} if not a valid operator.
 */
protected String getOperatorSymbol(XAbstractFeatureCall call) {
	if (call != null) {
		final Resource res = call.eResource();
		if (res instanceof StorageAwareResource) {
			final boolean isLoadedFromStorage = ((StorageAwareResource) res).isLoadedFromStorage();
			if (isLoadedFromStorage) {
				final QualifiedName operator = getOperatorMapping().getOperator(
						QualifiedName.create(call.getFeature().getSimpleName()));
				return Objects.toString(operator);
			}
		}
		return call.getConcreteSyntaxFeatureName();
	}
	return null;
}
 
Example 3
Source File: JvmAnnotationReferencePrinter.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected String internalHandleAbstractFeatureCall(String prefix, XAbstractFeatureCall abstractFeatureCall) {
	final String postfix;
	if (abstractFeatureCall.getFeature() != null && !abstractFeatureCall.getFeature().eIsProxy()) {
		postfix = createLinkWithLabel(XtextElementLinks.XTEXTDOC_SCHEME, EcoreUtil.getURI(abstractFeatureCall.getFeature()), abstractFeatureCall.getConcreteSyntaxFeatureName());
	} else {
		postfix = abstractFeatureCall.getConcreteSyntaxFeatureName();
	}

	if (prefix == null) {
		return postfix;
	} else {
		return prefix + "." + postfix;
	}
}
 
Example 4
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;
}