Java 类org.eclipse.xtext.xbase.XForLoopExpression 实例源码

项目:xtext-extras    文件:XbaseSyntacticSequencer.java   
/**
 * Syntax: '('*
 */
@Override
protected void emit_XParenthesizedExpression_LeftParenthesisKeyword_0_a(EObject semanticObject,
        ISynNavigable transition, List<INode> nodes) {

    Keyword kw = grammarAccess.getXParenthesizedExpressionAccess().getLeftParenthesisKeyword_0();

    if (nodes == null) {
        if (semanticObject instanceof XIfExpression || semanticObject instanceof XTryCatchFinallyExpression) {
            EObject cnt = semanticObject.eContainer();
            if (cnt instanceof XExpression && !(cnt instanceof XBlockExpression)
                    && !(cnt instanceof XForLoopExpression))
                acceptUnassignedKeyword(kw, kw.getValue(), null);
        }
        if (semanticObject instanceof XConstructorCall) {
            XConstructorCall call = (XConstructorCall) semanticObject;
            if (!call.isExplicitConstructorCall() && call.getArguments().isEmpty()) {
                acceptUnassignedKeyword(kw, kw.getValue(), null);
            }
        }
    }
    acceptNodes(transition, nodes);
}
项目:xtext-extras    文件:XbaseInterpreter.java   
protected Object _doEvaluate(XForLoopExpression forLoop, IEvaluationContext context, CancelIndicator indicator) {
    Object iterableOrIterator = internalEvaluate(forLoop.getForExpression(), context, indicator);
    if (iterableOrIterator == null)
        return throwNullPointerException(forLoop.getForExpression(), "iterable evaluated to 'null'");
    Iterator<?> iter = null;
    if (iterableOrIterator instanceof Iterable<?>) {
        iter = ((Iterable<?>) iterableOrIterator).iterator();
    } else if (iterableOrIterator.getClass().isArray()) {
        iter = ((Iterable<?>) Conversions.doWrapArray(iterableOrIterator)).iterator();
    } else {
        return throwClassCastException(forLoop.getForExpression(), iterableOrIterator, java.lang.Iterable.class);
    }
    IEvaluationContext forkedContext = context.fork();
    QualifiedName paramName = QualifiedName.create(forLoop.getDeclaredParam().getName());
    forkedContext.newValue(paramName, null);
    while (iter.hasNext()) {
        Object next = iter.next();
        forkedContext.assignValue(paramName, next);
        internalEvaluate(forLoop.getEachExpression(), forkedContext, indicator);
    }
    return null;
}
项目:dsl-devkit    文件:AbstractCheckSemanticSequencer.java   
/**
 * Constraint:
 *     (declaredParam=JvmFormalParameter forExpression=XExpression eachExpression=XExpression)
 */
protected void sequence_XForLoopExpression(EObject context, XForLoopExpression semanticObject) {
    if(errorAcceptor != null) {
        if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION) == ValueTransient.YES)
            errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION));
        if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION) == ValueTransient.YES)
            errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION));
        if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__DECLARED_PARAM) == ValueTransient.YES)
            errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__DECLARED_PARAM));
    }
    INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
    SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
    feeder.accept(grammarAccess.getXForLoopExpressionAccess().getDeclaredParamJvmFormalParameterParserRuleCall_0_0_3_0(), semanticObject.getDeclaredParam());
    feeder.accept(grammarAccess.getXForLoopExpressionAccess().getForExpressionXExpressionParserRuleCall_1_0(), semanticObject.getForExpression());
    feeder.accept(grammarAccess.getXForLoopExpressionAccess().getEachExpressionXExpressionParserRuleCall_3_0(), semanticObject.getEachExpression());
    feeder.finish();
}
项目:dsl-devkit    文件:AbstractCheckCfgSemanticSequencer.java   
/**
 * Constraint:
 *     (declaredParam=JvmFormalParameter forExpression=XExpression eachExpression=XExpression)
 */
protected void sequence_XForLoopExpression(EObject context, XForLoopExpression semanticObject) {
    if(errorAcceptor != null) {
        if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION) == ValueTransient.YES)
            errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION));
        if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION) == ValueTransient.YES)
            errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION));
        if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__DECLARED_PARAM) == ValueTransient.YES)
            errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__DECLARED_PARAM));
    }
    INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
    SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
    feeder.accept(grammarAccess.getXForLoopExpressionAccess().getDeclaredParamJvmFormalParameterParserRuleCall_0_0_3_0(), semanticObject.getDeclaredParam());
    feeder.accept(grammarAccess.getXForLoopExpressionAccess().getForExpressionXExpressionParserRuleCall_1_0(), semanticObject.getForExpression());
    feeder.accept(grammarAccess.getXForLoopExpressionAccess().getEachExpressionXExpressionParserRuleCall_3_0(), semanticObject.getEachExpression());
    feeder.finish();
}
项目:xtext-extras    文件:XbaseTypeComputer.java   
protected void _computeTypes(final XForLoopExpression object, final ITypeComputationState state) {
    JvmFormalParameter declaredParam = object.getDeclaredParam();
    ITypeComputationState eachState = state.withoutExpectation();
    if (declaredParam != null) {
        LightweightTypeReference parameterType = computeForLoopParameterType(object, state);
        eachState = assignType(declaredParam, parameterType, eachState);
        eachState.withinScope(object);
    }
    eachState.computeTypes(object.getEachExpression());

    LightweightTypeReference primitiveVoid = getPrimitiveVoid(state);
    state.acceptActualType(primitiveVoid);
}
项目:xtext-extras    文件:XbaseCompiler.java   
/**
 * @param isReferenced unused in this context but necessary for dispatch signature 
 */
protected void _toJavaStatement(XForLoopExpression expr, ITreeAppendable b, boolean isReferenced) {
    internalToJavaStatement(expr.getForExpression(), b, true);
    b.newLine();
    ITreeAppendable loopAppendable = b.trace(expr);
    loopAppendable.append("for (");
    ITreeAppendable parameterAppendable = loopAppendable.trace(expr.getDeclaredParam());
    appendForLoopParameter(expr, parameterAppendable);
    loopAppendable.append(" : ");
    internalToJavaExpression(expr.getForExpression(), loopAppendable);
    loopAppendable.append(") {").increaseIndentation();
    internalToJavaStatement(expr.getEachExpression(), loopAppendable, false);
    loopAppendable.decreaseIndentation().newLine().append("}");
}
项目:xtext-extras    文件:XbaseCompiler.java   
protected void appendForLoopParameter(XForLoopExpression expr, ITreeAppendable appendable) {
    appendable.append("final ");
    JvmTypeReference paramType = getForLoopParameterType(expr);
    serialize(paramType, expr, appendable);
    appendable.append(" ");
    final String name = makeJavaIdentifier(expr.getDeclaredParam().getName());
    String varName = appendable.declareVariable(expr.getDeclaredParam(), name);
    appendable.trace(expr.getDeclaredParam(), TypesPackage.Literals.JVM_FORMAL_PARAMETER__NAME, 0).append(varName);
}
项目:xtext-extras    文件:DefaultEarlyExitComputer.java   
protected Collection<IEarlyExitComputer.ExitPoint> _exitPoints(final XForLoopExpression expression) {
  Collection<IEarlyExitComputer.ExitPoint> exitPoints = this.getExitPoints(expression.getForExpression());
  boolean _isNotEmpty = this.isNotEmpty(exitPoints);
  if (_isNotEmpty) {
    return exitPoints;
  }
  return Collections.<IEarlyExitComputer.ExitPoint>emptyList();
}
项目:xtext-extras    文件:DefaultEarlyExitComputer.java   
protected Collection<IEarlyExitComputer.ExitPoint> exitPoints(final XExpression expression) {
  if (expression instanceof XDoWhileExpression) {
    return _exitPoints((XDoWhileExpression)expression);
  } else if (expression instanceof XWhileExpression) {
    return _exitPoints((XWhileExpression)expression);
  } else if (expression instanceof XAbstractFeatureCall) {
    return _exitPoints((XAbstractFeatureCall)expression);
  } else if (expression instanceof XBasicForLoopExpression) {
    return _exitPoints((XBasicForLoopExpression)expression);
  } else if (expression instanceof XBlockExpression) {
    return _exitPoints((XBlockExpression)expression);
  } else if (expression instanceof XConstructorCall) {
    return _exitPoints((XConstructorCall)expression);
  } else if (expression instanceof XForLoopExpression) {
    return _exitPoints((XForLoopExpression)expression);
  } else if (expression instanceof XIfExpression) {
    return _exitPoints((XIfExpression)expression);
  } else if (expression instanceof XReturnExpression) {
    return _exitPoints((XReturnExpression)expression);
  } else if (expression instanceof XSwitchExpression) {
    return _exitPoints((XSwitchExpression)expression);
  } else if (expression instanceof XSynchronizedExpression) {
    return _exitPoints((XSynchronizedExpression)expression);
  } else if (expression instanceof XThrowExpression) {
    return _exitPoints((XThrowExpression)expression);
  } else if (expression instanceof XTryCatchFinallyExpression) {
    return _exitPoints((XTryCatchFinallyExpression)expression);
  } else if (expression instanceof XVariableDeclaration) {
    return _exitPoints((XVariableDeclaration)expression);
  } else if (expression != null) {
    return _exitPoints(expression);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(expression).toString());
  }
}
项目:xtext-extras    文件:XbaseParserTest.java   
@Test public void testForLoopExpression() throws Exception {
    XForLoopExpression forExp = (XForLoopExpression) expression("for(s : foo) bar");
    assertFeatureCall("foo",forExp.getForExpression());
    assertEquals("s",forExp.getDeclaredParam().getName());
    assertNull(forExp.getDeclaredParam().getParameterType());
    assertFeatureCall("bar",forExp.getEachExpression());
}
项目:xtext-extras    文件:AbstractXbaseLinkingTest.java   
@Test public void testForLoop_01() throws Exception {
    final XBlockExpression block = (XBlockExpression) expression("{val s = null as Iterable<String>; for(String s: s) s}");
    XForLoopExpression forLoop = (XForLoopExpression) block.getExpressions().get(1);
    XFeatureCall forFeatureCall = (XFeatureCall) forLoop.getForExpression();
    assertEquals(block.getExpressions().get(0), forFeatureCall.getFeature());
    XFeatureCall eachFeatureCall = (XFeatureCall) forLoop.getEachExpression();
    assertFalse(eachFeatureCall.getFeature().eIsProxy());
    assertSame(forLoop.getDeclaredParam(), eachFeatureCall.getFeature());
}
项目:xtext-extras    文件:AbstractXbaseSemanticSequencer.java   
/**
 * Contexts:
 *     XExpression returns XForLoopExpression
 *     XAssignment returns XForLoopExpression
 *     XAssignment.XBinaryOperation_1_1_0_0_0 returns XForLoopExpression
 *     XOrExpression returns XForLoopExpression
 *     XOrExpression.XBinaryOperation_1_0_0_0 returns XForLoopExpression
 *     XAndExpression returns XForLoopExpression
 *     XAndExpression.XBinaryOperation_1_0_0_0 returns XForLoopExpression
 *     XEqualityExpression returns XForLoopExpression
 *     XEqualityExpression.XBinaryOperation_1_0_0_0 returns XForLoopExpression
 *     XRelationalExpression returns XForLoopExpression
 *     XRelationalExpression.XInstanceOfExpression_1_0_0_0_0 returns XForLoopExpression
 *     XRelationalExpression.XBinaryOperation_1_1_0_0_0 returns XForLoopExpression
 *     XOtherOperatorExpression returns XForLoopExpression
 *     XOtherOperatorExpression.XBinaryOperation_1_0_0_0 returns XForLoopExpression
 *     XAdditiveExpression returns XForLoopExpression
 *     XAdditiveExpression.XBinaryOperation_1_0_0_0 returns XForLoopExpression
 *     XMultiplicativeExpression returns XForLoopExpression
 *     XMultiplicativeExpression.XBinaryOperation_1_0_0_0 returns XForLoopExpression
 *     XUnaryOperation returns XForLoopExpression
 *     XCastedExpression returns XForLoopExpression
 *     XCastedExpression.XCastedExpression_1_0_0_0 returns XForLoopExpression
 *     XPostfixOperation returns XForLoopExpression
 *     XPostfixOperation.XPostfixOperation_1_0_0 returns XForLoopExpression
 *     XMemberFeatureCall returns XForLoopExpression
 *     XMemberFeatureCall.XAssignment_1_0_0_0_0 returns XForLoopExpression
 *     XMemberFeatureCall.XMemberFeatureCall_1_1_0_0_0 returns XForLoopExpression
 *     XPrimaryExpression returns XForLoopExpression
 *     XParenthesizedExpression returns XForLoopExpression
 *     XForLoopExpression returns XForLoopExpression
 *     XExpressionOrVarDeclaration returns XForLoopExpression
 *
 * Constraint:
 *     (declaredParam=JvmFormalParameter forExpression=XExpression eachExpression=XExpression)
 */
protected void sequence_XForLoopExpression(ISerializationContext context, XForLoopExpression semanticObject) {
    if (errorAcceptor != null) {
        if (transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__DECLARED_PARAM) == ValueTransient.YES)
            errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__DECLARED_PARAM));
        if (transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION) == ValueTransient.YES)
            errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION));
        if (transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION) == ValueTransient.YES)
            errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION));
    }
    SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
    feeder.accept(grammarAccess.getXForLoopExpressionAccess().getDeclaredParamJvmFormalParameterParserRuleCall_0_0_3_0(), semanticObject.getDeclaredParam());
    feeder.accept(grammarAccess.getXForLoopExpressionAccess().getForExpressionXExpressionParserRuleCall_1_0(), semanticObject.getForExpression());
    feeder.accept(grammarAccess.getXForLoopExpressionAccess().getEachExpressionXExpressionParserRuleCall_3_0(), semanticObject.getEachExpression());
    feeder.finish();
}
项目:xtext-extras    文件:AbstractXbaseSemanticSequencer.java   
@Deprecated
protected void sequence_XForLoopExpression(EObject context, XForLoopExpression semanticObject) {
    sequence_XForLoopExpression(createContext(context, semanticObject), semanticObject);
}
项目:xtext-extras    文件:XbaseTypeComputer.java   
@Override
public void computeTypes(XExpression expression, ITypeComputationState state) {
    if (expression instanceof XAssignment) {
        _computeTypes((XAssignment)expression, state);
    } else if (expression instanceof XAbstractFeatureCall) {
        _computeTypes((XAbstractFeatureCall)expression, state);
    } else if (expression instanceof XDoWhileExpression) {
        _computeTypes((XDoWhileExpression)expression, state);
    } else if (expression instanceof XWhileExpression) {
        _computeTypes((XWhileExpression)expression, state);
    } else if (expression instanceof XBlockExpression) {
        _computeTypes((XBlockExpression)expression, state);
    } else if (expression instanceof XBooleanLiteral) {
        _computeTypes((XBooleanLiteral)expression, state);
    } else if (expression instanceof XCastedExpression) {
        _computeTypes((XCastedExpression)expression, state);
    } else if (expression instanceof XClosure) {
        _computeTypes((XClosure)expression, state);
    } else if (expression instanceof XConstructorCall) {
        _computeTypes((XConstructorCall)expression, state);
    } else if (expression instanceof XForLoopExpression) {
        _computeTypes((XForLoopExpression)expression, state);
    } else if (expression instanceof XBasicForLoopExpression) {
        _computeTypes((XBasicForLoopExpression)expression, state);
    } else if (expression instanceof XIfExpression) {
        _computeTypes((XIfExpression)expression, state);
    } else if (expression instanceof XInstanceOfExpression) {
        _computeTypes((XInstanceOfExpression)expression, state);
    } else if (expression instanceof XNumberLiteral) {
        _computeTypes((XNumberLiteral)expression, state);
    } else if (expression instanceof XNullLiteral) {
        _computeTypes((XNullLiteral)expression, state);
    } else if (expression instanceof XReturnExpression) {
        _computeTypes((XReturnExpression)expression, state);
    } else if (expression instanceof XStringLiteral) {
        _computeTypes((XStringLiteral)expression, state);
    } else if (expression instanceof XSwitchExpression) {
        _computeTypes((XSwitchExpression)expression, state);
    } else if (expression instanceof XThrowExpression) {
        _computeTypes((XThrowExpression)expression, state);
    } else if (expression instanceof XTryCatchFinallyExpression) {
        _computeTypes((XTryCatchFinallyExpression)expression, state);
    } else if (expression instanceof XTypeLiteral) {
        _computeTypes((XTypeLiteral)expression, state);
    } else if (expression instanceof XVariableDeclaration) {
        _computeTypes((XVariableDeclaration)expression, state);
    } else if (expression instanceof XListLiteral) {
        _computeTypes((XListLiteral)expression, state);
    } else if (expression instanceof XSetLiteral) {
        _computeTypes((XSetLiteral)expression, state);
    } else if (expression instanceof XSynchronizedExpression) {
        _computeTypes((XSynchronizedExpression)expression, state);
    } else {
        throw new UnsupportedOperationException("Missing type computation for expression type: " + expression.eClass().getName() + " / " + state);
    }
}
项目:xtext-extras    文件:ExtendedEarlyExitComputer.java   
/**
 * Returns <code>true</code> for expressions that seem to be early exit expressions, e.g.
 * <pre>
 *   while(condition) {
 *     if (anotherCondition)
 *       return value
 *     changeResultOfFirstCondition
 *   }
 * </pre>
 */
public boolean isIntentionalEarlyExit(/* @Nullable */ XExpression expression) {
    if (expression == null) {
        return true;
    }
    if (expression instanceof XBlockExpression) {
        XBlockExpression block = (XBlockExpression) expression;
        List<XExpression> children = block.getExpressions();
        for(XExpression child: children) {
            if (isIntentionalEarlyExit(child)) {
                return true;
            }
        }
    } else if (expression instanceof XIfExpression) {
        return isIntentionalEarlyExit(((XIfExpression) expression).getThen()) 
                || isIntentionalEarlyExit(((XIfExpression) expression).getElse());
    } else if (expression instanceof XSwitchExpression) {
        XSwitchExpression switchExpression = (XSwitchExpression) expression;
        for(XCasePart caseExpression: switchExpression.getCases()) {
            if (isIntentionalEarlyExit(caseExpression.getThen())) {
                return true;
            }
        }
        if (isIntentionalEarlyExit(switchExpression.getDefault())) {
            return true;
        }
    } else if (expression instanceof XTryCatchFinallyExpression) {
        XTryCatchFinallyExpression tryCatchFinally = (XTryCatchFinallyExpression) expression;
        if (isIntentionalEarlyExit(tryCatchFinally.getExpression())) {
            for(XCatchClause catchClause: tryCatchFinally.getCatchClauses()) {
                if (!isIntentionalEarlyExit(catchClause.getExpression()))
                    return false;
            }
            return true;
        }
        return false;
    } else if (expression instanceof XAbstractWhileExpression) {
        return isIntentionalEarlyExit(((XAbstractWhileExpression) expression).getBody());
    } else if (expression instanceof XForLoopExpression) {
        return isIntentionalEarlyExit(((XForLoopExpression) expression).getEachExpression());
    } else if (expression instanceof XBasicForLoopExpression) {
        return isIntentionalEarlyExit(((XBasicForLoopExpression) expression).getEachExpression());
    } else if (expression instanceof XSynchronizedExpression) {
        return isIntentionalEarlyExit(((XSynchronizedExpression) expression).getExpression());
    }
    return expression instanceof XReturnExpression || expression instanceof XThrowExpression;
}
项目:xtext-extras    文件:XbaseCompiler.java   
@Override
protected void doInternalToJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced) {
    if (obj instanceof XBlockExpression) {
        _toJavaStatement((XBlockExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XCastedExpression) {
        _toJavaStatement((XCastedExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XClosure) {
        _toJavaStatement((XClosure) obj, appendable, isReferenced);
    } else if (obj instanceof XConstructorCall) {
        _toJavaStatement((XConstructorCall) obj, appendable, isReferenced);
    } else if (obj instanceof XDoWhileExpression) {
        _toJavaStatement((XDoWhileExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XForLoopExpression) {
        _toJavaStatement((XForLoopExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XBasicForLoopExpression) {
        _toJavaStatement((XBasicForLoopExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XIfExpression) {
        _toJavaStatement((XIfExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XInstanceOfExpression) {
        _toJavaStatement((XInstanceOfExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XReturnExpression) {
        _toJavaStatement((XReturnExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XSwitchExpression) {
        _toJavaStatement((XSwitchExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XThrowExpression) {
        _toJavaStatement((XThrowExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XTryCatchFinallyExpression) {
        _toJavaStatement((XTryCatchFinallyExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XVariableDeclaration) {
        _toJavaStatement((XVariableDeclaration) obj, appendable, isReferenced);
    } else if (obj instanceof XWhileExpression) {
        _toJavaStatement((XWhileExpression) obj, appendable, isReferenced);
    } else if (obj instanceof XListLiteral) {
        _toJavaStatement((XListLiteral) obj, appendable, isReferenced);
    } else if (obj instanceof XSetLiteral) {
        _toJavaStatement((XSetLiteral) obj, appendable, isReferenced);
    } else if (obj instanceof XSynchronizedExpression) {
        _toJavaStatement((XSynchronizedExpression) obj, appendable, isReferenced);
    } else {
        super.doInternalToJavaStatement(obj, appendable, isReferenced);
    }
}
项目:xtext-extras    文件:XbaseCompiler.java   
protected JvmTypeReference getForLoopParameterType(XForLoopExpression expr) {
    JvmFormalParameter declaredParam = expr.getDeclaredParam();
    return getParameterType(declaredParam);
}
项目:xtext-extras    文件:XbaseInterpreter.java   
/**
 * don't call this directly. Always call evaluate() internalEvaluate()
 */
protected Object doEvaluate(XExpression expression, IEvaluationContext context, CancelIndicator indicator) {
    if (expression instanceof XAssignment) {
      return _doEvaluate((XAssignment)expression, context, indicator);
    } else if (expression instanceof XDoWhileExpression) {
      return _doEvaluate((XDoWhileExpression)expression, context, indicator);
    } else if (expression instanceof XMemberFeatureCall) {
      return _doEvaluate((XMemberFeatureCall)expression, context, indicator);
    } else if (expression instanceof XWhileExpression) {
      return _doEvaluate((XWhileExpression)expression, context, indicator);
    } else if (expression instanceof XFeatureCall) {
        return _doEvaluate((XFeatureCall)expression, context, indicator);
    } else if (expression instanceof XAbstractFeatureCall) {
        return _doEvaluate((XAbstractFeatureCall)expression, context, indicator);
    } else if (expression instanceof XBlockExpression) {
      return _doEvaluate((XBlockExpression)expression, context, indicator);
    } else if (expression instanceof XSynchronizedExpression) {
      return _doEvaluate((XSynchronizedExpression)expression, context, indicator);
    } else if (expression instanceof XBooleanLiteral) {
      return _doEvaluate((XBooleanLiteral)expression, context, indicator);
    } else if (expression instanceof XCastedExpression) {
      return _doEvaluate((XCastedExpression)expression, context, indicator);
    } else if (expression instanceof XClosure) {
      return _doEvaluate((XClosure)expression, context, indicator);
    } else if (expression instanceof XConstructorCall) {
      return _doEvaluate((XConstructorCall)expression, context, indicator);
    } else if (expression instanceof XForLoopExpression) {
      return _doEvaluate((XForLoopExpression)expression, context, indicator);
    } else if (expression instanceof XBasicForLoopExpression) {
      return _doEvaluate((XBasicForLoopExpression)expression, context, indicator);
    } else if (expression instanceof XIfExpression) {
      return _doEvaluate((XIfExpression)expression, context, indicator);
    } else if (expression instanceof XInstanceOfExpression) {
      return _doEvaluate((XInstanceOfExpression)expression, context, indicator);
    } else if (expression instanceof XNullLiteral) {
      return _doEvaluate((XNullLiteral)expression, context, indicator);
    } else if (expression instanceof XNumberLiteral) {
      return _doEvaluate((XNumberLiteral)expression, context, indicator);
    } else if (expression instanceof XReturnExpression) {
      return _doEvaluate((XReturnExpression)expression, context, indicator);
    } else if (expression instanceof XStringLiteral) {
      return _doEvaluate((XStringLiteral)expression, context, indicator);
    } else if (expression instanceof XSwitchExpression) {
      return _doEvaluate((XSwitchExpression)expression, context, indicator);
    } else if (expression instanceof XThrowExpression) {
      return _doEvaluate((XThrowExpression)expression, context, indicator);
    } else if (expression instanceof XTryCatchFinallyExpression) {
      return _doEvaluate((XTryCatchFinallyExpression)expression, context, indicator);
    } else if (expression instanceof XTypeLiteral) {
      return _doEvaluate((XTypeLiteral)expression, context, indicator);
    } else if (expression instanceof XVariableDeclaration) {
          return _doEvaluate((XVariableDeclaration)expression, context, indicator);
    } else if (expression instanceof XListLiteral) {
          return _doEvaluate((XListLiteral)expression, context, indicator);
    } else if (expression instanceof XSetLiteral) {
          return _doEvaluate((XSetLiteral)expression, context, indicator);
    } else {
      throw new IllegalArgumentException("Unhandled parameter types: " +
        Arrays.<Object>asList(expression, context, indicator).toString());
    }
}
项目:xtext-extras    文件:XbaseParserTest.java   
@Test public void testForLoopExpression_1() throws Exception {
    XForLoopExpression forExp = (XForLoopExpression) expression("for(String s : foo) bar");
    doTestForLoopExpression_1(forExp);
}
项目:xtext-extras    文件:XbaseParserTest.java   
protected void doTestForLoopExpression_1(XForLoopExpression forExp) {
    assertFeatureCall("foo",forExp.getForExpression());
    assertEquals("s",forExp.getDeclaredParam().getName());
    assertEquals("java.lang.String", forExp.getDeclaredParam().getParameterType().getIdentifier());
    assertFeatureCall("bar",forExp.getEachExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_0() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (java.lang.String x : null) null");
    // if the type is null, we use a simple expectation, error is 'null' is not allowed, anyways
    assertExpected("java.lang.Iterable<? extends java.lang.String>", loop.getForExpression());
    assertExpected(null, loop.getEachExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_1() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (x : null) null");
    assertExpected("java.lang.Iterable<? extends java.lang.Object>", loop.getForExpression());
    assertExpected(null, loop.getEachExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_2_a() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (java.lang.String x : new Object) null");
    assertExpected("java.lang.Iterable<? extends java.lang.String> | java.lang.String[]", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_2_b() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (int x : new Object) null");
    assertExpected("int[] | java.lang.Iterable<? extends java.lang.Integer> | java.lang.Integer[]", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_2_c() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (double x : null as Iterable<? super Integer>) null");
    assertExpected("double[] | java.lang.Iterable<? extends java.lang.Double> | java.lang.Double[]", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_2_d() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for(Double d: null as int[])) {}");
    assertExpected("java.lang.Iterable<? extends java.lang.Double> | double[] | java.lang.Double[]", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_3_a() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (java.lang.String x : null as String[]) null");
    assertExpected("java.lang.String[]", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_3_b() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (int x : 1..2) null");
    assertExpected("org.eclipse.xtext.xbase.lib.IntegerRange", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_3_c() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (x : 1..2) null");
    assertExpected("org.eclipse.xtext.xbase.lib.IntegerRange", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_3_d() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (Integer x : 1..2) null");
    assertExpected("org.eclipse.xtext.xbase.lib.IntegerRange", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_3_e() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (Integer x : null as int[]) null");
    assertExpected("int[]", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_3_f() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (java.lang.String x : null as Iterable<String>) null");
    assertExpected("java.lang.Iterable<java.lang.String>", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_3_g() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (java.lang.String x : null as Iterable<? extends String>) null");
    assertExpected("java.lang.Iterable<? extends java.lang.String>", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_3_h() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (Object x : null as Iterable<? super Integer>) null");
    assertExpected("java.lang.Iterable<? super java.lang.Integer>", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_4_a() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (Object x : null as double[]) null");
    assertExpected("double[]", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_4_b() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (double x : null as int[]) null");
    assertExpected("int[]", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_4_c() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (double x : null as Integer[]) null");
    assertExpected("java.lang.Integer[]", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_4_d() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (double x : null as Iterable<Integer>) null");
    assertExpected("java.lang.Iterable<java.lang.Integer>", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_4_e() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for (double x : null as Iterable<? extends Integer>) null");
    assertExpected("java.lang.Iterable<? extends java.lang.Integer>", loop.getForExpression());
}
项目:xtext-extras    文件:XbaseExpectedTypeProviderTest.java   
@Test public void testForLoopExpression_4_f() throws Exception {
    XForLoopExpression loop = (XForLoopExpression) expression("for(double d: <Integer>newArrayList) { d.toString }");
    assertExpected("java.util.ArrayList<java.lang.Integer>", loop.getForExpression());
}