Skip to content

Commit

Permalink
fix getParentTypes for EolCollectionType
Browse files Browse the repository at this point in the history
  • Loading branch information
pkourouklidis committed Nov 27, 2024
1 parent 2c58910 commit d71f93a
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
******************************************************************************/
package org.eclipse.epsilon.eol.staticanalyser.types;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class EolCollectionType extends EolType {

protected EolType contentType = EolAnyType.Instance;
Expand Down Expand Up @@ -107,4 +111,18 @@ public EolType getParentType() {
return EolAnyType.Instance;
}
}

@Override
public List<EolType> getParentTypes() {
List<EolType> parentTypes = new ArrayList<EolType>();
if (this.isBag() || this.isSet() || this.isOrderedSet() || this.isSequence())
parentTypes.add(new EolCollectionType("Collection", this.getContentType()));
else
parentTypes.add(EolAnyType.Instance);

if (!(this.getContentType() instanceof EolAnyType))
parentTypes.addAll(this.getContentType().getParentTypes().stream()
.map(e -> new EolCollectionType(this.getName(), e)).collect(Collectors.toList()));
return parentTypes;
}
}

0 comments on commit d71f93a

Please sign in to comment.