@Override
public boolean validate(IAcceptor<? super AbstractDiagnostic> result) {
JvmIdentifiableElement implicitFeature = getFeature();
if (implicitFeature instanceof XVariableDeclaration) {
XVariableDeclaration casted = (XVariableDeclaration) implicitFeature;
if (casted.isWriteable()) {
String message = getState().getResolver().getInvalidWritableVariableAccessMessage(casted, getFeatureCall(), getState().getResolvedTypes());
if (message != null) {
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR,
IssueCodes.INVALID_MUTABLE_VARIABLE_ACCESS, message, getOwner(),
XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null);
result.accept(diagnostic);
return false;
}
}
if (EcoreUtil.isAncestor(casted, getFeatureCall())) {
String message = String.format("The implicitly referenced variable %s may not have been initialized", implicitFeature.getSimpleName());
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR,
IssueCodes.ILLEGAL_FORWARD_REFERENCE, message, getOwner(),
XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null);
result.accept(diagnostic);
return false;
}
}
return true;
}