Package com.sonar.sslr.api
Class PreprocessorAction
- java.lang.Object
-
- com.sonar.sslr.api.PreprocessorAction
-
@Deprecated public class PreprocessorAction extends Object
Deprecated.in 1.20, use your own preprocessor API instead.This class encapsulates the actions to be performed by a preprocessor.
-
-
Field Summary
Fields Modifier and Type Field Description static PreprocessorAction
NO_OPERATION
Deprecated.Use this no operation preprocessor action for improved readability and performances.
-
Constructor Summary
Constructors Constructor Description PreprocessorAction(int numberOfConsumedTokens, List<Trivia> triviaToInject, List<Token> tokensToInject)
Deprecated.Construct a preprocessor action.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
getNumberOfConsumedTokens()
Deprecated.List<Token>
getTokensToInject()
Deprecated.List<Trivia>
getTriviaToInject()
Deprecated.
-
-
-
Field Detail
-
NO_OPERATION
public static final PreprocessorAction NO_OPERATION
Deprecated.Use this no operation preprocessor action for improved readability and performances.
Equivalent to: new PreprocessorAction(0, new ArrayList<Trivia>(), new ArrayList<Token>());
-
-
Constructor Detail
-
PreprocessorAction
public PreprocessorAction(int numberOfConsumedTokens, List<Trivia> triviaToInject, List<Token> tokensToInject)
Deprecated.Construct a preprocessor action.
The actions are executed in this order:
- Deletions of tokens, handled by numberOfConsumedTokens
- Injections of trivia, handled by triviaToInject
- Injections of tokens, handled by tokensToInject
Preprocessor actions are executed as follows:
- If numberOfConsumedTokens is greater than 0, then this number of tokens are deleted. Their trivia is added to a pending list of trivia. The preprocessor will not be called on deleted tokens.
- All trivia from triviaToInject are added to the same pending list of trivia
- All tokens from tokensToInject are injected. If present, the first token of tokensToInject is augmented with the pending trivia, which is then cleared. If not present, the pending trivia is left unchanged.
- Finally, if numberOfConsumedTokens was 0, the current token is injected, with any pending trivia which is then cleared.
- No operation action: new PreprocessorAction(0, new ArrayList<Trivia>(), new ArrayList<Token>());
- Delete current token action: new PreprocessorAction(1, new ArrayList<Trivia>(), new ArrayList<Token>());
- Modify current token action: new PreprocessorAction(1, new ArrayList<Trivia>(), Arrays.asList(modifiedToken));
- Inject trivia to current token action: new PreprocessorAction(0, Arrays.asList(newTrivia), new ArrayList<Token>());
- Parameters:
numberOfConsumedTokens
- Number of tokens consumed by the preprocessor, which can be 0. Consumed tokens are deleted and will not lead to successive calls to the preprocessor.triviaToInject
- Trivia to inject.tokensToInject
- Tokens to inject. Injected tokens will not lead to successive calls to the preprocessor.
-
-