protected CandidateCompareResult compareByArityWith(AbstractPendingLinkingCandidate<?> right) { CandidateCompareResult arityCompareResult = compareByArity(getArityMismatch(), right.getArityMismatch()); return arityCompareResult; }
/** * Returns the mismatch of actually given arguments and declared parameters. * Receivers and staticness of the feature is taken into account, too. The mismatch * may either be negative or positive. */ public int getArityMismatch() { JvmIdentifiableElement identifiable = getFeature(); if (identifiable instanceof JvmExecutable) { return getArityMismatch((JvmExecutable) identifiable, getArguments()); } else if (getExpression() instanceof XAssignment) { return getArguments().size() - 1; } else { return getArguments().size(); } }
protected boolean validateArity(IAcceptor<? super AbstractDiagnostic> result) { if (getArityMismatch() != 0) { String message; if (getArguments().isEmpty()) { message = String.format("Invalid number of arguments. The %1$s %2$s%3$s is not applicable without arguments" , getFeatureTypeName(), getSimpleFeatureName(), getFeatureParameterTypesAsString()); } else { message = String.format("Invalid number of arguments. The %1$s %2$s%3$s is not applicable for the arguments %4$s" , getFeatureTypeName(), getSimpleFeatureName(), getFeatureParameterTypesAsString(), getArgumentTypesAsString()); } AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.INVALID_NUMBER_OF_ARGUMENTS, message, getExpression(), getInvalidArgumentsValidationFeature(), -1, null); result.accept(diagnostic); return false; } return true; }