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


Java Resource.getResourceSet方法代码示例

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


在下文中一共展示了Resource.getResourceSet方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createToggleBreakpointsUtils

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@Override
protected DSLToggleBreakpointsUtils createToggleBreakpointsUtils() {
	return new DSLToggleBreakpointsUtils(getModelIdentifier()){
		
		@Override
		protected DSLBreakpoint createBreakpoint(Object selected,
				EObject instruction) throws CoreException {
			final Resource res = ((EObject)instruction).eResource();
			final ResourceSet resSet = res.getResourceSet();
			final MelangeResource mr = resSet.getResources().stream().filter(r -> {
				return r instanceof MelangeResource;
			}).map(r -> (MelangeResource)r).findFirst().orElse(null);
			if (mr != null) {
				final String fragmentURI = res.getURIFragment(instruction);
				instruction = mr.getWrappedResource().getEObject(fragmentURI);
			}
			return new GemocBreakpoint(identifier, instruction, true);
		}
		
	};
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:22,代码来源:GemocToggleBreakpointAction.java

示例3: caseApi

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@Override
public Api caseApi(final Api api) {
    final Resource resource = api.eResource();
    final ResourceSet resourceSet = resource.getResourceSet();
    final Api resolvedApi = copy(api);
    final URI resolvedApiUri = resource.getURI().appendQuery("resolved=true");
    final Resource resolvedResource = resourceSet.createResource(resolvedApiUri);

    resolvedResource.getContents().add(resolvedApi);
    resolvedResource.getErrors().addAll(resource.getErrors());

    final ResourceResolver resourceResolver = new ResourceResolver();
    final BodyContentTypeResolver bodyContentTypeResolver = new BodyContentTypeResolver(api.getMediaType());

    resolvedApi.eAllContents().forEachRemaining(eObject -> {
        resourceResolver.doSwitch(eObject);
        bodyContentTypeResolver.doSwitch(eObject);
    });

    return resolvedApi;
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:22,代码来源:RamlModelBuilder.java

示例4: createGlueModel

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public static Root createGlueModel(CIMRoot cim, Substandard substandard, COSEMRoot cosem) {
	Resource cimResource = cim.eResource();
	Resource cosemResource = cosem.eResource();

	ResourceSet rs = cimResource.getResourceSet();
	if (rs != cosemResource.getResourceSet()) {
		throw new RuntimeException("Different ResourceSets");
	}

	Resource fwdResource = rs.createResource(URI.createURI("fwd.src.xmi"));

	Root root = GluemodelFactory.eINSTANCE.createRoot();
	root.setCim(cim);
	root.setCosem(cosem);

	Hashtable<String, MeterAsset> allMeterAssets = getAllMeterAssets(cimResource);
	root.getAssets().addAll(allMeterAssets.values());


	cosem(cosemResource, root, allMeterAssets);

	if (substandard != null) {
		root.setSubstandard(substandard);
		substandard(substandard.eResource(), root, allMeterAssets);
	}

	fwdResource.getContents().add(root);
	return root;
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:30,代码来源:GlueModelCreator.java

示例5: isProjectVisible

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

示例6: isPublicInternalVisible

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

示例7: getEditorInput

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@Override
public IEditorInput getEditorInput(Object element) {
	if (element instanceof EObject) {
		
		EObject eObject = (EObject) element;
		EObject target = eObject;
		
		Resource res = eObject.eResource();
		if(res != null && res.getResourceSet() != null) {
			
			MelangeResourceImpl mr = null;
			for(Resource candidate : res.getResourceSet().getResources()) {
				if(candidate instanceof MelangeResourceImpl) {
					mr = (MelangeResourceImpl) candidate;
					break;
				}
			}
			
			if(mr != null) {
				String uriFragment = res.getURIFragment(eObject);
				target = mr.getWrappedResource().getEObject(uriFragment);
			}
		}
		
		 Resource r = eObject.eResource();
		 if (r instanceof XtextResource) {
			 URI uri = target.eResource().getURI();
		     if(uri.toPlatformString(true) !=  null){
		    	 IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true)));
		    	 IFileEditorInput input = new FileEditorInput(file);
		    	 return input;
		     }
		 }
		 else {
			 //Default
		 return getPresentation().getEditorInput(eObject);
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:41,代码来源:GemocSourceLocator.java

示例8: load

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public void load() {
	final Resource curRes = this.eResource();
	if (curRes != null) {
		final ResourceSet curResSet = curRes.getResourceSet();//new ResourceSetImpl();
		if (curResSet != null) {
			final Resource res = curResSet.getResource(uri, true);
			setResource(res);					
		}
	}
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:11,代码来源:ResourceArtefactImpl.java

示例9: getBuiltInTypeScope

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * Finds the built in type scope for the given resource and its applicable context.
 *
 * @param resource
 *            the resource that is currently linked
 * @return an instance of the {@link BuiltInTypeScope}
 */
protected BuiltInTypeScope getBuiltInTypeScope(Resource resource) {
	ResourceSet resourceSet = resource.getResourceSet();
	return BuiltInTypeScope.get(resourceSet);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:DefaultN4GlobalScopeProvider.java


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