当前位置: 首页>>代码示例>>Java>>正文


Java URI.trimFragment方法代码示例

本文整理汇总了Java中org.eclipse.emf.common.util.URI.trimFragment方法的典型用法代码示例。如果您正苦于以下问题:Java URI.trimFragment方法的具体用法?Java URI.trimFragment怎么用?Java URI.trimFragment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.common.util.URI的用法示例。


在下文中一共展示了URI.trimFragment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEditor

import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private XtextEditor getEditor(URI uri) {
	// note: trimming fragment in previous line makes this more stable in case of changes to the
	// Xtext editor's contents (we are not interested in a particular element, just the editor)
	final URI uriToEditor = uri != null ? uri.trimFragment() : null;
	if (uriToEditor != null) {
		final IEditorPart editor = getEditorOpener().open(uriToEditor, false);
		if (editor instanceof XtextEditor)
			return (XtextEditor) editor;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:ChangeManager.java

示例2: onDoubleClick

import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
 * Invoked when user double-clicks a result node in the UI.
 */
protected void onDoubleClick() {
	final ISelection selection = testTreeViewer.getSelection();
	final ResultNode resultNode = (ResultNode) ((IStructuredSelection) selection).getFirstElement();

	if (resultNode == null) {
		return;
	}

	TestElement testElement = resultNode.getElement();
	if (testElement instanceof TestCase) {

		final URI testCaseURI = ((TestCase) testElement).getURI();
		if (testCaseURI == null) {
			return;
		}

		final IN4JSEclipseProject project = core.findProject(testCaseURI).orNull();
		if (null != project && project.exists()) {
			final URI moduleLocation = testCaseURI.trimFragment();
			final String[] projectRelativeSegments = moduleLocation.deresolve(project.getLocation()).segments();
			final String path = Joiner.on(SEPARATOR)
					.join(copyOfRange(projectRelativeSegments, 1, projectRelativeSegments.length));
			final IFile module = project.getProject().getFile(path);
			if (null != module && module.isAccessible()) {
				uriOpener.open(testCaseURI, true);
			} else {
				openError(getShell(), "Cannot open editor", "Test class not found in selected project.");
			}
		} else {
			openError(getShell(), "Cannot open editor", "The container project not found in the workspace.");
		}

	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:38,代码来源:TestResultsView.java

示例3: getSessions

import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
 * Gets the {@link List} of {@link Session} referencing the given semantic {@link URI}.
 * 
 * @param uri
 *            the semantic {@link URI}
 * @return the {@link List} of {@link Session} referencing the given semantic {@link URI}
 */
public static List<Session> getSessions(URI uri) {
	final List<Session> res = new ArrayList<Session>();
	final URI resourceURI = uri.trimFragment();
	for (Session session : SessionManager.INSTANCE.getSessions()) {
		for (Resource resource : session.getSemanticResources()) {
			if (resourceURI.equals(resource.getURI())) {
				res.add(session);
				break;
			}
		}
	}

	return res;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:22,代码来源:SiriusEditorUtils.java

示例4: AbstractAtomicChange

import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
 * Constructs a new atomic change.
 *
 * @see IAtomicChange
 */
public AbstractAtomicChange(URI uri, int offset, int length) {
	this.uri = uri.trimFragment();
	this.offset = offset;
	this.length = length;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:11,代码来源:IAtomicChange.java

示例5: 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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:79,代码来源:N4JSResource.java

示例6: resolve

import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private IEObjectDescription resolve(IEObjectDescription original) {
	if (original != null && original.getEObjectOrProxy().eIsProxy()
			&& EcoreUtil2.isAssignableFrom(type, original.getEClass())) {
		final URI objectURI = original.getEObjectURI();
		final URI resourceURI = objectURI.trimFragment();
		Resource resource = resourceSet.getResource(resourceURI, false);
		if (resource != null && resource.isLoaded()) {
			return original;
		}
		final boolean mustLoadFromSource = canLoadFromDescriptionHelper.mustLoadFromSource(resourceURI,
				resourceSet);
		resource = resourceSet.getResource(resourceURI, mustLoadFromSource);
		if (resource != null && resource.isLoaded()) {
			return original;
		}
		if (mustLoadFromSource) {
			// error case: forced loading failed
			// --> still avoid loading from index; instead simply return 'original' as in other error cases
			return original;
		}
		if (resource == null) {
			resource = resourceSet.createResource(resourceURI);
		}
		if (resource instanceof N4JSResource) {
			if (resource.getContents().isEmpty()) {
				N4JSResource casted = (N4JSResource) resource;
				IResourceDescription resourceDescription = container.getResourceDescription(resourceURI);
				if (resourceDescription != null) {
					if (casted.isLoaded()) {
						// LiveShadowingResourceDescriptions (part of Xtext's rename refactoring)
						// will load that stuff on #getResourceDescription
						return original;
					}
					try {
						if (!casted.loadFromDescription(resourceDescription)) {
							return original;
						}
					} catch (Exception e) {
						casted.unload();
						return original;
					}
				} else {
					return original;
				}
			}
			// resolveProxy is implemented recursively thus we have to avoid
			// that here by decorating the
			// description and return the resolved instance instead
			EObject resolved = resolveObject(objectURI, resource);
			if (resolved == null) {
				return original;
			}
			return new ResolvedDescription(resolved, original);
		}
	}
	return original;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:58,代码来源:UserDataAwareScope.java


注:本文中的org.eclipse.emf.common.util.URI.trimFragment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。