本文整理汇总了Java中org.eclipse.xtext.xbase.XExpression.eContainer方法的典型用法代码示例。如果您正苦于以下问题:Java XExpression.eContainer方法的具体用法?Java XExpression.eContainer怎么用?Java XExpression.eContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.xbase.XExpression
的用法示例。
在下文中一共展示了XExpression.eContainer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mustInsertTypeCast
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
private boolean mustInsertTypeCast(XExpression expression, LightweightTypeReference actualType) {
IResolvedTypes resolvedTypes = getResolvedTypes(expression);
if (mustCheckForMandatoryTypeCast(resolvedTypes, expression)) {
if (expression instanceof XAbstractFeatureCall) {
LightweightTypeReference featureType = resolvedTypes.getActualType(((XAbstractFeatureCall) expression).getFeature());
if (featureType != null && !featureType.isMultiType() && actualType.isAssignableFrom(featureType)) {
return false;
}
}
if (expression.eContainer() instanceof XCastedExpression) {
XCastedExpression castedExpression = (XCastedExpression) expression.eContainer();
LightweightTypeReference castedExpressionType = getResolvedTypes(castedExpression).getActualType(castedExpression);
if (castedExpressionType != null) {
return actualType.getType() != castedExpressionType.getType();
}
}
return true;
}
return false;
}
示例2: convertArrayToList
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
private void convertArrayToList(final LightweightTypeReference left, final ITreeAppendable appendable, XExpression context,
final Later expression) {
if (!(context.eContainer() instanceof XCastedExpression)) {
if (context.eContainer() instanceof XAbstractFeatureCall) {
appendable.append("((");
} else {
appendable.append("(");
}
appendable.append(left);
appendable.append(")");
}
appendable.append(Conversions.class);
appendable.append(".doWrapArray(");
expression.exec(appendable);
if (!(context.eContainer() instanceof XCastedExpression)) {
if (context.eContainer() instanceof XAbstractFeatureCall) {
appendable.append("))");
} else {
appendable.append(")");
}
} else {
appendable.append(")");
}
}
示例3: bracesAreAddedByOuterStructure
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
protected boolean bracesAreAddedByOuterStructure(XExpression expression) {
EObject container = expression.eContainer();
if (container instanceof XTryCatchFinallyExpression
|| container instanceof XIfExpression
|| container instanceof XClosure
|| container instanceof XSynchronizedExpression) {
return true;
}
if (container instanceof XBlockExpression) {
XBlockExpression blockExpression = (XBlockExpression) container;
EList<XExpression> expressions = blockExpression.getExpressions();
if (expressions.size() == 1 && expressions.get(0) == expression) {
return bracesAreAddedByOuterStructure(blockExpression);
}
}
if (!(container instanceof XExpression)) {
return true;
}
return false;
}
示例4: convertWrapperToPrimitive
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
/**
* @param wrapper unused in this context but useful for inheritors
*/
private void convertWrapperToPrimitive(
final LightweightTypeReference wrapper,
final LightweightTypeReference primitive,
XExpression context,
final ITreeAppendable appendable,
final Later expression) {
XExpression normalized = normalizeBlockExpression(context);
if (normalized instanceof XAbstractFeatureCall && !(context.eContainer() instanceof XAbstractFeatureCall)) {
// Avoid javac bug
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=410797
// TODO make that dependent on the compiler version (javac 1.7 fixed that bug)
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) normalized;
if (featureCall.isStatic()) {
JvmIdentifiableElement feature = featureCall.getFeature();
if (feature instanceof JvmOperation) {
if (!((JvmOperation) feature).getTypeParameters().isEmpty()) {
appendable.append("(");
appendable.append(primitive);
appendable.append(") ");
expression.exec(appendable);
return;
}
}
}
}
appendable.append("(");
if (mustInsertTypeCast(context, wrapper)) {
appendable.append("(");
appendable.append(wrapper);
appendable.append(") ");
}
expression.exec(appendable);
appendable.append(")");
appendable.append(".");
appendable.append(primitive);
appendable.append("Value()");
}
示例5: getFeatureCall
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
protected XAbstractFeatureCall getFeatureCall(final XExpression argument) {
EObject expr = argument.eContainer();
if (expr instanceof XAbstractFeatureCall) {
return (XAbstractFeatureCall) expr;
}
if (expr instanceof XBlockExpression) {
XBlockExpression blockExpression = (XBlockExpression) expr;
if (blockExpression.getExpressions().size() == 1)
return getFeatureCall(blockExpression);
}
return null;
}
示例6: isValueExpectedRecursive
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
@Override
protected boolean isValueExpectedRecursive(final XExpression expr) {
EObject container = expr.eContainer();
if (container instanceof XIssueExpression || container instanceof XGuardExpression) {
return true;
}
return super.isValueExpectedRecursive(expr);
}
示例7: isValueExpectedRecursive
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
protected boolean isValueExpectedRecursive(XExpression expr) {
EStructuralFeature feature = expr.eContainingFeature();
EObject container = expr.eContainer();
// is part of block
if (container instanceof XBlockExpression) {
XBlockExpression blockExpression = (XBlockExpression) container;
final List<XExpression> expressions = blockExpression.getExpressions();
if (expressions.get(expressions.size()-1) != expr) {
return false;
}
}
// no expectation cases
if (feature == XbasePackage.Literals.XTRY_CATCH_FINALLY_EXPRESSION__FINALLY_EXPRESSION
|| feature == XbasePackage.Literals.XABSTRACT_WHILE_EXPRESSION__BODY
|| feature == XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION) {
return false;
}
// is value expected
if (container instanceof XAbstractFeatureCall
|| container instanceof XConstructorCall
|| container instanceof XAssignment
|| container instanceof XVariableDeclaration
|| container instanceof XReturnExpression
|| container instanceof XThrowExpression
|| feature == XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION
|| feature == XbasePackage.Literals.XSWITCH_EXPRESSION__SWITCH
|| feature == XbasePackage.Literals.XCASE_PART__CASE
|| feature == XbasePackage.Literals.XIF_EXPRESSION__IF
|| feature == XbasePackage.Literals.XABSTRACT_WHILE_EXPRESSION__PREDICATE
|| feature == XbasePackage.Literals.XBASIC_FOR_LOOP_EXPRESSION__EXPRESSION
|| feature == XbasePackage.Literals.XSYNCHRONIZED_EXPRESSION__PARAM) {
return true;
}
if (isLocalClassSemantics(container) || logicalContainerProvider.getLogicalContainer(expr) != null) {
LightweightTypeReference expectedReturnType = typeResolver.resolveTypes(expr).getExpectedReturnType(expr);
return expectedReturnType == null || !expectedReturnType.isPrimitiveVoid();
}
if (container instanceof XCasePart || container instanceof XCatchClause) {
container = container.eContainer();
}
if (container instanceof XExpression) {
return isValueExpectedRecursive((XExpression) container);
}
return true;
}
示例8: isVariableDeclarationRequired
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
@Override
protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) {
if (expr instanceof XAnnotation) {
return false;
}
if (expr instanceof XListLiteral) {
return false;
}
if (expr instanceof XSetLiteral) {
return false;
}
if (expr instanceof XCastedExpression) {
return false;
}
if (expr instanceof XInstanceOfExpression) {
return false;
}
if (expr instanceof XMemberFeatureCall && isVariableDeclarationRequired((XMemberFeatureCall) expr, b))
return true;
EObject container = expr.eContainer();
if ((container instanceof XVariableDeclaration)
|| (container instanceof XReturnExpression)
|| (container instanceof XThrowExpression)) {
return false;
}
if (container instanceof XIfExpression) {
XIfExpression ifExpression = (XIfExpression) container;
if (ifExpression.getThen() == expr || ifExpression.getElse() == expr) {
return false;
}
}
if (container instanceof XCasePart) {
XCasePart casePart = (XCasePart) container;
if (casePart.getThen() == expr) {
return false;
}
}
if (container instanceof XSwitchExpression) {
XSwitchExpression switchExpression = (XSwitchExpression) container;
if (switchExpression.getDefault() == expr) {
return false;
}
}
if (container instanceof XBlockExpression) {
List<XExpression> siblings = ((XBlockExpression) container).getExpressions();
if (siblings.get(siblings.size() - 1) == expr) {
return isVariableDeclarationRequired(getFeatureCall(expr), expr, b);
}
}
if (container instanceof XClosure) {
if (((XClosure) container).getExpression() == expr) {
return false;
}
}
if (expr instanceof XAssignment) {
XAssignment a = (XAssignment) expr;
for (XExpression arg : getActualArguments(a)) {
if (isVariableDeclarationRequired(arg, b, recursive)) {
return true;
}
}
}
return super.isVariableDeclarationRequired(expr, b, recursive);
}