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


Java EObject.eResource方法代码示例

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


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

示例1: isResolvedAndExternal

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
 * Checks, if the second EObject is resolved and if it is contained in different resource than the first EObject. If
 * the second EObject is a proxy than its proxy URI fragment is used to check for different resources. The first
 * EObject is expected to be already resolved.
 *
 * @param from
 *            the EObject containing the reference to the second EObject
 * @param to
 *            the EObject referenced by the first EObject
 * @return true, when second EObject can be resolved and not in the same resource as the first EObject is
 */
// Copied from DefaultResourceDescriptionStrategy
public boolean isResolvedAndExternal(EObject from, EObject to) {
	if (to == null)
		return false;
	if (!to.eIsProxy()) {
		if (to.eResource() == null) {
			LOG.error("Reference from " + EcoreUtil.getURI(from) + " to " + to
					+ " cannot be exported as the target is not contained in a resource.");
			return false;
		}
		return from.eResource() != to.eResource();
	}
	return !uriEncoder
			.isCrossLinkFragment(from.eResource(), ((InternalEObject) to).eProxyURI().fragment());
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:27,代码来源:N4JSExternalReferenceChecker.java

示例2: scopeWithResource

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
 * Compares scope including resource name but not line number.
 */
@Xpect
@ParameterParser(syntax = "('at' arg1=OFFSET)?")
public void scopeWithResource( //
		@N4JSCommaSeparatedValuesExpectation IN4JSCommaSeparatedValuesExpectation expectation, //
		ICrossEReferenceAndEObject arg1 //
) {
	EObject eobj = arg1.getEObject();
	IScope scope = scopeProvider.getScope(eobj, arg1.getCrossEReference());
	for (IEObjectDescription eo : scope.getAllElements()) {
		eo.getEObjectURI();
	}
	URI uri = eobj == null ? null : eobj.eResource() == null ? null : eobj.eResource().getURI();
	expectation.assertEquals(new ScopeAwareIterable(uri, false, scope),
			new IsInScopeWithOptionalPositionPredicate(converter,
					uri, false, scope));
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:ScopeXpectMethod.java

示例3: getDocSafely

import org.eclipse.emf.ecore.EObject; //导入方法依赖的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

示例4: fileExtensionPredicate

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
 * This method check if the extension of the resource file associated with
 * the Sirius session is provided by viewpoint specifier.
 * 
 * @return True if the current page can be used with the current resource.
 * @generated
 */
protected boolean fileExtensionPredicate() {
	final EObject rootSemanticModel = ActivityExplorerManager.INSTANCE.getRootSemanticModel();
	final Resource eResource = rootSemanticModel.eResource();
	if (null == eResource)
		return false;

	final URI resourceURI = eResource.getURI();
	if (null == resourceURI)
		return false;

	final List<String> allowedFileExtensions = Arrays.asList("fileExtension");
	final String fileExtension = resourceURI.fileExtension().toLowerCase();

	return allowedFileExtensions.contains(fileExtension);
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:23,代码来源:PageNamePredicate.java

示例5: assertNoIssuesExcept

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
 * Asserts the given model to not have any issues except the ones specified by the exception issue codes parameter.
 *
 * @param model
 *            The model
 * @param exceptionIssueCodes
 *            Issue codes which should be ignored
 */
public void assertNoIssuesExcept(EObject model, String... exceptionIssueCodes) {
	Resource resource = model.eResource();
	final List<Issue> issues = validate(resource);

	if (removeIssuesWithCode(issues, exceptionIssueCodes).size() > 0) {
		fail("Expected no issues, but got :" + getIssuesAsString(resource, issues, new StringBuilder()));
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:17,代码来源:N4JSValidationTestHelper.java

示例6: getURI

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private static void getURI(EObject parent, EObject target, Appendable buf) throws Exception {
	Resource r = target.eResource();
	buf.append(target.eClass().getName());
	buf.append("@");
	if (r == null) {
		if (((InternalEObject) target).eIsProxy()) {
			buf.append("(unresolved proxy " + ((InternalEObject) target).eProxyURI() + ")");
		} else {
			buf.append("(resource null)");
		}
	} else if (parent.eResource() == r)
		buf.append(r.getURIFragment(target));
	else
		buf.append(r.getURI().toString()).append("#").append(r.getURIFragment(target));
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:OrderedEmfFormatter.java

示例7: isVisible

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
 * Returns the MemberVisibility of the <i>member</i> of the <i>receiverType</> in the given <i>context</i>
 * <i>supercall</i> indicates if the target of the context is the super type.
 */
private MemberVisibility isVisible(EObject context, TypeRef receiverType, TMember member,
		boolean supercall) {
	// special case: union types
	if (receiverType instanceof UnionTypeExpression) {
		// note: we are here a bit more restrictive than required,
		// because we use the combined accessibility for all members
		for (TypeRef currUnitedTypeRef : ((UnionTypeExpression) receiverType).getTypeRefs())
			if (!isVisible(context, currUnitedTypeRef, member, supercall).visibility)
				return new MemberVisibility(false);
		return new MemberVisibility(true);
	}

	// standard case:
	Resource contextResource = context.eResource();
	N4TypeDefinition typeDefiningContainer = EcoreUtil2.getContainerOfType(context, N4TypeDefinition.class);
	Script script = EcoreUtil2.getContainerOfType(typeDefiningContainer != null ? typeDefiningContainer : context,
			Script.class);
	Type contextType = null;
	TModule contextModule = script.getModule();
	if (typeDefiningContainer != null) {
		contextType = typeDefiningContainer.getDefinedType();
	}
	Type declaredReceiverType = getActualDeclaredReceiverType(context, receiverType,
			contextResource.getResourceSet());
	if (declaredReceiverType != null
			&& typeVisibilityChecker.isVisible(contextResource, declaredReceiverType).visibility) {
		// check for local usage of locally defined member
		if (shortcutIsVisible(member, contextType, contextModule, declaredReceiverType)) {
			return new MemberVisibility(true);
		}

		return isVisible(contextModule, contextType, declaredReceiverType, member, supercall);
	}
	return new MemberVisibility(false);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:40,代码来源:MemberVisibilityChecker.java

示例8: getServiceForContext

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
 * Same as {@link #getServiceForContext(URI, Class)}, but accepts any {@link EObject} contained in an Xtext language
 * resource. Returns <code>null</code> if the given context object is not contained in a {@link Resource}.
 */
public static <T> Optional<T> getServiceForContext(EObject context, Class<T> serviceType) {
	Objects.requireNonNull(context);
	Objects.requireNonNull(serviceType);
	final Resource res = context.eResource();
	final URI uri = res != null ? res.getURI() : null;
	return uri != null ? getServiceForContext(uri, serviceType) : Optional.empty();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:N4LanguageUtils.java

示例9: getResourceSet

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
 * Returns the ResourceSet containing the first given object. If it is not contained in a ResourceSet, the other
 * objects are searched for a containing ResourceSet in the given order. Returns null if none of the objects is
 * contained in a ResourceSet.
 */
public static ResourceSet getResourceSet(EObject obj, EObject... otherObjs) {
	ResourceSet resSet = obj != null && obj.eResource() != null ? obj.eResource().getResourceSet() : null;
	if (resSet != null)
		return resSet;
	for (EObject currObj : otherObjs) {
		resSet = currObj != null && currObj.eResource() != null ? currObj.eResource().getResourceSet() : null;
		if (resSet != null)
			return resSet;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:17,代码来源:EcoreUtilN4.java

示例10: getResource

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
 * Returns the Resource containing the first given object. If it is not contained in a Resource, the other objects
 * are searched for a containing Resource in the given order. Returns null if none of the objects is contained in a
 * Resource.
 */
public static Resource getResource(EObject obj, EObject... otherObjs) {
	Resource res = obj != null ? obj.eResource() : null;
	if (res != null)
		return res;
	for (EObject currObj : otherObjs) {
		res = currObj != null ? currObj.eResource() : null;
		if (res != null)
			return res;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:17,代码来源:EcoreUtilN4.java

示例11: getEditorId

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
@Override
public String getEditorId(IEditorInput input, Object element) {
	if (element instanceof EObject) {
		EObject eObject = (EObject) element;
		Resource r = eObject.eResource();
		if (r instanceof XtextResource) {
			return ((XtextResource) r).getLanguageName();
		}
	}
	 
	//Default
	ISourcePresentation presentation = getPresentation();
	return presentation.getEditorId(input, element);
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:15,代码来源:GemocSourceLocator.java

示例12: getConnectedEdgesForEObject

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
 * Add outgoing references
 */
private void getConnectedEdgesForEObject(Node node, final List<Node> allNodes, final List<Edge> result,
		final EObject eobj) {

	for (EReference currRef : eobj.eClass().getEAllReferences()) {
		if (!currRef.isDerived() && !currRef.isContainer()) {
			if (currRef.isMany()) {
				final Object targets = eobj.eGet(currRef, false);
				if (targets instanceof Collection<?>) {
					getConnectedEdgesForEObjectManyCase(node, allNodes, result, currRef, targets);
				}
			} else {
				final Object target = eobj.eGet(currRef, false);
				if (target instanceof EObject) {
					getConnectedEdgesForEObjectSingleCase(node, allNodes, result, currRef, target);
				}
			}
		}
	}

	// add reference to containing Resource if immediate container is not in graph
	// (required when showing lower-level objects while hiding their ancestors)
	Node nodeForElement = GraphUtils.getNodeForElement(eobj.eContainer(), allNodes);

	if (eobj.eResource() != null && eobj.eContainer() != null && nodeForElement == null) {
		final Node nodeForResource = GraphUtils.getNodeForElement(eobj.eResource(), allNodes);
		if (nodeForResource != null) {
			Edge edge = new Edge(
					"<... containment omitted ...>",
					false, // not a cross-link
					nodeForResource,
					Collections.singletonList(node),
					Collections.emptyList());

			result.add(edge);
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:41,代码来源:ASTGraphProvider.java

示例13: isLocatedInOtherResource

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private boolean isLocatedInOtherResource(Resource resource, EObject eobj) {
	if (eobj == null || eobj.eResource() == null)
		return false;

	boolean ret = !N4Scheme.isFromResourceWithN4Scheme(eobj)
			&& externalReferenceChecker.isResolvedAndExternal(resource, eobj);
	return ret;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:N4JSCrossReferenceComputer.java

示例14: isDangling

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private static final boolean isDangling(EObject target) {
	return target != null && target.eResource() == null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:4,代码来源:N4JSValidationTestHelper.java

示例15: getResourceURI

import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private URI getResourceURI(EObject root) {
	Resource resource = root.eResource();
	if (resource != null)
		return resource.getURI();
	return EcoreUtil.getURI(root).trimFragment();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:7,代码来源:N4JSUnloader.java


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