Class CompilationUnit

    • Constructor Detail

      • CompilationUnit

        public CompilationUnit​(java.lang.String name)
    • Method Detail

      • addImportDeclaration

        public void addImportDeclaration​(ImportDeclaration dec)
        Adds an import declaration to this compilation unit.
        Parameters:
        dec - The import declaration.
        See Also:
        getImports()
      • addParserNotice

        public void addParserNotice​(Token t,
                                    java.lang.String msg)
        Shorthand for "addParserNotice(new ParserNotice(t, msg))".
        Parameters:
        t - The token to add a parser notice for.
        msg - The message of the parser notice.
        See Also:
        addParserNotice(ParserNotice)
      • getAnnotationCount

        public int getAnnotationCount()
      • getAnnotationIterator

        public java.util.Iterator<Annotation> getAnnotationIterator()
      • getDeepestTypeDeclarationAtOffset

        public TypeDeclaration getDeepestTypeDeclarationAtOffset​(int offs)
        Returns the deepest-nested type declaration that contains a given offset.
        Parameters:
        offs - The offset.
        Returns:
        The deepest-nested type declaration containing the offset, or null if the offset is outside any type declaration (such as in the import statements, etc.).
        See Also:
        getTypeDeclarationAtOffset(int)
      • getEnclosingMethodRange

        public java.awt.Point getEnclosingMethodRange​(int offs)
        TODO: Return range for more instances than just class methods. Also handle child TypeDeclarations.
        Parameters:
        offs - The offset to check.
        Returns:
        The starting and ending offset of the enclosing method range.
      • getImportCount

        public int getImportCount()
      • getImports

        public java.util.List<ImportDeclaration> getImports()
        Returns the import declarations of this compilation unit. This is a copy of the list of imports, but the actual individual ImportDeclarations are not copies, so modifying them will modify this compilation unit!
        Returns:
        A list or imports, or an empty list if there are none.
      • getImportIterator

        public java.util.Iterator<ImportDeclaration> getImportIterator()
      • getPackage

        public Package getPackage()
        Returns the package of this compilation unit.
        Returns:
        The package of this compilation unit, or null if this compilation unit is not in a package.
        See Also:
        getPackageName()
      • getPackageName

        public java.lang.String getPackageName()
        Returns the fully-qualified package name of this compilation unit.
        Returns:
        The package name, or null if this compilation unit is not in a package (in the default package).
        See Also:
        getPackage()
      • getParserNotice

        public ParserNotice getParserNotice​(int index)
        Returns the specified parser notice.
        Parameters:
        index - The index of the parser notice.
        Returns:
        The parser notice.
        See Also:
        getParserNoticeCount()
      • getParserNoticeCount

        public int getParserNoticeCount()
      • getTypeDeclaration

        public TypeDeclaration getTypeDeclaration​(int index)
        Returns the specified type declaration.
        Parameters:
        index - The index of the type declaration.
        Returns:
        The type declaration.
        See Also:
        getTypeDeclarationCount()
      • getTypeDeclarationAtOffset

        public TypeDeclaration getTypeDeclarationAtOffset​(int offs)
        Returns the type declaration in this file that contains the specified offset.
        Parameters:
        offs - The offset.
        Returns:
        The type declaration, or null if the offset is outside any type declaration.
        See Also:
        getDeepestTypeDeclarationAtOffset(int)
      • getTypeDeclarationCount

        public int getTypeDeclarationCount()
      • getTypeDeclarationIterator

        public java.util.Iterator<TypeDeclaration> getTypeDeclarationIterator()
      • setPackage

        public void setPackage​(Package pkg)