Search in sources :

Example 1 with Acceptor

use of org.eclipse.xtext.xbase.validation.ImplicitReturnFinder.Acceptor in project xtext-xtend by eclipse.

the class XtendValidator method checkImplicitReturn.

@Check
protected void checkImplicitReturn(final XtendFunction method) {
    if (isIgnored(IMPLICIT_RETURN))
        return;
    JvmOperation jvmOperation = associations.getDirectlyInferredOperation(method);
    IResolvedTypes types = batchTypeResolver.resolveTypes(method);
    if (jvmOperation != null && types.getActualType(jvmOperation).isPrimitiveVoid())
        return;
    implicitReturnFinder.findImplicitReturns(method.getExpression(), new Acceptor() {

        @Override
        public void accept(XExpression implicitReturn) {
            if (method.getExpression() == implicitReturn)
                return;
            addIssue("Implicit return", implicitReturn, IMPLICIT_RETURN);
        }
    });
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) ValidationMessageAcceptor(org.eclipse.xtext.validation.ValidationMessageAcceptor) Acceptor(org.eclipse.xtext.xbase.validation.ImplicitReturnFinder.Acceptor) IResolvedTypes(org.eclipse.xtext.xbase.typesystem.IResolvedTypes) XExpression(org.eclipse.xtext.xbase.XExpression) Check(org.eclipse.xtext.validation.Check)

Aggregations

JvmOperation (org.eclipse.xtext.common.types.JvmOperation)1 Check (org.eclipse.xtext.validation.Check)1 ValidationMessageAcceptor (org.eclipse.xtext.validation.ValidationMessageAcceptor)1 XExpression (org.eclipse.xtext.xbase.XExpression)1 IResolvedTypes (org.eclipse.xtext.xbase.typesystem.IResolvedTypes)1 Acceptor (org.eclipse.xtext.xbase.validation.ImplicitReturnFinder.Acceptor)1