本文整理汇总了Java中org.eclipse.xtext.xbase.XInstanceOfExpression.getType方法的典型用法代码示例。如果您正苦于以下问题:Java XInstanceOfExpression.getType方法的具体用法?Java XInstanceOfExpression.getType怎么用?Java XInstanceOfExpression.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.xbase.XInstanceOfExpression
的用法示例。
在下文中一共展示了XInstanceOfExpression.getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _computeTypes
import org.eclipse.xtext.xbase.XInstanceOfExpression; //导入方法依赖的package包/类
protected void _computeTypes(XInstanceOfExpression object, ITypeComputationState state) {
ITypeComputationState expressionState = state.withExpectation(state.getReferenceOwner().newReferenceToObject());
expressionState.computeTypes(object.getExpression());
JvmTypeReference type = object.getType();
if (type != null && type.getType() instanceof JvmTypeParameter) {
LightweightTypeReference lightweightReference = state.getReferenceOwner().toLightweightTypeReference(type);
LightweightTypeReference rawTypeRef = lightweightReference.getRawTypeReference();
state.addDiagnostic(new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.INVALID_USE_OF_TYPE_PARAMETER,
"Cannot perform instanceof check against type parameter "+lightweightReference.getHumanReadableName()+". Use its erasure "+rawTypeRef.getHumanReadableName()+" instead since further generic type information will be erased at runtime.",
object.getType(),
null,
-1,
new String[] {
}));
}
LightweightTypeReference bool = getRawTypeForName(Boolean.TYPE, state);
state.acceptActualType(bool);
}
示例2: reassignCheckedType
import org.eclipse.xtext.xbase.XInstanceOfExpression; //导入方法依赖的package包/类
/**
* If the condition is a {@link XInstanceOfExpression type check}, the checked expression
* will be automatically casted in the returned state.
*/
protected ITypeComputationState reassignCheckedType(XExpression condition, /* @Nullable */ XExpression guardedExpression, ITypeComputationState state) {
if (condition instanceof XInstanceOfExpression) {
XInstanceOfExpression instanceOfExpression = (XInstanceOfExpression) condition;
JvmTypeReference castedType = instanceOfExpression.getType();
if (castedType != null) {
state = state.withTypeCheckpoint(guardedExpression);
JvmIdentifiableElement refinable = getRefinableCandidate(instanceOfExpression.getExpression(), state);
if (refinable != null) {
state.reassignType(refinable, state.getReferenceOwner().toLightweightTypeReference(castedType));
}
}
}
return state;
}
示例3: checkInstanceOfOrder
import org.eclipse.xtext.xbase.XInstanceOfExpression; //导入方法依赖的package包/类
@Check
public void checkInstanceOfOrder(XIfExpression expression) {
if (isIgnored(IssueCodes.UNREACHABLE_IF_BLOCK)) {
return;
}
if (expression.eContainer() instanceof XIfExpression) {
XIfExpression container = (XIfExpression) expression.eContainer();
if (container.getElse() == expression) {
return;
}
}
List<XExpression> ifParts = collectIfParts(expression, new ArrayList<XExpression>());
ITypeReferenceOwner owner = new StandardTypeReferenceOwner(getServices(), expression);
Multimap<JvmIdentifiableElement, LightweightTypeReference> previousTypeReferences = HashMultimap.create();
for (XExpression ifPart : ifParts) {
if (!(ifPart instanceof XInstanceOfExpression)) {
continue;
}
XInstanceOfExpression instanceOfExpression = (XInstanceOfExpression) ifPart;
if (!(instanceOfExpression.getExpression() instanceof XAbstractFeatureCall)) {
continue;
}
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) instanceOfExpression.getExpression();
JvmIdentifiableElement feature = featureCall.getFeature();
if (!(feature instanceof XVariableDeclaration)
&& !(feature instanceof JvmField)
&& !(feature instanceof JvmFormalParameter)) {
continue;
}
JvmTypeReference type = instanceOfExpression.getType();
LightweightTypeReference actualType = owner.toLightweightTypeReference(type);
if (actualType == null) {
continue;
}
if (isHandled(actualType, previousTypeReferences.get(feature))) {
addIssue("Unreachable code: The if condition can never match. It is already handled by a previous condition.", type, IssueCodes.UNREACHABLE_IF_BLOCK);
continue;
}
previousTypeReferences.put(feature, actualType);
}
}