Class JavaOutputSink

All Implemented Interfaces:
ICodeDocument, ITextDocumentPart

public class JavaOutputSink extends CppLikeDocumentPart
This output sink is the recipient for the generation of a decompiled Java Abstract Syntax Tree (AST). The sink also contains configuration elements that will guide how certain AST elements are generated. Typically, a sink receives the output for a class or a method element.

Generating an AST yields a special type of elements, called items, that a client (such as the decompiler UI) may want to track to achieve higher level purpose such as xrefs building, renaming, easy syntax coloring, etc. Items include keywords, class/field/method/variable names, labels, etc. The type of items generated depends on the item factory provided to JavaOutputSink constructors.

  • Constructor Details

    • JavaOutputSink

      public JavaOutputSink(int baseAnchorId)
    • JavaOutputSink

      public JavaOutputSink(int baseAnchorId, JavaDocument doc, IDexDecompilerUnit dexdec)
  • Method Details

    • getDocument

      public JavaDocument getDocument()
      May be null
    • getDecompilerUnit

      public IDexDecompilerUnit getDecompilerUnit()
      May be null
    • getSortItemsForRendering

      public int getSortItemsForRendering()
    • getUseDebugInfoNames

      public boolean getUseDebugInfoNames()
    • getDisplayPrivateMethodsLast

      public boolean getDisplayPrivateMethodsLast()
    • getInsertBlankLinesAfterCompounds

      public boolean getInsertBlankLinesAfterCompounds()
    • getGenerateSyntheticFields

      public boolean getGenerateSyntheticFields()
    • getGenerateSyntheticMethods

      public boolean getGenerateSyntheticMethods()
    • getGenerateAnnotations

      public boolean getGenerateAnnotations()
    • getDisplayMethodInternalsAsComment

      public int getDisplayMethodInternalsAsComment()
    • getResolveMethodCallTargets

      public boolean getResolveMethodCallTargets()
    • getResolveFieldAccessTargets

      public boolean getResolveFieldAccessTargets()
    • getGenerateOverrideAnnotations

      public boolean getGenerateOverrideAnnotations()
    • getGenerateLambdas

      public boolean getGenerateLambdas()
    • getSplitCallArgThreshold

      public int getSplitCallArgThreshold()
    • getDoNotGenerateThisIfPossible

      public boolean getDoNotGenerateThisIfPossible()
    • getDisregardCollapse

      public boolean getDisregardCollapse()
    • pushContainingClass

      public void pushContainingClass(IJavaClass c)
    • popContainingClass

      public IJavaClass popContainingClass()
    • getCurrentContainingClass

      public IJavaClass getCurrentContainingClass()
    • getTopLevelClass

      public IJavaClass getTopLevelClass()
    • isBeingGenerated

      public boolean isBeingGenerated(IJavaElement elt)
    • astPush

      public IJavaElement astPush(IJavaElement elt)
    • astPop

      public IJavaElement astPop()
    • astParent

      public IJavaElement astParent()
      Make sure to call before generateEnter.
      Returns:
      the parent of the element AST about to be rendered or null if there is none or none can be found
    • astDepth

      public int astDepth()
    • pushContainingMethod

      public void pushContainingMethod(IJavaMethod m)
    • popContainingMethod

      public IJavaMethod popContainingMethod()
    • getCurrentContainingMethod

      public IJavaMethod getCurrentContainingMethod()
    • getContainingMethods

      public Collection<IJavaMethod> getContainingMethods()
    • setDynamicContentManager

      public void setDynamicContentManager(IDynamicContentManager dcm)
    • getDynamicContentManager

      public IDynamicContentManager getDynamicContentManager()
    • setCurrentMethodIndex

      public int setCurrentMethodIndex(int index)
      Set the method index of the method being generated
      Parameters:
      index - the current method index
      Returns:
      the previous index
    • getCurrentMethodIndex

      public int getCurrentMethodIndex()
      Get the method index of the method being generated
      Returns:
      <0 if cannot be determined or invalid
    • appendKeyword

      public void appendKeyword(JavaKeyword keyword)
    • appendKeyword

      public void appendKeyword(JavaKeyword keyword, long itemId)
    • renderPreComment

      public void renderPreComment(ICodeCoordinates coord)
      note: EOL always appended
    • renderInlineComment

      public void renderInlineComment(ICodeCoordinates coord, boolean appendEOL)
    • loadCommentInline

      public void loadCommentInline(ICodeCoordinates insnCoord)
    • appendAnnotationsList

      public void appendAnnotationsList(List<IJavaAnnotation> annotations, char charAfterAnno)
    • appendAnnotationsList

      public void appendAnnotationsList(List<IJavaAnnotation> annotations, char charAfterAnno, Set<String> skiplist)
    • recordIdentifierCoordinates

      public void recordIdentifierCoordinates(long objectId, ICodeCoordinates coordinates)
    • getIdentifierCoordinates

      public Map<Long,List<ICodeCoordinates>> getIdentifierCoordinates()
    • pushAnonymousBaseType

      public void pushAnonymousBaseType(IJavaType type)
    • popAnonymousBaseType

      public IJavaType popAnonymousBaseType()
    • getCurrentAnonymousBaseType

      public IJavaType getCurrentAnonymousBaseType()
    • pushAnonymousCaptureInfo

      public void pushAnonymousCaptureInfo(JavaOutputSink.CaptureInfo info)
    • popAnonymousCaptureInfo

      public JavaOutputSink.CaptureInfo popAnonymousCaptureInfo()
    • getCurrentAnonymousCaptureInfo

      public JavaOutputSink.CaptureInfo getCurrentAnonymousCaptureInfo()
    • addGeneratedAnon

      public void addGeneratedAnon(IJavaElement container, IJavaClass c)
      Register an anonymous type (most likely a class) that's about to be rendered as inline code, inside a method or another class. We use this multi-map to track anonymous types that were actually rendered, and those that were not. That can happen in obfuscated files where anonymous inner classes are used by third-party (not the container) classes only.
      Parameters:
      container - method or class
      c - an anonymous that's about to be generated (recorded to avoid generated it later)
    • getGeneratedAnon

      public List<IJavaClass> getGeneratedAnon(IJavaElement container)
    • pushReplacements

      public void pushReplacements(Map<IJavaIdentifier,IJavaExpression> replmap)
    • popReplacements

      public Map<IJavaIdentifier,IJavaExpression> popReplacements()
    • getReplacementFor

      public IJavaExpression getReplacementFor(IJavaIdentifier ident)
    • setGeneratingReplacement

      public void setGeneratingReplacement(boolean generatingReplacement)
    • requestGeneratingReplacement

      public boolean requestGeneratingReplacement()
    • doneGeneratingReplacement

      public void doneGeneratingReplacement()
    • recordGeneratedDecompilable

      public void recordGeneratedDecompilable(String signature)
    • getDecompilables

      public List<String> getDecompilables()
      Retrieve the list of addresses of the decompilable (classes, fields, methods) items generated in this part.
      Returns:
      a list of items, ordered as they appear in the decompiled output
    • validate

      public void validate()
      Overrides:
      validate in class CppLikeDocumentPart