/** * Returns the packageName: PatternModel.packageName or "" when nullOrEmpty. */ public String getPackageName(final Pattern pattern) { EObject _eContainer = pattern.eContainer(); String packageName = ((PatternModel) _eContainer).getPackageName(); boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(packageName); if (_isNullOrEmpty) { packageName = ""; } return packageName.toLowerCase(); }
_builder.newLine(); _builder.append("<p> From package "); String _packageName = model.getPackageName(); _builder.append(_packageName, ""); _builder.append(", the group contains the definition of the following patterns: <ul>"); _builder.newLineIfNotEmpty(); EList<Pattern> _patterns = model.getPatterns(); for(final Pattern p : _patterns) { _builder.append("<li>");
@Check public void checkPatterns(PatternModel model) { resourceDescriptions.setContext(model); if (model.getPatterns() != null) { // TODO: more precise calculation is needed for duplicate patterns // (number and type of pattern parameters) for (Pattern pattern : model.getPatterns()) { QualifiedName fullyQualifiedName = nameProvider.getFullyQualifiedName(pattern); final Iterable<IEObjectDescription> shadowingPatternDescriptions = resourceDescriptions.getExportedObjects(PatternLanguagePackage.Literals.PATTERN, fullyQualifiedName, true); for (IEObjectDescription shadowingPatternDescription : shadowingPatternDescriptions) { EObject shadowingPattern = shadowingPatternDescription.getEObjectOrProxy(); if (shadowingPattern != pattern) { URI resourceUri = pattern.eResource().getURI(); URI otherResourceUri = shadowingPatternDescription.getEObjectURI().trimFragment(); // not using shadowingPattern because it might be proxy IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(resourceUri); IResourceDescription otherResourceDescription = resourceDescriptions.getResourceDescription(otherResourceUri); List<IContainer> visible = containerManager.getVisibleContainers(resourceDescription, resourceDescriptions); List<IContainer> visibleFromOther = containerManager.getVisibleContainers(otherResourceDescription, resourceDescriptions); if (Iterables.any(visible, contains(otherResourceDescription)) || Iterables.any(visibleFromOther, contains(resourceDescription))) { String otherResourcePath = Objects.firstNonNull(otherResourceUri.toPlatformString(true), otherResourceUri.toFileString()); error(String.format(DUPLICATE_PATTERN_DEFINITION_MESSAGE, fullyQualifiedName, otherResourcePath), pattern, PatternLanguagePackage.Literals.PATTERN__NAME, IssueCodes.DUPLICATE_PATTERN_DEFINITION); } } } } } }
JvmConstructor _inferConstructor = this.inferConstructor(model, groupClass); this._eMFJvmTypesBuilder.<JvmConstructor>operator_add(_members_2, _inferConstructor); EList<Pattern> _patterns = model.getPatterns(); final Function1<Pattern, Boolean> _function = new Function1<Pattern, Boolean>() { @Override
@Check public void checkPackageDeclaration(PatternModel model) { String packageName = model.getPackageName(); if (packageName == null || packageName.isEmpty()) { error("The package declaration must not be empty", PatternLanguagePackage.Literals.PATTERN_MODEL__PACKAGE_NAME, IssueCodes.PACKAGE_NAME_EMPTY); } if (packageName != null && !packageName.equals(packageName.toLowerCase())) { error("Only lowercase package names supported", PatternLanguagePackage.Literals.PATTERN_MODEL__PACKAGE_NAME, IssueCodes.PACKAGE_NAME_MISMATCH); } }
/** * Returns the name of the container package of the selected pattern * @return a name of the pattern; never null, but may be empty string */ public static String getPackageName(Pattern pattern) { if(pattern == null || pattern.eIsProxy()) { return ""; } PatternModel patternModel = (PatternModel) pattern.eContainer(); return (patternModel == null) ? null : patternModel.getPackageName(); }
/** * Returns the packageName: PatternModel.packageName + Pattern.name, packageName is ignored, when nullOrEmpty. */ public String getPackageNameOld(final Pattern pattern) { EObject _eContainer = pattern.eContainer(); String packageName = ((PatternModel) _eContainer).getPackageName(); boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(packageName); if (_isNullOrEmpty) { packageName = ""; } else { packageName = (packageName + "."); } String _name = pattern.getName(); String _plus = (packageName + _name); return _plus.toLowerCase(); }
@Override public void apply(final JvmGenericType it) { String _packageName = model.getPackageName(); it.setPackageName(_packageName); it.setFinal(true); EList<JvmTypeReference> _superTypes = it.getSuperTypes(); JvmTypeReference _typeRef = PatternGroupClassInferrer.this.builder.typeRef(BaseGeneratedPatternGroup.class); PatternGroupClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); } };