Package org.revapi
Interface ElementForest<E extends Element<E>>
-
- Type Parameters:
E
- the common super type of all elements in the forest
- All Known Implementing Classes:
BaseElementForest
,SimpleElementForest
public interface ElementForest<E extends Element<E>>
A representation of some "unit" understood by an API analyzer. Typically an abstract syntax tree of a language.- Since:
- 0.1
- Author:
- Lukas Krejci
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ElementForest.Visitor<E extends Element<E>>
A visitor of the element forest.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description static <E extends Element<E>>
ElementForest<E>empty(API api)
API
getApi()
SortedSet<E>
getRoots()
A sorted set of all root elements of the forest.default <T extends Element<T>>
Iterator<T>iterateOverElements(Class<T> resultType, boolean recurse, Filter<? super T> filter, Element<T> searchRoot)
Deprecated.use the more versatilestream(Class, boolean, Element)
default <T extends Element<T>>
List<T>search(Class<T> resultType, boolean recurse, Filter<? super T> filter, Element<T> searchRoot)
Deprecated.in favor of more versatilestream(Class, boolean, Element)
default <T extends Element<E>>
Stream<T>stream(Class<T> resultType, boolean recurse, Element<E> searchRoot)
<T extends Element<E>>
Stream<T>stream(Class<T> resultType, boolean recurse, TreeFilter<E> filter, Element<E> root)
Walks through the forest and returns a stream of elements that match the provided filter.static <E extends Element<E>>
voidwalk(E root, ElementForest.Visitor<E> visitor)
static <E extends Element<E>>
voidwalk(ElementForest<E> forest, ElementForest.Visitor<E> visitor)
-
-
-
Method Detail
-
walk
static <E extends Element<E>> void walk(ElementForest<E> forest, ElementForest.Visitor<E> visitor)
-
walk
static <E extends Element<E>> void walk(E root, ElementForest.Visitor<E> visitor)
-
empty
static <E extends Element<E>> ElementForest<E> empty(API api)
-
getApi
API getApi()
- Returns:
- the API this forest represents
-
getRoots
SortedSet<E> getRoots()
A sorted set of all root elements of the forest. The set uses the natural order of the element implementations.- Returns:
- the roots elements of the forest.
-
search
@Deprecated @Nonnull default <T extends Element<T>> List<T> search(@Nonnull Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter, @Nullable Element<T> searchRoot)
Deprecated.in favor of more versatilestream(Class, boolean, Element)
Searches through the forest for elements of given type, potentially further filtering.If the
searchRoot
is not null, this is technically equivalent to calling theElement.searchChildren(java.lang.Class, boolean, org.revapi.query.Filter)
on thesearchRoot
.- Type Parameters:
T
- the type of the elements to look for- Parameters:
resultType
- the type of the elements to be contained in the resultsrecurse
- false to only search direct children, true for searching recursivelyfilter
- the optional filtersearchRoot
- optional element from which to conduct the search- Returns:
- a list of elements of given type (or any subtype) from the forest, filtered by the filter if provided
-
iterateOverElements
@Deprecated @Nonnull default <T extends Element<T>> Iterator<T> iterateOverElements(@Nonnull Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter, @Nullable Element<T> searchRoot)
Deprecated.use the more versatilestream(Class, boolean, Element)
-
stream
@Nonnull default <T extends Element<E>> Stream<T> stream(@Nonnull Class<T> resultType, boolean recurse, @Nullable Element<E> searchRoot)
-
stream
<T extends Element<E>> Stream<T> stream(Class<T> resultType, boolean recurse, TreeFilter<E> filter, @Nullable Element<E> root)
Walks through the forest and returns a stream of elements that match the provided filter.- Type Parameters:
T
- the expected type of results- Parameters:
resultType
- the expected type of resultsrecurse
- whether to recursively descend into children. If false, only the direct children of the root are searched.filter
- the filter to use when looking for matching childrenroot
- the search root. If null, the whole element forest is searched- Returns:
- the stream of the matching elements
-
-