Search in sources :

Example 1 with ISerializationDiagnostic

use of org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic in project xtext-core by eclipse.

the class CrossReferenceSerializer method getCrossReferenceNameFromScope.

protected String getCrossReferenceNameFromScope(EObject semanticObject, CrossReference crossref, EObject target, final IScope scope, Acceptor errors) {
    String ruleName = linkingHelper.getRuleNameFrom(crossref);
    boolean foundOne = false;
    List<ISerializationDiagnostic> recordedErrros = null;
    for (IEObjectDescription desc : scope.getElements(target)) {
        foundOne = true;
        String unconverted = qualifiedNameConverter.toString(desc.getName());
        try {
            return valueConverter.toString(unconverted, ruleName);
        } catch (ValueConverterException e) {
            if (errors != null) {
                if (recordedErrros == null)
                    recordedErrros = Lists.newArrayList();
                recordedErrros.add(diagnostics.getValueConversionExceptionDiagnostic(semanticObject, crossref, unconverted, e));
            }
        }
    }
    if (errors != null) {
        if (recordedErrros != null)
            for (ISerializationDiagnostic diag : recordedErrros) errors.accept(diag);
        if (!foundOne)
            errors.accept(diagnostics.getNoEObjectDescriptionFoundDiagnostic(semanticObject, crossref, target, scope));
    }
    return null;
}
Also used : ISerializationDiagnostic(org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic) ValueConverterException(org.eclipse.xtext.conversion.ValueConverterException) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

ValueConverterException (org.eclipse.xtext.conversion.ValueConverterException)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 ISerializationDiagnostic (org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic)1