本文整理汇总了Java中org.eclipse.xtext.xbase.XExpression.eContainingFeature方法的典型用法代码示例。如果您正苦于以下问题:Java XExpression.eContainingFeature方法的具体用法?Java XExpression.eContainingFeature怎么用?Java XExpression.eContainingFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.xbase.XExpression
的用法示例。
在下文中一共展示了XExpression.eContainingFeature方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkInvalidReturnExpression
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
@Check
public void checkInvalidReturnExpression(XExpression expression) {
final EReference contFeature = (EReference) expression.eContainingFeature();
final Map<EReference, EarlyExitKind> map = getDisallowedEarlyExitReferences();
if (map.containsKey(contFeature)) {
EarlyExitKind exitKind = map.get(contFeature);
List<XExpression> returns = newArrayList();
collectExits(expression, returns);
for (XExpression expr : returns) {
if (expr instanceof XReturnExpression && (exitKind == EarlyExitKind.RETURN || exitKind == EarlyExitKind.BOTH)) {
error("A return expression is not allowed in this context.", expr, null, IssueCodes.INVALID_EARLY_EXIT);
}
if (expr instanceof XThrowExpression && (exitKind == EarlyExitKind.THROW || exitKind == EarlyExitKind.BOTH)) {
error("A throw expression is not allowed in this context.", expr, null, IssueCodes.INVALID_EARLY_EXIT);
}
}
}
}
示例2: createTypeDiagnostic
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
protected AbstractDiagnostic createTypeDiagnostic(XExpression expression, LightweightTypeReference actualType, LightweightTypeReference expectedType) {
if (!expectedType.isAny()) {
String actualName = actualType.getSimpleName();
String expectedName = expectedType.getSimpleName();
if (actualName.equals(expectedName)) {
if (expectedType.isAssignableFrom(actualType)) {
return null;
}
}
if (expression.eContainingFeature() == XbasePackage.Literals.XABSTRACT_FEATURE_CALL__IMPLICIT_FIRST_ARGUMENT) {
return new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.INCOMPATIBLE_TYPES, String.format(
"Type mismatch: cannot convert implicit first argument from %s to %s", actualType.getHumanReadableName(), expectedType.getHumanReadableName()),
expression, null, -1, null);
} else {
return new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.INCOMPATIBLE_TYPES, String.format(
"Type mismatch: cannot convert from %s to %s", actualType.getHumanReadableName(), expectedType.getHumanReadableName()),
expression, null, -1, null);
}
} else {
return new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.INCOMPATIBLE_TYPES, String.format(
"Type mismatch: type %s is not applicable at this location", actualType.getHumanReadableName()), expression, null, -1,
null);
}
}
示例3: isValueExpectedRecursive
import org.eclipse.xtext.xbase.XExpression; //导入方法依赖的package包/类
protected boolean isValueExpectedRecursive(XExpression expr) {
EStructuralFeature feature = expr.eContainingFeature();
EObject container = expr.eContainer();
// is part of block
if (container instanceof XBlockExpression) {
XBlockExpression blockExpression = (XBlockExpression) container;
final List<XExpression> expressions = blockExpression.getExpressions();
if (expressions.get(expressions.size()-1) != expr) {
return false;
}
}
// no expectation cases
if (feature == XbasePackage.Literals.XTRY_CATCH_FINALLY_EXPRESSION__FINALLY_EXPRESSION
|| feature == XbasePackage.Literals.XABSTRACT_WHILE_EXPRESSION__BODY
|| feature == XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION) {
return false;
}
// is value expected
if (container instanceof XAbstractFeatureCall
|| container instanceof XConstructorCall
|| container instanceof XAssignment
|| container instanceof XVariableDeclaration
|| container instanceof XReturnExpression
|| container instanceof XThrowExpression
|| feature == XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION
|| feature == XbasePackage.Literals.XSWITCH_EXPRESSION__SWITCH
|| feature == XbasePackage.Literals.XCASE_PART__CASE
|| feature == XbasePackage.Literals.XIF_EXPRESSION__IF
|| feature == XbasePackage.Literals.XABSTRACT_WHILE_EXPRESSION__PREDICATE
|| feature == XbasePackage.Literals.XBASIC_FOR_LOOP_EXPRESSION__EXPRESSION
|| feature == XbasePackage.Literals.XSYNCHRONIZED_EXPRESSION__PARAM) {
return true;
}
if (isLocalClassSemantics(container) || logicalContainerProvider.getLogicalContainer(expr) != null) {
LightweightTypeReference expectedReturnType = typeResolver.resolveTypes(expr).getExpectedReturnType(expr);
return expectedReturnType == null || !expectedReturnType.isPrimitiveVoid();
}
if (container instanceof XCasePart || container instanceof XCatchClause) {
container = container.eContainer();
}
if (container instanceof XExpression) {
return isValueExpectedRecursive((XExpression) container);
}
return true;
}