Class JavaDocument

All Implemented Interfaces:
IGenericDocument, ITextDocument, IEventSource

public class JavaDocument extends CodeDocument
Java AST document used to render a decompiled piece of Java code. These documents are provided by the IDexDecompilerUnit or generated by IJavaSourceUnit.
  • Field Details

    • propnameSortItemsForRendering

      public static final String propnameSortItemsForRendering
      Property name for source-item sorting before rendering.
      See Also:
    • propnameUseDebugInfoNames

      public static final String propnameUseDebugInfoNames
      Property name for using dex debug-information names.
      See Also:
    • propnameDisplayMethodInternalsAsComment

      public static final String propnameDisplayMethodInternalsAsComment
      Property name for rendering method internals as comments.
      See Also:
    • propnameDisplayPrivateMethodsLast

      public static final String propnameDisplayPrivateMethodsLast
      Property name for rendering private methods last.
      See Also:
    • propnameInsertBlankLinesAfterCompounds

      public static final String propnameInsertBlankLinesAfterCompounds
      Property name for inserting blank lines after compound statements.
      See Also:
    • propnameGenerateSyntheticFields

      public static final String propnameGenerateSyntheticFields
      Property name for rendering synthetic fields.
      See Also:
    • propnameGenerateSyntheticMethods

      public static final String propnameGenerateSyntheticMethods
      Property name for rendering synthetic methods.
      See Also:
    • propnameGenerateAnnotations

      public static final String propnameGenerateAnnotations
      Property name for rendering Java annotations.
      See Also:
    • propnameResolveMethodCallTargets

      public static final String propnameResolveMethodCallTargets
      Property name for resolving method-call targets.
      See Also:
    • propnameResolveFieldAccessTargets

      public static final String propnameResolveFieldAccessTargets
      Property name for resolving field-access targets.
      See Also:
    • propnameGenerateOverrideAnnotations

      public static final String propnameGenerateOverrideAnnotations
      Property name for generating @Override annotations.
      See Also:
    • propnameGenerateLambdas

      public static final String propnameGenerateLambdas
      Property name for rendering lambdas when possible.
      See Also:
    • propnameUseVarReservedType

      public static final String propnameUseVarReservedType
      Property name for using the var reserved type when possible.
      See Also:
    • propnameDisplayASTElementStackOnHover

      public static final String propnameDisplayASTElementStackOnHover
      Property name for displaying AST element stacks on hover.
      See Also:
    • propnameSplitCallArgThreshold

      public static final String propnameSplitCallArgThreshold
      Property name for splitting calls with many arguments.
      See Also:
    • propnameDoNotGenerateThisIfPossible

      public static final String propnameDoNotGenerateThisIfPossible
      Property name for omitting this when possible.
      See Also:
    • propnameDisregardCollapse

      public static final String propnameDisregardCollapse
      Property name for disregarding item collapse metadata.
      See Also:
  • Constructor Details

    • JavaDocument

      public JavaDocument(IJavaSourceUnit ast)
      Create a Java document backed by a Java source unit.
      Parameters:
      ast - Java source unit
  • Method Details

    • buildPDM

      public static void buildPDM(IPropertyDefinitionManager unitPDM)
      Build Java document property definitions.
      Parameters:
      unitPDM - property definition manager to populate
    • getOwnerUnit

      public IJavaSourceUnit getOwnerUnit()
      Retrieve the owning Java source unit.
      Returns:
      owner unit
    • dispose

      public void dispose()
      Description copied from class: AbstractTextDocument
      The default implementation does nothing.
      Specified by:
      dispose in interface IGenericDocument
      Overrides:
      dispose in class AbstractTextDocument
    • getUnit

      public IUnit getUnit()
      Description copied from interface: IGenericDocument
      If available, retrieve the unit that backs up this document.
      Returns:
      an optional unit reference (may be null)
    • getAnchorCount

      public long getAnchorCount()
      Description copied from interface: ITextDocument
      Get the range of anchor points in the document. Returning 1 means that the document returns a single part, holding the entire contents.

      Note that the anchor at "ITextDocument.getFirstAnchor() + ITextDocument.getAnchorCount()" is the "end" anchor (one after the last), and lies outside the document. It is not a valid anchor.

      Returns:
      the count/range of anchors in this document, must be greater than zero
    • getDocumentPart

      public JavaOutputSink getDocumentPart(long anchorId, int linesAfter, int linesBefore)
      Description copied from interface: ITextDocument
      Retrieve a document part. Clients call this method to retrieve a document part starting at a specific anchor, and containing the given amount of lines after and before the anchor. It is the responsibility of the implementor to sanitize the input (eg, negative number of lines, invalid anchor, etc.) and provide appropriate response (eg, truncating). It is recommended that implementors try not to raise an exception on error. In the worst case scenario, an empty document can be returned.
      Parameters:
      anchorId - the anchor identifier
      linesAfter - hint lines count to return after the given anchor, could be more or less
      linesBefore - hint lines count to return before the given anchor, could be more or less
      Returns:
      a document part containing as many anchors as required to honor the client requests. If linesAfter is non-null, the first anchor within the document part may not be anchorId, but one anchor before that. This method should return null if an invalid anchor was provided
    • coordinatesToAddress

      public String coordinatesToAddress(ICoordinates coordinates, AddressConversionPrecision precision)
      Description copied from interface: ITextDocument
      Convert document-specific text coordinates to a unit-specific address.

      Note: The addressing scheme is unit specific, and defined by the plugin developer. Addresses should not start with the reserved '@' prefix.

      Specified by:
      coordinatesToAddress in interface ITextDocument
      Overrides:
      coordinatesToAddress in class AbstractTextDocument
      Parameters:
      coordinates - the coordinates
      precision - indicate the precision of the address ( AddressConversionPrecision.COARSE will return a raw address, with a faster result while AddressConversionPrecision.FINE will return a more precise address that can be a bit longer). If AddressConversionPrecision.COARSE can not be retrieved, it may return a null result, and the user will need to recall this method with another precision.
      Returns:
      the address, null on error
    • coordinatesToCodeCoordinates

      public ICodeCoordinates coordinatesToCodeCoordinates(ICoordinates coordinates)
      Convert text coordinates in this document to code coordinates.
      Parameters:
      coordinates - text coordinates
      Returns:
      code coordinates, or null if conversion failed
    • addressToCoordinates

      public ICoordinates addressToCoordinates(String address, CoordinatesConversionPrecision precision)
      Description copied from class: AbstractTextDocument
      Precision is not used - Use an exact address
      Specified by:
      addressToCoordinates in interface ITextDocument
      Overrides:
      addressToCoordinates in class AbstractTextDocument
      Parameters:
      address - a textual address
      precision - requested conversion strategy
      Returns:
      the text coordinates, null on error