needle icon indicating copy to clipboard operation
needle copied to clipboard

Support precompilation

Open hyperpape opened this issue 5 years ago • 3 comments

Users might want to create subclasses of Pattern at build-time, not run-time. A solution could be more or less involved (these aren’t mutually exclusive):

  1. A method to compile a regex and write it to a .class file.
  2. Methods to compile one or more regexes and package as a jar.
  3. A maven plug-in to create classes/jars.
  4. Use annotations to define classes that should be created.

3 & 4 are probably overkill.

hyperpape avatar Jul 19 '20 03:07 hyperpape

I don't know why I wrote that 3 & 4 seemed like overkill. They seem worthwhile.

hyperpape avatar Jun 25 '21 02:06 hyperpape

I've juste discovered your project and find it incredible. I have no time, yet, but I would gladly try to help you about this subject (I have some experience in writing maven plugin that read Java code - using as an example JavaParser libray for direct source access)

Riduidel avatar May 08 '24 07:05 Riduidel

Cool! I haven't spent much time actively thinking about this since I created the initial issue, and I must admit, on second thought, I can't 100% reconstruct what I was thinking with (4).

Writing an annotation that describes a regex is straightforward enough. You'd have to provide the regex string, the classname and the package. But what would the annotation be applied to? I guess it could be a class level annotation?

As for (3) I don't really have a feel for how code-generation plugins are typically used. I know Immutables has a thing where you have to run the plugin for the first time on compiling a project, but I haven't looked into how that's achieved.

hyperpape avatar May 08 '24 21:05 hyperpape