Class LanguageFrontend

    • Field Detail

      • log

        protected static final org.slf4j.Logger log
      • objectListeners

        protected java.util.Map<java.lang.Object,​java.util.function.BiConsumer<java.lang.Object,​java.lang.Object>> objectListeners
        Two data structures used to associate Objects input to a pass to results of a pass, e.g. Javaparser AST-Nodes to CPG-Nodes. The "Listeners" in processedListener are called after the node they are saved under get an entry in processedMapping. THis combination allows to keep the information on which AST-Node build which CPG-Node and operate with these associations once they exist, important to resolve connections between labels and label usages.
      • predicateListeners

        protected java.util.Map<java.util.function.BiPredicate<java.lang.Object,​java.lang.Object>,​java.util.function.BiConsumer<java.lang.Object,​java.lang.Object>> predicateListeners
      • processedMapping

        protected java.util.Map<java.lang.Object,​java.lang.Object> processedMapping
    • Method Detail

      • process

        public void process​(java.lang.Object from,
                            java.lang.Object to)
      • registerObjectListener

        public void registerObjectListener​(java.lang.Object from,
                                           java.util.function.BiConsumer<java.lang.Object,​java.lang.Object> biConsumer)
      • registerPredicateListener

        public void registerPredicateListener​(java.util.function.BiPredicate<java.lang.Object,​java.lang.Object> predicate,
                                              java.util.function.BiConsumer<java.lang.Object,​java.lang.Object> biConsumer)
      • clearProcessed

        public void clearProcessed()
      • getScopeManager

        public @NonNull ScopeManager getScopeManager()
      • setScopeManager

        public void setScopeManager​(@NonNull ScopeManager scopeManager)
      • getCodeFromRawNode

        public abstract <T> @Nullable java.lang.String getCodeFromRawNode​(T astNode)
        Returns the raw code of the ast node, generic for java or c++ ast nodes.
        Type Parameters:
        T - the raw ast type
        Parameters:
        astNode - the ast node
        Returns:
        the source code
      • getLocationFromRawNode

        public abstract <T> @Nullable PhysicalLocation getLocationFromRawNode​(T astNode)
        Returns the Region of the code with line and column, index starting at 1, generic for java or c++ ast nodes.
        Type Parameters:
        T - the raw ast type
        Parameters:
        astNode - the ast node
        Returns:
        the location
      • setCodeAndRegion

        public <N,​S> void setCodeAndRegion​(@NonNull N cpgNode,
                                                 @NonNull S astNode)
      • getNewLineType

        public java.lang.String getNewLineType​(Node node)
        To prevent issues with different newline types and formatting.
        Parameters:
        node - - The newline type is extracted from the nodes code.
        Returns:
        the String of the newline
      • getCodeOfSubregion

        public java.lang.String getCodeOfSubregion​(Node node,
                                                   Region nodeRegion,
                                                   Region subRegion)
        Returns the code represented by the subregion extracted from the parent node and its region.
        Parameters:
        node - - The parent node of the subregion
        nodeRegion - - region needs to be precomputed.
        subRegion - - precomputed subregion
        Returns:
        the code of the subregion.
      • mergeRegions

        public Region mergeRegions​(Region regionOne,
                                   Region regionTwo)
        Merges two regions. The new region contains both and is the minimal region to do so.
        Parameters:
        regionOne - the first region
        regionTwo - the second region
        Returns:
        the merged region
      • getRecords

        public java.util.Map<java.lang.String,​RecordDeclaration> getRecords()
      • cleanup

        public void cleanup()
      • getNamespaceDelimiter

        public java.lang.String getNamespaceDelimiter()
      • setComment

        public abstract <S,​T> void setComment​(S s,
                                                    T ctx)
      • getRecordForName

        public java.util.Optional<RecordDeclaration> getRecordForName​(java.lang.String name)
        Returns a record declaration, if it exists for the given name
        Parameters:
        name - the record name
        Returns:
        an optional containing the RecordDeclaration, if it exists.