[janino-dev] [jira] Created: (JANINO-91) Add support for returning tokens of whitespace

View: New views
8 Messages — Rating Filter:   Alert me  

[janino-dev] [jira] Created: (JANINO-91) Add support for returning tokens of whitespace

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Add support for returning tokens of whitespace
----------------------------------------------

                 Key: JANINO-91
                 URL: http://jira.codehaus.org/browse/JANINO-91
             Project: Janino
          Issue Type: New Feature
            Reporter: Adam Heath
            Assignee: Arno Unkrig
            Priority: Minor
         Attachments: feature_swallowable_whitespace_comment_tokens.patch

I have code that filters package/import stmts from source files, then wraps the remaining code in a class definition.  To keep line numbers identical after adding the class definition, I need to have comments and whitespace parsed an return to my application.  The attached patch does this.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Commented: (JANINO-91) Add support for returning tokens of whitespace

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-91?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_96324 ]

Arno Unkrig commented on JANINO-91:
-----------------------------------

Seems like what you want to have is EXACTLY what ClassBodyEvaluator does!? If not, please tell me what you want differently; maybe we can enhance CBE accordingly.

> Add support for returning tokens of whitespace
> ----------------------------------------------
>
>                 Key: JANINO-91
>                 URL: http://jira.codehaus.org/browse/JANINO-91
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Minor
>         Attachments: feature_swallowable_whitespace_comment_tokens.patch
>
>
> I have code that filters package/import stmts from source files, then wraps the remaining code in a class definition.  To keep line numbers identical after adding the class definition, I need to have comments and whitespace parsed an return to my application.  The attached patch does this.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Commented: (JANINO-91) Add support for returning tokens of whitespace

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-91?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_96404 ]

Adam Heath commented on JANINO-91:
----------------------------------

I have a file, that has possible import statements, possible comments, no package header at the top.  Then, it has a method body.

With this and other patches, I parse out the header(by popping all comments, whitespace, and import tokens) into a StringBuffer, then the rest of the tokens are parsed into another String.  During compillation, I then concat these two, but wrap the method body in a generated package and classname.  The added text has no embedded newlines, so that I can maintain proper line numbers in stack traces.

So, I don't need a CBE.

> Add support for returning tokens of whitespace
> ----------------------------------------------
>
>                 Key: JANINO-91
>                 URL: http://jira.codehaus.org/browse/JANINO-91
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Minor
>         Attachments: feature_swallowable_whitespace_comment_tokens.patch
>
>
> I have code that filters package/import stmts from source files, then wraps the remaining code in a class definition.  To keep line numbers identical after adding the class definition, I need to have comments and whitespace parsed an return to my application.  The attached patch does this.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Commented: (JANINO-91) Add support for returning tokens of whitespace

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-91?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_99246 ]

Arno Unkrig commented on JANINO-91:
-----------------------------------

OK, your "remaining code" is a METHOD BODY, not a CLASS BODY. Then you need the ScriptEvaluator class;

{code}
import java.util.*;
import com.acme.Foo;

System.out.println("Hello");
return 7;
{code}

The package/class/method name you would set through "setClassName()" and "setMethodName()".


CU

Arno

> Add support for returning tokens of whitespace
> ----------------------------------------------
>
>                 Key: JANINO-91
>                 URL: http://jira.codehaus.org/browse/JANINO-91
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Minor
>         Attachments: feature_swallowable_whitespace_comment_tokens.patch
>
>
> I have code that filters package/import stmts from source files, then wraps the remaining code in a class definition.  To keep line numbers identical after adding the class definition, I need to have comments and whitespace parsed an return to my application.  The attached patch does this.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Resolved: (JANINO-91) Add support for returning tokens of whitespace

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ http://jira.codehaus.org/browse/JANINO-91?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Arno Unkrig resolved JANINO-91.
-------------------------------

    Resolution: Won't Fix

Again, I got no feedback on this one for a long time, so I set it to "resolved".


CU

Arno

> Add support for returning tokens of whitespace
> ----------------------------------------------
>
>                 Key: JANINO-91
>                 URL: http://jira.codehaus.org/browse/JANINO-91
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Minor
>         Attachments: feature_swallowable_whitespace_comment_tokens.patch
>
>
> I have code that filters package/import stmts from source files, then wraps the remaining code in a class definition.  To keep line numbers identical after adding the class definition, I need to have comments and whitespace parsed an return to my application.  The attached patch does this.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


[janino-dev] [jira] Commented: (JANINO-91) Add support for returning tokens of whitespace

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-91?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=145630#action_145630 ]

Adam Heath commented on JANINO-91:
----------------------------------

But how do I then have static declarations?  I'd like to be able to create static helper methods, and static variables, inside the ScriptEvaluator.  Like this:

==
import java.util.HashMap;
import java.util.Map;

static final String CONSTANT_VALUE = "foobarbaz";
static Map toMap(Object[] args) {
    if (args.length % 2 != 0) throw new IllegalArgumentException("even number of args expected");
    Map result = new HashMap();
    for (int i = 0; i < args.length; ) {
        Object key = args[i++];
        Object value = args[i++];
        result.put(key, value);
    }
    return result;
}

webslinger.event("/Path/To/Event", toMap(new Object[] {"key", "value"}));
return null;
==

Additionally, the reason I needed the whitespace, is that when I parse the above, I remember the imports, find all leading static declarations, then save the rest; I then use string manipulation to insert the package and class name declarations, *without* changing any line numbers.  This latter is important, so that stack traces give correct line numbers, for debugging purposes.


> Add support for returning tokens of whitespace
> ----------------------------------------------
>
>                 Key: JANINO-91
>                 URL: http://jira.codehaus.org/browse/JANINO-91
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Minor
>         Attachments: feature_swallowable_whitespace_comment_tokens.patch
>
>
> I have code that filters package/import stmts from source files, then wraps the remaining code in a class definition.  To keep line numbers identical after adding the class definition, I need to have comments and whitespace parsed an return to my application.  The attached patch does this.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[janino-dev] [jira] Reopened: (JANINO-91) Add support for returning tokens of whitespace

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ http://jira.codehaus.org/browse/JANINO-91?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Arno Unkrig reopened JANINO-91:
-------------------------------


> Add support for returning tokens of whitespace
> ----------------------------------------------
>
>                 Key: JANINO-91
>                 URL: http://jira.codehaus.org/browse/JANINO-91
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Minor
>         Attachments: feature_swallowable_whitespace_comment_tokens.patch
>
>
> I have code that filters package/import stmts from source files, then wraps the remaining code in a class definition.  To keep line numbers identical after adding the class definition, I need to have comments and whitespace parsed an return to my application.  The attached patch does this.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[janino-dev] [jira] Commented: (JANINO-91) Add support for returning tokens of whitespace

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-91?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=146050#action_146050 ]

Adam Heath commented on JANINO-91:
----------------------------------

Well, I don't this feature anymore.  I've rewritten my code, so that I extend SimpleCompiler, and peek/parse out the stuff I need, adding it to a CompilationUnit as nescessary.

> Add support for returning tokens of whitespace
> ----------------------------------------------
>
>                 Key: JANINO-91
>                 URL: http://jira.codehaus.org/browse/JANINO-91
>             Project: Janino
>          Issue Type: New Feature
>            Reporter: Adam Heath
>            Assignee: Arno Unkrig
>            Priority: Minor
>         Attachments: feature_swallowable_whitespace_comment_tokens.patch
>
>
> I have code that filters package/import stmts from source files, then wraps the remaining code in a class definition.  To keep line numbers identical after adding the class definition, I need to have comments and whitespace parsed an return to my application.  The attached patch does this.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email