本文整理汇总了Java中org.eclipse.xtext.xbase.XThrowExpression类的典型用法代码示例。如果您正苦于以下问题:Java XThrowExpression类的具体用法?Java XThrowExpression怎么用?Java XThrowExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XThrowExpression类属于org.eclipse.xtext.xbase包,在下文中一共展示了XThrowExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkInvalidReturnExpression
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的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);
}
}
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:EarlyExitValidator.java
示例2: checkValidReturn
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
protected void checkValidReturn(XReturnExpression object, ITypeComputationState state) {
// if the expectation comes from a method's return type
// then it is legal, thus we must check if the return is
// contained in a throw expression
if (hasThrowableExpectation(state) &&
EcoreUtil2.getContainerOfType(object, XThrowExpression.class) != null) {
state.addDiagnostic(new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.INVALID_RETURN,
"Invalid return inside throw.",
object,
null,
-1,
new String[] {
}));
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:XbaseTypeComputer.java
示例3: collectExits
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
protected void collectExits(EObject expr, List<XExpression> found) {
if (expr instanceof XReturnExpression) {
found.add((XExpression) expr);
} else if (expr instanceof XThrowExpression) {
found.add((XExpression) expr);
} else if (expr instanceof XClosure) {
return;
}
for (EObject child : expr.eContents()) {
collectExits(child, found);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:EarlyExitValidator.java
示例4: _computeTypes
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
protected void _computeTypes(XThrowExpression object, ITypeComputationState state) {
LightweightTypeReference throwable = getRawTypeForName(Throwable.class, state);
ITypeComputationState expressionState = state.withExpectation(throwable);
ITypeComputationResult types = expressionState.computeTypes(object.getExpression());
LightweightTypeReference thrownException = types.getActualExpressionType();
state.acceptActualType(getPrimitiveVoid(state), ConformanceFlags.NO_IMPLICIT_RETURN | ConformanceFlags.THROWN_EXCEPTION);
if (thrownException != null && !thrownException.isUnknown()) {
if (!state.isIgnored(IssueCodes.UNHANDLED_EXCEPTION) && thrownException.isSubtypeOf(Throwable.class)
&& !thrownException.isSubtypeOf(RuntimeException.class) && !thrownException.isSubtypeOf(Error.class)) {
boolean declarationFound = false;
for (LightweightTypeReference declaredException : state.getExpectedExceptions())
if (declaredException.isAssignableFrom(thrownException)) {
declarationFound = true;
break;
}
if (!declarationFound) {
JvmType exceptionType = thrownException.getNamedType().getType();
state.addDiagnostic(new EObjectDiagnosticImpl(
expressionState.getSeverity(IssueCodes.UNHANDLED_EXCEPTION),
IssueCodes.UNHANDLED_EXCEPTION,
"Unhandled exception type " + exceptionType.getSimpleName(),
object,
XbasePackage.Literals.XTHROW_EXPRESSION__EXPRESSION,
-1,
new String[] {
EcoreUtil.getURI(exceptionType).toString(),
EcoreUtil.getURI(object).toString()
}));
}
}
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:34,代码来源:XbaseTypeComputer.java
示例5: internalToConvertedExpression
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
@Override
protected void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) {
if (obj instanceof XBlockExpression) {
_toJavaExpression((XBlockExpression) obj, appendable);
} else if (obj instanceof XCastedExpression) {
_toJavaExpression((XCastedExpression) obj, appendable);
} else if (obj instanceof XClosure) {
_toJavaExpression((XClosure) obj, appendable);
} else if (obj instanceof XAnnotation) {
_toJavaExpression((XAnnotation) obj, appendable);
} else if (obj instanceof XConstructorCall) {
_toJavaExpression((XConstructorCall) obj, appendable);
} else if (obj instanceof XIfExpression) {
_toJavaExpression((XIfExpression) obj, appendable);
} else if (obj instanceof XInstanceOfExpression) {
_toJavaExpression((XInstanceOfExpression) obj, appendable);
} else if (obj instanceof XSwitchExpression) {
_toJavaExpression((XSwitchExpression) obj, appendable);
} else if (obj instanceof XTryCatchFinallyExpression) {
_toJavaExpression((XTryCatchFinallyExpression) obj, appendable);
} else if (obj instanceof XListLiteral) {
_toJavaExpression((XListLiteral) obj, appendable);
} else if (obj instanceof XSetLiteral) {
_toJavaExpression((XSetLiteral) obj, appendable);
} else if (obj instanceof XSynchronizedExpression) {
_toJavaExpression((XSynchronizedExpression) obj, appendable);
} else if (obj instanceof XReturnExpression) {
_toJavaExpression((XReturnExpression) obj, appendable);
} else if (obj instanceof XThrowExpression) {
_toJavaExpression((XThrowExpression) obj, appendable);
} else {
super.internalToConvertedExpression(obj, appendable);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:35,代码来源:XbaseCompiler.java
示例6: _toJavaStatement
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
/**
* @param isReferenced unused in this context but necessary for dispatch signature
*/
protected void _toJavaStatement(XThrowExpression expr, ITreeAppendable b, boolean isReferenced) {
internalToJavaStatement(expr.getExpression(), b, true);
b.newLine().append("throw ");
internalToConvertedExpression(expr.getExpression(), b, null);
b.append(";");
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:XbaseCompiler.java
示例7: _doEvaluate
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
protected Object _doEvaluate(XThrowExpression throwExpression, IEvaluationContext context, CancelIndicator indicator) {
Object thrown = internalEvaluate(throwExpression.getExpression(), context, indicator);
if (thrown == null) {
return throwNullPointerException(throwExpression, "throwable expression evaluated to 'null'");
}
if (!(thrown instanceof Throwable)) {
return throwClassCastException(throwExpression.getExpression(), thrown, Throwable.class);
}
throw new EvaluationException((Throwable) thrown);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseInterpreter.java
示例8: _format
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
protected void _format(final XThrowExpression expr, @Extension final IFormattableDocument format) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.<XExpression>prepend(expr.getExpression(), _function);
format.<XExpression>format(expr.getExpression());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseFormatter.java
示例9: exitPoints
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
protected Collection<IEarlyExitComputer.ExitPoint> exitPoints(final XExpression expression) {
if (expression instanceof XDoWhileExpression) {
return _exitPoints((XDoWhileExpression)expression);
} else if (expression instanceof XWhileExpression) {
return _exitPoints((XWhileExpression)expression);
} else if (expression instanceof XAbstractFeatureCall) {
return _exitPoints((XAbstractFeatureCall)expression);
} else if (expression instanceof XBasicForLoopExpression) {
return _exitPoints((XBasicForLoopExpression)expression);
} else if (expression instanceof XBlockExpression) {
return _exitPoints((XBlockExpression)expression);
} else if (expression instanceof XConstructorCall) {
return _exitPoints((XConstructorCall)expression);
} else if (expression instanceof XForLoopExpression) {
return _exitPoints((XForLoopExpression)expression);
} else if (expression instanceof XIfExpression) {
return _exitPoints((XIfExpression)expression);
} else if (expression instanceof XReturnExpression) {
return _exitPoints((XReturnExpression)expression);
} else if (expression instanceof XSwitchExpression) {
return _exitPoints((XSwitchExpression)expression);
} else if (expression instanceof XSynchronizedExpression) {
return _exitPoints((XSynchronizedExpression)expression);
} else if (expression instanceof XThrowExpression) {
return _exitPoints((XThrowExpression)expression);
} else if (expression instanceof XTryCatchFinallyExpression) {
return _exitPoints((XTryCatchFinallyExpression)expression);
} else if (expression instanceof XVariableDeclaration) {
return _exitPoints((XVariableDeclaration)expression);
} else if (expression != null) {
return _exitPoints(expression);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(expression).toString());
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:37,代码来源:DefaultEarlyExitComputer.java
示例10: _format
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
protected void _format(final XThrowExpression expr, final FormattableDocument format) {
final Procedure1<FormattingDataInit> _function = (FormattingDataInit it) -> {
it.oneSpace();
};
Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _prepend = this._formattingDataFactory.prepend(this._nodeModelAccess.nodeForEObject(expr.getExpression()), _function);
format.operator_add(_prepend);
this.format(expr.getExpression(), format);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:XbaseFormatter2.java
示例11: hasReturnExpression
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
public boolean hasReturnExpression(final XExpression expression) {
boolean _switchResult = false;
boolean _matched = false;
if (expression instanceof XReturnExpression) {
_matched=true;
_switchResult = true;
}
if (!_matched) {
if (expression instanceof XThrowExpression) {
_matched=true;
_switchResult = true;
}
}
if (!_matched) {
if (expression instanceof XClosure) {
_matched=true;
_switchResult = false;
}
}
if (!_matched) {
final Function1<EObject, Boolean> _function = (EObject content) -> {
boolean _switchResult_1 = false;
boolean _matched_1 = false;
if (content instanceof XExpression) {
_matched_1=true;
_switchResult_1 = this.hasReturnExpression(((XExpression)content));
}
if (!_matched_1) {
_switchResult_1 = false;
}
return Boolean.valueOf(_switchResult_1);
};
_switchResult = IterableExtensions.<EObject>exists(expression.eContents(), _function);
}
return _switchResult;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:37,代码来源:AbstractBatchReturnTypeTest.java
示例12: testUnreachableCode_01
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
@Test public void testUnreachableCode_01() throws Exception {
XBlockExpression expression = (XBlockExpression) expression(
"{" +
" while (false) {" +
" throw new Exception() " +
" }" +
" null" +
"}");
XWhileExpression whileLoop = (XWhileExpression) expression.getExpressions().get(0);
XThrowExpression throwExpression = (XThrowExpression) ((XBlockExpression) whileLoop.getBody()).getExpressions().get(0);
helper.assertError(throwExpression, XbasePackage.Literals.XTHROW_EXPRESSION, UNREACHABLE_CODE);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:ValidationTests.java
示例13: doTestTryCatchExpression
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
protected void doTestTryCatchExpression(XTryCatchFinallyExpression tryEx) {
assertFeatureCall("foo", ((XThrowExpression)tryEx.getExpression()).getExpression());
assertFeatureCall("baz", tryEx.getFinallyExpression());
assertEquals(1,tryEx.getCatchClauses().size());
XCatchClause clause = tryEx.getCatchClauses().get(0);
assertFeatureCall("bar", clause.getExpression());
assertEquals("java.lang.Exception", clause.getDeclaredParam().getParameterType().getIdentifier());
assertEquals("e", clause.getDeclaredParam().getName());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseParserTest.java
示例14: sequence_XThrowExpression
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
/**
* Constraint:
* expression=XExpression
*/
protected void sequence_XThrowExpression(EObject context, XThrowExpression semanticObject) {
if(errorAcceptor != null) {
if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XTHROW_EXPRESSION__EXPRESSION) == ValueTransient.YES)
errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XTHROW_EXPRESSION__EXPRESSION));
}
INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
feeder.accept(grammarAccess.getXThrowExpressionAccess().getExpressionXExpressionParserRuleCall_2_0(), semanticObject.getExpression());
feeder.finish();
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:15,代码来源:AbstractCheckSemanticSequencer.java
示例15: sequence_XThrowExpression
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
@Deprecated
protected void sequence_XThrowExpression(EObject context, XThrowExpression semanticObject) {
sequence_XThrowExpression(createContext(context, semanticObject), semanticObject);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:5,代码来源:AbstractXbaseSemanticSequencer.java
示例16: isValueExpectedRecursive
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的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;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:47,代码来源:XbaseValidator.java
示例17: computeTypes
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的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
示例18: caseXThrowExpression
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
@Override
public Boolean caseXThrowExpression(XThrowExpression object) {
accept(getType(object.getExpression()));
return Boolean.TRUE;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:6,代码来源:ThrownExceptionSwitch.java
示例19: isIntentionalEarlyExit
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
/**
* Returns <code>true</code> for expressions that seem to be early exit expressions, e.g.
* <pre>
* while(condition) {
* if (anotherCondition)
* return value
* changeResultOfFirstCondition
* }
* </pre>
*/
public boolean isIntentionalEarlyExit(/* @Nullable */ XExpression expression) {
if (expression == null) {
return true;
}
if (expression instanceof XBlockExpression) {
XBlockExpression block = (XBlockExpression) expression;
List<XExpression> children = block.getExpressions();
for(XExpression child: children) {
if (isIntentionalEarlyExit(child)) {
return true;
}
}
} else if (expression instanceof XIfExpression) {
return isIntentionalEarlyExit(((XIfExpression) expression).getThen())
|| isIntentionalEarlyExit(((XIfExpression) expression).getElse());
} else if (expression instanceof XSwitchExpression) {
XSwitchExpression switchExpression = (XSwitchExpression) expression;
for(XCasePart caseExpression: switchExpression.getCases()) {
if (isIntentionalEarlyExit(caseExpression.getThen())) {
return true;
}
}
if (isIntentionalEarlyExit(switchExpression.getDefault())) {
return true;
}
} else if (expression instanceof XTryCatchFinallyExpression) {
XTryCatchFinallyExpression tryCatchFinally = (XTryCatchFinallyExpression) expression;
if (isIntentionalEarlyExit(tryCatchFinally.getExpression())) {
for(XCatchClause catchClause: tryCatchFinally.getCatchClauses()) {
if (!isIntentionalEarlyExit(catchClause.getExpression()))
return false;
}
return true;
}
return false;
} else if (expression instanceof XAbstractWhileExpression) {
return isIntentionalEarlyExit(((XAbstractWhileExpression) expression).getBody());
} else if (expression instanceof XForLoopExpression) {
return isIntentionalEarlyExit(((XForLoopExpression) expression).getEachExpression());
} else if (expression instanceof XBasicForLoopExpression) {
return isIntentionalEarlyExit(((XBasicForLoopExpression) expression).getEachExpression());
} else if (expression instanceof XSynchronizedExpression) {
return isIntentionalEarlyExit(((XSynchronizedExpression) expression).getExpression());
}
return expression instanceof XReturnExpression || expression instanceof XThrowExpression;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:57,代码来源:ExtendedEarlyExitComputer.java
示例20: isDefiniteEarlyExit
import org.eclipse.xtext.xbase.XThrowExpression; //导入依赖的package包/类
public boolean isDefiniteEarlyExit(XExpression expression) {
// TODO further improvements
if (expression instanceof XIfExpression) {
XIfExpression ifExpression = (XIfExpression) expression;
return isDefiniteEarlyExit(ifExpression.getThen()) && isDefiniteEarlyExit(ifExpression.getElse());
} else if (expression instanceof XSwitchExpression) {
XSwitchExpression switchExpression = (XSwitchExpression) expression;
if (isDefiniteEarlyExit(switchExpression.getDefault())) {
for(XCasePart caseExpression: switchExpression.getCases()) {
if (!isDefiniteEarlyExit(caseExpression.getThen())) {
return false;
}
}
return true;
}
return false;
} else if (expression instanceof XTryCatchFinallyExpression) {
XTryCatchFinallyExpression tryExpression = (XTryCatchFinallyExpression) expression;
if (isDefiniteEarlyExit(tryExpression.getFinallyExpression())) {
return true;
}
if (isDefiniteEarlyExit(tryExpression.getExpression())) {
for(XCatchClause catchClause: tryExpression.getCatchClauses()) {
if (!isDefiniteEarlyExit(catchClause.getExpression())) {
return false;
}
}
return true;
}
return false;
} else if (expression instanceof XBlockExpression) {
List<XExpression> expressions = ((XBlockExpression) expression).getExpressions();
for(int i = expressions.size() - 1; i >= 0; i--) {
if (isDefiniteEarlyExit(expressions.get(i))) {
return true;
}
}
} else if (expression instanceof XSynchronizedExpression) {
return isDefiniteEarlyExit(((XSynchronizedExpression) expression).getExpression());
}
return expression instanceof XReturnExpression || expression instanceof XThrowExpression;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:43,代码来源:ExtendedEarlyExitComputer.java
注:本文中的org.eclipse.xtext.xbase.XThrowExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论