當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。