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


Java XVariableDeclaration.getRight方法代码示例

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


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

示例1: _toJavaStatement

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
/**
 * @param isReferenced unused in this context but necessary for dispatch signature 
 */
protected void _toJavaStatement(XVariableDeclaration varDeclaration, ITreeAppendable b, boolean isReferenced) {
	if (varDeclaration.getRight() != null) {
		internalToJavaStatement(varDeclaration.getRight(), b, true);
	}
	b.newLine();
	LightweightTypeReference type = appendVariableTypeAndName(varDeclaration, b);
	b.append(" = ");
	if (varDeclaration.getRight() != null) {
		internalToConvertedExpression(varDeclaration.getRight(), b, type);
	} else {
		appendDefaultLiteral(b, type);
	}
	b.append(";");
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:XbaseCompiler.java

示例2: _doEvaluate

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
protected Object _doEvaluate(XVariableDeclaration variableDecl, IEvaluationContext context, CancelIndicator indicator) {
	Object initialValue = null;
	if (variableDecl.getRight()!=null) {
		initialValue = internalEvaluate(variableDecl.getRight(), context, indicator);
	} else {
		if (services.getPrimitives().isPrimitive(variableDecl.getType())) {
			Primitive primitiveKind = services.getPrimitives().primitiveKind((JvmPrimitiveType) variableDecl.getType().getType());
			switch(primitiveKind) {
				case Boolean:
					initialValue = Boolean.FALSE; break;
				case Char:
					initialValue = Character.valueOf((char) 0); break;
				case Double:
					initialValue = Double.valueOf(0d); break;
				case Byte:
					initialValue = Byte.valueOf((byte) 0); break;
				case Float:
					initialValue = Float.valueOf(0f); break;
				case Int:
					initialValue = Integer.valueOf(0); break;
				case Long:
					initialValue = Long.valueOf(0L); break;
				case Short:
					initialValue = Short.valueOf((short) 0); break;
				case Void:
					throw new IllegalStateException("Void is not a valid variable type.");
				default:
					throw new IllegalStateException("Unknown primitive type " + primitiveKind);
			}
		}
	}
	context.newValue(QualifiedName.create(variableDecl.getName()), initialValue);
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:35,代码来源:XbaseInterpreter.java

示例3: testTypeParamInference_09

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Test public void testTypeParamInference_09() throws Exception {
	XBlockExpression block = (XBlockExpression) expression("{ var this = new testdata.ClosureClient() var Integer i = invoke1([e|null],'foo') }");
	XVariableDeclaration var = (XVariableDeclaration) block.getExpressions().get(1);
	XFeatureCall fc = (XFeatureCall) var.getRight();
	final XExpression closure = fc.getFeatureCallArguments().get(0);
	assertExpected(Functions.class.getCanonicalName()+"$Function1<java.lang.String, java.lang.Integer>", closure);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseExpectedTypeProviderTest.java

示例4: testImplicitLambdaParameter

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Test
public void testImplicitLambdaParameter() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val Comparable<String> c = [ length ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("c.toString");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    XExpression _parse = this._parseHelper.parse(_builder);
    final XBlockExpression block = ((XBlockExpression) _parse);
    Resource _eResource = block.eResource();
    final BatchLinkableResource resource = ((BatchLinkableResource) _eResource);
    resource.resolveLazyCrossReferences(null);
    XExpression _head = IterableExtensions.<XExpression>head(block.getExpressions());
    final XVariableDeclaration assignment = ((XVariableDeclaration) _head);
    XExpression _right = assignment.getRight();
    final XClosure lambda = ((XClosure) _right);
    final JvmFormalParameter implicitParameter = IterableExtensions.<JvmFormalParameter>head(lambda.getImplicitFormalParameters());
    Assert.assertEquals("String", implicitParameter.getParameterType().getSimpleName());
    resource.update(0, 0, "");
    Assert.assertNull(implicitParameter.eResource());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:32,代码来源:BeforeLinkingTest.java

示例5: testStaticFeatureCall_26

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Ignore("TODO eager binding of type arguments to expectation")
@Test public void testStaticFeatureCall_26() throws Exception {
	XBlockExpression block = (XBlockExpression) expression("{ val Iterable<CharSequence> iterable = testdata.MethodOverrides4.staticM5(null) }");
	XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0);
	XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight();
	assertEquals("testdata.MethodOverrides3.staticM5(T)", featureCall.getFeature().getIdentifier());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:AbstractXbaseLinkingTest.java

示例6: testStaticFeatureCall_08

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Ignore("TODO eager binding of type arguments to expectation")
@Test public void testStaticFeatureCall_08() throws Exception {
	XBlockExpression block = (XBlockExpression) expression("{ val Iterable<CharSequence> iterable = testdata::MethodOverrides4::staticM5(null) }");
	XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0);
	XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight();
	assertEquals("testdata.MethodOverrides3.staticM5(T)", featureCall.getFeature().getIdentifier());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:AbstractXbaseLinkingTest.java

示例7: testStaticFeatureCall_17

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Ignore("TODO eager binding of type arguments to expectation")
@Test public void testStaticFeatureCall_17() throws Exception {
	XBlockExpression block = (XBlockExpression) expression("{ val Iterable<CharSequence> iterable = testdata.MethodOverrides4::staticM5(null) }");
	XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0);
	XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight();
	assertEquals("testdata.MethodOverrides3.staticM5(T)", featureCall.getFeature().getIdentifier());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:AbstractXbaseLinkingTest.java

示例8: getContext

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
/**
 * Retrieves the evaluation context (= set of variables) for a rule. The context is shared with all rules in the same model (= rule file).
 * 
 * @param rule the rule to get the context for
 * @return the evaluation context
 */
public static synchronized IEvaluationContext getContext(Rule rule) {
    RuleModel ruleModel = (RuleModel) rule.eContainer();

    // check if a context already exists on the resource
    for(Adapter adapter : ruleModel.eAdapters()) {
		if(adapter instanceof RuleContextAdapter) {
			return ((RuleContextAdapter) adapter).getContext();
		}
	}
	
	// no evaluation context found, so create a new one
    IEvaluationContext evaluationContext = contextProvider.get();
    for(XExpression expr : ruleModel.getVariables()) {
    	if (expr instanceof XVariableDeclaration) {
			XVariableDeclaration var = (XVariableDeclaration) expr;
			try {
		    	Object initialValue = var.getRight()==null ? null : scriptEngine.newScriptFromXExpression(var.getRight()).execute();
				evaluationContext.newValue(QualifiedName.create(var.getName()), initialValue);
			} catch (ScriptExecutionException e) {
				logger.warn("Variable '{}' on rule file '{}' cannot be initialized with value '{}': {}", 
						new String[] { var.getName(), ruleModel.eResource().getURI().path(), var.getRight().toString(), e.getMessage() });
			}
		}
    }
    ruleModel.eAdapters().add(new RuleContextAdapter(evaluationContext));
	return evaluationContext;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:34,代码来源:RuleContextHelper.java

示例9: testStaticFeatureCall_31

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Test public void testStaticFeatureCall_31() throws Exception {
	XBlockExpression block = (XBlockExpression) expression("{ val boolean x = nested.NestedTypes.primitive}");
	XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0);
	XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight();
	assertEquals("nested.NestedTypes$primitive", featureCall.getFeature().getIdentifier());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:7,代码来源:AbstractXbaseLinkingTest.java

示例10: toJavaBasicForStatement

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的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

示例11: testStaticFeatureCall_28

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Test public void testStaticFeatureCall_28() throws Exception {
	XBlockExpression block = (XBlockExpression) expression("{ val Iterable<Object> iterable = testdata.MethodOverrides4.staticM5(null) }");
	XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0);
	XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight();
	assertEquals("testdata.MethodOverrides4.staticM5(T)", featureCall.getFeature().getIdentifier());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:7,代码来源:AbstractXbaseLinkingTest.java

示例12: testStaticFeatureCall_27

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Test public void testStaticFeatureCall_27() throws Exception {
	XBlockExpression block = (XBlockExpression) expression("{ val Iterable<Object> iterable = testdata.MethodOverrides4.staticM5(null) }");
	XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0);
	XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight();
	assertEquals("testdata.MethodOverrides4.staticM5(T)", featureCall.getFeature().getIdentifier());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:7,代码来源:AbstractXbaseLinkingTest.java

示例13: expressionWithExpectedType

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
protected XExpression expressionWithExpectedType(String expression, String expectedType) throws Exception {
	XBlockExpression blockExpression = (XBlockExpression) expression("{ var " + expectedType + " foo = " + expression + " }");
	XVariableDeclaration variableDeclaration = (XVariableDeclaration) blockExpression.getExpressions().get(0);
	return variableDeclaration.getRight();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:6,代码来源:XbaseExpectedTypeProviderTest.java

示例14: testStaticFeatureCall_06

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Test public void testStaticFeatureCall_06() throws Exception {
	XBlockExpression block = (XBlockExpression) expression("{ val iterable = testdata::MethodOverrides4::staticM5(null) }");
	XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0);
	XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight();
	assertEquals("testdata.MethodOverrides4.staticM5(T)", featureCall.getFeature().getIdentifier());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:7,代码来源:AbstractXbaseLinkingTest.java

示例15: testStaticFeatureCall_07

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Test public void testStaticFeatureCall_07() throws Exception {
	XBlockExpression block = (XBlockExpression) expression("{ val Iterable<java.io.Serializable> iterable = testdata::MethodOverrides4::staticM5(null) }");
	XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0);
	XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight();
	assertEquals("testdata.MethodOverrides4.staticM5(T)", featureCall.getFeature().getIdentifier());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:7,代码来源:AbstractXbaseLinkingTest.java


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