author | cushon |
Thu, 13 Sep 2018 15:29:44 -0700 | |
changeset 51734 | e6b524cdcc34 |
permissions | -rw-r--r-- |
51734
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
1 |
/* |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Google Inc. All rights reserved. |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
4 |
* |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
8 |
* |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
13 |
* accompanied this code). |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
14 |
* |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
18 |
*/ |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
19 |
|
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
20 |
import java.util.Set; |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
21 |
import javax.annotation.processing.RoundEnvironment; |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
22 |
import javax.annotation.processing.SupportedAnnotationTypes; |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
23 |
import javax.lang.model.element.PackageElement; |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
24 |
import javax.lang.model.element.TypeElement; |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
25 |
|
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
26 |
@SupportedAnnotationTypes("*") |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
27 |
public class Processor extends JavacTestingAbstractProcessor { |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
28 |
|
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
29 |
@Override |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
30 |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
31 |
PackageElement p = processingEnv.getElementUtils().getPackageElement("p"); |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
32 |
// Ensure that the annotations on the package-info for p are present during all annotation |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
33 |
// processing rounds. |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
34 |
if (p.getAnnotationMirrors().isEmpty()) { |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
35 |
throw new AssertionError("expected package annotations"); |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
36 |
} |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
37 |
return false; |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
38 |
} |
e6b524cdcc34
8193037: package-info annotations are not reported when annotation processing is enabled
cushon
parents:
diff
changeset
|
39 |
} |