Package spoon.reflect.path
Class CtElementPathBuilder
java.lang.Object
spoon.reflect.path.CtElementPathBuilder
This builder allow to create some CtPath from CtElements
Created by nharrand on 21/02/2018.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfromElement(CtElement el)
Build absolute path to a CtElement el.fromElement(CtElement el, CtElement root)
Build path to a CtElement el, from one of its parent.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.
-
Constructor Details
-
CtElementPathBuilder
public CtElementPathBuilder()
-
-
Method Details
-
fromElement
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
Build path to a CtElement el, from one of its parent.- Parameters:
el
- : the element to which the CtPath leads toroot
- : Starting point of the CtPath- Returns:
- CtPath from root to el
- Throws:
CtPathException
- is thrown when root is not a parent of el.
-
setUseNamesInPath
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
-