Throws TypeNotPresentException if type is an javax.lang.model.type.ErrorType.
(TypeMirror type)
| 152 | * javax.lang.model.type.ErrorType}. |
| 153 | */ |
| 154 | static void checkTypePresent(TypeMirror type) { |
| 155 | type.accept( |
| 156 | // TODO(ronshapiro): Extract a base class that visits all components of a complex type |
| 157 | // and put it in auto.common |
| 158 | new SimpleTypeVisitor8<Void, Void>() { |
| 159 | @Override |
| 160 | public Void visitArray(ArrayType arrayType, Void p) { |
| 161 | return arrayType.getComponentType().accept(this, p); |
| 162 | } |
| 163 | |
| 164 | @Override |
| 165 | public Void visitDeclared(DeclaredType declaredType, Void p) { |
| 166 | declaredType.getTypeArguments().forEach(t -> t.accept(this, p)); |
| 167 | return null; |
| 168 | } |
| 169 | |
| 170 | @Override |
| 171 | public Void visitError(ErrorType errorType, Void p) { |
| 172 | throw new TypeNotPresentException(type.toString(), null); |
| 173 | } |
| 174 | }, |
| 175 | null); |
| 176 | } |
| 177 | |
| 178 | private static final ImmutableSet<Class<?>> FUTURE_TYPES = |
| 179 | ImmutableSet.of(ListenableFuture.class, FluentFuture.class); |
no test coverage detected