Class TargetSelector
java.lang.Object
org.spongepowered.asm.mixin.injection.selectors.TargetSelector
Utility class for parsing selectors
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Set<ITargetSelector> parse(Iterable<?> selectors, ISelectorContext context) Parse a collection of target selector representations (strings, annotations, class literals) into selectors.static Set<ITargetSelector> parse(Iterable<?> selectors, ISelectorContext context, Set<ITargetSelector> parsed) Parse a collection of target selector representations (strings, annotations, class literals) into selectors and store them in the provided collection.static ITargetSelectorparse(String string, ISelectorContext context) Parse a target selector from a stringstatic ITargetSelectorparse(IAnnotationHandle annotation, ISelectorContext context) Parse a target selector from the supplied annotationstatic Set<ITargetSelector> parseAndValidate(Iterable<?> selectors, ISelectorContext context) Parse a collection of target selector representations (strings, annotations, class literals) into selectors.static ITargetSelectorparseAndValidate(String string, ISelectorContext context) Parse a target selector from a string and perform validationstatic ITargetSelectorparseAndValidate(IAnnotationHandle annotation, ISelectorContext context) Parse a target selector from the supplied annotation and perform validationstatic StringparseName(String name, ISelectorContext context) Parse a target selector from the supplied name, and then return the name of the match.static voidregister(Class<? extends ITargetSelectorDynamic> type, String namespace) Register a dynamic target selector class.static <TNode> TargetSelector.Result<TNode> run(Iterable<ITargetSelector> selector, Iterable<ElementNode<TNode>> nodes) Run query on supplied target nodesstatic <TNode> TargetSelector.Result<TNode> run(ITargetSelector selector, Iterable<ElementNode<TNode>> nodes) Run query on supplied target nodes
-
Method Details
-
register
Register a dynamic target selector class. The supplied class must be decorated with anITargetSelectorDynamic.SelectorIdannotation for registration to succeed.- Parameters:
type- ITargetSelectorDynamic to registernamespace- namespace for SelectorId
-
parseAndValidate
public static ITargetSelector parseAndValidate(IAnnotationHandle annotation, ISelectorContext context) throws InvalidSelectorException Parse a target selector from the supplied annotation and perform validation- Parameters:
annotation- Annotation to parse target selector fromcontext- Context to use for reference mapping- Returns:
- parsed target selector
- Throws:
InvalidSelectorException
-
parseAndValidate
public static ITargetSelector parseAndValidate(String string, ISelectorContext context) throws InvalidSelectorException Parse a target selector from a string and perform validation- Parameters:
string- String to parse target selector fromcontext- Context to use for reference mapping- Returns:
- parsed target selector
- Throws:
InvalidSelectorException
-
parseAndValidate
public static Set<ITargetSelector> parseAndValidate(Iterable<?> selectors, ISelectorContext context) throws InvalidSelectorException Parse a collection of target selector representations (strings, annotations, class literals) into selectors.- Parameters:
selectors- Selectors to parsecontext- Selection context- Returns:
- parsed collection of selectors, uses LinkedHashSet to preserve parse ordering
- Throws:
InvalidSelectorException
-
parse
Parse a collection of target selector representations (strings, annotations, class literals) into selectors.- Parameters:
selectors- Selectors to parsecontext- Selection context- Returns:
- parsed collection of selectors, uses LinkedHashSet to preserve parse ordering
-
parse
public static Set<ITargetSelector> parse(Iterable<?> selectors, ISelectorContext context, Set<ITargetSelector> parsed) Parse a collection of target selector representations (strings, annotations, class literals) into selectors and store them in the provided collection.- Parameters:
selectors- Selectors to parsecontext- Selection contextparsed- Collection to add parsed selectors to, initialised as a LinkedHashSet if null- Returns:
- the same collection passed in via the parsed parameter, for convenience
-
parse
Parse a target selector from the supplied annotation- Parameters:
annotation- String to parse target selector fromcontext- Context to use for reference mapping- Returns:
- parsed target selector
-
parse
Parse a target selector from a string- Parameters:
string- String to parse target selector fromcontext- Context to use for reference mapping- Returns:
- parsed target selector
-
parseName
Parse a target selector from the supplied name, and then return the name of the match. This is used mainly to remap input names in the same context as a selector without needing the selector itself. If the supplied name does not successfully parse to a name-based selector, then the name is returned unchanged.- Parameters:
name- Name to parsecontext- Mixin context- Returns:
- remapped name or original name
-
run
public static <TNode> TargetSelector.Result<TNode> run(ITargetSelector selector, Iterable<ElementNode<TNode>> nodes) Run query on supplied target nodes- Type Parameters:
TNode- Node type- Parameters:
selector- Target selectornodes- Node collection to enumerate- Returns:
- query result
-
run
public static <TNode> TargetSelector.Result<TNode> run(Iterable<ITargetSelector> selector, Iterable<ElementNode<TNode>> nodes) Run query on supplied target nodes- Type Parameters:
TNode- Node type- Parameters:
selector- Target selectornodes- Node collection to enumerate- Returns:
- query result
-