• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java XTypeLiteral类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



XTypeLiteral类属于org.eclipse.xtext.xbase包,在下文中一共展示了XTypeLiteral类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: _computeTypes

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
protected void _computeTypes(XTypeLiteral object, ITypeComputationState state) {
	JvmType type = object.getType();
	if (type == null) {
		return;
	}
	checkTypeParameterNotAllowedAsLiteral(object, type, state);
	ITypeReferenceOwner owner = state.getReferenceOwner();
	LightweightTypeReference clazz = owner.newParameterizedTypeReference(type);
	for (int i = 0; i < object.getArrayDimensions().size(); i++) {
		clazz = owner.newArrayTypeReference(clazz);
	}
	if (object.getArrayDimensions().isEmpty()) {
		if (clazz.isPrimitiveVoid()) {
			clazz = state.getReferenceOwner().newReferenceTo(Void.class);
		} else {
			clazz = clazz.getWrapperTypeIfPrimitive();
		}
	}
	LightweightTypeReference result = owner.newReferenceTo(Class.class);
	if (result instanceof ParameterizedTypeReference) {
		ParameterizedTypeReference parameterizedTypeReference = (ParameterizedTypeReference) result;
		parameterizedTypeReference.addTypeArgument(clazz);
	}
	state.acceptActualType(result);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:XbaseTypeComputer.java


示例2: internalToConvertedExpression

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@Override
protected void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) {
	if (obj instanceof XStringLiteral) {
		_toJavaExpression((XStringLiteral) obj, appendable);
	} else if (obj instanceof XNumberLiteral) {
		_toJavaExpression((XNumberLiteral) obj, appendable);
	} else if (obj instanceof XNullLiteral) {
		_toJavaExpression((XNullLiteral) obj, appendable);
	} else if (obj instanceof XBooleanLiteral) {
		_toJavaExpression((XBooleanLiteral) obj, appendable);
	} else if (obj instanceof XTypeLiteral) {
		_toJavaExpression((XTypeLiteral) obj, appendable);
	} else {
		super.internalToConvertedExpression(obj, appendable);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:LiteralsCompiler.java


示例3: doInternalToJavaStatement

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@Override
protected void doInternalToJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced) {
	if (obj instanceof XStringLiteral) {
		_toJavaStatement((XStringLiteral) obj, appendable, isReferenced);
	} else if (obj instanceof XNumberLiteral) {
		_toJavaStatement((XNumberLiteral) obj, appendable, isReferenced);
	} else if (obj instanceof XNullLiteral) {
		_toJavaStatement((XNullLiteral) obj, appendable, isReferenced);
	} else if (obj instanceof XBooleanLiteral) {
		_toJavaStatement((XBooleanLiteral) obj, appendable, isReferenced);
	} else if (obj instanceof XTypeLiteral) {
		_toJavaStatement((XTypeLiteral) obj, appendable, isReferenced);
	} else {
		super.doInternalToJavaStatement(obj, appendable, isReferenced);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:LiteralsCompiler.java


示例4: isConstant

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
public boolean isConstant(final XExpression expression) {
  if (expression instanceof XAbstractFeatureCall) {
    return _isConstant((XAbstractFeatureCall)expression);
  } else if (expression instanceof XBooleanLiteral) {
    return _isConstant((XBooleanLiteral)expression);
  } else if (expression instanceof XCastedExpression) {
    return _isConstant((XCastedExpression)expression);
  } else if (expression instanceof XNumberLiteral) {
    return _isConstant((XNumberLiteral)expression);
  } else if (expression instanceof XStringLiteral) {
    return _isConstant((XStringLiteral)expression);
  } else if (expression instanceof XTypeLiteral) {
    return _isConstant((XTypeLiteral)expression);
  } else if (expression != null) {
    return _isConstant(expression);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(expression).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:ConstantExpressionValidator.java


示例5: internalEvaluate

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
public Object internalEvaluate(final XExpression it, final Context ctx) {
  if (it instanceof XBinaryOperation) {
    return _internalEvaluate((XBinaryOperation)it, ctx);
  } else if (it instanceof XUnaryOperation) {
    return _internalEvaluate((XUnaryOperation)it, ctx);
  } else if (it instanceof XBooleanLiteral) {
    return _internalEvaluate((XBooleanLiteral)it, ctx);
  } else if (it instanceof XCastedExpression) {
    return _internalEvaluate((XCastedExpression)it, ctx);
  } else if (it instanceof XStringLiteral) {
    return _internalEvaluate((XStringLiteral)it, ctx);
  } else if (it instanceof XTypeLiteral) {
    return _internalEvaluate((XTypeLiteral)it, ctx);
  } else if (it instanceof XAnnotation) {
    return _internalEvaluate((XAnnotation)it, ctx);
  } else if (it != null) {
    return _internalEvaluate(it, ctx);
  } else if (it == null) {
    return _internalEvaluate((Void)null, ctx);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, ctx).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:AbstractConstantExpressionsInterpreter.java


示例6: toResolvedOperations

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
public ResolvedFeatures toResolvedOperations(final Class<?> type) {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("typeof(");
    String _canonicalName = type.getCanonicalName();
    _builder.append(_canonicalName);
    _builder.append(")");
    XExpression _expression = this.expression(_builder);
    final XTypeLiteral typeLiteral = ((XTypeLiteral) _expression);
    JvmType _type = typeLiteral.getType();
    final ResolvedFeatures result = this.overrideHelper.getResolvedFeatures(((JvmDeclaredType) _type));
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:ResolvedFeaturesTest.java


示例7: checkDeprecated

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@Check
public void checkDeprecated(XTypeLiteral expression) {
	if (!isIgnored(DEPRECATED_MEMBER_REFERENCE)) {
		JvmType jvmType = expression.getType();
		checkDeprecated(
				jvmType,
				expression,
				XbasePackage.Literals.XTYPE_LITERAL__TYPE);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseValidator.java


示例8: hasSideEffects

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
/**
 * @return whether the expression itself (not its children) possibly causes a side-effect
 */
public boolean hasSideEffects(XExpression expr) {
	if (expr instanceof XClosure
		|| expr instanceof XStringLiteral
		|| expr instanceof XTypeLiteral
		|| expr instanceof XBooleanLiteral
		|| expr instanceof XNumberLiteral
		|| expr instanceof XNullLiteral
		|| expr instanceof XAnnotation
		)
		return false;
	if(expr instanceof XCollectionLiteral) {
		for(XExpression element: ((XCollectionLiteral)expr).getElements()) {
			if(hasSideEffects(element))
				return true;
		}
		return false;
	}
	if (expr instanceof XAbstractFeatureCall) {
		XAbstractFeatureCall featureCall = (XAbstractFeatureCall) expr;
		return hasSideEffects(featureCall, true);
	}
	if (expr instanceof XConstructorCall) {
		XConstructorCall constrCall = (XConstructorCall) expr;
		return findPureAnnotation(constrCall.getConstructor()) == null;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:31,代码来源:XExpressionHelper.java


示例9: isVariableDeclarationRequired

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@Override
protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) {
	if (expr instanceof XBooleanLiteral
		|| expr instanceof XStringLiteral
		|| expr instanceof XNumberLiteral
		|| expr instanceof XTypeLiteral
		|| expr instanceof XClosure
		|| expr instanceof XNullLiteral)
		return false;
	return super.isVariableDeclarationRequired(expr,b, recursive);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:LiteralsCompiler.java


示例10: _doEvaluate

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
/**
 * @param context unused in this context but required for dispatching
 * @param indicator unused in this context but required for dispatching
 */
protected Object _doEvaluate(XTypeLiteral literal, IEvaluationContext context, CancelIndicator indicator) {
	if (literal.getType() == null || literal.getType().eIsProxy()) {
		List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(literal,
				XbasePackage.Literals.XTYPE_LITERAL__TYPE);
		// TODO cleanup
		if (nodesForFeature.isEmpty())
			throw new EvaluationException(new ClassNotFoundException());
		throw new EvaluationException(new ClassNotFoundException(nodesForFeature.get(0).getText()));
	}
	JvmType type = literal.getType();
	Object result = translateJvmTypeToResult(type, literal.getArrayDimensions().size());
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:XbaseInterpreter.java


示例11: internalEvaluate

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
public EvaluationResult internalEvaluate(final XExpression it, final EvaluationContext context) {
  if (it instanceof XBinaryOperation) {
    return _internalEvaluate((XBinaryOperation)it, context);
  } else if (it instanceof XUnaryOperation) {
    return _internalEvaluate((XUnaryOperation)it, context);
  } else if (it instanceof XAbstractFeatureCall) {
    return _internalEvaluate((XAbstractFeatureCall)it, context);
  } else if (it instanceof XBooleanLiteral) {
    return _internalEvaluate((XBooleanLiteral)it, context);
  } else if (it instanceof XCastedExpression) {
    return _internalEvaluate((XCastedExpression)it, context);
  } else if (it instanceof XNullLiteral) {
    return _internalEvaluate((XNullLiteral)it, context);
  } else if (it instanceof XNumberLiteral) {
    return _internalEvaluate((XNumberLiteral)it, context);
  } else if (it instanceof XStringLiteral) {
    return _internalEvaluate((XStringLiteral)it, context);
  } else if (it instanceof XTypeLiteral) {
    return _internalEvaluate((XTypeLiteral)it, context);
  } else if (it != null) {
    return _internalEvaluate(it, context);
  } else if (it == null) {
    return _internalEvaluate((Void)null, context);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, context).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:29,代码来源:ConstantConditionsInterpreter.java


示例12: internalEvaluate

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
public Object internalEvaluate(final XExpression it, final Context ctx) {
  if (it instanceof XBinaryOperation) {
    return _internalEvaluate((XBinaryOperation)it, ctx);
  } else if (it instanceof XUnaryOperation) {
    return _internalEvaluate((XUnaryOperation)it, ctx);
  } else if (it instanceof XAbstractFeatureCall) {
    return _internalEvaluate((XAbstractFeatureCall)it, ctx);
  } else if (it instanceof XBooleanLiteral) {
    return _internalEvaluate((XBooleanLiteral)it, ctx);
  } else if (it instanceof XCastedExpression) {
    return _internalEvaluate((XCastedExpression)it, ctx);
  } else if (it instanceof XNumberLiteral) {
    return _internalEvaluate((XNumberLiteral)it, ctx);
  } else if (it instanceof XStringLiteral) {
    return _internalEvaluate((XStringLiteral)it, ctx);
  } else if (it instanceof XTypeLiteral) {
    return _internalEvaluate((XTypeLiteral)it, ctx);
  } else if (it instanceof XAnnotation) {
    return _internalEvaluate((XAnnotation)it, ctx);
  } else if (it != null) {
    return _internalEvaluate(it, ctx);
  } else if (it == null) {
    return _internalEvaluate((Void)null, ctx);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, ctx).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:29,代码来源:SwitchConstantExpressionsInterpreter.java


示例13: visit

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
public void visit(final EObject jvmType, final INode originNode, final ImportsAcceptor acceptor) {
  if (jvmType instanceof JvmGenericType) {
    _visit((JvmGenericType)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof JvmDeclaredType) {
    _visit((JvmDeclaredType)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XFeatureCall) {
    _visit((XFeatureCall)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XMemberFeatureCall) {
    _visit((XMemberFeatureCall)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XAbstractFeatureCall) {
    _visit((XAbstractFeatureCall)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XConstructorCall) {
    _visit((XConstructorCall)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XTypeLiteral) {
    _visit((XTypeLiteral)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XAnnotation) {
    _visit((XAnnotation)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof JvmTypeReference) {
    _visit((JvmTypeReference)jvmType, originNode, acceptor);
    return;
  } else if (jvmType != null) {
    _visit(jvmType, originNode, acceptor);
    return;
  } else if (jvmType == null) {
    _visit((Void)null, originNode, acceptor);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(jvmType, originNode, acceptor).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:40,代码来源:ImportsCollector.java


示例14: testReferenceToString_0

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@Test
public void testReferenceToString_0() throws Exception {
	XExpression expr = expression("typeof(foo.String)", true);
	assertTrue(expr instanceof XTypeLiteral);
	XTypeLiteral operator = (XTypeLiteral) expr;
	JvmType type = operator.getType();
	JvmTypeReference reference = this.typeReferences.createTypeRef(type);
	assertEquals("String", this.uiStrings.referenceToString(reference, "the-default-value"));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:UIStringsTest.java


示例15: testReferenceToString_1

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@Test
public void testReferenceToString_1() throws Exception {
	XExpression expr = expression("typeof(String)", true);
	assertTrue(expr instanceof XTypeLiteral);
	XTypeLiteral operator = (XTypeLiteral) expr;
	JvmType type = operator.getType();
	JvmTypeReference reference = this.typeReferences.createTypeRef(type);
	assertEquals("String", this.uiStrings.referenceToString(reference, "the-default-value"));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:UIStringsTest.java


示例16: testAppendUnresolvedType

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@Test
public void testAppendUnresolvedType() {
  try {
    XExpression _expression = this.expression("typeof(  \tUnresolved\n)");
    final XTypeLiteral e = ((XTypeLiteral) _expression);
    final ErrorTreeAppendable app = this.createErrorTreeAppendable(e);
    app.append(e.getType());
    Assert.assertEquals("Unresolved", app.getContent());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:ErrorTreeAppendableTest.java


示例17: sequence_XTypeLiteral

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@Deprecated
protected void sequence_XTypeLiteral(EObject context, XTypeLiteral semanticObject) {
	sequence_XTypeLiteral(createContext(context, semanticObject), semanticObject);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:5,代码来源:AbstractXbaseSemanticSequencer.java


示例18: checkTypeLiteral

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@Check
public void checkTypeLiteral(XTypeLiteral typeLiteral) {
	if (!typeLiteral.getArrayDimensions().isEmpty() && typeLiteral.getType().getIdentifier().equals("void")) {
		error("'void"+Joiner.on("").join(typeLiteral.getArrayDimensions()) +"' is not a valid type", null, INVALID_TYPE);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:7,代码来源:XbaseValidator.java


示例19: computeTypes

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:57,代码来源:XbaseTypeComputer.java


示例20: _toJavaExpression

import org.eclipse.xtext.xbase.XTypeLiteral; //导入依赖的package包/类
public void _toJavaExpression(XTypeLiteral expr, ITreeAppendable b) {
	b.append(expr.getType()).append(Joiner.on("").join(expr.getArrayDimensions())).append(".class");
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:4,代码来源:LiteralsCompiler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BackRefNode类代码示例发布时间:2022-05-22
下一篇:
Java IntObjectHashMap类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap