java.lang.Object
org.variantsync.diffdetective.variation.diff.view.DiffView

public class DiffView extends Object
This class groups the implementations for functions that generate views on variation diffs, as described in Chapter 5 of our SPLC'23 paper - Views on Edits to Variational Software.
  • Constructor Details

    • DiffView

      public DiffView()
  • Method Details

    • computeWhenNodesAreRelevant

      public static <L extends Label> BiPredicate<Time,Projection<L>> computeWhenNodesAreRelevant(VariationDiff<L> d, Relevance rho)
      Translates a relevance predicate for nodes on variation trees to a relevance predicate on nodes in a variation diff. The returned predicate determines if a node in the given variation diff is relevant at a given time.
      Parameters:
      d - The variation diff on which relevance of nodes should be determined.
      rho - A relevance predicate for view generation.
      Returns:
      A binary predicate that determines whether a node in a variation diff is relevant at a given time. The variation diff node has to be given in terms of its projection at the corresponding time.
    • naive

      private static <L extends Label> VariationDiff<DiffLinesLabel> naive(VariationDiff<L> d, Relevance rho, String[] projectionViewText) throws IOException, DiffParseException
      This method is not intended to be used directly and exists for optimization purposes only. Instead, consider using naive(VariationDiff, Relevance).

      This method behaves as naive(VariationDiff, Relevance) but takes as additional parameter, an array of length two that contains the text representation of the views on the two variation trees of the given variation diff d. This method assumes that projectionViewText[Time.BEFORE.ordinal()] represents the text of d.project(Time.BEFORE) and that projectionViewText[Time.AFTER.ordinal()] represents the text of d.project(Time.AFTER). This array is used for a text-based differencing of the two texts. The resulting diff is considered to be the view on the given variation diff d and is subsequently parsed to a variation diff and returned.

      Parameters:
      projectionViewText - The text-based representation of the views on the two variation trees represented by the given diff d.
      Throws:
      IOException - When the text-based diffing fails because of an IO error.
      DiffParseException - When the text-based diff could not be parsed to a variation diff.
    • naive

      public static <L extends Label> VariationDiff<DiffLinesLabel> naive(VariationDiff<L> d, Relevance rho, BiPredicate<Time,Projection<L>> inView) throws IOException, DiffParseException
      This method is not intended to be used directly and exists for optimization purposes only. Instead, consider using naive(VariationDiff, Relevance). This method is used to compare different the naive view generation to other algorithms, independently of the shared preprocessing in terms of computeWhenNodesAreRelevant(VariationDiff, Relevance).

      This method behaves as naive(VariationDiff, Relevance) but takes as additional parameter, the translation of the given relevance predicate to a relevance on a variation diff. This additional parameter is assumed to be created from the given relevance predicate in terms of computeWhenNodesAreRelevant(VariationDiff, Relevance).

      Parameters:
      inView - computeWhenNodesAreRelevant(VariationDiff, Relevance) for the given variation diff d and relevance predicate rho.
      Throws:
      IOException - When the text-based diffing fails because of an IO error.
      DiffParseException - When the text-based diff could not be parsed to a variation diff.
    • naive

      public static <L extends Label> VariationDiff<DiffLinesLabel> naive(VariationDiff<L> d, Relevance rho) throws IOException, DiffParseException
      This function generates a view on the given variation diff by generating views on the underlying variation trees, and then differencing these tree views. Implementation of the function view_naive (Equation 8) from SPLC'23 paper - Views on Edits to Variational Software.
      Parameters:
      d - The variation diff to generate a view on.
      rho - A relevance predicate that determines which nodes should be contained in the view.
      Returns:
      A variation diff that constitutes a view on the given variation diff.
      Throws:
      IOException - When the text-based diffing fails because of an IO error.
      DiffParseException - When the text-based diff could not be parsed to a variation diff.
    • badgood

      public static <L extends Label> VariationDiff<L> badgood(VariationDiff<L> d, Relevance rho)
      An alternative algorithm for generating of views on variation diffs based on (1) removing cycles in the variation diff, (2) interpreting the resulting acyclic variation diff as a colored variation tree, (3) creating a view on the variation tree, (4) and finally reintroducing the removed cycles.
      Parameters:
      d - The variation diff to generate a view on.
      rho - A relevance predicate that determines which nodes should be contained in the view.
      Returns:
      A variation diff that constitutes a view on the given variation diff.
    • optimized

      public static <L extends Label> VariationDiff<L> optimized(VariationDiff<L> d, Relevance rho, BiPredicate<Time,Projection<L>> inView)
      This method is not intended to be used directly and exists for optimization purposes only. Instead, consider using optimized(VariationDiff, Relevance). This method is used to compare different the naive view generation to other algorithms, independently of the shared preprocessing in terms of computeWhenNodesAreRelevant(VariationDiff, Relevance).

      This method behaves as optimized(VariationDiff, Relevance) but takes as additional parameter, the translation of the given relevance predicate to a relevance on a variation diff. This additional parameter is assumed to be created from the given relevance predicate in terms of computeWhenNodesAreRelevant(VariationDiff, Relevance).

      Parameters:
      inView - computeWhenNodesAreRelevant(VariationDiff, Relevance) for the given variation diff d and relevance predicate rho.
    • optimized

      public static <L extends Label> VariationDiff<L> optimized(VariationDiff<L> d, Relevance rho)
      This function generates a view on the given variation diff by determining the times of relevance for each node. Implementation of the function view_smart (Equation 10) from SPLC'23 paper - Views on Edits to Variational Software.
      Parameters:
      d - The variation diff to generate a view on.
      rho - A relevance predicate that determines which nodes should be contained in the view.
      Returns:
      A variation diff that constitutes a view on the given variation diff.