< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java

Print this page

1127 
1128     protected Copier createCopier(TreeMaker maker) {
1129         return new Copier(maker);
1130     }
1131 
1132     /**
1133      * Returns the original type from the ErrorType object.
1134      * @param errorType The errorType for which we want to get the original type.
1135      * @return TypeMirror corresponding to the original type, replaced by the ErrorType.
1136      *         noType (type.tag == NONE) is returned if there is no original type.
1137      */
1138     @Override @DefinedBy(Api.COMPILER_TREE)
1139     public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
1140         if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType targetErrorType) {
1141             return targetErrorType.getOriginalType();
1142         }
1143         if (errorType instanceof com.sun.tools.javac.code.Type.ClassType classType &&
1144             errorType.getKind() == TypeKind.ERROR) {
1145             return extraType2OriginalMap.computeIfAbsent(classType, tt ->
1146                     new ClassType(classType.getEnclosingType(), classType.typarams_field,
1147                             classType.tsym, classType.getMetadata()) {
1148                         @Override
1149                         public Type baseType() { return classType; }
1150                         @Override
1151                         public TypeKind getKind() {
1152                             return TypeKind.DECLARED;
1153                         }
1154                     });
1155         }
1156 
1157         return com.sun.tools.javac.code.Type.noType;
1158     }
1159 
1160     /**
1161      * Prints a message of the specified kind at the location of the
1162      * tree within the provided compilation unit
1163      *
1164      * @param kind the kind of message
1165      * @param msg  the message, or an empty string if none
1166      * @param t    the tree to use as a position hint
1167      * @param root the compilation unit that contains tree

1127 
1128     protected Copier createCopier(TreeMaker maker) {
1129         return new Copier(maker);
1130     }
1131 
1132     /**
1133      * Returns the original type from the ErrorType object.
1134      * @param errorType The errorType for which we want to get the original type.
1135      * @return TypeMirror corresponding to the original type, replaced by the ErrorType.
1136      *         noType (type.tag == NONE) is returned if there is no original type.
1137      */
1138     @Override @DefinedBy(Api.COMPILER_TREE)
1139     public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
1140         if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType targetErrorType) {
1141             return targetErrorType.getOriginalType();
1142         }
1143         if (errorType instanceof com.sun.tools.javac.code.Type.ClassType classType &&
1144             errorType.getKind() == TypeKind.ERROR) {
1145             return extraType2OriginalMap.computeIfAbsent(classType, tt ->
1146                     new ClassType(classType.getEnclosingType(), classType.typarams_field,
1147                                   classType.tsym, classType.getMetadata(), classType.getFlavor()) {
1148                         @Override
1149                         public Type baseType() { return classType; }
1150                         @Override
1151                         public TypeKind getKind() {
1152                             return TypeKind.DECLARED;
1153                         }
1154                     });
1155         }
1156 
1157         return com.sun.tools.javac.code.Type.noType;
1158     }
1159 
1160     /**
1161      * Prints a message of the specified kind at the location of the
1162      * tree within the provided compilation unit
1163      *
1164      * @param kind the kind of message
1165      * @param msg  the message, or an empty string if none
1166      * @param t    the tree to use as a position hint
1167      * @param root the compilation unit that contains tree
< prev index next >