Java 类org.eclipse.xtext.util.Triple 实例源码

项目:n4js    文件:N4JSResource.java   
@Override
protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple) {
    // check if unresolved reference is special case handled by {@link N4JSScopingDiagnostician}
    DiagnosticMessage scopingDiagnostic = scopingDiagnostician.getMessageFor(triple.getFirst(), triple.getSecond(),
            triple.getThird());
    // if so, use more specific diagnostic message
    if (null != scopingDiagnostic) {
        List<Diagnostic> list = getDiagnosticList(scopingDiagnostic);
        Diagnostic diagnostic = createDiagnostic(triple, scopingDiagnostic);
        if (!list.contains(diagnostic)) {
            list.add(diagnostic);
        }
    } else {
        // if not, use default generic scoping message
        super.createAndAddDiagnostic(triple);
    }
}
项目:xtext-extras    文件:BatchLinkableResource.java   
@Override
protected EObject handleCyclicResolution(Triple<EObject, EReference, INode> triple) throws AssertionError {
    if (!isValidationDisabled()) {
        EObject context = triple.getFirst();
        if (context.eClass() == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE) {
            // here we may end up with cyclic resolution requests in rare situations, e.g. for input types
            // like :
            /*
             * package p;
             * class C extends p.C.Bogus {}
             */
            return null;
        }
        DiagnosticMessage message = new DiagnosticMessage("Cyclic linking detected : " + getReferences(triple, resolving), Severity.ERROR, "cyclic-resolution");
        List<Diagnostic> list = getDiagnosticList(message);
        Diagnostic diagnostic = createDiagnostic(triple, message);
        if (!list.contains(diagnostic))
            list.add(diagnostic);
    }
    return null;
}
项目:xtext-extras    文件:ErrorTreeAppendable.java   
@Override
public TreeAppendable append(JvmType type) {
    if(type.eIsProxy()) {
        String fragment = ((InternalEObject)type).eProxyURI().fragment();
        Triple<EObject, EReference, INode> unresolvedLink = encoder.decode(getState().getResource(), fragment);
        if(unresolvedLink != null) {
            INode linkNode = unresolvedLink.getThird();
            if(linkNode != null) {
                append(NodeModelUtils.getTokenText(linkNode));
                return this;
            }
        }
        append("unresolved type");
        return this;
    }
    return super.append(type);
}
项目:xtext-extras    文件:TestErrorAcceptor.java   
private boolean compareTriple(Triple<TransformationErrorCode, String, EObject> one,
        Triple<TransformationErrorCode, String, EObject> other) {
    if (one.equals(other))
        return true;
    if (other == null)
        return false;
    if (other == one)
        return true;

    TransformationErrorCode first = one.getFirst();
    boolean isFirstEqual = ((first == null) ? other.getFirst() == null : first.equals(other.getFirst()));
    if (!isFirstEqual)
        return false;

    String second = one.getSecond();
    boolean isSecondEqual = second == ANY_STRING
            || ((second == null) ? other.getSecond() == null : second.equals(other.getSecond()));
    if (!isSecondEqual)
        return false;

    EObject third = one.getThird();
    boolean isThirdEqual = third == ANY_EOBJECT
            || (third == null ? other.getThird() == null : one.getThird().equals(other.getThird()));
    return isThirdEqual;
}
项目:xtext-core    文件:SemanticNodeIterator.java   
protected Triple<INode, AbstractElement, EObject> findNext(INode node, boolean prune) {
    INode current = next(node, prune);
    while (current != null) {
        if (current instanceof ILeafNode && ((ILeafNode) current).isHidden()) {
            current = next(current, true);
            continue;
        }
        EObject ge = current.getGrammarElement();
        if (ge instanceof AbstractElement && isEObjectNode(current))
            return Tuples.create(current, (AbstractElement) ge, getEObjectNodeEObject(current));
        else if (GrammarUtil.isAssigned(ge) && !GrammarUtil.isEObjectRuleCall(ge)) {
            if (ge instanceof CrossReference)
                return Tuples.create(current, ((CrossReference) ge).getTerminal(), null);
            else
                return Tuples.create(current, (AbstractElement) ge, null);
        } else
            current = next(current, false);
    }
    return null;
}
项目:xtext-core    文件:LazyLinkingResource.java   
@Override
public synchronized EObject getEObject(String uriFragment) {
    try {
        if (getEncoder().isCrossLinkFragment(this, uriFragment)) {
            Triple<EObject, EReference, INode> triple = getEncoder().decode(this, uriFragment);
            return getEObject(uriFragment, triple);
        }
    } catch (RuntimeException e) {
        operationCanceledManager.propagateAsErrorIfCancelException(e);
        getErrors().add(new ExceptionDiagnostic(e));
        log.error("resolution of uriFragment '" + uriFragment + "' failed.", e);
        // wrapped because the javaDoc of this method states that WrappedExceptions are thrown
        // logged because EcoreUtil.resolve will ignore any exceptions.
        throw new WrappedException(e);
    }
    return super.getEObject(uriFragment);
}
项目:xtext-core    文件:TestErrorAcceptor.java   
private boolean compareTriple(Triple<TransformationErrorCode, String, EObject> one,
        Triple<TransformationErrorCode, String, EObject> other) {
    if (one.equals(other))
        return true;
    if (other == null)
        return false;
    if (other == one)
        return true;

    TransformationErrorCode first = one.getFirst();
    boolean isFirstEqual = ((first == null) ? other.getFirst() == null : first.equals(other.getFirst()));
    if (!isFirstEqual)
        return false;

    String second = one.getSecond();
    boolean isSecondEqual = second == ANY_STRING
            || ((second == null) ? other.getSecond() == null : second.equals(other.getSecond()));
    if (!isSecondEqual)
        return false;

    EObject third = one.getThird();
    boolean isThirdEqual = third == ANY_EOBJECT
            || (third == null ? other.getThird() == null : one.getThird().equals(other.getThird()));
    return isThirdEqual;
}
项目:dsl-devkit    文件:AbstractTypeProvider.java   
/**
 * Gets the containing info for an expression.
 * <p>
 * The containing info for an expression consists of
 * <ul>
 * <li>the EObject that contains the expression,
 * <li>the containment EReference of that containing EObject
 * <li>if the multiplicity is > 1, the index of the expression in the containing EReference; else -1
 * </ul>
 *
 * @param expression
 *          the expression to get the containing info for
 * @return the containing info for {@code expression}
 */
protected Triple<EObject, EReference, Integer> getContainingInfo(final IExpression expression) {
  if (expression == null) {
    return null;
  }
  if (expression.eIsProxy()) {
    return null;
  }
  EReference containmentReference = expression.eContainmentFeature();
  if (containmentReference == null) {
    return null;
  }
  EObject container = expression.eContainer();
  int index = (containmentReference.isMany()) ? ((List<?>) container.eGet(containmentReference)).indexOf(expression) : -1;
  return Tuples.create(container, containmentReference, index);
}
项目:dsl-devkit    文件:ParallelResourceLoader.java   
public ParallelLoadOperation(final ResourceSet parent, final IProject project) {
  this.parent = parent;
  if (queueSize == -1) {
    this.resourceQueue = new LinkedBlockingQueue<Triple<URI, Resource, Throwable>>();
  } else if (queueSize == 0) {
    this.resourceQueue = new SynchronousQueue<Triple<URI, Resource, Throwable>>();
  } else {
    this.resourceQueue = new ArrayBlockingQueue<Triple<URI, Resource, Throwable>>(queueSize);
  }
  this.resourceSetProvider = new ThreadLocal<ResourceSet>() {
    @Override
    protected ResourceSet initialValue() {
      ResourceSet resourceSet = getResourceSetProvider().get(project);
      resourceSet.getLoadOptions().putAll(parent.getLoadOptions());
      // we are not loading as part of a build
      resourceSet.getLoadOptions().remove(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE);
      resourceSet.setURIConverter(parent.getURIConverter());
      return resourceSet;
    }
  };
  this.executor = Executors.newFixedThreadPool(nThreads);
  this.waitTime = getTimeout();
}
项目:dsl-devkit    文件:LazyLinkingResource2.java   
@Override
public void createAndAddDiagnostic(final Triple<EObject, EReference, INode> triple) {
  if (isValidationDisabled()) {
    return;
  }
  if (diagnosticFilter.suppressDiagnostic(triple)) {
    return;
  } else {
    super.createAndAddDiagnostic(triple);
    if (LOGGER.isDebugEnabled()) {
      // call to super does not return the new diagnostic so create a temporary one
      Diagnostic error = createDiagnostic(triple, createDiagnosticMessage(triple));
      LOGGER.debug(getURI() + " error: " + error); //$NON-NLS-1$
    }
  }
}
项目:dsl-devkit    文件:AbstractScopingTest.java   
/**
 * Asserts the scope for the given context, reference, source type, and elements.
 *
 * @param context
 *          the context object
 * @param reference
 *          the reference feature
 * @param expectedSourceType
 *          the source-type name
 * @param elements
 *          list of triples with the expected elements, each triple ordered as: {element name, source name, URI fragment}
 */
protected void assertScopeForElements(final EObject context, final EReference reference, final String expectedSourceType, final List<Triple<String, String, String>> elements) {
  Iterable<IEObjectDescription> allElements = getScopeProvider().getScope(context, reference).getAllElements();

  // create a set containing the URIs (to avoid counting any duplicates the scope provider might have delivered)
  Set<URI> uris = new HashSet<URI>();
  for (IEObjectDescription d : allElements) {
    uris.add(d.getEObjectURI());
  }

  int actualScopeSizeWithoutDuplicates = uris.size();
  assertEquals(NUMBER_OF_ELEMENTS_MESSAGE, elements.size(), actualScopeSizeWithoutDuplicates);
  for (Triple<String, String, String> elementName : elements) {
    assertScopeForElement(context, reference, elementName.getFirst(), elementName.getSecond(), expectedSourceType, elementName.getThird());
  }
}
项目:statecharts    文件:AbstractSCTResource.java   
@Override
public synchronized EObject getEObject(String uriFragment) {
    if (encoder.isCrossLinkFragment(this, uriFragment)) {
        Triple<EObject, EReference, INode> triple = encoder.decode(this, uriFragment);
        List<EObject> linkedObjects = null;
        linkedObjects = linkingService.getLinkedObjects(triple.getFirst(), triple.getSecond(), triple.getThird());
        if (!linkedObjects.isEmpty()) {
            return linkedObjects.get(0);
        } else {
            createDiagnostic(triple);
            return null;
        }
    }
    if (uriFragment != null && uriFragment.startsWith(SCT_PREFIX)) {
        return super.getEObject(uriFragment.substring(SCT_PREFIX.length()));
    }
    return super.getEObject(uriFragment);
}
项目:n4js    文件:N4JSBuilderPreferencePage.java   
/**
 * Initializes default compiler configuration.
 */
@Inject
public N4JSBuilderPreferencePage(ICompositeGenerator compositeGenerator) {
    super(new ArrayList<Triple<String, String, CompilerDescriptor>>());
    for (CompilerDescriptor compilerDescriptor : compositeGenerator.getCompilerDescriptors()) {
        this.components.add(Tuples.create(compilerDescriptor.getIdentifier(), compilerDescriptor.getName(),
                compilerDescriptor));
    }
}
项目:n4js    文件:AbstractN4JSPreferencePage.java   
/**
 * Creates the page with given components, project is set to nul by default.
 */
public AbstractN4JSPreferencePage(
        ArrayList<Triple<String, String, DESCR_TYPE>> components) {
    this.components = components;
    blockStatus = new StatusInfo();
    blockEnableState = null;
    project = null;
    pageData = null;
    entriesDiffering = null;
}
项目:n4js    文件:N4JSResource.java   
@Override
public Triple<EObject, EReference, INode> getLazyProxyInformation(int idx) {
    // note: following line was copied from the old index-URI implementation (the one that used field "uris")
    // to make the new implementation behave as the old one; whether doing a demand load here actually
    // makes sense remains to be reconsidered (see IDEBUG-257 and IDEBUG-233) ...
    contents.get(0); // trigger demand load if necessary
    return super.getLazyProxyInformation(idx);
}
项目:n4js    文件:N4JSResource.java   
@Override
protected EObject handleCyclicResolution(Triple<EObject, EReference, INode> triple) throws AssertionError {
    // Don't throw exception for cyclic resolution of IdentifierRef.id or PropertyAccess.property
    // since this is currently unavoidable because type system and scoping don't work together
    // but have independent control flow logic.
    // This JS snippet will cause trouble:
    //
    // function(a){ return a.b }
    // System.err.println("CYCLIC RESOLUTION FOR: " + NodeModelUtils.getTokenText(triple.getThird()));
    if (N4JSPackage.Literals.IDENTIFIER_REF__ID == triple.getSecond()
            || N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION__PROPERTY == triple.getSecond()) {
        return null;
    }
    return super.handleCyclicResolution(triple);
}
项目:xtext-extras    文件:BatchLinkableResource.java   
/**
 * {@inheritDoc}
 * 
 * Delegates to the {@link BatchLinkingService} if the requested reference is 
 * {@link BatchLinkingService#isBatchLinkable(EReference) linkeable in batch mode}.
 * 
 * Implementation detail: This specialization of {@link #getEObject(String) getEObject}
 * synchronizes on the {@link #getLock() lock} which is exposed by the synchronizable
 * resource rather than on the resource directly. This guards against reentrant resolution
 * from different threads that could block each other.
 * 
 * Usually one would want to lock only in the {@link BatchLinkingService} but we could
 * have intermixed {@link LazyURIEncoder#isCrossLinkFragment(org.eclipse.emf.ecore.resource.Resource, String)
 * lazy cross reference} and vanilla EMF cross references which again could lead to a
 * dead lock.
 */
@Override
public EObject getEObject(String uriFragment) {
    synchronized (getLock()) {
        try {
            if (getEncoder().isCrossLinkFragment(this, uriFragment) && !isLoadedFromStorage()) {
                if (!getUnresolvableURIFragments().contains(uriFragment)) {
                    Triple<EObject, EReference, INode> triple = getEncoder().decode(this, uriFragment);
                    if (batchLinkingService.isBatchLinkable(triple.getSecond())) {
                        if (compilerPhases.isIndexing(this))
                            log.error("Don't resolve expressions during indexing!", new IllegalStateException("Resource URI : "+getURI()+", fragment : "+uriFragment));
                        return batchLinkingService.resolveBatched(triple.getFirst(), triple.getSecond(), uriFragment);
                    }
                    return super.getEObject(uriFragment, triple);
                } else {
                    return null;
                }
            }
            return super.getEObject(uriFragment);
        } catch (RuntimeException e) {
            operationCanceledManager.propagateAsErrorIfCancelException(e);
            getErrors().add(new ExceptionDiagnostic(e));
            log.error("resolution of uriFragment '" + uriFragment + "' failed.", e);
            // wrapped because the javaDoc of this method states that WrappedExceptions are thrown
            // logged because EcoreUtil.resolve will ignore any exceptions.
            throw new WrappedException(e);
        }
    }
}
项目:xtext-extras    文件:BatchLinkableResource.java   
/**
 * Executes any {@link Runnable}s added through {@link #addJvmMemberInitializer(Runnable)}
 * 
 * @since 2.8
 * @noreference This method is not intended to be referenced by clients.
 */
@Override
public void ensureJvmMembersInitialized() {
    if (jvmMemberInitializers == null)
        return;
    Set<Runnable> localRunnables = null;
    synchronized(this) {
        localRunnables = jvmMemberInitializers;
        jvmMemberInitializers = null;
        hasJvmMemberInitializers = false;
    }
    if (localRunnables == null)
        return;
    boolean wasDeliver = eDeliver();
    LinkedHashSet<Triple<EObject, EReference, INode>> before = resolving;
    try {
        eSetDeliver(false);
        if (!before.isEmpty()) {
            resolving = new LinkedHashSet<Triple<EObject, EReference, INode>>();
        }
        if (isInitializingJvmMembers) {
            throw new IllegalStateException("Reentrant attempt to initialize JvmMembers");
        }
        try {
            isInitializingJvmMembers = true;
            for (Runnable runnable : localRunnables) {
                runnable.run();
            }
        } finally {
            isInitializingJvmMembers = false;
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    } finally {
        if (!before.isEmpty()) {
            resolving = before;
        }
        eSetDeliver(wasDeliver);
    }
}
项目:xtext-extras    文件:TestErrorAcceptor.java   
@Override
public void acceptError(TransformationErrorCode errorCode, String message, EObject element) {
    Triple<TransformationErrorCode, String, EObject> create = Tuples.create(errorCode, message, element);
    //      System.out.println((write ? "Write>" : "Read>") + " errorCode: " + (errorCode != null ? errorCode : "")
    //              + ", message: " + (message != null ? message : "") + ", element: " + (element != null ? element : ""));
    if (write) {
        flugschreiber.push(create);
    } else {
        Triple<TransformationErrorCode, String, EObject> pop = flugschreiber.removeLast();
        assertNotNull("Queue is empty", pop);
        boolean equals = compareTriple(pop, create);
        assertTrue("Verified", equals);
    }
}
项目:xtext-core    文件:EClassifierInfos.java   
private boolean isPackageKnown(String nsURI) {
    for (Triple<String, String, String> key : infoMap.keySet()) {
        if (key.getFirst().equals(nsURI))
            return true;
    }
    for(EClassifierInfos parent: parents) {
        if (parent.isPackageKnown(nsURI))
            return true;
    }
    return false;
}
项目:xtext-core    文件:SemanticNodeIterator.java   
@Override
public Triple<INode, AbstractElement, EObject> next() {
    Triple<INode, AbstractElement, EObject> oldNext = next;
    if (next != null)
        next = findNext(next.getFirst(), true);
    return oldNext;
}
项目:xtext-core    文件:NodeModelSemanticSequencer.java   
@Override
public void createSequence(ISerializationContext context, EObject semanticObject) {
    SemanticNodeIterator ni = new SemanticNodeIterator(semanticObject);
    while (ni.hasNext()) {
        Triple<INode, AbstractElement, EObject> node = ni.next();
        if (node.getSecond() instanceof RuleCall) {
            RuleCall rc = (RuleCall) node.getSecond();
            TypeRef ruleType = rc.getRule().getType();
            if (ruleType == null || ruleType.getClassifier() instanceof EClass)
                acceptSemantic(semanticObject, rc, node.getThird(), node.getFirst());
            else if (GrammarUtil.containingCrossReference(node.getSecond()) != null) {
                EStructuralFeature feature = FeatureFinderUtil.getFeature(node.getSecond(),
                        semanticObject.eClass());
                acceptSemantic(semanticObject, rc, semanticObject.eGet(feature), node.getFirst());
            } else {
                String strVal = NodeModelUtils.getTokenText(node.getFirst());
                Object val = valueConverter.toValue(strVal, ruleNames.getQualifiedName(rc.getRule()),
                        node.getFirst());
                acceptSemantic(semanticObject, rc, val, node.getFirst());
            }
        } else if (node.getSecond() instanceof Keyword)
            acceptSemantic(semanticObject, node.getSecond(), node.getFirst().getText(), node.getFirst());
        else if (node.getSecond() instanceof Action) {
            acceptSemantic(semanticObject, node.getSecond(), semanticObject, node.getFirst());
        }
    }
}
项目:xtext-core    文件:LazyLinkingResource.java   
protected String getReferences(Triple<EObject, EReference, INode> triple,
        LinkedHashSet<Triple<EObject, EReference, INode>> resolving2) {
    StringBuffer buffer = new StringBuffer();
    boolean found = false;
    for (Triple<EObject, EReference, INode> triple2 : resolving2) {
        found = found || triple2.equals(triple);
        if (found)
            buffer.append(getQualifiedName(triple2.getSecond())).append("->");
    }
    buffer.append(getQualifiedName(triple.getSecond()));
    return buffer.toString();
}
项目:xtext-core    文件:LazyLinkingResource.java   
protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple) {
    if (isValidationDisabled())
        return;
    DiagnosticMessage message = createDiagnosticMessage(triple);
    if (message != null) {
        List<Diagnostic> list = getDiagnosticList(message);
        Diagnostic diagnostic = createDiagnostic(triple, message);
        if (!list.contains(diagnostic))
            list.add(diagnostic);
    }
}
项目:xtext-core    文件:LazyLinkingResource.java   
/**
 * @since 2.3
 */
protected void createAndAddDiagnostic(Triple<EObject, EReference, INode> triple, IllegalNodeException ex) {
    if (isValidationDisabled())
        return;
    ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext context = createDiagnosticMessageContext(triple);
    DiagnosticMessage message = linkingDiagnosticMessageProvider.getIllegalNodeMessage(context, ex);
    if (message != null) {
        List<Diagnostic> list = getDiagnosticList(message);
        Diagnostic diagnostic = createDiagnostic(triple, message);
        if (!list.contains(diagnostic))
            list.add(diagnostic);
    }
}
项目:xtext-core    文件:LazyLinkingResource.java   
protected void removeDiagnostic(Triple<EObject, EReference, INode> triple) {
    // return early if there's nothing to remove
    if (getErrors().isEmpty() && getWarnings().isEmpty())
        return;
    DiagnosticMessage message = createDiagnosticMessage(triple);
    List<Diagnostic> list = getDiagnosticList(message);
    if (!list.isEmpty()) {
        Diagnostic diagnostic = createDiagnostic(triple, message);
        list.remove(diagnostic);
    }
}
项目:xtext-core    文件:LazyLinkingResource.java   
/**
 * @since 2.7
 */
public Triple<EObject,EReference,INode> getLazyProxyInformation(int idx) {
    if (!hasLazyProxyInformation(idx)) {
        throw new IllegalArgumentException("No proxy information for index '"+idx+"' available.");
    }
    return proxyInformation.get(idx);
}
项目:xtext-core    文件:LazyURIEncoder.java   
/**
 * decodes the uriFragment
 * 
 * @param res the resource that contains the feature holder
 * @param uriFragment the fragment that should be decoded
 * @return the decoded information
 * @see LazyURIEncoder#encode(EObject, EReference, INode)
 */
public Triple<EObject, EReference, INode> decode(Resource res, String uriFragment) {
    if (isUseIndexFragment(res)) {
        return getLazyProxyInformation(res, uriFragment);
    }
    List<String> split = Strings.split(uriFragment, SEP);
    EObject source = resolveShortFragment(res, split.get(1));
    EReference ref = fromShortExternalForm(source.eClass(), split.get(2));
    INode compositeNode = NodeModelUtils.getNode(source);
    if (compositeNode==null)
        throw new IllegalStateException("Couldn't resolve lazy link, because no node model is attached.");
    INode textNode = getNode(compositeNode, split.get(3));
    return Tuples.create(source, ref, textNode);
}
项目:xtext-core    文件:LazyURIEncoder.java   
/**
 * @since 2.7
 */
protected Triple<EObject, EReference, INode> getLazyProxyInformation(Resource res, String uriFragment) {
    if (!(res instanceof LazyLinkingResource)) {
        throw new IllegalArgumentException("Given resource not a LazyLinkingResource");
    }
    int idx = getIndex(uriFragment);
    LazyLinkingResource lazyResource = (LazyLinkingResource) res;
    return lazyResource.getLazyProxyInformation(idx);
}
项目:xtext-core    文件:AbstractXtextInspectorTest.java   
@Override
public void acceptError(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
    if (!isExpectingErrors())
        fail("unexpected call to acceptError");
    Triple<String,EObject,EStructuralFeature> error = Tuples.create(message, object, feature);
    errors.add(error);
}
项目:xtext-core    文件:AbstractXtextInspectorTest.java   
@Override
public void acceptWarning(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
    if (!isExpectingWarnings())
        fail("unexpected call to acceptWarning");
    Triple<String,EObject,EStructuralFeature> warning = Tuples.create(message, object, feature);
    warnings.add(warning);
}
项目:xtext-core    文件:AbstractXtextInspectorTest.java   
@Override
public void acceptInfo(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
    if (!isExpectingInfos())
        fail("unexpected call to acceptInfo");
    Triple<String,EObject,EStructuralFeature> warning = Tuples.create(message, object, feature);
    infos.add(warning);
}
项目:xtext-core    文件:TestErrorAcceptor.java   
@Override
public void acceptError(TransformationErrorCode errorCode, String message, EObject element) {
    Triple<TransformationErrorCode, String, EObject> create = Tuples.create(errorCode, message, element);
    //      System.out.println((write ? "Write>" : "Read>") + " errorCode: " + (errorCode != null ? errorCode : "")
    //              + ", message: " + (message != null ? message : "") + ", element: " + (element != null ? element : ""));
    if (write) {
        flugschreiber.push(create);
    } else {
        Triple<TransformationErrorCode, String, EObject> pop = flugschreiber.removeLast();
        assertNotNull("Queue is empty", pop);
        boolean equals = compareTriple(pop, create);
        assertTrue("Verified", equals);
    }
}
项目:dsl-devkit    文件:AbstractTypeProvider.java   
@Override
protected IType doComputation(final IExpression expression) {
  Triple<EObject, EReference, Integer> triple = getContainingInfo(expression);
  if (triple != null) {
    return expectedType(triple.getFirst(), triple.getSecond(), triple.getThird());
  } else {
    return null;
  }
}
项目:dsl-devkit    文件:ParallelResourceLoader.java   
/**
 * Publish the result of loading a {@link Resource}.
 *
 * @param result
 *          the result of resource loading
 */
private void publishLoadResult(final Triple<URI, Resource, Throwable> result) {
  try {
    resourceQueue.put(result); // Block here if queue is full
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }
}
项目:dsl-devkit    文件:ResourceDescriptionDelta.java   
/**
 * Computes a detailed diff for this delta.
 * 
 * @return triple containing collections of deleted objects, changed objects, and added objects (in that order)
 */
public Triple<Collection<IEObjectDescription>, Collection<Pair<IEObjectDescription, IEObjectDescription>>, Collection<IEObjectDescription>> computeDetailedDiff() {
  if (diff == null) {
    diff = computeDetailedDiff(oldDesc, getNew());
    discardOld();
  }

  return diff;
}
项目:dsl-devkit    文件:FastLazyURIEncoder.java   
@Override
public Triple<EObject, EReference, INode> decode(final Resource res, final String uriFragment) {
  if (isUseIndexFragment(res)) {
    return getLazyProxyInformation(res, uriFragment);
  }
  try {
    int idx = DECODE_START_IDX;
    int idx2 = uriFragment.indexOf(SEP, idx);
    EObject source = resolveShortFragment(res, uriFragment.substring(idx, idx2));

    idx = idx2 + 2;
    idx2 = uriFragment.indexOf(SEP, idx);
    INode node = NodeModelUtils.getNode(source);
    if (node == null) {
      throw new IllegalStateException("Couldn't resolve lazy link, because no node model is attached."); //$NON-NLS-1$
    }

    EReference ref = fromShortExternalForm(source.eClass(), uriFragment.substring(idx, idx2));
    idx = idx2 + 2;
    INode text = getNode(node, uriFragment.substring(idx));
    return Tuples.create(source, ref, text);
    // CHECKSTYLE:OFF Yes, we *do* want to catch RuntimeExceptions here
  } catch (RuntimeException ex) {
    // CHECKSTYLE:ON
    throw new DecodingError(ex);
  }
}
项目:dsl-devkit    文件:LazyLinkingResource2.java   
/** {@inheritDoc} */
@Override
public synchronized EObject getEObject(final String uriFragment) {
  try {
    final EObject result = super.getEObject(uriFragment);
    if (result == null && getEncoder().isCrossLinkFragment(this, uriFragment)) {
      final ResourceSet rs = getResourceSet();
      if (rs.getLoadOptions().get(MARK_UNRESOLVABLE_XREFS) == Boolean.FALSE) {
        rs.getLoadOptions().put(MARK_UNRESOLVABLE_XREFS, Boolean.TRUE);
      }
    }
    return result;
  } catch (FastLazyURIEncoder.DecodingError err) {
    RuntimeException cause = err.getCause();
    getErrors().add(new ExceptionDiagnostic(cause));
    throw new WrappedException(cause);
  } catch (WrappedException e) {
    boolean logged = false;
    try {
      if (getEncoder().isCrossLinkFragment(this, uriFragment)) {
        Triple<EObject, EReference, INode> triple = getEncoder().decode(this, uriFragment);
        INode node = triple.getThird();
        final String nodeName = getLinkingHelper().getCrossRefNodeAsString(node, true);
        LOGGER.error("Resolution of uriFragment '" + uriFragment + "' in the resource '" + this.getURI() + "' node_name " + nodeName //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            + " line " + node.getStartLine() + " offset " + node.getOffset() + " failed.", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        logged = true;
      }
      // CHECKSTYLE:OFF
    } catch (RuntimeException e1) {
      // CHECKSTYLE:ON
      // ignore
    }
    if (!logged) {
      LOGGER.error("Resolution of uriFragment '" + uriFragment + "' in the resource '" + this.getURI() + "' failed.", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
    throw e;
  }
}
项目:dsl-devkit    文件:LazyLinkingResource2.java   
/**
 * {@inheritDoc}
 *
 * @return true if the {@link ICrossReferenceHelper} returns true
 */
@Override
public boolean suppressDiagnostic(final Triple<EObject, EReference, INode> triple) {
  final EObject context = triple.getFirst();
  final EReference reference = triple.getSecond();
  final INode node = triple.getThird();
  return crossReferenceHelper.isOptionalReference(context, reference, node);
}
项目:dsl-devkit    文件:LazyLinkingResource2.java   
@Override
protected EObject handleCyclicResolution(final Triple<EObject, EReference, INode> triple) {
  try {
    return super.handleCyclicResolution(triple);
  } catch (AssertionError ae) {
    throw new IllegalStateException(ae.getMessage() + " in resource " + getURI(), ae); //$NON-NLS-1$
  }
}