本文整理汇总了Java中org.eclipse.xtext.EcoreUtil2.getResourceSet方法的典型用法代码示例。如果您正苦于以下问题:Java EcoreUtil2.getResourceSet方法的具体用法?Java EcoreUtil2.getResourceSet怎么用?Java EcoreUtil2.getResourceSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.EcoreUtil2
的用法示例。
在下文中一共展示了EcoreUtil2.getResourceSet方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findKnownTopLevelType
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
protected JvmType findKnownTopLevelType(Class<?> rawType, Notifier context) {
if (rawType.isArray()) {
throw new IllegalArgumentException(rawType.getCanonicalName());
}
if (rawType.isPrimitive()) {
throw new IllegalArgumentException(rawType.getName());
}
ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
if (resourceSet == null) {
return null;
}
Resource typeResource = resourceSet.getResource(URIHelperConstants.OBJECTS_URI.appendSegment(rawType.getName()), true);
List<EObject> resourceContents = typeResource.getContents();
if (resourceContents.isEmpty())
return null;
JvmType type = (JvmType) resourceContents.get(0);
return type;
}
示例2: findKnownType
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
protected JvmType findKnownType(Class<?> rawType, Notifier context) {
if (rawType.isArray()) {
throw new IllegalArgumentException(rawType.getCanonicalName());
}
if (rawType.isPrimitive()) {
throw new IllegalArgumentException(rawType.getName());
} ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
if (resourceSet == null) {
return null;
}
Class<?> declaringClass = rawType.getDeclaringClass();
if (declaringClass == null) {
return findKnownTopLevelType(rawType, resourceSet);
}
JvmType result = (JvmType) resourceSet.getEObject(URIHelperConstants.OBJECTS_URI.appendSegment(declaringClass.getName()).appendFragment(rawType.getName()), true);
return result;
}
示例3: getJavaLangObjectTypeRef
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
protected JvmTypeReference getJavaLangObjectTypeRef(JvmType rawType, TypesFactory typesFactory) {
ResourceSet rs = EcoreUtil2.getResourceSet(rawType);
JvmParameterizedTypeReference refToObject = typesFactory.createJvmParameterizedTypeReference();
if (rs != null) {
EObject javaLangObject = rs.getEObject(javaLangObjectURI, true);
if (javaLangObject instanceof JvmType) {
JvmType objectDeclaration = (JvmType) javaLangObject;
refToObject.setType(objectDeclaration);
return refToObject;
}
}
JvmGenericType proxy = typesFactory.createJvmGenericType();
((InternalEObject)proxy).eSetProxyURI(javaLangObjectURI);
refToObject.setType(proxy);
return refToObject;
}
示例4: findDeclaredType
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
/**
* looks up a JVMType corresponding to the given {@link Class}. This method ignores any Jvm types created in non-
* {@link TypeResource} in the given context's resourceSet, but goes straight to the Java-layer, using a
* {@link IJvmTypeProvider}.
*
* @return the JvmType with the same qualified name as the given {@link Class} object, or null if no such JvmType
* could be found using the context's resourceSet.
*/
public JvmType findDeclaredType(String typeName, Notifier context) {
if (typeName == null)
throw new NullPointerException("typeName");
if (context == null)
throw new NullPointerException("context");
ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
if (resourceSet == null)
return null;
// make sure a type provider is configured in the resource set.
IJvmTypeProvider typeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
try {
final JvmType result = typeProvider.findTypeByName(typeName);
return result;
} catch (RuntimeException e) {
operationCanceledManager.propagateAsErrorIfCancelException(e);
log.info("Couldn't find JvmType for name '" + typeName + "' in context " + context, e);
return null;
}
}
示例5: setContext
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
@Override
public void setContext(final Notifier ctx) {
IResourceDescriptions _localDescriptions = this.getLocalDescriptions();
final Procedure1<ResourceSetBasedResourceDescriptions> _function = (ResourceSetBasedResourceDescriptions it) -> {
it.setContext(ctx);
it.setData(null);
};
ObjectExtensions.<ResourceSetBasedResourceDescriptions>operator_doubleArrow(((ResourceSetBasedResourceDescriptions) _localDescriptions), _function);
final ResourceSet resourceSet = EcoreUtil2.getResourceSet(ctx);
this.setGlobalDescriptions(ChunkedResourceDescriptions.findInEmfObject(resourceSet));
IProjectConfig _projectConfig = null;
if (this.projectConfigProvider!=null) {
_projectConfig=this.projectConfigProvider.getProjectConfig(resourceSet);
}
IWorkspaceConfig _workspaceConfig = null;
if (_projectConfig!=null) {
_workspaceConfig=_projectConfig.getWorkspaceConfig();
}
this.workspaceConfig = _workspaceConfig;
}
示例6: findAnnotationType
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
private JvmAnnotationType findAnnotationType(Class<? extends Annotation> type, Notifier context) {
ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
if (resourceSet == null)
return null;
IJvmTypeProvider typeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
try {
final JvmType result = typeProvider.findTypeByName(type.getName());
if (result instanceof JvmAnnotationType)
return (JvmAnnotationType) result;
return null;
} catch (RuntimeException e) {
return null;
}
}
示例7: isIndexing
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
public boolean isIndexing(Notifier ctx) {
ResourceSet set = EcoreUtil2.getResourceSet(ctx);
if (set != null) {
return EcoreUtil.getAdapter(set.eAdapters(), IndexingAdapter.INSTANCE) != null;
}
return false;
}
示例8: setIndexing
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
public void setIndexing(Notifier ctx, boolean isIndex) {
ResourceSet set = EcoreUtil2.getResourceSet(ctx);
if (isIndex) {
set.eAdapters().add(IndexingAdapter.INSTANCE);
} else {
set.eAdapters().remove(IndexingAdapter.INSTANCE);
}
}
示例9: setContext
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
@Override
public void setContext(Notifier ctx) {
this.resourceSet = EcoreUtil2.getResourceSet(ctx);
if (resourceSet != null) {
data = ResourceDescriptionsData.ResourceSetAdapter.findResourceDescriptionsData(resourceSet);
}
}
示例10: setContext
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
/**
* Set the context.
*
* @param ctx
* The context
*/
@Override
public void setContext(final Notifier ctx) {
super.setContext(ctx);
final ResourceSet resourceSet = EcoreUtil2.getResourceSet(ctx);
IResourceDescriptions adapter = (IResourceDescriptions) EcoreUtil2.getAdapter(resourceSet.eAdapters(), CurrentDescriptions.class);
if (adapter instanceof IResourceDescriptions2) {
delegate = (IResourceDescriptions2) adapter;
} else {
delegate = new ResourceDescriptions2(adapter);
}
}
示例11: setContext
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
@Override
public void setContext(Notifier ctx) {
this.resourceSet = EcoreUtil2.getResourceSet(ctx);
}
示例12: get
import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
public static ResourceSetContext get(Notifier context) {
ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
return new ResourceSetContext(resourceSet);
}