public void setContext(Notifier ctx) { this.resourceSet = EcoreUtil2.getResourceSet(ctx); }
public void setContext(Notifier ctx) { this.resourceSet = EcoreUtil2.getResourceSet(ctx); }
@Nullable 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; } }
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; } }
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; }
/** * Set the context. * * @param ctx * The context */ public void setContext(Notifier ctx) { final ResourceSet resourceSet = EcoreUtil2.getResourceSet(ctx); delegate = (IResourceDescriptions) EcoreUtil.getAdapter(resourceSet.eAdapters(), CurrentDescriptions.class); }
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; }
/** * 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) { log.info("Couldn't find JvmType for name '" + typeName + "' in context " + context, e); return null; } }
@Override public GeneratorConfig get(EObject context) { // Search for the Eclipse configuration final ResourceSet resourceSet = EcoreUtil2.getResourceSet(context); if (resourceSet != null) { final GeneratorConfigProvider.GeneratorConfigAdapter adapter = GeneratorConfigProvider.GeneratorConfigAdapter.findInEmfObject(resourceSet); if (adapter != null && adapter.getLanguage2GeneratorConfig().containsKey(this.languageId)) { return adapter.getLanguage2GeneratorConfig().get(this.languageId); } } // Create the default configuration final GeneratorConfig config = createDefaultGeneratorConfig(); return config; }
/** * 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; } }
@Override public GeneratorConfig get(EObject context) { EMFPatternLanguageGeneratorConfig config = new EMFPatternLanguageGeneratorConfig(); ResourceSet resourceSet = EcoreUtil2.getResourceSet(context); if (resourceSet != null) { IProjectConfig projectConfig = projectConfigProvider.getProjectConfig(resourceSet); if (projectConfig != null) { URI configFilePath = projectConfig.getPath().appendSegments(new String[] {".settings", "org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs"}); File f = new File(configFilePath.toFileString()); if (f.canRead()) { Properties vqlCompilerSettings = new Properties(); try { vqlCompilerSettings.load(new FileInputStream(f)); config.parseBuilderConfigurationPropertiesFile(vqlCompilerSettings); } catch (IOException e) { logger.warn(e); } } } } return config; }
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; }
final SarlLibraryErrorCode errorCode = Utils.getSARLLibraryVersionOnClasspath(typeReferences, sarlScript, sarlLibraryVersion); if (errorCode != SarlLibraryErrorCode.SARL_FOUND) { final ResourceSet resourceSet = EcoreUtil2.getResourceSet(sarlScript); final StringBuilder classPath = new StringBuilder(); for (final Resource resource : resourceSet.getResources()) {