langtools/test/tools/javac/T6458823/MyProcessor.java
author jjg
Wed, 29 Oct 2014 17:25:23 -0700
changeset 27319 030080f03e4f
parent 6586 0d40dc0c06cb
child 34752 9c262a013456
permissions -rw-r--r--
8062348: langtools tests should close file manager (group 1) Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6586
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
     1
 /*
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
     2
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
     3
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
     4
  *
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
     5
  * This code is free software; you can redistribute it and/or modify it
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
     6
  * under the terms of the GNU General Public License version 2 only, as
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
     7
  * published by the Free Software Foundation.
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
     8
  *
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
     9
  * This code is distributed in the hope that it will be useful, but WITHOUT
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    10
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    11
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    12
  * version 2 for more details (a copy is included in the LICENSE file that
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    13
  * accompanied this code).
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    14
  *
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    15
  * You should have received a copy of the GNU General Public License version
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    16
  * 2 along with this work; if not, write to the Free Software Foundation,
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    17
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    18
  *
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    19
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    20
  * or visit www.oracle.com if you need additional information or have any
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    21
  * questions.
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    22
  */
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    23
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    24
import java.util.Set;
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    25
import javax.annotation.processing.*;
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    26
import javax.lang.model.element.*;
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    27
import javax.lang.model.util.ElementFilter;
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    28
import javax.lang.model.SourceVersion;
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    29
import static javax.tools.Diagnostic.Kind.*;
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    30
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    31
@SupportedAnnotationTypes("*")
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    32
public class MyProcessor extends AbstractProcessor {
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    33
    private Messager messager;
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    34
    public void init(ProcessingEnvironment processingEnv) {
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    35
        this.messager = processingEnv.getMessager();
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    36
    }
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    37
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    38
    public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    39
        if (!renv.processingOver()) {
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    40
            for(TypeElement e : ElementFilter.typesIn(renv.getRootElements())) {
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    41
                for (TypeParameterElement tp : e.getTypeParameters()) {
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    42
                    if (tp.getSimpleName().toString().length() > 1) {
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    43
                        messager.printMessage(WARNING,
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    44
                            "Type param names should be of length 1", tp);
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    45
                    }
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    46
                }
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    47
            }
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    48
        }
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    49
        return true;
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    50
    }
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    51
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    52
    public SourceVersion getSupportedSourceVersion() {
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    53
        return SourceVersion.latest();
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    54
    }
0d40dc0c06cb 6458823: Messager messages on TypeParamterElements to not include position information.
sundar
parents:
diff changeset
    55
}