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


Java ResourceSet.getEObject方法代码示例

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


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

示例1: getFirstInstruction

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
 * Gets the first {@link EObject instruction}.
 * 
 * @param configuration
 *            the {@link ILaunchConfiguration}
 * @return the first {@link EObject instruction}
 */
protected EObject getFirstInstruction(ILaunchConfiguration configuration) {
EObject res = null;
final ResourceSet rs = getResourceSet();

try {
	rs.getResource(URI.createPlatformResourceURI(configuration.getAttribute(RESOURCE_URI, ""),
		true), true);
	res = rs.getEObject(URI.createURI(configuration.getAttribute(FIRST_INSTRUCTION_URI, ""),
		true), true);
} catch (CoreException e) {
	Activator.getDefault().error(e);
}

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

示例2: getTarget

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private EObject getTarget(XtextResource resource, IHyperlink hyperlink) {
	final ResourceSet resourceSet = resource != null ? resource.getResourceSet() : null;
	final URI uri = hyperlink instanceof XtextHyperlink ? ((XtextHyperlink) hyperlink).getURI() : null;
	final EObject target = resourceSet != null && uri != null ? resourceSet.getEObject(uri, true) : null;
	if (target instanceof SyntaxRelatedTElement)
		return ((SyntaxRelatedTElement) target).getAstElement();
	return target;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:HyperlinkXpectMethod.java

示例3: isProjectVisible

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private boolean isProjectVisible(Resource contextResource, URI elementLocation) {
	URI moduleURI = getURI(contextResource);

	if (moduleURI.isPlatformResource() && elementLocation.isPlatformResource()) {
		// Not valid for PUBLIC_INTERNAL
		final boolean visible = moduleURI.segment(1).equals(elementLocation.segment(1));
		// A special case when checking visibility between host and test project. Since type is not resolved and
		// we do not want additional CPU cycles we check whether the context resource contained in a test
		// project that has a host at all.
		// TODO IDEBUG-640 this needs to be reviewed again, since the refactoring made here are invalid.
		if (visible) {
			return true;
		} else {
			if (getTestedProjects(getURI(contextResource)).isEmpty()) {
				return false;
			}
			//$FALL-THROUGH$ if the project for the context resource has a host project.
		}
	} else {
		ResourceSet resourceSet = contextResource.getResourceSet();

		EObject loadedType = resourceSet.getEObject(elementLocation, false);
		if (loadedType == null) {
			loadedType = resourceSet.getEObject(elementLocation, true);
		}
		if (loadedType instanceof Type) {
			// delegate to the *real* impl
			return isVisible(contextResource, TypeAccessModifier.PROJECT, (Type) loadedType).visibility;
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:33,代码来源:TypeVisibilityChecker.java

示例4: isPublicInternalVisible

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private boolean isPublicInternalVisible(Resource contextResource, URI elementLocation) {
	// for more detailed checks, we have to obtain the referenced type from the resource set
	ResourceSet resourceSet = contextResource.getResourceSet();

	EObject loadedType = resourceSet.getEObject(elementLocation, false);
	if (loadedType == null) {
		loadedType = resourceSet.getEObject(elementLocation, true);
	}
	if (loadedType instanceof Type) {
		// delegate to the *real* impl
		return isVisible(contextResource, TypeAccessModifier.PUBLIC_INTERNAL, (Type) loadedType).visibility;
	}
	return false;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:15,代码来源:TypeVisibilityChecker.java

示例5: isOneInstructionPresent

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
 * Tells if at least one of the given instruction {@link URI} is present in the given
 * {@link ResourceSet}.
 * 
 * @param instructionUris
 *            the {@link Set} of instructions {@link URI}
 * @param resourceSet
 *            the {@link ResourceSet}
 * @return <code>true</code> if at least one of the given instruction {@link URI} is present in the
 *         given {@link ResourceSet}, <code>false</code> otherwise
 */
private static boolean isOneInstructionPresent(Set<URI> instructionUris,
		final ResourceSet resourceSet) {
	boolean instructionPresent = false;
	for (URI instructionUri : instructionUris) {
		if (resourceSet.getEObject(instructionUri, false) != null) {
			instructionPresent = true;
			break;
		}
	}
	return instructionPresent;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:23,代码来源:AbstractDSLDebuggerServices.java

示例6: isOneInstructionPresent

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**Tells if at least one of the given instruction {@link URI} is present in the given {@link ResourceSet}.
 * @param instructionUris the {@link Set} of instructions {@link URI}
 * @param resourceSet the {@link ResourceSet}
 * @return <code>true</code> if at least one of the given instruction {@link URI} is present in the given {@link ResourceSet}, <code>false</code> otherwise
 */
private boolean isOneInstructionPresent(Set<URI> instructionUris,
		final ResourceSet resourceSet) {
	boolean instructionPresent = false;
	for (URI instructionUri : instructionUris) {
		if (resourceSet.getEObject(instructionUri, false) != null) {
			instructionPresent = true;
			break;
		}
	}
	return instructionPresent;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:17,代码来源:AbstractGemocAnimatorServices.java

示例7: addInclude

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
public static void addInclude ( final Profile profile, final ResourceSet resourceSet, final URI uri )
{
    final EObject content = resourceSet.getEObject ( uri, true );
    if ( content instanceof Profile )
    {
        profile.getIncludes ().add ( (Profile)content );
    }
    else
    {
        throw new IllegalStateException ( String.format ( "URI '%s' must point to an object of type '%s'.", uri, Profile.class.getName () ) );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:Profiles.java

示例8: doResolveProxy

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

示例9: isAccepted

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
@Override
protected boolean isAccepted(IEObjectDescription description) {
	EObject proxyOrInstance = description.getEObjectOrProxy();

	if (proxyOrInstance instanceof Type) {
		Type type = (Type) proxyOrInstance;
		if (type.eIsProxy() && contextResource != null) {
			// we found a proxy. Only valid precondition for a proxy that was returned from a
			// UserDataAwareScope is that the resource that contains the real instance is already
			// available in the resource set and loaded.
			// thus it's save to use resourceSet.getEObject(uri, false) and it has to return a proper instance
			//
			ResourceSet resourceSet = contextResource.getResourceSet();
			// don't load on demand
			EObject fromResourceSet = resourceSet.getEObject(description.getEObjectURI(), false);
			if (fromResourceSet instanceof Type) {
				type = (Type) fromResourceSet;
			} else {
				// type is no longer available in resource set because index state is out of sync
				// assume the unresolved proxy to be visible to reduce number of follow-up problems.
				return true;
			}
		}
		// paranoid double check - object from resource set should never be a proxy
		if (!type.eIsProxy()) {
			TypeVisibility typeVisibility = checker.isVisible(contextResource, type);

			if (typeVisibility.visibility) {
				accessModifierSuggestionStore.put(description.getEObjectURI().toString(),
						typeVisibility.accessModifierSuggestion);
			}
			return typeVisibility.visibility;

		} else {
			throw new IllegalStateException("Unexpected proxy:" + type);

		}
	}
	return true;

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

示例10: getElement

import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
 * Gets the element to pass in the {@link LabelProviderChangedEvent} from the given {@link DSLBreakpoint}
 * and {@link ResourceSet}.
 * 
 * @param rs
 *            the {@link ResourceSet}
 * @param breakpoint
 *            the {@link DSLBreakpoint}
 * @return the element to pass in the {@link LabelProviderChangedEvent} from the given
 *         {@link DSLBreakpoint} and {@link ResourceSet}
 */
protected Object getElement(ResourceSet rs, DSLBreakpoint breakpoint) {
	return rs.getEObject(((DSLBreakpoint)breakpoint).getURI(), false);
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:15,代码来源:DSLLabelDecorator.java


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