Class TypeHierarchyResolver

java.lang.Object
de.fraunhofer.aisec.cpg.passes.Pass
de.fraunhofer.aisec.cpg.passes.TypeHierarchyResolver
All Implemented Interfaces:
java.util.function.Consumer<TranslationResult>

public class TypeHierarchyResolver
extends Pass
Transitively RecordDeclaration nodes with their supertypes' records.

Supertypes are all interfaces a class implements and the superclass it inherits from, including all of their respective supertypes). The JavaParser provides us with initial info about direct ancestors' names. This pass then recursively maps those and their own supertypes to the correct RecordDeclaration (if available).

After determining the ancestors of a class, all inherited methods are scanned to find out which of them are overridden/implemented in the current class. See FunctionDeclaration.getOverriddenBy()

Attention: Needs to be run before other analysis passes, as it triggers a type refresh. This is needed e.g. for TypeManager.getCommonType(Collection) to be re-evaluated at places where it is crucial to have parsed all RecordDeclarations. Otherwise, type information in the graph might not be fully correct

  • Field Details

  • Constructor Details

    • TypeHierarchyResolver

      public TypeHierarchyResolver()
  • Method Details

    • getLang

      public LanguageFrontend getLang()
      Overrides:
      getLang in class Pass
      Returns:
      May be null
    • setLang

      public void setLang​(LanguageFrontend lang)
      Description copied from class: Pass
      Passes may need information about what source language they are parsing.
      Overrides:
      setLang in class Pass
      Parameters:
      lang - May be null
    • accept

      public void accept​(TranslationResult translationResult)
    • findRecordsAndEnums

      protected void findRecordsAndEnums​(de.fraunhofer.aisec.cpg.graph.Node node)
    • getAllMethodsFromSupertypes

      protected java.util.List<MethodDeclaration> getAllMethodsFromSupertypes​(java.util.Set<RecordDeclaration> supertypeRecords)
    • findSupertypeRecords

      protected java.util.Set<RecordDeclaration> findSupertypeRecords​(RecordDeclaration record)
    • analyzeOverridingMethods

      protected void analyzeOverridingMethods​(RecordDeclaration declaration, java.util.List<MethodDeclaration> allMethodsFromSupertypes)
    • cleanup

      public void cleanup()
      Specified by:
      cleanup in class Pass