本文整理汇总了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());
}
示例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));
}
示例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);
}
}
示例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);
}
示例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()));
}
}
示例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));
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例14: isDangling
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private static final boolean isDangling(EObject target) {
return target != null && target.eResource() == null;
}
示例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();
}