{"action":"created","comment":{"url":"https://api.github.com/repos/Fueled/flowr/pulls/comments/118243464","pull_request_review_id":40015099,"id":118243464,"diff_hunk":"@@ -0,0 +1,306 @@\n+package com.fueled.flowr.compilers;\n+\n+import com.fueled.flowr.annotations.DeepLink;\n+import com.squareup.javapoet.ClassName;\n+import com.squareup.javapoet.FieldSpec;\n+import com.squareup.javapoet.JavaFile;\n+import com.squareup.javapoet.MethodSpec;\n+import com.squareup.javapoet.ParameterizedTypeName;\n+import com.squareup.javapoet.TypeName;\n+import com.squareup.javapoet.TypeSpec;\n+import com.squareup.javapoet.TypeVariableName;\n+import com.squareup.javapoet.WildcardTypeName;\n+\n+import java.io.IOException;\n+import java.util.ArrayList;\n+import java.util.HashMap;\n+import java.util.Iterator;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Set;\n+import java.util.regex.Matcher;\n+import java.util.regex.Pattern;\n+\n+import javax.annotation.processing.AbstractProcessor;\n+import javax.annotation.processing.RoundEnvironment;\n+import javax.annotation.processing.SupportedAnnotationTypes;\n+import javax.annotation.processing.SupportedSourceVersion;\n+import javax.lang.model.SourceVersion;\n+import javax.lang.model.element.Element;\n+import javax.lang.model.element.Modifier;\n+import javax.lang.model.element.TypeElement;\n+\n+\n+/**\n+ * Annotation processor that will generate the FlowrDeepLinkHandlerImpl based on the information provided by {@link com.fueled.flowr.annotations.DeepLink}.\n+ */\n+@SupportedAnnotationTypes(\"com.fueled.flowr.annotations.DeepLink\")\n+@SupportedSourceVersion(SourceVersion.RELEASE_7)\n+public class DeepLinkAnnotationCompiler extends AbstractProcessor {\n+    private static final String deeplinkFormat = \"addFragment($S, (Class<? extends T>) $T.class)\";\n+    private static final String HANDLER_FILE_NAME = \"FlowrDeepLinkHandlerImpl\";\n+    private static final String FLOWR_PACKAGE_NAME = \"com.fueled.flowr\";\n+    private static final String FLOWR_INTERNAL_PACKAGE_NAME = \"com.fueled.flowr.internal\";\n+\n+    private static final TypeVariableName fragmentTypeVariableName = TypeVariableName.get(\"T\", ClassName.get(\"android.support.v4.app\", \"Fragment\"), ClassName.get(FLOWR_PACKAGE_NAME, \"FlowrFragment\"));\n+    private static final ParameterizedTypeName classExtendsFragmentTypeName = ParameterizedTypeName.get(ClassName.get(Class.class), WildcardTypeName.subtypeOf(fragmentTypeVariableName));\n+    private static final ClassName FlowrDeepLinkInfoClassName = ClassName.get(FLOWR_INTERNAL_PACKAGE_NAME, \"FlowrDeepLinkInfo\");\n+\n+    private static final ClassName bundleClassName = ClassName.get(\"android.os\", \"Bundle\");\n+    private static final ClassName uriClassName = ClassName.get(\"android.net\", \"Uri\");\n+    private static final ParameterizedTypeName listStringTypeName = ParameterizedTypeName.get(List.class, String.class);\n+\n+    /**\n+     * Check if a list of string contains the same substring.\n+     *\n+     * @param strings The list of String to search\n+     * @param pos     The position until where the character are the same.\n+     * @return\n+     */\n+    private static boolean allCharactersAreSame(List<String> strings, int pos) {\n+        String first = strings.get(0);\n+        for (String curString : strings) {\n+            if (curString.length() <= pos\n+                    || curString.charAt(pos) != first.charAt(pos)) {\n+                return false;\n+            }\n+        }\n+        return true;\n+    }\n+\n+    /**\n+     * Create the JavaPoet Type builder for the FlowrDeepLinkHandlerImpl class.\n+     *\n+     * @return The builder for the FlowrDeepLinkHandlerImpl class.\n+     */\n+    private static TypeSpec.Builder getClassObject() {\n+        return TypeSpec.classBuilder(HANDLER_FILE_NAME)\n+                .addTypeVariable(fragmentTypeVariableName)\n+                .addModifiers(Modifier.PUBLIC, Modifier.FINAL)\n+                .addSuperinterface(ClassName.get(FLOWR_INTERNAL_PACKAGE_NAME, \"FlowrDeepLinkHandler\"));\n+    }\n+\n+    /**\n+     * Create the bundleUriInfo method of FlowrDeepLinkHandlerImpl class. This method extract the variables from a URL and add them to a Bundle.\n+     * The structure is <variable, value>.\n+     * For example the pattern in the DeepLink annotation \\\"/user/{userId}\\\", if the user access the app through \\\"/user/1234\\\", the function will return <userId,1234>.\n+     * Please note that all the variable will a string.\n+     *\n+     * @return a Bundle that contains the variables from the deep link.\n+     */\n+    private static MethodSpec bundleUriInfo() {\n+        return MethodSpec.methodBuilder(\"bundleUriInfo\")\n+                .addModifiers(Modifier.PRIVATE, Modifier.STATIC)\n+                .returns(bundleClassName)\n+                .addParameter(uriClassName, \"uri\")\n+                .addParameter(String.class, \"pattern\")\n+                .addCode(\"        String regex = getRegexPattern(pattern);\\n\" +","path":"flowr-compilers/src/main/java/com/fueled/flowr/compilers/DeepLinkAnnotationCompiler.java","position":97,"original_position":97,"commit_id":"b36e0763f27d0170609ed00f0a99e8e65a4abe10","original_commit_id":"b36e0763f27d0170609ed00f0a99e8e65a4abe10","user":{"login":"chetan-fueled","id":25499779,"avatar_url":"https://avatars3.githubusercontent.com/u/25499779?v=3","gravatar_id":"","url":"https://api.github.com/users/chetan-fueled","html_url":"https://github.com/chetan-fueled","followers_url":"https://api.github.com/users/chetan-fueled/followers","following_url":"https://api.github.com/users/chetan-fueled/following{/other_user}","gists_url":"https://api.github.com/users/chetan-fueled/gists{/gist_id}","starred_url":"https://api.github.com/users/chetan-fueled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chetan-fueled/subscriptions","organizations_url":"https://api.github.com/users/chetan-fueled/orgs","repos_url":"https://api.github.com/users/chetan-fueled/repos","events_url":"https://api.github.com/users/chetan-fueled/events{/privacy}","received_events_url":"https://api.github.com/users/chetan-fueled/received_events","type":"User","site_admin":false},"body":"Fair enough. Thanks for clearing that up 👍 ","created_at":"2017-05-24T12:54:49Z","updated_at":"2017-05-24T12:54:49Z","html_url":"https://github.com/Fueled/flowr/pull/19#discussion_r118243464","pull_request_url":"https://api.github.com/repos/Fueled/flowr/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/Fueled/flowr/pulls/comments/118243464"},"html":{"href":"https://github.com/Fueled/flowr/pull/19#discussion_r118243464"},"pull_request":{"href":"https://api.github.com/repos/Fueled/flowr/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/Fueled/flowr/pulls/19","id":119984075,"html_url":"https://github.com/Fueled/flowr/pull/19","diff_url":"https://github.com/Fueled/flowr/pull/19.diff","patch_url":"https://github.com/Fueled/flowr/pull/19.patch","issue_url":"https://api.github.com/repos/Fueled/flowr/issues/19","number":19,"state":"open","locked":false,"title":"Deep link Support","user":{"login":"julien-fueled","id":16091308,"avatar_url":"https://avatars2.githubusercontent.com/u/16091308?v=3","gravatar_id":"","url":"https://api.github.com/users/julien-fueled","html_url":"https://github.com/julien-fueled","followers_url":"https://api.github.com/users/julien-fueled/followers","following_url":"https://api.github.com/users/julien-fueled/following{/other_user}","gists_url":"https://api.github.com/users/julien-fueled/gists{/gist_id}","starred_url":"https://api.github.com/users/julien-fueled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julien-fueled/subscriptions","organizations_url":"https://api.github.com/users/julien-fueled/orgs","repos_url":"https://api.github.com/users/julien-fueled/repos","events_url":"https://api.github.com/users/julien-fueled/events{/privacy}","received_events_url":"https://api.github.com/users/julien-fueled/received_events","type":"User","site_admin":false},"body":"I am planning to add deep link support to the lib. The idea is to get something similar to [this](https://github.com/airbnb/DeepLinkDispatch) for fragments.\r\n\r\nthe final goal is to be able to setup deep link like:\r\n```java\r\n@DeepLink(\"/path1/\")\r\npublic class TestFragment extends Fragment implement FlowrFragment\r\n```\r\nit will also support multiple URL:\r\n```java\r\n@DeepLink({\"/path1/\",\"path2\"})\r\npublic class TestFragment extends Fragment implement FlowrFragment\r\n```\r\nand variables that will be added to the bundle:\r\n```java\r\n@DeepLink(\"/{id}/details\")\r\npublic class TestFragment extends Fragment implement FlowrFragment\r\n.\r\n.\r\n.\r\nString url = getArguments().getString(Flowr.DEEP_LINK_URL,\"\");\r\nString id = getArguments().getString(\"id\",\"\");\r\n```\r\nTo trigger the deep linking, simply call `setDeepLinkContext()`\r\n```java\r\ngetFlowr().setDeepLinkContext(getIntent())\r\n    .open(HomeFragment.class)\r\n    .skipBackStack(true)\r\n    .displayFragment();\r\n```\r\n\r\nAdditionally you can access to a Fragment via the link attached to it:\r\n```java\r\ngetFlowr()\r\n    .open(\"/path1/\")\r\n    .skipBackStack(true)\r\n    .displayFragment();\r\n```\r\nvariables work too:\r\n```java\r\ngetFlowr()\r\n    .open(\"/1234/details\")\r\n    .skipBackStack(true)\r\n    .displayFragment();\r\n```","created_at":"2017-05-10T21:37:15Z","updated_at":"2017-05-24T12:54:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"acd790713e4865b7b03a3cdaaa91f4f1d5325881","assignee":null,"assignees":[],"requested_reviewers":[{"login":"hussein-fueled","id":9694703,"avatar_url":"https://avatars1.githubusercontent.com/u/9694703?v=3","gravatar_id":"","url":"https://api.github.com/users/hussein-fueled","html_url":"https://github.com/hussein-fueled","followers_url":"https://api.github.com/users/hussein-fueled/followers","following_url":"https://api.github.com/users/hussein-fueled/following{/other_user}","gists_url":"https://api.github.com/users/hussein-fueled/gists{/gist_id}","starred_url":"https://api.github.com/users/hussein-fueled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hussein-fueled/subscriptions","organizations_url":"https://api.github.com/users/hussein-fueled/orgs","repos_url":"https://api.github.com/users/hussein-fueled/repos","events_url":"https://api.github.com/users/hussein-fueled/events{/privacy}","received_events_url":"https://api.github.com/users/hussein-fueled/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Fueled/flowr/pulls/19/commits","review_comments_url":"https://api.github.com/repos/Fueled/flowr/pulls/19/comments","review_comment_url":"https://api.github.com/repos/Fueled/flowr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Fueled/flowr/issues/19/comments","statuses_url":"https://api.github.com/repos/Fueled/flowr/statuses/b36e0763f27d0170609ed00f0a99e8e65a4abe10","head":{"label":"Fueled:deep-link","ref":"deep-link","sha":"b36e0763f27d0170609ed00f0a99e8e65a4abe10","user":{"login":"Fueled","id":3440434,"avatar_url":"https://avatars2.githubusercontent.com/u/3440434?v=3","gravatar_id":"","url":"https://api.github.com/users/Fueled","html_url":"https://github.com/Fueled","followers_url":"https://api.github.com/users/Fueled/followers","following_url":"https://api.github.com/users/Fueled/following{/other_user}","gists_url":"https://api.github.com/users/Fueled/gists{/gist_id}","starred_url":"https://api.github.com/users/Fueled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fueled/subscriptions","organizations_url":"https://api.github.com/users/Fueled/orgs","repos_url":"https://api.github.com/users/Fueled/repos","events_url":"https://api.github.com/users/Fueled/events{/privacy}","received_events_url":"https://api.github.com/users/Fueled/received_events","type":"Organization","site_admin":false},"repo":{"id":81500686,"name":"flowr","full_name":"Fueled/flowr","owner":{"login":"Fueled","id":3440434,"avatar_url":"https://avatars2.githubusercontent.com/u/3440434?v=3","gravatar_id":"","url":"https://api.github.com/users/Fueled","html_url":"https://github.com/Fueled","followers_url":"https://api.github.com/users/Fueled/followers","following_url":"https://api.github.com/users/Fueled/following{/other_user}","gists_url":"https://api.github.com/users/Fueled/gists{/gist_id}","starred_url":"https://api.github.com/users/Fueled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fueled/subscriptions","organizations_url":"https://api.github.com/users/Fueled/orgs","repos_url":"https://api.github.com/users/Fueled/repos","events_url":"https://api.github.com/users/Fueled/events{/privacy}","received_events_url":"https://api.github.com/users/Fueled/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Fueled/flowr","description":"FlowR is a wrapper class around the Fragment Manager.","fork":false,"url":"https://api.github.com/repos/Fueled/flowr","forks_url":"https://api.github.com/repos/Fueled/flowr/forks","keys_url":"https://api.github.com/repos/Fueled/flowr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Fueled/flowr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Fueled/flowr/teams","hooks_url":"https://api.github.com/repos/Fueled/flowr/hooks","issue_events_url":"https://api.github.com/repos/Fueled/flowr/issues/events{/number}","events_url":"https://api.github.com/repos/Fueled/flowr/events","assignees_url":"https://api.github.com/repos/Fueled/flowr/assignees{/user}","branches_url":"https://api.github.com/repos/Fueled/flowr/branches{/branch}","tags_url":"https://api.github.com/repos/Fueled/flowr/tags","blobs_url":"https://api.github.com/repos/Fueled/flowr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Fueled/flowr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Fueled/flowr/git/refs{/sha}","trees_url":"https://api.github.com/repos/Fueled/flowr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Fueled/flowr/statuses/{sha}","languages_url":"https://api.github.com/repos/Fueled/flowr/languages","stargazers_url":"https://api.github.com/repos/Fueled/flowr/stargazers","contributors_url":"https://api.github.com/repos/Fueled/flowr/contributors","subscribers_url":"https://api.github.com/repos/Fueled/flowr/subscribers","subscription_url":"https://api.github.com/repos/Fueled/flowr/subscription","commits_url":"https://api.github.com/repos/Fueled/flowr/commits{/sha}","git_commits_url":"https://api.github.com/repos/Fueled/flowr/git/commits{/sha}","comments_url":"https://api.github.com/repos/Fueled/flowr/comments{/number}","issue_comment_url":"https://api.github.com/repos/Fueled/flowr/issues/comments{/number}","contents_url":"https://api.github.com/repos/Fueled/flowr/contents/{+path}","compare_url":"https://api.github.com/repos/Fueled/flowr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Fueled/flowr/merges","archive_url":"https://api.github.com/repos/Fueled/flowr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Fueled/flowr/downloads","issues_url":"https://api.github.com/repos/Fueled/flowr/issues{/number}","pulls_url":"https://api.github.com/repos/Fueled/flowr/pulls{/number}","milestones_url":"https://api.github.com/repos/Fueled/flowr/milestones{/number}","notifications_url":"https://api.github.com/repos/Fueled/flowr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Fueled/flowr/labels{/name}","releases_url":"https://api.github.com/repos/Fueled/flowr/releases{/id}","deployments_url":"https://api.github.com/repos/Fueled/flowr/deployments","created_at":"2017-02-09T22:19:36Z","updated_at":"2017-05-05T12:27:04Z","pushed_at":"2017-05-23T21:36:20Z","git_url":"git://github.com/Fueled/flowr.git","ssh_url":"git@github.com:Fueled/flowr.git","clone_url":"https://github.com/Fueled/flowr.git","svn_url":"https://github.com/Fueled/flowr","homepage":"","size":211,"stargazers_count":39,"watchers_count":39,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":39,"default_branch":"master"}},"base":{"label":"Fueled:master","ref":"master","sha":"be57dcfbea8a5bb43d2625616ba754301db68439","user":{"login":"Fueled","id":3440434,"avatar_url":"https://avatars2.githubusercontent.com/u/3440434?v=3","gravatar_id":"","url":"https://api.github.com/users/Fueled","html_url":"https://github.com/Fueled","followers_url":"https://api.github.com/users/Fueled/followers","following_url":"https://api.github.com/users/Fueled/following{/other_user}","gists_url":"https://api.github.com/users/Fueled/gists{/gist_id}","starred_url":"https://api.github.com/users/Fueled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fueled/subscriptions","organizations_url":"https://api.github.com/users/Fueled/orgs","repos_url":"https://api.github.com/users/Fueled/repos","events_url":"https://api.github.com/users/Fueled/events{/privacy}","received_events_url":"https://api.github.com/users/Fueled/received_events","type":"Organization","site_admin":false},"repo":{"id":81500686,"name":"flowr","full_name":"Fueled/flowr","owner":{"login":"Fueled","id":3440434,"avatar_url":"https://avatars2.githubusercontent.com/u/3440434?v=3","gravatar_id":"","url":"https://api.github.com/users/Fueled","html_url":"https://github.com/Fueled","followers_url":"https://api.github.com/users/Fueled/followers","following_url":"https://api.github.com/users/Fueled/following{/other_user}","gists_url":"https://api.github.com/users/Fueled/gists{/gist_id}","starred_url":"https://api.github.com/users/Fueled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fueled/subscriptions","organizations_url":"https://api.github.com/users/Fueled/orgs","repos_url":"https://api.github.com/users/Fueled/repos","events_url":"https://api.github.com/users/Fueled/events{/privacy}","received_events_url":"https://api.github.com/users/Fueled/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Fueled/flowr","description":"FlowR is a wrapper class around the Fragment Manager.","fork":false,"url":"https://api.github.com/repos/Fueled/flowr","forks_url":"https://api.github.com/repos/Fueled/flowr/forks","keys_url":"https://api.github.com/repos/Fueled/flowr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Fueled/flowr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Fueled/flowr/teams","hooks_url":"https://api.github.com/repos/Fueled/flowr/hooks","issue_events_url":"https://api.github.com/repos/Fueled/flowr/issues/events{/number}","events_url":"https://api.github.com/repos/Fueled/flowr/events","assignees_url":"https://api.github.com/repos/Fueled/flowr/assignees{/user}","branches_url":"https://api.github.com/repos/Fueled/flowr/branches{/branch}","tags_url":"https://api.github.com/repos/Fueled/flowr/tags","blobs_url":"https://api.github.com/repos/Fueled/flowr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Fueled/flowr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Fueled/flowr/git/refs{/sha}","trees_url":"https://api.github.com/repos/Fueled/flowr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Fueled/flowr/statuses/{sha}","languages_url":"https://api.github.com/repos/Fueled/flowr/languages","stargazers_url":"https://api.github.com/repos/Fueled/flowr/stargazers","contributors_url":"https://api.github.com/repos/Fueled/flowr/contributors","subscribers_url":"https://api.github.com/repos/Fueled/flowr/subscribers","subscription_url":"https://api.github.com/repos/Fueled/flowr/subscription","commits_url":"https://api.github.com/repos/Fueled/flowr/commits{/sha}","git_commits_url":"https://api.github.com/repos/Fueled/flowr/git/commits{/sha}","comments_url":"https://api.github.com/repos/Fueled/flowr/comments{/number}","issue_comment_url":"https://api.github.com/repos/Fueled/flowr/issues/comments{/number}","contents_url":"https://api.github.com/repos/Fueled/flowr/contents/{+path}","compare_url":"https://api.github.com/repos/Fueled/flowr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Fueled/flowr/merges","archive_url":"https://api.github.com/repos/Fueled/flowr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Fueled/flowr/downloads","issues_url":"https://api.github.com/repos/Fueled/flowr/issues{/number}","pulls_url":"https://api.github.com/repos/Fueled/flowr/pulls{/number}","milestones_url":"https://api.github.com/repos/Fueled/flowr/milestones{/number}","notifications_url":"https://api.github.com/repos/Fueled/flowr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Fueled/flowr/labels{/name}","releases_url":"https://api.github.com/repos/Fueled/flowr/releases{/id}","deployments_url":"https://api.github.com/repos/Fueled/flowr/deployments","created_at":"2017-02-09T22:19:36Z","updated_at":"2017-05-05T12:27:04Z","pushed_at":"2017-05-23T21:36:20Z","git_url":"git://github.com/Fueled/flowr.git","ssh_url":"git@github.com:Fueled/flowr.git","clone_url":"https://github.com/Fueled/flowr.git","svn_url":"https://github.com/Fueled/flowr","homepage":"","size":211,"stargazers_count":39,"watchers_count":39,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":39,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Fueled/flowr/pulls/19"},"html":{"href":"https://github.com/Fueled/flowr/pull/19"},"issue":{"href":"https://api.github.com/repos/Fueled/flowr/issues/19"},"comments":{"href":"https://api.github.com/repos/Fueled/flowr/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/Fueled/flowr/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/Fueled/flowr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Fueled/flowr/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/Fueled/flowr/statuses/b36e0763f27d0170609ed00f0a99e8e65a4abe10"}}}}
{"actor":{"display_login":"chetan-fueled"}}