Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate Java Annotation to replace a token with code
    primarykey
    data
    text
    <p>I'm doing a project which in essence is a way for a user to create macros for very long/repetitive code so they can then put these macros into a their code to increase readability and encourage re-usability.</p> <p>The project is split up into two areas: an RCP application where the user constructs their macros and saves them to file, and a plugin-in in eclipse where a user can insert a macro.</p> <p>The RCP application has come along nicely, but now I'm getting to the real bit where I want java to look at a piece of code and at compile time go 'Oh, that piece of code means this'.</p> <p>For example a user could have created a macro with an identifier <code>macro1</code> that represents the code <code>System.out.println("Hello World");</code>. They want to use it in their class <code>foo</code> which will look like:</p> <pre><code>class foo{ //lots of java.... macro1 //lots more java } </code></pre> <p>I want the user to run their class, and when Java compiles it replace <code>macro1</code> with it's value.</p> <p>I have been looking into this for a while and read up a little bit on JavaCC and looked into Ants Replace Task but I feel I want to go down the road of creating a custom annotation to inform Java that this string below the annotation should be transformed into/replaced by a piece of java code located in a specific text file. Hopefully ending up with something like:</p> <pre><code>@ExpandMacro macro1 </code></pre> <p>To me it seems like it could be possible but I don't know if I'm just being too optimistic! :)</p> <p>Also one of my concerns is how deployable would it be as a plugin? If I create a custom annotation how would I make it available to the user to use?</p> <p>Any advice/insights would be very helpful!</p> <p><strong>Edit:</strong> I have also looked into <a href="http://projectlombok.org/" rel="nofollow">Project Lombok</a> which is looks extremely insteresting. But again I'm concerned about deployability because of the amount of setup required for a lombok project.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload