public Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> createEnvironment() { EcoreEnvironment result = new EcoreEnvironment(this, null); return result; }
/** * Initializes me with a parent environment, from which I inherit such things * as a package registry and a resource. * * @param parent my parent environment */ protected EcoreEnvironment( Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> parent) { super((EcoreEnvironment) parent); EcoreEnvironment eparent = (EcoreEnvironment) parent; if (eparent != null) { factory = eparent.factory; registry = eparent.registry; typeResolver = eparent.getTypeResolver(); oppositeEndFinder = eparent.oppositeEndFinder; } else { registry = EPackage.Registry.INSTANCE; typeResolver = createTypeResolver(); } }
/** * Looks in the EMF registry for a package with the specified qualified * package name. Uses the global package registry. * * @param packageNames * the qualified package name * @return the matching EPackage, or <code>null</code> if not found */ static public EPackage findPackage(List<String> packageNames) { return findPackage(packageNames, EPackage.Registry.INSTANCE); }
Variable<EClassifier, EParameter> vdcl = lookupImplicitSourceForOppositeProperty(name); findOppositeEnds(owner, name, matches); } else if (matches.size() > 1) { if (notOK(ProblemOption.AMBIGUOUS_ASSOCIATION_ENDS)) { ProblemHandler.Severity sev = getValue(ProblemOption.AMBIGUOUS_ASSOCIATION_ENDS); name, getUMLReflection().getName(owner)); getProblemHandler().analyzerProblem(sev, message, "lookupNonNavigableProperty", -1, -1); //$NON-NLS-1$
EClassifier, EParameter>> params, Constraint constraint) { resetTypeCaches(); EOperation result = EcoreFactory.eINSTANCE.createEOperation(); result.setEType((type == null) ? getOCLStandardLibrary().getOclVoid() : type); param.setName(next.getName()); param.setEType((next.getType() == null)? getOCLStandardLibrary().getOclVoid() : next.getType()); Constraint existing = getDefinition(result); if (existing != null) { addHelperOperation(owner, result);
EClassifier, EParameter> variable, Constraint constraint) { resetTypeCaches(); EStructuralFeature result; result.setEType(type); Constraint existing = getDefinition(result); if (existing != null) { addHelperProperty(owner, result);
private EPackage findPackageWithStrategy(List<String> newNames, EPackage.Registry registry) { EPackage pkg; switch (ParsingOptions.getValue(this, ParsingOptions.PACKAGE_LOOKUP_STRATEGY)) { case LOOKUP_PACKAGE_BY_ALIAS: pkg = findPackageByAlias(newNames, registry); break; case LOOKUP_PACKAGE_BY_ALIAS_THEN_NAME: pkg = findPackageByAlias(newNames, registry); if (pkg == null) { pkg = findPackage(newNames, registry); } break; case LOOKUP_PACKAGE_BY_NAME: pkg = findPackage(newNames, registry); break; default: throw new RuntimeException("Unknown PACKAGE_LOOKUP_STRATEGY value "+ //$NON-NLS-1$ ParsingOptions.getValue(this, ParsingOptions.PACKAGE_LOOKUP_STRATEGY)); } return pkg; }
&& EcoreForeignMethods.isNamed(name, ePackage)) { EPackage tentativeResult = findNestedPackage( packageNames.subList(1, packageNames.size()), ePackage); return findPackageByNSPrefix(packageNames, registry);
/** * Initializes me with a package registry for package look-ups. * * @param reg a package registry * @deprecated Use {@link #EcoreEnvironment(EcoreEnvironmentFactory, null)} instead */ @Deprecated protected EcoreEnvironment(EPackage.Registry reg) { registry = reg; typeResolver = createTypeResolver(); }
/** * This will return the classifier representing the invalid type. * * @return Classifier representing the invalid type. */ public EClassifier getOCLInvalid() { if (oclInvalid == null) { final OCLStandardLibrary<EClassifier> stdLib = environment.getOCLStandardLibrary(); String methodName = "getInvalid"; //$NON-NLS-1$ if (AcceleoCompatibilityHelper.getCurrentVersion() == OCLVersion.HELIOS) { methodName = "getOclInvalid"; //$NON-NLS-1$ } try { final Method method = stdLib.getClass().getMethod(methodName); oclInvalid = (EClassifier)method.invoke(stdLib); } catch (NoSuchMethodException e) { // Shouldn't happen AcceleoCommonPlugin.log(e, true); } catch (InvocationTargetException e) { // cannot happen AcceleoCommonPlugin.log(e, true); } catch (IllegalAccessException e) { // We know this method is public AcceleoCommonPlugin.log(e, true); } } return oclInvalid; }
/** * Looks in the given registry for an 'nsURI' matching the first element in <tt>packageNames</tt>. * If found, further elements of <tt>packageNames</tt> identify nested packages. * <t> * This search supports the {@link ParsingOptions.LOOKUP_PACKAGE_BY_ALIAS} strategy. * * @param packageNames * the qualified package name * @param registry * the EPackage.Registry to look in * @return the matching EPackage, or <code>null</code> if not found */ static private EPackage findPackageByAlias(List<String> packageNames, EPackage.Registry registry) { if (packageNames.isEmpty()) { return null; } String name = packageNames.get(0); EPackage ePackage = registry.getEPackage(name); if (ePackage != null) { List<String> packageSubList = packageNames.subList(1, packageNames.size()); ePackage = findNestedPackage(packageSubList, ePackage); } return ePackage; }
/** * Obtains the states matching the specified path prefix in the owner type * by trying the {@link #collectStates} method on it and, recursively, its * supertypes to find all matches. For implicit (<code>null</code>) owners, * looks up the innermost-scoped variable as the implicit source and tries * again on this variable's type. * <p> * To extend this implementation, override the * {@link #collectStates} method. * </p> */ public List<EObject> getStates(EClassifier owner, List<String> pathPrefix) { EList<EObject> result = new BasicEList<EObject>(); collectStates(owner, pathPrefix, result); if (owner instanceof EClass) { // search supertypes for (EClass superclass : ((EClass) owner).getEAllSuperTypes()) { collectStates(superclass, pathPrefix, result); } } return result; }
/** * Creates a new type resolver for use with this environment, persisted * in a default resource. * * @return a new type resolver * * @deprecated Override the {@link #createTypeResolver(Resource)} method, * instead, handling the case where the resource is <code>null</code> */ @Deprecated protected TypeResolver<EClassifier, EOperation, EStructuralFeature> createTypeResolver() { return createTypeResolver(null); }
final OCLStandardLibrary<EClassifier> stdLib = environment.getOCLStandardLibrary(); String methodName = "getOclInvalid"; //$NON-NLS-1$ if (AcceleoCompatibilityHelper.getCurrentVersion() == OCLVersion.HELIOS) {
/** * Initializes me with a package registry and a resource in which I am * persisted (and from which I load myself if it already has content). * * @param reg a package registry * @param resource a resource, which may or may not already have content * @deprecated Use {@link #EcoreEnvironment(EcoreEnvironmentFactory, Resource)} instead */ @Deprecated protected EcoreEnvironment(EPackage.Registry reg, Resource resource) { registry = reg; typeResolver = createTypeResolver(resource); }
public Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> loadEnvironment(Resource resource) { EcoreEnvironment result = new EcoreEnvironment(this, resource); return result; }
@Override protected EPackage lookupPackage(List<String> pathname) { return EcoreEnvironment.findPackage(pathname, registry); }
/** * Initializes me with an environment factory from which package registry * and opposite end finder (if any) are obtained consistently, and from a * resource in which I am persisted (and from which I load myself if it * already has content). * * @param reg * a package registry * @param resource * a resource, which may or may not already have content * @since 3.1 */ protected EcoreEnvironment(EcoreEnvironmentFactory fac, Resource resource) { factory = fac; registry = fac.getEPackageRegistry(); oppositeEndFinder = fac.getOppositeEndFinder(); typeResolver = createTypeResolver(resource); }
public Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> createEnvironment(Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> parent) { if (!(parent instanceof EcoreEnvironment)) { throw new IllegalArgumentException( "Parent environment must be an Ecore environment: " + parent); //$NON-NLS-1$ } EcoreEnvironment result = new EcoreEnvironment(parent); return result; }