Java Code Examples for org.eclipse.emf.ecore.util.EcoreUtil.getExistingAdapter()

The following are Jave code examples for showing how to use getExistingAdapter() of the org.eclipse.emf.ecore.util.EcoreUtil class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: rest-modeling-framework   File:   Source Code and License Vote up 5 votes
private void addValidationError(final org.eclipse.emf.common.util.Diagnostic diagnostic) {
    int line = -1;
    int column = -1;
    String source = diagnostic.getSource();
    if (diagnostic.getData().size() > 0 && diagnostic.getData().get(0) instanceof EObject) {
        final EObject eObject = (EObject) diagnostic.getData().get(0);
        final RamlTokenProvider ramlTokenProvider = (RamlTokenProvider) EcoreUtil.getExistingAdapter(eObject, RamlTokenProvider.class);
        final RamlToken ramlToken = ramlTokenProvider.get();
        line = ramlToken.getLine();
        column = ramlToken.getCharPositionInLine();
        source = ramlToken.getLocation();
    getErrors().add(RamlDiagnostic.of(diagnostic.getMessage(), source, line, column));