Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*******************************************************************************/
package org.eclipse.xtext.linking.lazy;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.WrappedException;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.EClassImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.diagnostics.DiagnosticMessage;
import org.eclipse.xtext.diagnostics.ExceptionDiagnostic;
import org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider;
import org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext;
import org.eclipse.xtext.linking.ILinkingService;
import org.eclipse.xtext.linking.impl.IllegalNodeException;
import org.eclipse.xtext.linking.impl.LinkingHelper;
import org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.util.CancelIndicator;
import org.eclipse.xtext.util.Triple;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Provider;
/**
* @author Sven Efftinge - Initial contribution and API
* @author Holger Schill
*/
public class LazyLinkingResource extends XtextResource {
private static Logger log = Logger.getLogger(LazyLinkingResource.class);
/**
* The cache key for a Set of uri fragments that cannot be resolved.
* @since 2.4
*/
public static final String UNRESOLVEABLE_PROXIES_KEY = "UNRESOLVEABLE_PROXIES";
@Inject
private ILinkingService linkingService;
@Inject
private LazyURIEncoder encoder;
@Inject
private ILinkingDiagnosticMessageProvider diagnosticMessageProvider;
@Inject
private ILinkingDiagnosticMessageProvider.Extended linkingDiagnosticMessageProvider;
@Inject
private LinkingHelper linkingHelper;
private boolean eagerLinking = false;
@Override
protected void doLoad(InputStream inputStream, Map, ?> options) throws IOException {
super.doLoad(inputStream, options);
if (options != null && Boolean.TRUE.equals(options.get(OPTION_RESOLVE_ALL)))
EcoreUtil.resolveAll(this);
}
@Override
protected void doLinking() {
super.doLinking();
if (isEagerLinking())
EcoreUtil.resolveAll(this);
}
private LinkedHashSet> resolving = Sets.newLinkedHashSet();
/**
* resolves any lazy cross references in this resource, adding Issues for unresolvable elements to this resource.
* This resource might still contain resolvable proxies after this method has been called.
*
* @param mon a {@link CancelIndicator} can be used to stop the resolution.
*/
public void resolveLazyCrossReferences(final CancelIndicator mon) {
final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon;
TreeIterator