Class AnnotationFileUtil
java.lang.Object
org.checkerframework.framework.stub.AnnotationFileUtil
Utility class for annotation files (stub files and ajava files).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe types of files that can contain annotations.static final recordA qualified name, split into the part before the last period and the part after it. -
Method Summary
Modifier and TypeMethodDescriptionfindFileSystemLocation(String location) Returns the file system location that a path names.static voidforEachAnnotationFile(File location, AnnotationFileUtil.AnnotationFileType fileType, Consumer<AnnotationFileResource> action) Runsactionon each annotation file of typefileTypeat the given file system location.static booleanisCanonicalConstructor(ExecutableElement elt, Types types) Returns true if the givenExecutableElementis the canonical constructor of a record (i.e., the parameter types of the constructor correspond to the parameter types of the record components, ignoring annotations).partitionQualifiedName(String imported) Splits a name (which comes from an import statement) into the part before the last period and the part after the last period.
-
Method Details
-
partitionQualifiedName
Splits a name (which comes from an import statement) into the part before the last period and the part after the last period.- Parameters:
imported- the name to split- Returns:
- the type name and the member name
-
findFileSystemLocation
Returns the file system location that a path names. Looks for it as an absolute path or relative to the current directory, then relative to theuser.dirsystem property, then relative to thetest.srcsystem property (which jtreg sets to the directory that contains the test).- Parameters:
location- a relative or absolute path- Returns:
- the file or directory that
locationnames, or null if none exists
-
forEachAnnotationFile
public static void forEachAnnotationFile(File location, AnnotationFileUtil.AnnotationFileType fileType, Consumer<AnnotationFileResource> action) Runsactionon each annotation file of typefileTypeat the given file system location. Passes the files under a directory in order of their names, and the entries in an archive in the order that the archive stores them.If
locationis a directory, recurses on all files contained in it. Iflocationis a jarfile that cannot be opened or a directory that cannot be listed, passes a resource whoseAnnotationFileResource.getInputStream()throws an exception, so the client reports the error rather than treatinglocationas empty.- Parameters:
location- an annotation file (a stub file or ajava file), a jarfile, or a directoryfileType- type of annotation files to pass toactionaction- the operation to perform on each annotation file
-
isCanonicalConstructor
Returns true if the givenExecutableElementis the canonical constructor of a record (i.e., the parameter types of the constructor correspond to the parameter types of the record components, ignoring annotations).- Parameters:
elt- the constructor/method to checktypes- the Types instance to use for comparing types- Returns:
- true if elt is the canonical constructor of the record containing it
-