@Override public Iterable<Node> getChildren() { List<Node> children = new LinkedList<>(); children.addAll(members); children.addAll(annotations); if (baseType.isPresent()) { children.add(baseType.get()); } children.addAll(interfaces); return children; }
@Override public List<ReferenceTypeUsage> getAllAncestors() { if (getBaseType().isPresent()) { List<ReferenceTypeUsage> res = new ArrayList<>(); res.add(getBaseType().get().asReferenceTypeUsage()); res.addAll(getBaseType().get().asReferenceTypeUsage().getAllAncestors()); return res; } return ImmutableList.of(ReferenceTypeUsage.OBJECT(symbolResolver())); }
private void initializeImplicitConstructor(SymbolResolver resolver) { List<? extends FormalParameter> inheritedParams = Collections.emptyList(); if (getBaseType().isPresent()) { List<InternalConstructorDefinition> constructors = getBaseType().get().asReferenceTypeUsage().getTypeDefinition().getConstructors(); if (constructors.size() != 1) { throw new UnsupportedOperationException(); } inheritedParams = constructors.get(0).getFormalParameters(); } List<FormalParameterNode> newParams = this.assignableProperties(resolver) .stream() .map( (p) -> new FormalParameterNode( p.getTypeUsage().copy(), p.getName(), p.getDefaultValue())) .collect(Collectors.toList()); List<FormalParameter> allParams = new LinkedList<>(); allParams.addAll(inheritedParams); allParams.addAll(newParams); allParams.sort( new Comparator<FormalParameter>() { @Override public int compare(FormalParameter o1, FormalParameter o2) { return Boolean.compare(o1.hasDefaultValue(), o2.hasDefaultValue()); } }); for (FormalParameter p : allParams) { // needed to solve symbols if (p.isNode()) { p.asNode().setParent(this); } } addConstructorWithParams(allParams, resolver); }