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


Java Resource.getEObject方法代码示例

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


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

示例1: getDocSafely

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * Same as {@link #getDoc(EObject)}, but will never change the containing resource of the given element.
 * <p>
 * If the containing resource of the given element is not fully loaded (i.e. AST not loaded yet because only the
 * TModule was loaded from the Xtext index), then the given resource set will be used to load the resource, then the
 * corresponding EObject for element will be searched in that temporary resource, and the documentation will be
 * retrieved from there.
 */
public String getDocSafely(ResourceSet resourceSetForDocRetrieval, EObject element) {
	if (resourceSetForDocRetrieval == null)
		throw new IllegalArgumentException("resourceSetForDocRetrieval may not be null");
	if (element == null || element.eIsProxy())
		throw new IllegalArgumentException("element may not be null or a proxy");
	final Resource res = element.eResource();
	final ResourceSet resSet = res != null ? res.getResourceSet() : null;
	if (resSet == null || res == null)
		throw new IllegalArgumentException("element must be contained in a resource set");
	if (resourceSetForDocRetrieval != resSet) {
		final Resource resSafe = resourceSetForDocRetrieval.getResource(res.getURI(), true);
		final EObject elementSafe = resSafe.getEObject(res.getURIFragment(element));
		return elementSafe != null ? getDoc(elementSafe) : null;
	} else {
		return getDoc(element);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:N4JSDocHelper.java

示例2: updateMainElementName

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * Update _entryPointModelElement with pretty name
 */
private void updateMainElementName(){
	try {
		Resource model = getModel();
		EObject mainElement = null;
		if(model != null){
			mainElement = model.getEObject(_entryPointModelElementText.getText());
		}
		if(mainElement != null){
			org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider nameprovider = new DefaultDeclarativeQualifiedNameProvider();
			QualifiedName qname = nameprovider.getFullyQualifiedName(mainElement);
			String objectName = qname != null ? qname.toString(): mainElement.toString();
			String prettyName =	objectName+ " : "+mainElement.eClass().getName();
			_entryPointModelElementLabel.setText(prettyName);
		}
	} catch (Exception e) {	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:20,代码来源:LaunchConfigurationMainTab.java

示例3: load

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@Test
public void load() throws IOException {
    final Resource builtinTypesResource = fromUri(BuiltinType.RESOURCE_URI);
    assertThat(builtinTypesResource.getErrors()).hasSize(0);

    assertThat(builtinTypesResource).isNotNull();
    for (final BuiltinType builtinType : BuiltinType.values()) {
        final EObject anyType = builtinTypesResource.getEObject("/types/" + builtinType.getName());

        assertThat(anyType).isNotNull();
        assertThat(anyType).isInstanceOf(AnyType.class);
        final AnyType type = (AnyType) anyType;
        final AnyType superType = type.getType();
        assertThat(superType).isNull();

        final EObject anyAnnotationType = builtinTypesResource.getEObject("/annotationTypes/" + builtinType.getName());

        assertThat(anyAnnotationType).isNotNull();
        assertThat(anyAnnotationType).isInstanceOf(AnyAnnotationType.class);
        final AnyAnnotationType annotationType = (AnyAnnotationType) anyAnnotationType;
        final AnyAnnotationType superAnnotationType = annotationType.getType();
        assertThat(superAnnotationType).isNull();
    }
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:25,代码来源:BuiltinTypeTest.java

示例4: resolveObject

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * {@link EcoreUtil#resolve(EObject, EObject)} pretty much does the same thing but will eagerly load the resource.
 * We are happy with the content that we just put into it.
 */
private EObject resolveObject(URI objectURI, Resource resource) {
	if (resource.isLoaded())
		throw new IllegalStateException("Should not be loaded beforehand");
	EObject result = resource.getEObject(objectURI.fragment());
	if (resource.isLoaded())
		throw new IllegalStateException("Should not be loaded due to fragment traversal");
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:13,代码来源:UserDataAwareScope.java


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