refactoring: added hasOnlyErrorsFromPosition(ConstraintPosition)

to use it for errors from completer as well
This commit is contained in:
Svetlana Isakova
2013-10-01 14:42:22 +04:00
parent 6c584fd252
commit 0f444903f6
7 changed files with 21 additions and 19 deletions
@@ -106,15 +106,14 @@ public class ConstraintSystemImpl implements ConstraintSystem {
}
@Override
public boolean hasOnlyExpectedTypeMismatch() {
public boolean hasOnlyErrorsFromPosition(ConstraintPosition constraintPosition) {
if (isSuccessful()) return false;
ConstraintSystem systemWithoutExpectedTypeConstraint = filterConstraintsOut(EXPECTED_TYPE_POSITION);
if (systemWithoutExpectedTypeConstraint.getStatus().isSuccessful()) {
ConstraintSystem systemWithoutConstraintsFromPosition = filterConstraintsOut(constraintPosition);
if (systemWithoutConstraintsFromPosition.getStatus().isSuccessful()) {
return true;
}
if (errorConstraintPositions.size() == 1 && errorConstraintPositions.contains(EXPECTED_TYPE_POSITION)) {
// if systemWithoutExpectedTypeConstraint has unknown type parameters, it's not successful,
// but there can be expected type mismatch after expected type is added
if (errorConstraintPositions.size() == 1 && errorConstraintPositions.contains(constraintPosition)) {
// e.g. if systemWithoutConstraintsFromPosition has unknown type parameters, it's not successful
return true;
}
return false;
@@ -79,9 +79,10 @@ public interface ConstraintSystemStatus {
boolean hasTypeConstructorMismatchAt(@NotNull ConstraintPosition constraintPosition);
/**
* Returns <tt>true</tt> if there is type constructor mismatch only in {@link ConstraintPosition.EXPECTED_TYPE_POSITION}.
* Returns <tt>true</tt> if there is type constructor mismatch only in constraintPosition or
* constraint system is successful without constraints from this position.
*/
boolean hasOnlyExpectedTypeMismatch();
boolean hasOnlyErrorsFromPosition(ConstraintPosition constraintPosition);
/**
* Returns <tt>true</tt> if there is an error in constraining types. <p/>