use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class ExceptionAnalyser method getScriptErrors.
@Override
protected List<Diagnostic> getScriptErrors(Script script) {
EcoreUtil.resolveAll(script.eResource());
List<Diagnostic> diagnostics = super.getScriptErrors(script);
Iterator<Expression> expressions = Iterators.filter(EcoreUtil2.eAll(script), Expression.class);
List<Diagnostic> result = Lists.<Diagnostic>newArrayList(Iterables.filter(diagnostics, ExceptionDiagnostic.class));
while (expressions.hasNext()) {
Expression expression = expressions.next();
RuleEnvironment ruleEnvironment = RuleEnvironmentExtensions.newRuleEnvironment(expression);
Result<TypeRef> type = typeSystem.type(ruleEnvironment, expression);
if (type.getRuleFailedException() != null) {
Throwable cause = Throwables.getRootCause(type.getRuleFailedException());
if (!(cause instanceof RuleFailedException)) {
if (cause instanceof Exception) {
result.add(new ExceptionDiagnostic((Exception) cause));
} else {
throw new RuntimeException(cause);
}
}
}
}
validator.validate(script.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
return result;
}
use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class InternalTypeSystem method substTypeVariablesImpl.
protected Result<TypeArgument> substTypeVariablesImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ParameterizedTypeRef typeRef) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeArgument> _result_ = applyRuleSubstTypeVariablesInParameterizedTypeRef(G, _subtrace_, typeRef);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("substTypeVariablesInParameterizedTypeRef") + stringRepForEnv(G) + " |- " + stringRep(typeRef) + " ~> " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleSubstTypeVariablesInParameterizedTypeRef) {
substTypeVariablesThrowException(ruleName("substTypeVariablesInParameterizedTypeRef") + stringRepForEnv(G) + " |- " + stringRep(typeRef) + " ~> " + "TypeRef", SUBSTTYPEVARIABLESINPARAMETERIZEDTYPEREF, e_applyRuleSubstTypeVariablesInParameterizedTypeRef, typeRef, new ErrorInformation[] { new ErrorInformation(typeRef) });
return null;
}
}
use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class InternalTypeSystem method expectedTypeInImpl.
protected Result<TypeRef> expectedTypeInImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ReturnStatement stmt, final Expression expression) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleExpectedTypeInReturnStatement(G, _subtrace_, stmt, expression);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("expectedTypeInReturnStatement") + stringRepForEnv(G) + " |- " + stringRep(stmt) + " |> " + stringRep(expression) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleExpectedTypeInReturnStatement) {
expectedTypeInThrowException(ruleName("expectedTypeInReturnStatement") + stringRepForEnv(G) + " |- " + stringRep(stmt) + " |> " + stringRep(expression) + " : " + "TypeRef", EXPECTEDTYPEINRETURNSTATEMENT, e_applyRuleExpectedTypeInReturnStatement, stmt, expression, new ErrorInformation[] { new ErrorInformation(stmt), new ErrorInformation(expression) });
return null;
}
}
use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class InternalTypeSystem method upperBoundImpl.
protected Result<TypeRef> upperBoundImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FunctionTypeRef F) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleUpperBoundFunctionTypeRef(G, _subtrace_, F);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("upperBoundFunctionTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(F) + " /\\ " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleUpperBoundFunctionTypeRef) {
upperBoundThrowException(ruleName("upperBoundFunctionTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(F) + " /\\ " + "TypeRef", UPPERBOUNDFUNCTIONTYPEREF, e_applyRuleUpperBoundFunctionTypeRef, F, new ErrorInformation[] { new ErrorInformation(F) });
return null;
}
}
use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class InternalTypeSystem method upperBoundImpl.
protected Result<TypeRef> upperBoundImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final IntersectionTypeExpression I) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleUpperBoundIntersectionTypeExpression(G, _subtrace_, I);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("upperBoundIntersectionTypeExpression") + stringRepForEnv(G) + " |~ " + stringRep(I) + " /\\ " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleUpperBoundIntersectionTypeExpression) {
upperBoundThrowException(ruleName("upperBoundIntersectionTypeExpression") + stringRepForEnv(G) + " |~ " + stringRep(I) + " /\\ " + "TypeRef", UPPERBOUNDINTERSECTIONTYPEEXPRESSION, e_applyRuleUpperBoundIntersectionTypeExpression, I, new ErrorInformation[] { new ErrorInformation(I) });
return null;
}
}
Aggregations