/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Test processor used to check test programs using the @Test, @DA, and @TA
* annotations.
*
* The processor looks for elements annotated with @Test, and analyzes the
* syntax trees for those elements. Within such trees, the processor looks
* for the DA annotations on decls and TA annotations on types.
* The value of these annotations should be a simple string rendition of
* the tree node to which it is attached.
* The expected number of annotations is given by the parameter to the
* @Test annotation itself.
*/
@SupportedAnnotationTypes({"Test"})
return SourceVersion.latest();
}
/** Process trees for elements annotated with the @Test(n) annotation. */
if (renv.processingOver())
return true;
}
return true;
}
/** Get the AnnotationMirror on an element for a given annotation. */
for (AnnotationMirror m: e.getAnnotationMirrors()) {
return m;
}
return null;
}
/** Get the value of the value element of an annotation mirror. */
for (Map.Entry<? extends ExecutableElement,? extends AnnotationValue> e: m.getElementValues().entrySet()) {
}
}
return null;
}
/** Report an error to the annotation processing system. */
}
/** Report an error to the annotation processing system. */
// need better API for reporting tree position errors to the messager
}
/** Get the line number for the primary position for a tree.
* The code is intended to be simple, although not necessarily efficient.
* However, note that a file manager such as JavacFileManager is likely
* to cache the results of file.getCharContent, avoiding the need to read
* the bits from disk each time this method is called.
*/
try {
int line = 1;
line++;
}
return line;
} catch (IOException e) {
return -1;
}
}
/** Scan a tree, looking for @DA and @TA annotations, and verifying that such
* annotations are attached to the expected tree node matching the string
* parameter of the annotation.
*/
/** Create a scanner for a given file. */
}
/** Check the annotations in a given tree. */
foundCount = 0;
if (foundCount != expectCount)
error(file, tree, "Wrong number of annotations found: " + foundCount + ", expected: " + expectCount);
}
/** Check @DA annotations on a class declaration. */
super.visitClassDef(tree);
}
/** Check @DA annotations on a method declaration. */
super.visitMethodDef(tree);
}
/** Check @DA annotations on a field, parameter or local variable declaration. */
super.visitVarDef(tree);
}
/** Check @TA annotations on a type. */
super.visitAnnotatedType(tree);
}
/** Check to see if a list of annotations contains a named annotation, and
* if so, verify the annotation is expected by comparing the value of the
* annotation's argument against the string rendition of the reference tree
* node.
* @param annos the list of annotations to be checked
* @param name the name of the annotation to be checked
* @param tree the tree against which to compare the annotations's argument
*/
foundCount++;
}
}
}
/** Get the string value of an annotation argument, which is given by the
* expression <i>name</i>=<i>value</i>.
*/
}
}
throw new IllegalArgumentException(e.toString());
}
/** The file for the tree. Used to locate errors. */
/** The number of annotations that have been found. @see #check */
int foundCount;
}
/** Convert a type or decl tree to a reference string used by the @DA and @TA annotations. */
/** Convert a type or decl tree to a string. */
return null;
return result;
}
}
}
}
}
}
}
}
}
}
}
}
else
}
else
}
}
}