Class CtElementPathBuilder

java.lang.Object
spoon.reflect.path.CtElementPathBuilder

public class CtElementPathBuilder extends Object
This builder allow to create some CtPath from CtElements Created by nharrand on 21/02/2018.
  • Constructor Details

    • CtElementPathBuilder

      public CtElementPathBuilder()
  • Method Details

    • fromElement

      public CtPath fromElement(CtElement el) throws CtPathException
      Build absolute path to a CtElement el.
      Parameters:
      el - : the element to which the CtPath leads to
      Returns:
      CtPath from model root package to el
      Throws:
      CtPathException - is thrown when root is not a parent of el.
    • fromElement

      public CtPath fromElement(CtElement el, CtElement root) throws CtPathException
      Build path to a CtElement el, from one of its parent.
      Parameters:
      el - : the element to which the CtPath leads to
      root - : Starting point of the CtPath
      Returns:
      CtPath from root to el
      Throws:
      CtPathException - is thrown when root is not a parent of el.
    • setUseNamesInPath

      public CtElementPathBuilder setUseNamesInPath(boolean useNamesInPath)
      Configures what kind of path is generated for List based attributes
      A) #superRole[index=x] - always use index to identify item of List. For example `#typeMember[index=7]`. Such paths are fast. B) #subRole[name=x] - use simpleName or signature of List item if possible. Use the most specific role too. For example `#field[name=counter]` or `#method[signature=getCounter()]`. Such paths are more readable but slower.
      Parameters:
      useNamesInPath - if true then names are used instead of index
      Returns:
      this to support fluent API