refactoring: added hasOnlyErrorsFromPosition(ConstraintPosition)
to use it for errors from completer as well
This commit is contained in:
+5
-6
@@ -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;
|
||||
|
||||
+3
-2
@@ -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/>
|
||||
|
||||
Reference in New Issue
Block a user