gpt4 book ai didi

org.eclipse.xtext.xbase.XExpression.eContainer()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 14:41:05 26 4
gpt4 key购买 nike

本文整理了Java中org.eclipse.xtext.xbase.XExpression.eContainer()方法的一些代码示例,展示了XExpression.eContainer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XExpression.eContainer()方法的具体详情如下:
包路径:org.eclipse.xtext.xbase.XExpression
类名称:XExpression
方法名:eContainer

XExpression.eContainer介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.xtend/org.eclipse.xtend.core

@Override
protected boolean isValueExpectedRecursive(XExpression expr) {
  EObject container = expr.eContainer();
  if (container instanceof RichString 
    || container instanceof RichStringForLoop
    || container instanceof XtendField) {
    return true;
  }
  return super.isValueExpectedRecursive(expr);
}

代码示例来源:origin: io.sarl.lang/io.sarl.lang

@Override
protected boolean isValueExpectedRecursive(XExpression expr) {
  final EObject container = expr.eContainer();
  if (container instanceof SarlBreakExpression) {
    return false;
  }
  if (container instanceof SarlContinueExpression) {
    return false;
  }
  if (container instanceof SarlAssertExpression) {
    return true;
  }
  return super.isValueExpectedRecursive(expr);
}

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

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;
}

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

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;
}

代码示例来源:origin: org.eclipse.xtend/org.eclipse.xtend.core

@Override
public void acceptIfCondition(XExpression condition) {
  currentAppendable = null;
  ifStack.add((RichStringIf) condition.eContainer());
  appendable.newLine();
  pushAppendable(condition.eContainer());
  appendable.append("{").increaseIndentation();
  writeIf(condition);
}

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

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(")");
  }
}

代码示例来源:origin: io.sarl.lang/io.sarl.lang

@Override
protected boolean isVariableDeclarationRequired(XExpression expression, ITreeAppendable appendable, boolean recursive) {
  // Add the following test for avoiding to create an variable declaration when the expression has already a name.
  final String refName = getReferenceName(expression, appendable);
  if (!Strings.isEmpty(refName)) {
    return false;
  }
  // Overridden for enabling the expressions that are specific to SARL
  if (expression instanceof SarlBreakExpression) {
    return false;
  }
  if (expression instanceof SarlContinueExpression) {
    return false;
  }
  final EObject container = expression.eContainer();
  if (container instanceof SarlAssertExpression) {
    return false;
  }
  return super.isVariableDeclarationRequired(expression, appendable, recursive);
}

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.query.patternlanguage.emf

private void checkForWrongVariablesInXExpressionsInternal(final XExpression expression) {
  for (Variable variable : PatternLanguageHelper.getReferencedPatternVariablesOfXExpression(expression,
      associations)) {
    IInputKey classifier = typeInferrer.getType(variable);
    if (classifier instanceof BottomTypeKey) {
      error("Only simple EDataTypes are allowed in check() and eval() expressions. The variable "
          + variable.getName() + " has an unknown type.",
          expression.eContainer(), null, IssueCodes.CHECK_CONSTRAINT_SCALAR_VARIABLE_ERROR);
    } else if (classifier != null && !(classifier instanceof EDataTypeInSlotsKey)
        && !(classifier instanceof JavaTransitiveInstancesKey)) {// null-check needed, otherwise code throws
                                     // NPE for classifier.getName()
      error("Only simple EDataTypes are allowed in check() and eval() expressions. The variable "
          + variable.getName() + " has a type of " + classifier.getPrettyPrintableName() + ".",
          expression.eContainer(), null, IssueCodes.CHECK_CONSTRAINT_SCALAR_VARIABLE_ERROR);
    }
  }
}

代码示例来源:origin: org.eclipse.incquery/org.eclipse.incquery.patternlanguage.emf

private void checkForWrongVariablesInXExpressionsInternal(final XExpression expression) {
  for (Variable variable : CorePatternLanguageHelper.getReferencedPatternVariablesOfXExpression(expression, associations)) {
    EClassifier classifier = emfTypeProvider.getClassifierForVariable(variable);
    if (classifier != null && !(classifier instanceof EDataType)) {// null-check needed, otherwise code throws
                                    // NPE for classifier.getName()
      error("Only simple EDataTypes are allowed in check() and eval() expressions. The variable " + variable.getName()
          + " has a type of " + classifier.getName() + ".", expression.eContainer(), null,
          EMFIssueCodes.CHECK_CONSTRAINT_SCALAR_VARIABLE_ERROR);
    }
  }
}

代码示例来源:origin: org.eclipse.incquery/org.eclipse.incquery.patternlanguage

private void checkForImpureJavaCallsInternal(XExpression xExpression, EStructuralFeature feature) {
  Set<String> elementsWithWarnings = new HashSet<String>();
  if (xExpression != null) {
    TreeIterator<EObject> eAllContents = xExpression.eAllContents();
    while (eAllContents.hasNext()) {
      EObject nextEObject = eAllContents.next();
      if (nextEObject instanceof XMemberFeatureCall) {
        XMemberFeatureCall xFeatureCall = (XMemberFeatureCall) nextEObject;
        JvmIdentifiableElement jvmIdentifiableElement = xFeatureCall.getFeature();
        if (jvmIdentifiableElement instanceof JvmOperation) {
          JvmOperation jvmOperation = (JvmOperation) jvmIdentifiableElement;
          if (!PurityChecker.isPure(jvmOperation) && !jvmOperation.eIsProxy()) {
            elementsWithWarnings.add(jvmOperation.getQualifiedName());
          }
        }
      }
    }
  }
  if (!elementsWithWarnings.isEmpty()) {
    warning("There is at least one potentially problematic java call in the check()/eval() expression. Custom java calls "
        + "are considered unsafe in IncQuery unless they are annotated with @"
        + Pure.class.getSimpleName()
        + " or registered with the "
        + PureWhitelistExtensionLoader.EXTENSION_ID
        + " extension point. The possible erroneous calls are the following: " + elementsWithWarnings + ".",
        xExpression.eContainer(), feature, IssueCodes.CHECK_WITH_IMPURE_JAVA_CALLS);
  }
}

代码示例来源:origin: org.eclipse.xtend/org.eclipse.xtend.core

protected void writeIf(XExpression condition) {
  ITreeAppendable debugAppendable = appendable.trace(condition.eContainer(), true);
  internalToJavaStatement(condition, debugAppendable, true);
  debugAppendable.newLine();
  debugAppendable.append("if (");
  internalToJavaExpression(condition, debugAppendable);
  debugAppendable.append(") {").increaseIndentation();
}

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

@Override
public final ITypeComputationResult computeTypes(/* @Nullable */ XExpression expression) {
  resolvedTypes.checkCanceled();
  if (expression != null) {
    if (expression.eContainer() == null && expression.eResource() == null)
      throw new IllegalStateException("Dangling expression: " + expression);
    assert getResolvedTypes().doGetTypeData(expression) == null : "Expression was already resolved: " + expression;  
    ExpressionAwareStackedResolvedTypes stackedResolvedTypes = doComputeTypes(expression);
    stackedResolvedTypes.performMergeIntoParent();
    return new ResolutionBasedComputationResult(expression, resolvedTypes);
  } else {
    return new NoTypeResult(null, getReferenceOwner());
  }
}

代码示例来源:origin: org.eclipse.xtend/org.eclipse.xtend.core

@Override
protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) {
  boolean result = super.isVariableDeclarationRequired(expr, b, recursive);
  if (result && expr instanceof XConstructorCall) {
    EObject container = expr.eContainer();
    if (container instanceof AnonymousClass) {
      AnonymousClass anonymousClass = (AnonymousClass) container;
      result = isVariableDeclarationRequired(anonymousClass, b, recursive);
      if (result) {
        JvmConstructor constructor = anonymousClass.getConstructorCall().getConstructor();
        JvmDeclaredType type = constructor.getDeclaringType();
        if (((JvmGenericType) type).isAnonymous()) {
          return false;
        }
      }
    }
  }
  return result;
}

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

protected boolean isValueExpectedRecursive(XExpression expr) {
  EStructuralFeature feature = expr.eContainingFeature();
  EObject container = expr.eContainer();

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

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 (featureType != null && featureType.isMultiType()) {
        JvmTypeReference compliantTypeReference = featureType.toJavaCompliantTypeReference();
        if (actualType.isAssignableFrom(featureType.getOwner().toLightweightTypeReference(compliantTypeReference))) {
          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;
}

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

EObject container = expr.eContainer();
if ((container instanceof XVariableDeclaration)
  || (container instanceof XReturnExpression)

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

if (((XMemberFeatureCall) expr.eContainer()).isNullSafe()) {
  if (expr instanceof XFeatureCall) {
    JvmIdentifiableElement feature = ((XFeatureCall) expr).getFeature();
XBinaryOperation binaryOperation = (XBinaryOperation) expr.eContainer();
if (binaryOperation.isReassignFirstArgument()) {
  return true;

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

private LightweightTypeReference findRealReturnType(XExpression expression) {
  if (expression == null)
    return null;
  JvmIdentifiableElement logicalContainer = getLogicalContainerProvider().getLogicalContainer(expression);
  if (logicalContainer instanceof JvmOperation) {
    return getLightweightType(logicalContainer);
  }
  if (expression instanceof XClosure) {
    IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(expression);
    LightweightTypeReference type = resolvedTypes.getExpectedType(expression);
    if (type == null) {
      type = resolvedTypes.getActualType(expression);
    }
    if (type == null) {
      return null;
    }
    FunctionTypeReference functionType = type.tryConvertToFunctionTypeReference(false);
    if (functionType != null) {
      return functionType.getReturnType();
    }
    return null;
  }
  XExpression containerExpression = EcoreUtil2.getContainerOfType(expression.eContainer(), XExpression.class);
  if (containerExpression == null) {
    LightweightTypeReference returnType = getLightweightReturnType(expression);
    return returnType;
  }
  return findRealReturnType(containerExpression);
}

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase

final Later expression) {
XExpression normalized = normalizeBlockExpression(context);
if (normalized instanceof XAbstractFeatureCall && !(context.eContainer() instanceof XAbstractFeatureCall)) {

代码示例来源:origin: org.eclipse.xtend/org.eclipse.xtend.core

if (expression == null)
  throw new IllegalArgumentException("expression may not be null");
RichStringForLoop forLoop = (RichStringForLoop) expression.eContainer();
forStack.add(forLoop);
appendable.newLine();

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com