@Check public void checkPrivatePatternCall(PatternCall call) { final Pattern calledPattern = call.getPatternRef(); if (calledPattern != null) { if (Iterables.any(calledPattern.getModifiers(), new Predicate<Modifiers>() { @Override public boolean apply(Modifiers input) { return input.isPrivate(); } }) && calledPattern.eResource() != call.eResource()) { error(String.format("The pattern %s is not visible.", getFormattedPattern(calledPattern)), PatternLanguagePackage.Literals.PATTERN_CALL__PATTERN_REF, IssueCodes.PRIVATE_PATTERN_CALLED); } } }
Set<Resource> containerResources = new HashSet<Resource>(); for (Pattern pattern : patternSet) { Resource resource = pattern.eResource(); if (resource != null) { containerResources.add(resource);
@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); } } } } } }