Skip to content

Commit

Permalink
Merge pull request dsldevkit#1048 from rubenporras/contains
Browse files Browse the repository at this point in the history
Remove duplicated access to a set element and use lambas
  • Loading branch information
rubenporras authored Dec 4, 2024
2 parents be662ee + 751eda8 commit 085eeb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ protected List<IReferenceDescription> uniqueReferences(final List<IReferenceDesc
List<IReferenceDescription> noRepeats = Lists.newArrayListWithExpectedSize(refs.size());
for (IReferenceDescription ref : refs) {
String sourceURI = ref.getSourceEObjectUri().toString();
if (!addedRefs.contains(sourceURI)) {
addedRefs.add(sourceURI);
if (addedRefs.add(sourceURI)) {
noRepeats.add(ref);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import com.avaloq.tools.ddk.xtext.naming.QualifiedNames;
import com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2.ReferenceMatchPolicy;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
Expand Down Expand Up @@ -217,17 +215,8 @@ public static Iterable<IReferenceDescription> findReferencesToObjects(final IRes
* @return An {@link Iterable} of all {@link IReferenceDescription}s of all cross-references that reference the given objects.
*/
public static Iterable<IReferenceDescription> findReferencesToObjects(final Iterable<IResourceDescription> descriptions, final Set<URI> targetObjects) {
return Iterables.concat(Iterables.transform(descriptions, new Function<IResourceDescription, Iterable<IReferenceDescription>>() {
@Override
public Iterable<IReferenceDescription> apply(final IResourceDescription from) {
return Iterables.filter(from.getReferenceDescriptions(), new Predicate<IReferenceDescription>() {
@Override
public boolean apply(final IReferenceDescription input) {
return targetObjects.contains(input.getTargetEObjectUri());
}
});
}
}));
return Iterables.concat(Iterables.transform(descriptions, from -> Iterables.filter(//
from.getReferenceDescriptions(), input -> targetObjects.contains(input.getTargetEObjectUri()))));
}

}

0 comments on commit 085eeb4

Please sign in to comment.