当前位置: 首页>>代码示例>>Java>>正文


Java XBasicForLoopExpression.getUpdateExpressions方法代码示例

本文整理汇总了Java中org.eclipse.xtext.xbase.XBasicForLoopExpression.getUpdateExpressions方法的典型用法代码示例。如果您正苦于以下问题:Java XBasicForLoopExpression.getUpdateExpressions方法的具体用法?Java XBasicForLoopExpression.getUpdateExpressions怎么用?Java XBasicForLoopExpression.getUpdateExpressions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.xbase.XBasicForLoopExpression的用法示例。


在下文中一共展示了XBasicForLoopExpression.getUpdateExpressions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _computeTypes

import org.eclipse.xtext.xbase.XBasicForLoopExpression; //导入方法依赖的package包/类
protected void _computeTypes(final XBasicForLoopExpression object, final ITypeComputationState state) {
	for(XExpression initExpression : object.getInitExpressions()) {
		ITypeComputationState expressionState = state.withoutExpectation();
		expressionState.computeTypes(initExpression);
		addLocalToCurrentScope(initExpression, state);
	}
	state.withinScope(object);
	XExpression expression = object.getExpression();
	if (expression != null) {
		LightweightTypeReference booleanType = getRawTypeForName(Boolean.TYPE, state);
		ITypeComputationState conditionExpectation = state.withExpectation(booleanType);
		conditionExpectation.computeTypes(expression);
	}
	
	XExpression eachExpression = object.getEachExpression();
	ITypeComputationState stateWithoutExpectation = state.withoutExpectation();
	ITypeComputationState eachExpressionState = reassignCheckedType(expression, eachExpression, stateWithoutExpectation);
	eachExpressionState.computeTypes(eachExpression);
	
	for (XExpression updateExpression : object.getUpdateExpressions()) {
		eachExpressionState.computeTypes(updateExpression);
	}
	
	LightweightTypeReference primitiveVoid = getPrimitiveVoid(state);
	state.acceptActualType(primitiveVoid);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:XbaseTypeComputer.java

示例2: _doEvaluate

import org.eclipse.xtext.xbase.XBasicForLoopExpression; //导入方法依赖的package包/类
protected Object _doEvaluate(XBasicForLoopExpression forLoop, IEvaluationContext context, CancelIndicator indicator) {
	IEvaluationContext forkedContext = context.fork();
	for (XExpression initExpression : forLoop.getInitExpressions()) {
		internalEvaluate(initExpression, forkedContext, indicator);
	}
	XExpression expression = forLoop.getExpression();
	Object condition = expression == null ? Boolean.TRUE : internalEvaluate(expression, forkedContext, indicator);
	while (Boolean.TRUE.equals(condition)) {
		internalEvaluate(forLoop.getEachExpression(), forkedContext, indicator);
		for (XExpression updateExpression : forLoop.getUpdateExpressions()) {
			internalEvaluate(updateExpression, forkedContext, indicator);
		}
		condition = expression == null ? Boolean.TRUE : internalEvaluate(expression, forkedContext, indicator);
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:XbaseInterpreter.java

示例3: testBasicForLoopExpression_0

import org.eclipse.xtext.xbase.XBasicForLoopExpression; //导入方法依赖的package包/类
@Test public void testBasicForLoopExpression_0() throws Exception {
	XBasicForLoopExpression loop = (XBasicForLoopExpression) expression("for(var i = 0; i < 10; i = i + 1) {}");
	for (XExpression initExpression : loop.getInitExpressions()) {
		assertExpected(null, initExpression);	
	}
	assertExpected("boolean", loop.getExpression());
	for (XExpression updateExpression : loop.getUpdateExpressions()) {
		assertExpected(null, updateExpression);	
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseExpectedTypeProviderTest.java

示例4: testBasicForLoopExpression_1

import org.eclipse.xtext.xbase.XBasicForLoopExpression; //导入方法依赖的package包/类
@Test public void testBasicForLoopExpression_1() throws Exception {
	XBasicForLoopExpression loop = (XBasicForLoopExpression) expression("for(null; null; null) {}");
	for (XExpression initExpression : loop.getInitExpressions()) {
		assertExpected(null, initExpression);	
	}
	assertExpected("boolean", loop.getExpression());
	for (XExpression updateExpression : loop.getUpdateExpressions()) {
		assertExpected(null, updateExpression);	
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseExpectedTypeProviderTest.java

示例5: testBasicForLoopExpression_2

import org.eclipse.xtext.xbase.XBasicForLoopExpression; //导入方法依赖的package包/类
@Test public void testBasicForLoopExpression_2() throws Exception {
	XBasicForLoopExpression loop = (XBasicForLoopExpression) expression("for(;;) {}");
	for (XExpression initExpression : loop.getInitExpressions()) {
		assertExpected(null, initExpression);	
	}
	assertExpected(null, loop.getExpression());
	for (XExpression updateExpression : loop.getUpdateExpressions()) {
		assertExpected(null, updateExpression);	
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseExpectedTypeProviderTest.java

示例6: toJavaBasicForStatement

import org.eclipse.xtext.xbase.XBasicForLoopExpression; //导入方法依赖的package包/类
/**
 * @param isReferenced unused in this context but necessary for dispatch signature 
 */
protected void toJavaBasicForStatement(XBasicForLoopExpression expr, ITreeAppendable b, boolean isReferenced) {
	ITreeAppendable loopAppendable = b.trace(expr);
	loopAppendable.openPseudoScope();
	loopAppendable.newLine().append("for (");
	
	EList<XExpression> initExpressions = expr.getInitExpressions();
	XExpression firstInitExpression = IterableExtensions.head(initExpressions);
	if (firstInitExpression instanceof XVariableDeclaration) {
		XVariableDeclaration variableDeclaration = (XVariableDeclaration) firstInitExpression;
		LightweightTypeReference type = appendVariableTypeAndName(variableDeclaration, loopAppendable);
		loopAppendable.append(" = ");
		if (variableDeclaration.getRight() != null) {
			compileAsJavaExpression(variableDeclaration.getRight(), loopAppendable, type);
		} else {
			appendDefaultLiteral(loopAppendable, type);
		}
	} else {
		for (int i = 0; i < initExpressions.size(); i++) {
			if (i != 0) {
				loopAppendable.append(", ");
			}
			XExpression initExpression = initExpressions.get(i);
			compileAsJavaExpression(initExpression, loopAppendable, getLightweightType(initExpression));
		}
	}
	
	loopAppendable.append(";");
	
	XExpression expression = expr.getExpression();
	if (expression != null) {
		loopAppendable.append(" ");
		internalToJavaExpression(expression, loopAppendable);
	}
	loopAppendable.append(";");
	
	EList<XExpression> updateExpressions = expr.getUpdateExpressions();
	for (int i = 0; i < updateExpressions.size(); i++) {
		if (i != 0) {
			loopAppendable.append(",");
		}
		loopAppendable.append(" ");
		XExpression updateExpression = updateExpressions.get(i);
		internalToJavaExpression(updateExpression, loopAppendable);
	}
	loopAppendable.append(") {").increaseIndentation();
	
	XExpression eachExpression = expr.getEachExpression();
	internalToJavaStatement(eachExpression, loopAppendable, false);
	
	loopAppendable.decreaseIndentation().newLine().append("}");
	loopAppendable.closeScope();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:56,代码来源:XbaseCompiler.java

示例7: toJavaWhileStatement

import org.eclipse.xtext.xbase.XBasicForLoopExpression; //导入方法依赖的package包/类
protected void toJavaWhileStatement(XBasicForLoopExpression expr, ITreeAppendable b, boolean isReferenced) {
	ITreeAppendable loopAppendable = b.trace(expr);
	
	boolean needBraces = !bracesAreAddedByOuterStructure(expr);
	if (needBraces) {
		loopAppendable.newLine().increaseIndentation().append("{");
		loopAppendable.openPseudoScope();
	}
	
	EList<XExpression> initExpressions = expr.getInitExpressions();
	for (int i = 0; i < initExpressions.size(); i++) {
		XExpression initExpression = initExpressions.get(i);
		if (i < initExpressions.size() - 1) {
			internalToJavaStatement(initExpression, loopAppendable, false);
		} else {
			internalToJavaStatement(initExpression, loopAppendable, isReferenced);
			if (isReferenced) {
				loopAppendable.newLine().append(getVarName(expr, loopAppendable)).append(" = (");
				internalToConvertedExpression(initExpression, loopAppendable, getLightweightType(expr));
				loopAppendable.append(");");
			}
		}
	}

	final String varName = loopAppendable.declareSyntheticVariable(expr, "_while");
	
	XExpression expression = expr.getExpression();
	if (expression != null) {
		internalToJavaStatement(expression, loopAppendable, true);
		loopAppendable.newLine().append("boolean ").append(varName).append(" = ");
		internalToJavaExpression(expression, loopAppendable);
		loopAppendable.append(";");
	} else {
		loopAppendable.newLine().append("boolean ").append(varName).append(" = true;");
	}
	loopAppendable.newLine();
	loopAppendable.append("while (");
	loopAppendable.append(varName);
	loopAppendable.append(") {").increaseIndentation();
	loopAppendable.openPseudoScope();
	
	XExpression eachExpression = expr.getEachExpression();
	internalToJavaStatement(eachExpression, loopAppendable, false);
	
	EList<XExpression> updateExpressions = expr.getUpdateExpressions();
	if (!updateExpressions.isEmpty()) {
		for (XExpression updateExpression : updateExpressions) {
			internalToJavaStatement(updateExpression, loopAppendable, false);
		}
	}
	
	if (!isEarlyExit(eachExpression)) {
		if (expression != null) {
			internalToJavaStatement(expression, loopAppendable, true);
			loopAppendable.newLine().append(varName).append(" = ");
			internalToJavaExpression(expression, loopAppendable);
			loopAppendable.append(";");
		} else {
			loopAppendable.newLine().append(varName).append(" = true;");
		}
	}
	
	loopAppendable.closeScope();
	loopAppendable.decreaseIndentation().newLine().append("}");
	
	if (needBraces) {
		loopAppendable.closeScope();
		loopAppendable.decreaseIndentation().newLine().append("}");
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:71,代码来源:XbaseCompiler.java


注:本文中的org.eclipse.xtext.xbase.XBasicForLoopExpression.getUpdateExpressions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。