當前位置: 首頁>>代碼示例>>Java>>正文


Java EcoreUtil.resolve方法代碼示例

本文整理匯總了Java中org.eclipse.emf.ecore.util.EcoreUtil.resolve方法的典型用法代碼示例。如果您正苦於以下問題:Java EcoreUtil.resolve方法的具體用法?Java EcoreUtil.resolve怎麽用?Java EcoreUtil.resolve使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.emf.ecore.util.EcoreUtil的用法示例。


在下文中一共展示了EcoreUtil.resolve方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getActualReplacementString

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Return the to-be-inserted string if an existing import is present.
 */
@Override
public String getActualReplacementString(ConfigurableCompletionProposal proposal) {
	String syntacticReplacementString = proposal.getReplacementString();
	if (scope != null) {
		final QualifiedName qualifiedName = applyValueConverter(syntacticReplacementString);
		if (qualifiedName.getSegmentCount() == 1) {
			return syntacticReplacementString;
		}
		final IEObjectDescription element = scope.getSingleElement(qualifiedName);
		if (element != null) {
			EObject resolved = EcoreUtil.resolve(element.getEObjectOrProxy(), context);
			if (!resolved.eIsProxy()) {
				IEObjectDescription description = findApplicableDescription(resolved, qualifiedName, true);
				if (description != null) {
					String multisegmentProposal = applyValueConverter(description.getName());
					return multisegmentProposal;
				}
			}
		}
	}
	return syntacticReplacementString;

}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:27,代碼來源:FQNImporter.java

示例2: getPolyfillTypesFromScope

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private List<Type> getPolyfillTypesFromScope(QualifiedName fqn) {

			IScope contextScope = polyfillScopeAccess.getRecordingPolyfillScope(contextResource);
			List<Type> types = new ArrayList<>();

			// contextScope.getElements(fqn) returns all polyfills, since shadowing is handled differently
			// for them!
			for (IEObjectDescription descr : contextScope.getElements(fqn)) {
				Type polyfillType = (Type) descr.getEObjectOrProxy();
				if (polyfillType.eIsProxy()) {
					// TODO review: this seems odd... is this a test setup problem (since we do not use the
					// index
					// there and load the resource separately)?
					polyfillType = (Type) EcoreUtil.resolve(polyfillType, contextResource);
					if (polyfillType.eIsProxy()) {
						throw new IllegalStateException("unexpected proxy");
					}
				}
				types.add(polyfillType);
			}
			// }

			return types;
		}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:25,代碼來源:ContainerTypesHelper.java

示例3: loadTClass

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private Optional<TClass> loadTClass(final ResourceSet resSet, final IEObjectDescription objDesc) {
	if (T_CLASS.isSuperTypeOf(objDesc.getEClass())) {
		final EObject objectOrProxy = objDesc.getEObjectOrProxy();
		final EObject object = objectOrProxy.eIsProxy() ? EcoreUtil.resolve(objectOrProxy, resSet) : objectOrProxy;
		if (!object.eIsProxy()) {
			return fromNullable((TClass) object);
		}
	}
	return absent();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:11,代碼來源:TestDiscoveryHelper.java

示例4: getMessage

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
public String getMessage() {
	StringBuilder typeListStr = new StringBuilder();
	IdentifiableElement first = (IdentifiableElement) EcoreUtil.resolve(getEObjectOrProxy(), context);
	String typeIdent = first instanceof Type ? "type" : "variable";
	TModule module = (TModule) first.eContainer();
	typeListStr.append(module.getQualifiedName());
	Set<IdentifiableElement> uniqueTypes = Sets.newLinkedHashSet(elements);
	uniqueTypes.remove(first);
	Iterator<IdentifiableElement> iter = uniqueTypes.iterator();
	while (iter.hasNext()) {
		IdentifiableElement type = iter.next();
		if (iter.hasNext()) {
			typeListStr.append(", ");
		} else {
			typeListStr.append(" and ");
		}
		typeListStr.append(((TModule) type.eContainer()).getQualifiedName());
	}
	if (this.issueCode == IssueCodes.IMP_AMBIGUOUS_WILDCARD) {
		return IssueCodes.getMessageForIMP_AMBIGUOUS_WILDCARD(typeIdent, getName(), typeListStr.toString());
	} else if (this.issueCode == IssueCodes.IMP_AMBIGUOUS) {
		return IssueCodes.getMessageForIMP_AMBIGUOUS(typeIdent, getName(), typeListStr.toString());
	} else if (this.issueCode == IssueCodes.IMP_DUPLICATE_NAMESPACE) {
		return IssueCodes.getMessageForIMP_DUPLICATE_NAMESPACE(getName(), "stub");
	}
	return "Unknown ambiguous import issue: " + this.issueCode + " for " + context + ".";
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:29,代碼來源:AmbiguousImportDescription.java

示例5: getLanguage

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 */
@Override
public String getLanguage ()
{
    if ( this.reference != null )
    {
        final Script ref = (Script)EcoreUtil.resolve ( this.reference, this );
        return ref.getLanguage ();
    }
    else
    {
        return null;
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:20,代碼來源:ScriptReferenceImpl.java

示例6: getSource

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 */
@Override
public String getSource ()
{
    if ( this.reference != null )
    {
        final Script ref = (Script)EcoreUtil.resolve ( this.reference, this );
        return ref.getSource ();
    }
    else
    {
        return null;
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:20,代碼來源:ScriptReferenceImpl.java

示例7: findLaunchConfig

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Finds a launch configuration with the given name from the current EMF index. The index contains all
 * launch configurations from projects that have the Xtext nature. Launch configurations from projects
 * without the Xtext nature are not found. Use {@link #findLaunchConfig(String, IFile)} in this case.
 *
 * @param name the name of the configuration to find
 * @return the configuration or <code>null</code>
 */
public LaunchConfig findLaunchConfig(String name) {
    Iterable<IEObjectDescription> indexed = index.getExportedObjectsByType(LcDslPackage.eINSTANCE.getLaunchConfig());

    for (IEObjectDescription o : indexed) {
        if (o.getName().getLastSegment().equals(name)) {
            EObject obj = EcoreUtil.resolve(o.getEObjectOrProxy(), rsProvider.get());
            EcoreUtil.resolveAll(obj);
            return (LaunchConfig) obj;
        }
    }
    return null;
}
 
開發者ID:mduft,項目名稱:lcdsl,代碼行數:21,代碼來源:LcDslHelper.java

示例8: doResolveProxy

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Invoked from {@link ProxyResolvingEObjectImpl#eResolveProxy(InternalEObject)} whenever an EMF proxy inside an
 * N4JSResource is being resolved. The receiving resource is the resource containing the proxy, not necessarily the
 * resource the proxy points to.
 *
 * @param proxy
 *            the proxy to resolve.
 * @param objectContext
 *            the {@code EObject} contained in this resource that holds the given proxy.
 */
@Override
public EObject doResolveProxy(InternalEObject proxy, EObject objectContext) {
	// step 1: trigger post processing of the resource containing 'proxy' iff it is the first proxy being resolved
	// (if another proxy has been resolved before, post processing will already be running/completed, and in that
	// case the next line will simply do nothing, cf. #performPostProcessing())
	this.performPostProcessing();
	// step 2: now turn to resolving the proxy at hand
	final URI targetUri = proxy.eProxyURI();
	final boolean isLazyLinkingProxy = getEncoder().isCrossLinkFragment(this, targetUri.fragment());
	if (!isLazyLinkingProxy) {
		// we have an ordinary EMF proxy (not one of Xtext's lazy linking proxies) ...
		final ResourceSet resSet = getResourceSet();
		final URI targetResourceUri = targetUri.trimFragment();
		final String targetFileExt = targetResourceUri.fileExtension();
		if (N4JSGlobals.N4JS_FILE_EXTENSION.equals(targetFileExt)
				|| N4JSGlobals.N4JSD_FILE_EXTENSION.equals(targetFileExt)
				|| N4JSGlobals.N4JSX_FILE_EXTENSION.equals(targetFileExt)) {

			// proxy is pointing into an .n4js or .n4jsd file ...
			// check if we can work with the TModule from the index or if it is mandatory to load from source
			final boolean canLoadFromDescription = !targetUri.fragment().startsWith("/0")
					&& canLoadFromDescriptionHelper.canLoadFromDescription(targetResourceUri, getResourceSet());
			if (canLoadFromDescription) {

				final String targetFragment = targetUri.fragment();
				final Resource targetResource = resSet.getResource(targetResourceUri, false);

				// special handling #1:
				// if targetResource is not loaded yet, try to load it from index first
				if (targetResource == null) {
					if (targetFragment != null
							&& (targetFragment.equals("/1") || targetFragment.startsWith("/1/"))) {
						// uri points to a TModule element in a resource not yet contained in our resource set
						// --> try to load target resource from index
						final IResourceDescriptions index = n4jsCore.getXtextIndex(resSet);
						final IResourceDescription resDesc = index.getResourceDescription(targetResourceUri);
						if (resDesc != null) {
							// next line will add the new resource to resSet.resources
							n4jsCore.loadModuleFromIndex(resSet, resDesc, false);
						}
					}
				}
			}
			// standard behavior:
			// obtain target EObject from targetResource in the usual way
			// (might load targetResource from disk if it wasn't loaded from index above)
			final EObject targetObject = resSet.getEObject(targetUri, true);
			// special handling #2:
			// if targetResource exists, make sure it is post-processed *iff* this resource is post-processed
			// (only relevant in case targetResource wasn't loaded from index, because after loading from index it
			// is always marked as fullyPostProcessed==true)
			if (targetObject != null && (this.isPostProcessing() || this.isFullyProcessed())) {
				final Resource targetResource2 = targetObject.eResource();
				if (targetResource2 instanceof N4JSResource) {
					// no harm done, if already running/completed
					((N4JSResource) targetResource2).performPostProcessing();
				}
			}
			// return resolved target object
			return targetObject != null ? targetObject : proxy; // important: return proxy itself if unresolvable!
		}
	}
	// we will get here if
	// a) we have an Xtext lazy linking proxy or
	// b) targetUri points to an n4ts resource or some other, non-N4JS resource
	// --> above special handling not required, so just apply EMF's default resolution behavior
	return EcoreUtil.resolve(proxy, this);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:79,代碼來源:N4JSResource.java


注:本文中的org.eclipse.emf.ecore.util.EcoreUtil.resolve方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。