[JBoss JIRA] (ROASTER-75) Encoding of source[?] code cannot be easily configured.
by Shoji Kuzukami (JIRA)
Shoji Kuzukami created ROASTER-75:
-------------------------------------
Summary: Encoding of source[?] code cannot be easily configured.
Key: ROASTER-75
URL: https://issues.jboss.org/browse/ROASTER-75
Project: Roaster
Issue Type: Enhancement
Components: API, JDT
Affects Versions: 2.14.0.Final, 2.15.0.Final
Environment: Java 8 64bit, Eclipse Mars, Windows 8.1 Pro 64bit
Reporter: Shoji Kuzukami
Priority: Minor
The parser encoding for souce code can only be configured by the 'file.encoding' system parameter, as we can see in JavaParserImpl, "String encoding = System.getProperty("file.encoding", "ISO8859_1");".
Even the Roaster API can receive a 'String' source as "public static JavaType<?> parse(final String data)" in the 'Roaster.java', the 'String' of source can only contain "ISO8859_1" charsets if we don't change the "file.encoding".
The parser SPI in 'JavaParser.java' is defined as "JavaUnit parseUnit(final InputStream data);" instead of "JavaUnit parseUnit(Reader source);". I think it is adequate considering that the Roaster API will accept some binary sources (such as bytecode) in near future.
I recommend that the SPI "JavaUnit parseUnit(final InputStream data);" is expanded into "JavaUnit parseUnit(final InputStream data, Charset encodingIfText );" and some encoding refactors is done in the 'Roaster.java' without any change of semantics in the Roaster APIs except for the 'String' souce APIs as "public static JavaType<?> parse(final String data)".
The 'Charset' argument is used only if the 'data' of InputStream must be interpreted as 'String' ( as a case of source code ).
If this idea is accepted by this project design, I'll refactor the code and do a pull-requeust.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months
[JBoss JIRA] (ROASTER-72) Adds a new API to parse the multiple declarations of type in a file.
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-72?page=com.atlassian.jira.plugin... ]
George Gastaldi closed ROASTER-72.
----------------------------------
Assignee: George Gastaldi
Fix Version/s: 2.15.0.Final
(was: 2.x Future)
Resolution: Done
Created Roaster.parseUnit.
Thank you!
> Adds a new API to parse the multiple declarations of type in a file.
> --------------------------------------------------------------------
>
> Key: ROASTER-72
> URL: https://issues.jboss.org/browse/ROASTER-72
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT, Tests
> Affects Versions: 2.14.0.Final
> Environment: Java 8, Windows 8.1 64 bit, Eclipse mars 64bit
> Reporter: Shoji Kuzukami
> Assignee: George Gastaldi
> Fix For: 2.15.0.Final
>
>
> Although the java language permits multiple type declarations of top level in a java file, the 'roaster' cannot support this function in the API level. Therefore, I tentatively hack and create an API for the support of multiple declarations.
> Please refine and refactor the API until the next release because I cannot devote more efforts on this. The new API is initially marked as @Deprecated for such reasons.
> --comments--
> Adds a new API and data structure to parse the multiple declarations of
> classes in a java file.
> An instance of the 'JavaSourceUnit' represents a java source file which
> contains multiple declarations of type.
> An API named Roaster.parse2(String encoding, InputStream data) is
> tentatively created to extract the JavaSourceUnit result.
> Some tests for the new function are created at
> 'JavaClassMultiDeclsInAFile.java'.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months
[JBoss JIRA] (ROASTER-72) Adds a new API to parse the multiple declarations of type in a file.
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-72?page=com.atlassian.jira.plugin... ]
George Gastaldi edited comment on ROASTER-72 at 7/8/15 4:28 PM:
----------------------------------------------------------------
Of course that would also mean we should add a parseUnit method in Roaster
was (Author: gastaldi):
Of course that would also mean we should add a parseUnit method in Roaster, as well provide means to create one
> Adds a new API to parse the multiple declarations of type in a file.
> --------------------------------------------------------------------
>
> Key: ROASTER-72
> URL: https://issues.jboss.org/browse/ROASTER-72
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT, Tests
> Affects Versions: 2.14.0.Final
> Environment: Java 8, Windows 8.1 64 bit, Eclipse mars 64bit
> Reporter: Shoji Kuzukami
> Fix For: 2.x Future
>
>
> Although the java language permits multiple type declarations of top level in a java file, the 'roaster' cannot support this function in the API level. Therefore, I tentatively hack and create an API for the support of multiple declarations.
> Please refine and refactor the API until the next release because I cannot devote more efforts on this. The new API is initially marked as @Deprecated for such reasons.
> --comments--
> Adds a new API and data structure to parse the multiple declarations of
> classes in a java file.
> An instance of the 'JavaSourceUnit' represents a java source file which
> contains multiple declarations of type.
> An API named Roaster.parse2(String encoding, InputStream data) is
> tentatively created to extract the JavaSourceUnit result.
> Some tests for the new function are created at
> 'JavaClassMultiDeclsInAFile.java'.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months
[JBoss JIRA] (ROASTER-72) Adds a new API to parse the multiple declarations of type in a file.
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-72?page=com.atlassian.jira.plugin... ]
George Gastaldi updated ROASTER-72:
-----------------------------------
Comment: was deleted
(was: IMHO I think this API change does not justify for something that is highly discouraged (multiple types in a class), even though that the JLS supports it.
Can you send an email to the forge-dev list asking for feedback?)
> Adds a new API to parse the multiple declarations of type in a file.
> --------------------------------------------------------------------
>
> Key: ROASTER-72
> URL: https://issues.jboss.org/browse/ROASTER-72
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT, Tests
> Affects Versions: 2.14.0.Final
> Environment: Java 8, Windows 8.1 64 bit, Eclipse mars 64bit
> Reporter: Shoji Kuzukami
> Fix For: 2.x Future
>
>
> Although the java language permits multiple type declarations of top level in a java file, the 'roaster' cannot support this function in the API level. Therefore, I tentatively hack and create an API for the support of multiple declarations.
> Please refine and refactor the API until the next release because I cannot devote more efforts on this. The new API is initially marked as @Deprecated for such reasons.
> --comments--
> Adds a new API and data structure to parse the multiple declarations of
> classes in a java file.
> An instance of the 'JavaSourceUnit' represents a java source file which
> contains multiple declarations of type.
> An API named Roaster.parse2(String encoding, InputStream data) is
> tentatively created to extract the JavaSourceUnit result.
> Some tests for the new function are created at
> 'JavaClassMultiDeclsInAFile.java'.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months
[JBoss JIRA] (ROASTER-72) Adds a new API to parse the multiple declarations of type in a file.
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-72?page=com.atlassian.jira.plugin... ]
George Gastaldi commented on ROASTER-72:
----------------------------------------
IMHO I think this API change does not justify for something that is highly discouraged (multiple types in a class), even though that the JLS supports it.
Can you send an email to the forge-dev list asking for feedback?
> Adds a new API to parse the multiple declarations of type in a file.
> --------------------------------------------------------------------
>
> Key: ROASTER-72
> URL: https://issues.jboss.org/browse/ROASTER-72
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT, Tests
> Affects Versions: 2.14.0.Final
> Environment: Java 8, Windows 8.1 64 bit, Eclipse mars 64bit
> Reporter: Shoji Kuzukami
> Fix For: 2.x Future
>
>
> Although the java language permits multiple type declarations of top level in a java file, the 'roaster' cannot support this function in the API level. Therefore, I tentatively hack and create an API for the support of multiple declarations.
> Please refine and refactor the API until the next release because I cannot devote more efforts on this. The new API is initially marked as @Deprecated for such reasons.
> --comments--
> Adds a new API and data structure to parse the multiple declarations of
> classes in a java file.
> An instance of the 'JavaSourceUnit' represents a java source file which
> contains multiple declarations of type.
> An API named Roaster.parse2(String encoding, InputStream data) is
> tentatively created to extract the JavaSourceUnit result.
> Some tests for the new function are created at
> 'JavaClassMultiDeclsInAFile.java'.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months
[JBoss JIRA] (ROASTER-72) Adds a new API to parse the multiple declarations of type in a file.
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-72?page=com.atlassian.jira.plugin... ]
George Gastaldi commented on ROASTER-72:
----------------------------------------
Of course that would also mean we should add a parseUnit method in Roaster, as well provide means to create one
> Adds a new API to parse the multiple declarations of type in a file.
> --------------------------------------------------------------------
>
> Key: ROASTER-72
> URL: https://issues.jboss.org/browse/ROASTER-72
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT, Tests
> Affects Versions: 2.14.0.Final
> Environment: Java 8, Windows 8.1 64 bit, Eclipse mars 64bit
> Reporter: Shoji Kuzukami
> Fix For: 2.x Future
>
>
> Although the java language permits multiple type declarations of top level in a java file, the 'roaster' cannot support this function in the API level. Therefore, I tentatively hack and create an API for the support of multiple declarations.
> Please refine and refactor the API until the next release because I cannot devote more efforts on this. The new API is initially marked as @Deprecated for such reasons.
> --comments--
> Adds a new API and data structure to parse the multiple declarations of
> classes in a java file.
> An instance of the 'JavaSourceUnit' represents a java source file which
> contains multiple declarations of type.
> An API named Roaster.parse2(String encoding, InputStream data) is
> tentatively created to extract the JavaSourceUnit result.
> Some tests for the new function are created at
> 'JavaClassMultiDeclsInAFile.java'.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months
[JBoss JIRA] (ROASTER-72) Adds a new API to parse the multiple declarations of type in a file.
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-72?page=com.atlassian.jira.plugin... ]
George Gastaldi commented on ROASTER-72:
----------------------------------------
Hi Shoji,
Yes, I agree that we must have a in-memory model of this scenario.
Maybe the JavaUnit interface you provided could be returned from JavaParser implementations and we could deprecate the old parse method, thus returning the governing type referenced in your PR. What do you think?
Best Regards
George
> Adds a new API to parse the multiple declarations of type in a file.
> --------------------------------------------------------------------
>
> Key: ROASTER-72
> URL: https://issues.jboss.org/browse/ROASTER-72
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT, Tests
> Affects Versions: 2.14.0.Final
> Environment: Java 8, Windows 8.1 64 bit, Eclipse mars 64bit
> Reporter: Shoji Kuzukami
> Fix For: 2.x Future
>
>
> Although the java language permits multiple type declarations of top level in a java file, the 'roaster' cannot support this function in the API level. Therefore, I tentatively hack and create an API for the support of multiple declarations.
> Please refine and refactor the API until the next release because I cannot devote more efforts on this. The new API is initially marked as @Deprecated for such reasons.
> --comments--
> Adds a new API and data structure to parse the multiple declarations of
> classes in a java file.
> An instance of the 'JavaSourceUnit' represents a java source file which
> contains multiple declarations of type.
> An API named Roaster.parse2(String encoding, InputStream data) is
> tentatively created to extract the JavaSourceUnit result.
> Some tests for the new function are created at
> 'JavaClassMultiDeclsInAFile.java'.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months
[JBoss JIRA] (ROASTER-72) Adds a new API to parse the multiple declarations of type in a file.
by Shoji Kuzukami (JIRA)
[ https://issues.jboss.org/browse/ROASTER-72?page=com.atlassian.jira.plugin... ]
Shoji Kuzukami updated ROASTER-72:
----------------------------------
Git Pull Request: https://github.com/forge/roaster/pull/38 (was: https://github.com/forge/roaster/pull/34)
> Adds a new API to parse the multiple declarations of type in a file.
> --------------------------------------------------------------------
>
> Key: ROASTER-72
> URL: https://issues.jboss.org/browse/ROASTER-72
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT, Tests
> Affects Versions: 2.14.0.Final
> Environment: Java 8, Windows 8.1 64 bit, Eclipse mars 64bit
> Reporter: Shoji Kuzukami
> Fix For: 2.x Future
>
>
> Although the java language permits multiple type declarations of top level in a java file, the 'roaster' cannot support this function in the API level. Therefore, I tentatively hack and create an API for the support of multiple declarations.
> Please refine and refactor the API until the next release because I cannot devote more efforts on this. The new API is initially marked as @Deprecated for such reasons.
> --comments--
> Adds a new API and data structure to parse the multiple declarations of
> classes in a java file.
> An instance of the 'JavaSourceUnit' represents a java source file which
> contains multiple declarations of type.
> An API named Roaster.parse2(String encoding, InputStream data) is
> tentatively created to extract the JavaSourceUnit result.
> Some tests for the new function are created at
> 'JavaClassMultiDeclsInAFile.java'.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months
[JBoss JIRA] (ROASTER-72) Adds a new API to parse the multiple declarations of type in a file.
by Shoji Kuzukami (JIRA)
[ https://issues.jboss.org/browse/ROASTER-72?page=com.atlassian.jira.plugin... ]
Shoji Kuzukami commented on ROASTER-72:
---------------------------------------
Hi George.
As you said, the complexity of API apparently grows up.
But it comes merely for the complexity of java language, not for a verbosity or a confusing in API.
I think it is better that the in-memory-tree (so not visiting) stable model must be established quickly as well as possible
because an in-memory tree model is easier in many point of view than a visitor model
and a beautiful visitor pattern depends on stability and preciseness of the underlying model.
If we once get the precise model of tree, an API of visitor pattern can be easily built
because a lack of memory would not happen in a one-file source code analysis.
In the view point for me, I want to say
'How do I process such a multiple declaration .java file until the fixing of API you mentioned?'
> Adds a new API to parse the multiple declarations of type in a file.
> --------------------------------------------------------------------
>
> Key: ROASTER-72
> URL: https://issues.jboss.org/browse/ROASTER-72
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT, Tests
> Affects Versions: 2.14.0.Final
> Environment: Java 8, Windows 8.1 64 bit, Eclipse mars 64bit
> Reporter: Shoji Kuzukami
> Fix For: 2.x Future
>
>
> Although the java language permits multiple type declarations of top level in a java file, the 'roaster' cannot support this function in the API level. Therefore, I tentatively hack and create an API for the support of multiple declarations.
> Please refine and refactor the API until the next release because I cannot devote more efforts on this. The new API is initially marked as @Deprecated for such reasons.
> --comments--
> Adds a new API and data structure to parse the multiple declarations of
> classes in a java file.
> An instance of the 'JavaSourceUnit' represents a java source file which
> contains multiple declarations of type.
> An API named Roaster.parse2(String encoding, InputStream data) is
> tentatively created to extract the JavaSourceUnit result.
> Some tests for the new function are created at
> 'JavaClassMultiDeclsInAFile.java'.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months
[JBoss JIRA] (ROASTER-72) Adds a new API to parse the multiple declarations of type in a file.
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-72?page=com.atlassian.jira.plugin... ]
George Gastaldi commented on ROASTER-72:
----------------------------------------
Hi Shoji, thanks for your issue and your PR.
I think we should introduce a visitor pattern (acting as a callback) to solve this issue. Something like {{void Roaster.parse(contents, visitor)}}.
I am not entirely happy with the solution proposed in the PR, as I believe that your proposed changes will make the API harder to understand.
Thoughts are welcome.
> Adds a new API to parse the multiple declarations of type in a file.
> --------------------------------------------------------------------
>
> Key: ROASTER-72
> URL: https://issues.jboss.org/browse/ROASTER-72
> Project: Roaster
> Issue Type: Feature Request
> Components: API, JDT, Tests
> Affects Versions: 2.14.0.Final
> Environment: Java 8, Windows 8.1 64 bit, Eclipse mars 64bit
> Reporter: Shoji Kuzukami
> Fix For: 2.x Future
>
>
> Although the java language permits multiple type declarations of top level in a java file, the 'roaster' cannot support this function in the API level. Therefore, I tentatively hack and create an API for the support of multiple declarations.
> Please refine and refactor the API until the next release because I cannot devote more efforts on this. The new API is initially marked as @Deprecated for such reasons.
> --comments--
> Adds a new API and data structure to parse the multiple declarations of
> classes in a java file.
> An instance of the 'JavaSourceUnit' represents a java source file which
> contains multiple declarations of type.
> An API named Roaster.parse2(String encoding, InputStream data) is
> tentatively created to extract the JavaSourceUnit result.
> Some tests for the new function are created at
> 'JavaClassMultiDeclsInAFile.java'.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
10 years, 9 months