ErrorAPF.java revision 553
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy/*
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy *
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * This code is free software; you can redistribute it and/or modify it
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * under the terms of the GNU General Public License version 2 only, as
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * published by the Free Software Foundation.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy *
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * This code is distributed in the hope that it will be useful, but WITHOUT
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * version 2 for more details (a copy is included in the LICENSE file that
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * accompanied this code).
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy *
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * You should have received a copy of the GNU General Public License version
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * 2 along with this work; if not, write to the Free Software Foundation,
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy *
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * or visit www.oracle.com if you need additional information or have any
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * questions.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyimport com.sun.mirror.apt.*;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyimport com.sun.mirror.declaration.*;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyimport com.sun.mirror.type.*;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyimport com.sun.mirror.util.*;
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyimport java.util.Collection;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyimport java.util.Set;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyimport java.util.Arrays;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyimport static java.util.Collections.*;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyimport static com.sun.mirror.util.DeclarationVisitors.*;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy/*
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Construct a processor that does nothing but report an error.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedypublic class ErrorAPF implements AnnotationProcessorFactory {
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy static class ErrorAP implements AnnotationProcessor {
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy AnnotationProcessorEnvironment env;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy ErrorAP(AnnotationProcessorEnvironment env) {
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy this.env = env;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy }
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy public void process() {
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy Messager messager = env.getMessager();
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy messager.printError("It's a mad, mad, mad, mad world");
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy messager.printError("Something wicked this way comes");
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy for(TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations())
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy messager.printError(typeDecl.getPosition(), "Boring class name");
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy }
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy }
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy static Collection<String> supportedTypes;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy static {
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy String types[] = {"*"};
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy supportedTypes = unmodifiableCollection(Arrays.asList(types));
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy }
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy static Collection<String> supportedOptions;
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy static {
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy String options[] = {""};
supportedOptions = unmodifiableCollection(Arrays.asList(options));
}
public Collection<String> supportedOptions() {
return supportedOptions;
}
public Collection<String> supportedAnnotationTypes() {
return supportedTypes;
}
public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
AnnotationProcessorEnvironment env) {
return new ErrorAP(env);
}
}