Skip to content

Implement custom action preprocessor extension for plugins and cli #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mintdaniel42 opened this issue May 25, 2024 · 8 comments
Closed

Comments

@mintdaniel42
Copy link
Contributor

mintdaniel42 commented May 25, 2024

I've searched through half of the code in order to understand how the //#action directive works. As far as I understood one can plug in your own preprocessing macros through extending the PreprocessorExtension. But how can I set my own extension class so that the preprocessor uses it? Neither the documap nor the gradle task give any information about that. In addition to that, a PreprocessorContext.setPreprocessorExtension(PreprocessorExtension) method is defined but never used (at least I couldn't find any usages with IntelliJ decompiler & find usages). Is the feature not ready yet or did I just miss something?

@mintdaniel42 mintdaniel42 changed the title What does the //#action directive do? How does the //#action directive work? May 25, 2024
@raydac
Copy link
Owner

raydac commented May 25, 2024

it is very old mechanism developed 20+ years ago to provide some point where custom code can be called
to use it just set instance of your class into created context before execution as it is shown in com.igormaznitsa.jcp.usecases.UserFunctionTest

 context.setPreprocessorExtension(instanceOfYourClass);

then your registered extension should be called during preprocessing
//#action arg1, arg2, arg3 just will call processAction and arguments will be provided through array

@raydac raydac self-assigned this May 25, 2024
@mintdaniel42
Copy link
Contributor Author

Okay thanks, but how can I use this with a build tool?

@raydac
Copy link
Owner

raydac commented May 26, 2024

it was developed for use preprocessor programmatically as part of build process, for use on application level it needs improvements

@mintdaniel42
Copy link
Contributor Author

Oh okay but thanks anyway

@raydac
Copy link
Owner

raydac commented May 26, 2024

anyway it is a good point, I will provide way to register a class as action preprocessor extension in plugins

@raydac raydac changed the title How does the //#action directive work? Implement custom action preprocessor extension for plugins and cli May 26, 2024
raydac added a commit that referenced this issue May 26, 2024
@raydac
Copy link
Owner

raydac commented May 26, 2024

I have made some improvements in 7.1.2-SNAPSHOT, added /EA:<class.name> for CLI and actionPreprocessorExtension for plugins. It will be looking for the class by its name in class path and then the class will be instantiated through default constructor. So you can try if you wish.

@raydac raydac reopened this May 26, 2024
@mintdaniel42
Copy link
Contributor Author

Yoo, that's cool. Thank you! I'll take a look into it!

@raydac
Copy link
Owner

raydac commented Jun 8, 2024

the feature is released in 7.1.2

@raydac raydac closed this as completed Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants