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

The following examples show how to use org.eclipse.xtext.xbase.XAbstractFeatureCall#getActualArguments() . 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: XtendHoverSerializer.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public String computeArguments(XAbstractFeatureCall featureCall) {
	StringBuilder stringBuilder = new StringBuilder("(");
	if (featureCall != null) {
		XExpression implicitFirstArgument = featureCall.getImplicitFirstArgument();
		List<XExpression> arguments = featureCall.getActualArguments();
		if (implicitFirstArgument != null) {
			XbaseSwitch<String> xbaseSwitch = new XtendHoverXbaseSwitch();
			String doSwitch = xbaseSwitch.doSwitch(implicitFirstArgument).trim();
			if (doSwitch != null)
				stringBuilder.append(doSwitch);
		}
		int start = implicitFirstArgument != null ? 1 : 0;
		for(int i = start; i < arguments.size(); i++) {
			if (i != 0) {
				stringBuilder.append(SEPARATOR);
			}
			XExpression expression = arguments.get(i);
			ICompositeNode node = NodeModelUtils.findActualNodeFor(expression);
			if (node != null)
				stringBuilder.append(node.getText().trim());
		}
	}
	stringBuilder.append(")");
	return stringBuilder.toString();
}
 
Example 2
Source File: Utils.java    From sarl with Apache License 2.0 6 votes vote down vote up
private static boolean hasLocalParameters(EObject current, XExpression container, List<JvmFormalParameter> containerParameters) {
	if (current instanceof XAbstractFeatureCall) {
		final XAbstractFeatureCall featureCall = (XAbstractFeatureCall) current;
		if (isLocalEntity(featureCall, container, containerParameters)) {
			return true;
		}
		for (final XExpression argument : featureCall.getActualArguments()) {
			final Iterable<XAbstractFeatureCall> iterable;
			if (argument instanceof XAbstractFeatureCall) {
				iterable = Iterables.concat(
						Collections.singletonList((XAbstractFeatureCall) argument),
						EcoreUtil2.getAllContentsOfType(argument, XAbstractFeatureCall.class));
			} else {
				iterable = EcoreUtil2.getAllContentsOfType(argument, XAbstractFeatureCall.class);
			}
			for (final XAbstractFeatureCall c : iterable) {
				if (isLocalEntity(c, container, containerParameters)) {
					return true;
				}
			}
		}
	}
	return false;
}
 
Example 3
Source File: XExpressionHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public boolean hasSideEffects(XAbstractFeatureCall featureCall, boolean inspectContents) {
	if (featureCall instanceof XBinaryOperation) {
		XBinaryOperation binaryOperation = (XBinaryOperation) featureCall;
		if (binaryOperation.isReassignFirstArgument()) {
			return true;
		}
	}
	if (featureCall instanceof XAssignment) {
		return true;
	}
	if (featureCall.isPackageFragment() || featureCall.isTypeLiteral()) {
		return false;
	}
	final JvmIdentifiableElement feature = featureCall.getFeature();
	if (feature == null || feature.eIsProxy())
		return true; // linking problems ... could be anything
	if (feature instanceof JvmConstructor) { //super() and this()
		return true;
	}
	if (feature instanceof JvmOperation) {
		JvmOperation jvmOperation = (JvmOperation) feature;
		if (findPureAnnotation(jvmOperation) == null) {
			return true;
		} else {
			if(inspectContents) {
				for (XExpression param : featureCall.getActualArguments()) {
					if (hasSideEffects(param))
						return true;
				}
			}
		}
	}
	return false;
}
 
Example 4
Source File: FeatureCallCompiler.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected List<XExpression> getActualArguments(final XAbstractFeatureCall expr) {
	List<XExpression> actualArguments = expr.getActualArguments();
	return Lists.transform(actualArguments, new Function<XExpression, XExpression>() {
		@Override
		public XExpression apply(XExpression e) {
			return normalizeBlockExpression(e);
		}
	});
}
 
Example 5
Source File: DefaultEarlyExitComputer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected Collection<IEarlyExitComputer.ExitPoint> _exitPoints(final XAbstractFeatureCall expression) {
  EList<XExpression> _actualArguments = expression.getActualArguments();
  for (final XExpression argument : _actualArguments) {
    {
      Collection<IEarlyExitComputer.ExitPoint> argumentExitPoints = this.getExitPoints(argument);
      boolean _isNotEmpty = this.isNotEmpty(argumentExitPoints);
      if (_isNotEmpty) {
        return argumentExitPoints;
      }
    }
  }
  return Collections.<IEarlyExitComputer.ExitPoint>emptyList();
}
 
Example 6
Source File: XbaseCompiler.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected List<XExpression> getActualArguments(XAbstractFeatureCall featureCall) {
	EList<XExpression> actualArguments = featureCall.getActualArguments();
	List<XExpression> normalizedArguments = normalizeBlockExpression(actualArguments);
	return normalizedArguments;
}
 
Example 7
Source File: XbaseInterpreter.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected List<XExpression> getActualArguments(XAbstractFeatureCall featureCall) {
	return featureCall.getActualArguments();
}
 
Example 8
Source File: AbstractExpressionGenerator.java    From sarl with Apache License 2.0 4 votes vote down vote up
private List<XExpression> getActualArguments(XAbstractFeatureCall expr) {
	final List<XExpression> actualArguments = expr.getActualArguments();
	return Lists.transform(actualArguments, it  -> normalizeBlockExpression(it));
}