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


Java XTypeLiteral类代码示例

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


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


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