Java 类org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor 实例源码

项目:OCCI-Studio    文件:OCCICrossReferenceSerializer.java   
@Override
public String serializeCrossRef(EObject semanticObject, CrossReference crossref, EObject target, INode node,
        Acceptor errors) {
    if (((InternalEObject) target).eProxyURI() != null) {
        if (((InternalEObject) target).eProxyURI().toString().startsWith("#")) {
            return super.serializeCrossRef(semanticObject, crossref, getEObjectfromEProxy(semanticObject, target),
                    node, errors);
        }
    }

    return super.serializeCrossRef(semanticObject, crossref, target, node, errors);

}
项目:xtext-core    文件:CrossReferenceSerializer.java   
@Override
public boolean isValid(EObject semanticObject, CrossReference crossref, EObject target, INode node, Acceptor errors) {
    if ((target == null || target.eIsProxy()) && node != null) {
        CrossReference crossrefFromNode = GrammarUtil.containingCrossReference(node.getGrammarElement());
        return crossref == crossrefFromNode;
    }

    final EReference ref = GrammarUtil.getReference(crossref, semanticObject.eClass());
    final IScope scope = scopeProvider.getScope(semanticObject, ref);
    if (scope == null) {
        if (errors != null)
            errors.accept(diagnostics.getNoScopeFoundDiagnostic(semanticObject, crossref, target));
        return false;
    }

    if (target != null && target.eIsProxy()) {
        target = handleProxy(target, semanticObject, ref);
    }

    return getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors) != null;
}
项目:xtext-core    文件:ValueSerializer.java   
@Override
public String serializeAssignedValue(EObject context, RuleCall ruleCall, Object value, INode node, Acceptor errors) {
    AbstractRule rule = ruleCall.getRule();
    String ruleName = ruleNames.getQualifiedName(rule);
    if (node != null) {
        AbstractRule nodeRule = linkingHelper.getRuleFrom(node.getGrammarElement());
        // TODO: analyze why grammar element identity is broken here during generation of Xtext languages using MWE2  
        if (nodeRule != null && ruleNames.getQualifiedName(nodeRule).equals(ruleName)) {
            Object converted = converter.toValue(NodeModelUtils.getTokenText(node), ruleName, node);
            if (converted != null && converted.equals(value))
                return tokenUtil.serializeNode(node);
        }
    }
    try {
        String str = converter.toString(value, ruleName);
        if (str != null)
            return str;
        if (errors != null)
            errors.accept(diagnostics.getNullNotAllowedDiagnostic(context, ruleCall));
        return null;
    } catch (Throwable e) {
        if (errors != null)
            errors.accept(diagnostics.getValueConversionExceptionDiagnostic(context, ruleCall, value, e));
        return null;
    }
}
项目:n4js    文件:GrammarPrettyPrinter.java   
@Override
protected String getCrossReferenceNameFromScope(EObject semanticObject, CrossReference crossref,
        EObject target, IScope scope, Acceptor errors) {
    if (target instanceof AbstractRule) {
        return ((AbstractRule) target).getName();
    }
    if (target instanceof ENamedElement) {
        return ((ENamedElement) target).getName();
    }
    return super.getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors);
}
项目:xtext-core    文件:SequenceFeeder.java   
protected SequenceFeeder(Provider provider, ISerializationContext context, EObject semanticObject, INodesForEObjectProvider nodes,
        ISemanticSequencer masterSequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    super();
    if (semanticObject == null || nodes == null || sequenceAcceptor == null)
        throw new NullPointerException();
    this.context = context;
    this.provider = provider;
    this.semanticObject = semanticObject;
    this.nodes = nodes;
    this.masterSequencer = masterSequencer;
    this.sequenceAcceptor = sequenceAcceptor;
    this.errorAcceptor = errorAcceptor;
}
项目:xtext-core    文件:AbstractSemanticSequencer.java   
@Override
public void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor,
        ISerializationDiagnostic.Acceptor errorAcceptor) {
    this.masterSequencer = sequencer;
    this.sequenceAcceptor = sequenceAcceptor;
    this.errorAcceptor = errorAcceptor;
}
项目:xtext-core    文件:AbstractSyntacticSequencer.java   
@Override
@Deprecated
public void init(EObject context, EObject semanticObject, ISyntacticSequenceAcceptor sequenceAcceptor,
        Acceptor errorAcceptor) {
    ISerializationContext ctx = SerializationContext.fromEObject(context, semanticObject);
    init(ctx, semanticObject, sequenceAcceptor, errorAcceptor);
}
项目:xtext-core    文件:AbstractSyntacticSequencer.java   
@Override
public void init(ISerializationContext context, EObject semanticObject, ISyntacticSequenceAcceptor sequenceAcceptor,
        Acceptor errorAcceptor) {
    INode node = NodeModelUtils.findActualNodeFor(semanticObject);
    syntacticSequencerPDAs = pdaProvider.getSyntacticSequencerPDAs(grammar.getGrammar());
    ISynAbsorberState state = syntacticSequencerPDAs.get(context);
    Preconditions.checkNotNull(state, "Invalid context: " + context);
    SyntacticalContext acceptor = new SyntacticalContext(context, semanticObject, state, node);
    contexts.push(acceptor);
    delegate = sequenceAcceptor;
    this.errorAcceptor = errorAcceptor;
}
项目:xtext-core    文件:HiddenTokenSequencer.java   
@Override
@Deprecated
public void init(EObject context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    this.delegate = sequenceAcceptor;
    this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject);
    this.rootNode = lastNode;
    if (rootNode != null) {
        this.rootOffset = rootNode.getTotalOffset();
        this.rootEndOffset = rootNode.getTotalEndOffset();
    }
}
项目:xtext-core    文件:HiddenTokenSequencer.java   
@Override
public void init(ISerializationContext context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    this.delegate = sequenceAcceptor;
    this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject);
    this.rootNode = lastNode;
    if (rootNode != null) {
        this.rootOffset = rootNode.getTotalOffset();
        this.rootEndOffset = rootNode.getTotalEndOffset();
    }
}
项目:xtext-core    文件:CrossReferenceSerializer.java   
@Override
public String serializeCrossRef(EObject semanticObject, CrossReference crossref, EObject target, INode node,
        Acceptor errors) {
    if ((target == null || target.eIsProxy()) && node != null)
        return tokenUtil.serializeNode(node);

    final EReference ref = GrammarUtil.getReference(crossref, semanticObject.eClass());
    final IScope scope = scopeProvider.getScope(semanticObject, ref);
    if (scope == null) {
        if (errors != null)
            errors.accept(diagnostics.getNoScopeFoundDiagnostic(semanticObject, crossref, target));
        return null;
    }

    if (target != null && target.eIsProxy()) {
        target = handleProxy(target, semanticObject, ref);
    }

    if (target != null && node != null) {
        String text = linkingHelper.getCrossRefNodeAsString(node, true);
        QualifiedName qn = qualifiedNameConverter.toQualifiedName(text);
        URI targetURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(target);
        for (IEObjectDescription desc : scope.getElements(qn)) {
            if (targetURI.equals(desc.getEObjectURI()))
                return tokenUtil.serializeNode(node);
        }
    }

    return getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors);
}
项目:xtext-core    文件:CrossReferenceSerializer.java   
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;
}
项目:xtext-core    文件:EnumLiteralSerializer.java   
@Override
public String serializeAssignedEnumLiteral(EObject context, RuleCall ruleCall, Object value, INode node,
        Acceptor errorAcceptor) {
    Keyword nodeLit = getLiteral(node);
    Keyword modelLit = getLiteral(context, ruleCall, value);
    if (modelLit == null) {
        if (errorAcceptor != null)
            errorAcceptor.accept(diagnosticProvider.getInvalidEnumValueDiagnostic(context, ruleCall, value));
        return null;
    } else if (nodeLit != null && nodeLit.equals(modelLit))
        return tokenUtil.serializeNode(node);
    else
        return modelLit.getValue();
}
项目:xtext-core    文件:ValueSerializer.java   
@Override
public boolean isValid(EObject context, RuleCall ruleCall, Object value, Acceptor errors) {
    try {
        String str = converter.toString(value, ruleNames.getQualifiedName(ruleCall.getRule()));
        if (str != null)
            return true;
        if (errors != null)
            errors.accept(diagnostics.getNullNotAllowedDiagnostic(context, ruleCall));
        return false;
    } catch (Throwable e) {
        if (errors != null)
            errors.accept(diagnostics.getValueConversionExceptionDiagnostic(context, ruleCall, value, e));
        return false;
    }
}
项目:xtext-core    文件:IgnoreCaseKeywordSerializer.java   
@Override
public boolean isValid(EObject context, Keyword keyword, Object value, Acceptor errorAcceptor) {
    if (value instanceof String) {
        return keyword.getValue().equalsIgnoreCase((String) value);
    }
    return false;
}
项目:xtext-core    文件:KeywordSerializer.java   
@Override
public String serializeAssignedKeyword(EObject context, Keyword keyword, Object value, INode node,
        Acceptor errorAcceptor) {
    if (node != null && node.getGrammarElement() == keyword)
        return node.getText();
    return keyword.getValue();
}
项目:dsl-devkit    文件:ReorderingHiddenTokenSequencer.java   
@Override
public void init(final EObject context, final EObject semanticObject, final ISequenceAcceptor sequenceAcceptor, final Acceptor errorAcceptor) {
  this.delegate = sequenceAcceptor;
  this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject);
  this.rootNode = lastNode;
  if (rootNode != null) {
    this.rootOffset = rootNode.getTotalOffset();
    this.rootEndOffset = rootNode.getTotalEndOffset();
  }
}
项目:statecharts    文件:SGenCrossReferenceSerializer.java   
@Override
public String serializeCrossRef(EObject semanticObject,
        CrossReference crossref, EObject target, INode node, Acceptor errors) {
    // for statechart crossreferences, we do not want to check the scope
    if (target instanceof Statechart) {
        return provider.getFullyQualifiedName(target).toString();

    }
    return super.serializeCrossRef(semanticObject, crossref, target, node,
            errors);
}
项目:DocIT    文件:AbstractIOISemanticSequencer.java   
@Override
public void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    super.init(sequencer, sequenceAcceptor, errorAcceptor);
    this.genericSequencer = genericSequencerProvider.get();
    this.genericSequencer.init(sequencer, sequenceAcceptor, errorAcceptor);
}
项目:jason-eclipse-plugin    文件:AbstractMas2jSemanticSequencer.java   
@Override
public void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    super.init(sequencer, sequenceAcceptor, errorAcceptor);
    this.genericSequencer = genericSequencerProvider.get();
    this.genericSequencer.init(sequencer, sequenceAcceptor, errorAcceptor);
}
项目:xtext-core    文件:SequenceFeeder.java   
/**
 * @deprecated {@link #create(ISerializationContext, EObject, INodesForEObjectProvider, ISemanticSequencer, ISemanticSequenceAcceptor, Acceptor)}
 */
@Deprecated
public SequenceFeeder create(EObject semanticObject, INodesForEObjectProvider nodes, ISemanticSequencer masterSequencer,
        ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    return new SequenceFeeder(this, semanticObject, nodes, masterSequencer, sequenceAcceptor, errorAcceptor);
}
项目:xtext-core    文件:SequenceFeeder.java   
public SequenceFeeder create(ISerializationContext context, EObject semanticObject, INodesForEObjectProvider nodes,
        ISemanticSequencer masterSequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    return new SequenceFeeder(this, context, semanticObject, nodes, masterSequencer, sequenceAcceptor, errorAcceptor);
}
项目:xtext-core    文件:SequenceFeeder.java   
/**
 * @deprecated {@link #SequenceFeeder(Provider, ISerializationContext, EObject, INodesForEObjectProvider, ISemanticSequencer, ISemanticSequenceAcceptor, Acceptor)}
 */
@Deprecated
protected SequenceFeeder(Provider provider, EObject semanticObject, INodesForEObjectProvider nodes, ISemanticSequencer masterSequencer,
        ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    this(provider, null, semanticObject, nodes, masterSequencer, sequenceAcceptor, errorAcceptor);
}
项目:xtext-core    文件:AbstractSemanticSequencer.java   
@Override
public void init(ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    init(this, sequenceAcceptor, errorAcceptor);
}
项目:xtext-core    文件:AbstractDelegatingSemanticSequencer.java   
@Override
public void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    super.init(sequencer, sequenceAcceptor, errorAcceptor);
    this.genericSequencer = genericSequencerProvider.get();
    this.genericSequencer.init(sequencer, sequenceAcceptor, errorAcceptor);
}
项目:xtext-core    文件:EnumLiteralSerializer.java   
@Override
public boolean isValid(EObject context, RuleCall ruleCall, Object value, Acceptor errorAcceptor) {
    return getLiteral(context, ruleCall, value) != null;
}
项目:xtext-core    文件:IgnoreCaseKeywordSerializer.java   
@Override
public String serializeAssignedKeyword(EObject context, Keyword keyword, Object value, INode node, Acceptor errorAcceptor) {
    if (node != null && node.getGrammarElement() == keyword)
        return node.getText();
    return keyword.getValue();
}
项目:xtext-core    文件:KeywordSerializer.java   
@Override
public boolean isValid(EObject context, Keyword keyword, Object value, Acceptor errorAcceptor) {
    return keyword.getValue().equals(value);
}