com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntryKind Java Examples
The following examples show how to use
com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntryKind.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericArrayLocationCriterion.java From annotation-tools with MIT License | 5 votes |
/** * Determines if the given list holds only {@link TypePathEntry}s with the tag * {@link TypePathEntryKind#ARRAY}. * * @param location the list to check * @return {@code true} if the list only contains * {@link TypePathEntryKind#ARRAY}, {@code false} otherwise. */ private boolean containsOnlyArray(List<TypePathEntry> location) { for (TypePathEntry tpe : location) { if (tpe.tag != TypePathEntryKind.ARRAY) { return false; } } return true; }
Example #2
Source File: JavaEnvironment.java From j2cl with Apache License 2.0 | 4 votes |
private static int countInner(List<TypePathEntry> rest) { return !rest.isEmpty() && rest.get(0).tag == TypePathEntryKind.INNER_TYPE ? countInner(rest.subList(1, rest.size())) + 1 : 0; }
Example #3
Source File: TestSceneLib.java From annotation-tools with MIT License | 4 votes |
@Test public void testTypeASTMapper() { // Construct a TAST for the type structure: // 0< 3<4>[1][2], 5<6, 8[7], 9, 10> > MyTAST tast = MyTAST.parameterization(0, MyTAST.arrayOf(1, MyTAST.arrayOf(2, MyTAST.parameterization(3, new MyTAST(4) ) ) ), MyTAST.parameterization(5, new MyTAST(6), MyTAST.arrayOf(7, new MyTAST(8)), new MyTAST(9), new MyTAST(10) ) ); // Pretend myField represents a field of the type represented by tast. // We have to do this because clients are no longer allowed to create // AElements directly; instead, they must vivify. AElement myAField = new AScene().classes.getVivify("someclass").fields.getVivify("somefield"); ATypeElement myAFieldType = myAField.type; // load it with annotations we can check against IDs myAFieldType.tlAnnotationsHere.add(makeTLIdAnno(0)); final int ARRAY = TypePathEntryKind.ARRAY.tag; final int TYPE_ARGUMENT = TypePathEntryKind.TYPE_ARGUMENT.tag; assignId(myAFieldType, 1, TYPE_ARGUMENT, 0); assignId(myAFieldType, 2, TYPE_ARGUMENT, 0, ARRAY, 0); assignId(myAFieldType, 3, TYPE_ARGUMENT, 0, ARRAY, 0, ARRAY, 0); assignId(myAFieldType, 4, TYPE_ARGUMENT, 0, ARRAY, 0, ARRAY, 0, TYPE_ARGUMENT, 0); assignId(myAFieldType, 5, TYPE_ARGUMENT, 1); assignId(myAFieldType, 6, TYPE_ARGUMENT, 1, TYPE_ARGUMENT, 0); assignId(myAFieldType, 7, TYPE_ARGUMENT, 1, TYPE_ARGUMENT, 1); assignId(myAFieldType, 8, TYPE_ARGUMENT, 1, TYPE_ARGUMENT, 1, ARRAY, 0); assignId(myAFieldType, 9, TYPE_ARGUMENT, 1, TYPE_ARGUMENT, 2); // to test vivification, we don't assign 10 // now visit and make sure the ID numbers match up MyTASTMapper mapper = new MyTASTMapper(); mapper.traverse(tast, myAFieldType); for (int i = 0; i < 11; i++) { Assert.assertTrue(mapper.saw[i]); } // make sure it vivified #10 and our annotation stuck AElement e10 = myAFieldType.innerTypes.get( new InnerTypeLocation(TypeAnnotationPosition.getTypePathFromBinary(Arrays.asList(TYPE_ARGUMENT, 1, TYPE_ARGUMENT, 3)))); Assert.assertNotNull(e10); int e10aid = (Integer) e10.lookup("IdAnno").getFieldValue("id"); Assert.assertEquals(e10aid, 10); }
Example #4
Source File: TreeFinder.java From annotation-tools with MIT License | 2 votes |
/** * Determines if the last {@link TypePathEntry} in the given list is a * {@link TypePathEntryKind#WILDCARD}. * * @param location the list to check * @return {@code true} if the last {@link TypePathEntry} is a * {@link TypePathEntryKind#WILDCARD}, {@code false} otherwise. */ private boolean wildcardLast(List<TypePathEntry> location) { return location.get(location.size() - 1).tag == TypePathEntryKind.WILDCARD; }