{"action":"created","issue":{"url":"https://api.github.com/repos/javaparser/javaparser/issues/157","repository_url":"https://api.github.com/repos/javaparser/javaparser","labels_url":"https://api.github.com/repos/javaparser/javaparser/issues/157/labels{/name}","comments_url":"https://api.github.com/repos/javaparser/javaparser/issues/157/comments","events_url":"https://api.github.com/repos/javaparser/javaparser/issues/157/events","html_url":"https://github.com/javaparser/javaparser/issues/157","id":91492549,"number":157,"title":"Enhance parser frontend","user":{"login":"ptitjes","id":64956,"avatar_url":"https://avatars.githubusercontent.com/u/64956?v=3","gravatar_id":"","url":"https://api.github.com/users/ptitjes","html_url":"https://github.com/ptitjes","followers_url":"https://api.github.com/users/ptitjes/followers","following_url":"https://api.github.com/users/ptitjes/following{/other_user}","gists_url":"https://api.github.com/users/ptitjes/gists{/gist_id}","starred_url":"https://api.github.com/users/ptitjes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptitjes/subscriptions","organizations_url":"https://api.github.com/users/ptitjes/orgs","repos_url":"https://api.github.com/users/ptitjes/repos","events_url":"https://api.github.com/users/ptitjes/events{/privacy}","received_events_url":"https://api.github.com/users/ptitjes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/javaparser/javaparser/labels/Feature%20request","name":"Feature request","color":"5319e7"}],"state":"open","locked":false,"assignee":{"login":"matozoid","id":55701,"avatar_url":"https://avatars.githubusercontent.com/u/55701?v=3","gravatar_id":"","url":"https://api.github.com/users/matozoid","html_url":"https://github.com/matozoid","followers_url":"https://api.github.com/users/matozoid/followers","following_url":"https://api.github.com/users/matozoid/following{/other_user}","gists_url":"https://api.github.com/users/matozoid/gists{/gist_id}","starred_url":"https://api.github.com/users/matozoid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matozoid/subscriptions","organizations_url":"https://api.github.com/users/matozoid/orgs","repos_url":"https://api.github.com/users/matozoid/repos","events_url":"https://api.github.com/users/matozoid/events{/privacy}","received_events_url":"https://api.github.com/users/matozoid/received_events","type":"User","site_admin":false},"assignees":[{"login":"matozoid","id":55701,"avatar_url":"https://avatars.githubusercontent.com/u/55701?v=3","gravatar_id":"","url":"https://api.github.com/users/matozoid","html_url":"https://github.com/matozoid","followers_url":"https://api.github.com/users/matozoid/followers","following_url":"https://api.github.com/users/matozoid/following{/other_user}","gists_url":"https://api.github.com/users/matozoid/gists{/gist_id}","starred_url":"https://api.github.com/users/matozoid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matozoid/subscriptions","organizations_url":"https://api.github.com/users/matozoid/orgs","repos_url":"https://api.github.com/users/matozoid/repos","events_url":"https://api.github.com/users/matozoid/events{/privacy}","received_events_url":"https://api.github.com/users/matozoid/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2015-06-27T17:11:15Z","updated_at":"2016-08-30T21:44:01Z","closed_at":null,"body":"This bug is to discuss enhancements to the parser front-end as highlighted in #115, that is:\r\n\r\n- Make JavaParser a state-full object\r\n  - Give access to the (exception-free) parsing mechanism\r\n  - Keep static helpers that throw ParseException\r\n\r\n- Add problem reporting mechanism\r\n  - Introduce a Location object (source path + Position, comparable)\r\n  - Introduce a Problem object (comparable based on Location)\r\n  - Introduce a ParseResult` object that contains the parsed node and reported problems\r\n  - For the static helpers, make a `ParseException` that contains a list of problems\r\n\r\n\r\nI'd rather not introduce a `Reporter` interface as I previously noted in #115. Indeed, lexical preservation might enable us to later do continuous parsing à-la Papa Carlo, so I propose the creation of a `ParseResult` object which might later provide a method like `reparse(Parser, ParseHandler)` with `ParseHandler` being a reactive sink for problems and node addition/removal/replacement events. \r\n\r\nHere are, in a glance, the APIs that I propose for discussion:\r\n\r\n```java\r\npublic class Location {\r\n  public java.nio.Path path(); // May be null if not parsed from a file\r\n  public Position position();\r\n}\r\n\r\npublic class Problem {\r\n  public enum Severity { FATAL, ERROR, WARNING, INFO }\r\n  public Severity severity();\r\n  public Location location();\r\n  public String message();\r\n}\r\n\r\npublic class ParseResult<N extends Node> {\r\n  public List<Problem> problems();\r\n  public N node();\r\n}\r\n\r\npublic class ParserConfiguration {\r\n  private boolean parseComments; // + getter/setter\r\n  // other configuration...\r\n}\r\n\r\npublic abstract class ParseContext<N extends Node> {\r\n  // Required package-protected boilerplate code to call ad-hoc parser production...\r\n}\r\n\r\npublic class JavaParser {\r\n  public JavaParser(ParserConfiguration configuration) { /* ... */ }\r\n\r\n  public static ParseContext<CompilationUnit> COMPILATION_UNIT = ...;\r\n  public static ParseContext<BodyDeclaration> BODY_DECLARATION = ...;\r\n  public static ParseContext<Type> TYPE = ...;\r\n  public static ParseContext<Statement> STATEMENT = ...;\r\n  public static ParseContext<Expression> EXPRESSION = ...;\r\n  // ...\r\n\r\n  public <N extends Node> ParseResult<N> parse(ParseContext<N> context, InputStream input, Charset encoding);\r\n  public <N extends Node> ParseResult<N> parse(ParseContext<N> context, String input, Charset encoding);\r\n\r\n  public ParseResult<CompilationUnit> parse(Path path, InputStream input, Charset encoding);\r\n  // And some other variations\r\n\r\n  // + current static helpers throwing ParseException\r\n}\r\n\r\npublic class ParseException extends Exception {\r\n  private List<Problem> problems;\r\n  // ...\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/javaparser/javaparser/issues/comments/243591155","html_url":"https://github.com/javaparser/javaparser/issues/157#issuecomment-243591155","issue_url":"https://api.github.com/repos/javaparser/javaparser/issues/157","id":243591155,"user":{"login":"matozoid","id":55701,"avatar_url":"https://avatars.githubusercontent.com/u/55701?v=3","gravatar_id":"","url":"https://api.github.com/users/matozoid","html_url":"https://github.com/matozoid","followers_url":"https://api.github.com/users/matozoid/followers","following_url":"https://api.github.com/users/matozoid/following{/other_user}","gists_url":"https://api.github.com/users/matozoid/gists{/gist_id}","starred_url":"https://api.github.com/users/matozoid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matozoid/subscriptions","organizations_url":"https://api.github.com/users/matozoid/orgs","repos_url":"https://api.github.com/users/matozoid/repos","events_url":"https://api.github.com/users/matozoid/events{/privacy}","received_events_url":"https://api.github.com/users/matozoid/received_events","type":"User","site_admin":false},"created_at":"2016-08-30T21:44:00Z","updated_at":"2016-08-30T21:44:00Z","body":"Alright, I took some time to study the proposal and I agree it's very nice! And it's exactly the right time to implement it. \r\nNote 1: it seems like path/source should be in ParseResult.\r\nNote 2: This proposal can be split in three:\r\n\r\n1. create separate configuration object (how would you configure the static helpers?)\r\n2. all of the problem collection code\r\n3. make ParseContext to reduce the amount of parse methods."}}
{"actor":{"display_login":"matozoid"}}