本文整理汇总了Java中org.eclipse.emf.common.util.URI.fragment方法的典型用法代码示例。如果您正苦于以下问题:Java URI.fragment方法的具体用法?Java URI.fragment怎么用?Java URI.fragment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.URI
的用法示例。
在下文中一共展示了URI.fragment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simpleURIString
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
static String simpleURIString(URI uri) {
if (uri == null)
return "!!null!!";
return uri.lastSegment() + "#" + uri.fragment();
}
示例2: doResolveProxy
import org.eclipse.emf.common.util.URI; //导入方法依赖的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);
}