001/*
002 * Copyright 2010-2013 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.jetbrains.jet.rt.signature;
018
019import jet.typeinfo.TypeInfoVariance;
020
021/**
022 * @see SignatureVisitor
023 * @url http://confluence.jetbrains.net/display/JET/Jet+Signatures
024 */
025public interface JetSignatureVisitor {
026
027    /**
028     * Wildcard for an "extends" type argument.
029     */
030    char EXTENDS = '+';
031
032    /**
033     * Wildcard for a "super" type argument.
034     */
035    char SUPER = '-';
036
037    /**
038     * Wildcard for a normal type argument.
039     */
040    char INSTANCEOF = '=';
041
042    /**
043     * Visits a formal type parameter.
044     *
045     * TODO should not store reified flag in signature
046     *
047     * @param name the name of the formal parameter.
048     */
049    JetSignatureVisitor visitFormalTypeParameter(String name, TypeInfoVariance variance, boolean reified);
050
051    void visitFormalTypeParameterEnd();
052
053    /**
054     * Visits the class bound of the last visited formal type parameter.
055     *
056     * @return a non null visitor to visit the signature of the class bound.
057     */
058    JetSignatureVisitor visitClassBound();
059
060    /**
061     * Visits an interface bound of the last visited formal type parameter.
062     *
063     * @return a non null visitor to visit the signature of the interface bound.
064     */
065    JetSignatureVisitor visitInterfaceBound();
066
067    /**
068     * Visits the type of the super class.
069     *
070     * @return a non null visitor to visit the signature of the super class
071     *         type.
072     */
073    JetSignatureVisitor visitSuperclass();
074
075    /**
076     * Visits the type of an interface implemented by the class.
077     *
078     * @return a non null visitor to visit the signature of the interface type.
079     */
080    JetSignatureVisitor visitInterface();
081
082    /**
083     * Visits the type of a method parameter.
084     *
085     * @return a non null visitor to visit the signature of the parameter type.
086     */
087    JetSignatureVisitor visitParameterType();
088
089    /**
090     * Visits the return type of the method.
091     *
092     * @return a non null visitor to visit the signature of the return type.
093     */
094    JetSignatureVisitor visitReturnType();
095
096    /**
097     * Visits the type of a method exception.
098     *
099     * @return a non null visitor to visit the signature of the exception type.
100     */
101    JetSignatureVisitor visitExceptionType();
102
103    /**
104     * Visits a signature corresponding to a primitive type.
105     *
106     * @param descriptor the descriptor of the primitive type, or 'V' for
107     *        <tt>void</tt>.
108     */
109    void visitBaseType(char descriptor, boolean nullable);
110
111    /**
112     * Visits a signature corresponding to a type variable.
113     *
114     * @param name the name of the type variable.
115     */
116    void visitTypeVariable(String name, boolean nullable);
117
118    /**
119     * Visits a signature corresponding to an array type.
120     *
121     * @return a non null visitor to visit the signature of the array element
122     *         type.
123     */
124    JetSignatureVisitor visitArrayType(boolean nullable, JetSignatureVariance wildcard);
125
126    /**
127     * Starts the visit of a signature corresponding to a class or interface
128     * type.
129     *
130     * @param name the internal name of the class or interface.
131     */
132    void visitClassType(String name, boolean nullable, boolean forceReal);
133
134    /**
135     * Visits an inner class.
136     *
137     * @param name the full name of the inner class.
138     */
139    void visitInnerClassType(String name, boolean nullable, boolean forceReal);
140
141    /**
142     * Visits an unbounded type argument of the last visited class or inner
143     * class type.
144     */
145    void visitTypeArgument();
146
147    /**
148     * Visits a type argument of the last visited class or inner class type.
149     *
150     * @param wildcard '+', '-' or '='.
151     * @return a non null visitor to visit the signature of the type argument.
152     */
153    JetSignatureVisitor visitTypeArgument(JetSignatureVariance wildcard);
154
155    /**
156     * Ends the visit of a signature corresponding to a class or interface type.
157     */
158    void visitEnd();
159}