package net.peelo.kahvi.compiler.ast.type;

import net.peelo.kahvi.compiler.ast.AtomVisitor;
import net.peelo.kahvi.compiler.util.Name;
import net.peelo.kahvi.compiler.util.SourcePosition;

public final class ClassType extends ReferenceType
{
    private final Name className;

    public ClassType(SourcePosition position, Name className)
    {
        super(position);
        this.className = className;
    }

    public Name getClassName()
    {
        return this.className;
    }

    @Override
    public <R, P> R accept(TypeVisitor<R, P> visitor, P p)
    {
        return visitor.visitClassType(this, p);
    }

    @Override
    public <R, P> R accept(TypeArgumentVisitor<R, P> visitor, P p)
    {
        return visitor.visitClassType(this, p);
    }

    @Override
    public <R, P> R accept(AtomVisitor<R, P> visitor, P p)
    {
        return visitor.visitClassType(this, p);
    }

    @Override
    public String toString()
    {
        return this.className.toString();
    }
}

@@ -183,16 +183,70 @@
 ition;%0A%0A
+import java.util.Collections;%0Aimport java.util.List;%0A%0A
 public f
@@ -298,738 +298,1941 @@
     
-private final Name className;%0A%0A    public ClassType(SourcePosition position, Name className)%0A    %7B%0A        super(position);%0A        this.className = className;%0A    %7D%0A%0A    public Name getClassName()%0A    %7B%0A        return this.className;%0A    %7D%0A%0A    @Override%0A    public %3CR, P%3E R accept(TypeVisitor%3CR, P%3E visitor, P p)%0A    %7B%0A        return visitor.visitClassType(this, p);%0A    %7D%0A%0A    @Override%0A    public %3CR, P%3E R accept(TypeArgumentVisitor%3CR, P%3E visitor, P p)%0A    %7B%0A        return visitor.visitClassType(this, p);%0A    %7D%0A%0A    @Override%0A    public %3CR, P%3E R accept(AtomVisitor%3CR, P%3E visitor, P p)%0A    %7B%0A        return visitor.visitClassType(this, p);%0A    %7D%0A%0A    @Override%0A    public String toString()%0A    %7B%0A        return this.className
+/** Qualified name of the type. */%0A    private final Name className;%0A    /** Optional type arguments. */%0A    private final List%3CTypeArgument%3E typeArguments;%0A%0A    public ClassType(SourcePosition position, Name className)%0A    %7B%0A        this(position, className, Collections.%3CTypeArgument%3EemptyList());%0A    %7D%0A%0A    public ClassType(SourcePosition position,%0A                     Name className,%0A                     List%3CTypeArgument%3E typeArguments)%0A    %7B%0A        super(position);%0A        this.className = className;%0A        for (TypeArgument ta : (this.typeArguments = typeArguments))%0A        %7B%0A            ta.setEnclosingScope(this);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Returns qualified name of the class.%0A     */%0A    public Name getClassName()%0A    %7B%0A        return this.className;%0A    %7D%0A%0A    /**%0A     * Returns list of optional type arguments.%0A     */%0A    public List%3CTypeArgument%3E getTypeArguments()%0A    %7B%0A        return this.typeArguments;%0A    %7D%0A%0A    @Override%0A    public %3CR, P%3E R accept(TypeVisitor%3CR, P%3E visitor, P p)%0A    %7B%0A        return visitor.visitClassType(this, p);%0A    %7D%0A%0A    @Override%0A    public %3CR, P%3E R accept(TypeArgumentVisitor%3CR, P%3E visitor, P p)%0A    %7B%0A        return visitor.visitClassType(this, p);%0A    %7D%0A%0A    @Override%0A    public %3CR, P%3E R accept(AtomVisitor%3CR, P%3E visitor, P p)%0A    %7B%0A        return visitor.visitClassType(this, p);%0A    %7D%0A%0A    @Override%0A    public String toString()%0A    %7B%0A        StringBuilder sb = new StringBuilder();%0A%0A        sb.append(this.className);%0A        if (!this.typeArguments.isEmpty())%0A        %7B%0A            boolean first = true;%0A%0A            sb.append('%3C');%0A            for (TypeArgument ta : this.typeArguments)%0A            %7B%0A                if (first)%0A                %7B%0A                    first = false;%0A                %7D else %7B%0A                    sb.append(%22, %22);%0A                %7D%0A                sb.append(ta);%0A            %7D%0A            sb.append('%3E');%0A        %7D%0A%0A        return sb
 .toS

add type arguments