[
  {
    "path": ".gitignore",
    "content": "# Android lib\n*.dex\n*.class\n*bin/\n*gen/\n*out/\n*.gradle/\n*build/\n*local.properties\n*proguard/\n*.log\n*.navigation/\n*captures/\n*.iml\n*.idea/\n*.externalNativeBuild\n\n# Idea Plugin\nIdeaPlugin/IdeaPlugin.jar\n*target/\n*out/\n\n"
  },
  {
    "path": "AnnotationLib/build.gradle",
    "content": "group 'com.anupcowkur'\nversion '1.0.1'\n\napply plugin: 'java'\n\nsourceCompatibility = 1.7\ntargetCompatibility = 1.7\n\nrepositories {\n    mavenCentral()\n}\n\ntask sourcesJar(type: Jar, dependsOn: classes) {\n    classifier = 'sources'\n    from sourceSets.main.allSource\n}\n\ntask javadocJar(type: Jar, dependsOn: javadoc) {\n    classifier = 'javadoc'\n    from javadoc.destinationDir\n}\n\nartifacts {\n    archives sourcesJar\n    archives javadocJar\n}"
  },
  {
    "path": "AnnotationLib/gradle/wrapper/gradle-wrapper.properties",
    "content": "#Sat Mar 04 18:09:38 IST 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-3.1-bin.zip\n"
  },
  {
    "path": "AnnotationLib/gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\n# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong\nif [[ \"$(uname)\" == \"Darwin\" ]] && [[ \"$HOME\" == \"$PWD\" ]]; then\n  cd \"$(dirname \"$0\")\"\nfi\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "AnnotationLib/gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables with windows NT shell\r\nif \"%OS%\"==\"Windows_NT\" setlocal\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif \"%ERRORLEVEL%\" == \"0\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:init\r\n@rem Get command-line arguments, handling Windows variants\r\n\r\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\r\n\r\n:win9xME_args\r\n@rem Slurp the command line arguments.\r\nset CMD_LINE_ARGS=\r\nset _SKIP=2\r\n\r\n:win9xME_args_slurp\r\nif \"x%~1\" == \"x\" goto execute\r\n\r\nset CMD_LINE_ARGS=%*\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\r\n\r\n@rem Execute Gradle\r\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\r\n\r\n:end\r\n@rem End local scope for the variables with windows NT shell\r\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\r\n\r\n:fail\r\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r\nrem the _cmd.exe /c_ return code!\r\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\r\nexit /b 1\r\n\r\n:mainEnd\r\nif \"%OS%\"==\"Windows_NT\" endlocal\r\n\r\n:omega\r\n"
  },
  {
    "path": "AnnotationLib/settings.gradle",
    "content": "rootProject.name = 'herebedragons'\n\n"
  },
  {
    "path": "AnnotationLib/src/main/java/com/anupcowkur/herebedragons/SideEffect.java",
    "content": "package com.anupcowkur.herebedragons;\n\nimport java.lang.annotation.Documented;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.Target;\n\nimport static java.lang.annotation.ElementType.METHOD;\nimport static java.lang.annotation.RetentionPolicy.SOURCE;\n\n/**\n * Annotation to indicate Impure/Side effecting methods. HereBeDragons plugin uses\n * this annotation to show a dragon icon in the IDE gutter.\n */\n@Documented\n@Target(METHOD)\n@Retention(SOURCE)\npublic @interface SideEffect {\n}"
  },
  {
    "path": "IdeaPlugin/resources/META-INF/plugin.xml",
    "content": "<idea-plugin version=\"2\">\n  <id>com.anupcowkur.herebedragons</id>\n  <name>Here Be Dragons</name>\n  <version>1.0.1</version>\n  <vendor email=\"anupcowkur89@gmail.com\" url=\"https://github.com/anupcowkur/SideEffects\">Side Effects</vendor>\n\n  <description><![CDATA[\n      Annotate your methods with @SideEffect and let the little dragon show you when you're calling an impure method<br/>\n    ]]></description>\n\n  <change-notes><![CDATA[\n     1.0.1: Make compatible with Java 7.<br/>\n    ]]>\n  </change-notes>\n\n  <!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->\n  <idea-version since-build=\"145.0\"/>\n\n  <!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html\n       on how to target different products -->\n  <!-- uncomment to enable plugin in all products\n  <depends>com.intellij.modules.lang</depends>\n  -->\n\n  <extensions defaultExtensionNs=\"com.intellij\">\n    <codeInsight.lineMarkerProvider language=\"JAVA\"\n                                    implementationClass=\"com.anupcowkur.herebedragons.SideEffectLineMarkerProvider\"/>\n  </extensions>\n</idea-plugin>"
  },
  {
    "path": "IdeaPlugin/src/com/anupcowkur/herebedragons/AnnotationDetector.java",
    "content": "package com.anupcowkur.herebedragons;\n\nimport com.intellij.codeInsight.AnnotationUtil;\nimport com.intellij.psi.PsiAnnotation;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiModifierList;\nimport com.intellij.psi.PsiModifierListOwner;\n\npublic final class AnnotationDetector {\n\n    private AnnotationDetector() {\n    }\n\n    public static boolean hasAnnotation(PsiElement element, String annotationName) {\n        return findAnnotation(element, annotationName) != null;\n    }\n\n    static PsiAnnotation findAnnotation(PsiElement element, String annotationName) {\n        if (element instanceof PsiModifierListOwner) {\n            PsiModifierListOwner listOwner = (PsiModifierListOwner) element;\n            PsiModifierList modifierList = listOwner.getModifierList();\n\n            if (modifierList != null) {\n                for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {\n                    if (annotationName.equals(psiAnnotation.getQualifiedName())) {\n                        return psiAnnotation;\n                    }\n                }\n            }\n\n        }\n        return null;\n    }\n}\n"
  },
  {
    "path": "IdeaPlugin/src/com/anupcowkur/herebedragons/Constants.java",
    "content": "package com.anupcowkur.herebedragons;\n\npublic final class Constants {\n    private Constants() {\n    }\n\n    public static final String CLASS_SIDE_EFFECT = \"com.anupcowkur.herebedragons.SideEffect\";\n}\n"
  },
  {
    "path": "IdeaPlugin/src/com/anupcowkur/herebedragons/SideEffectLineMarkerProvider.java",
    "content": "package com.anupcowkur.herebedragons;\n\nimport com.intellij.codeInsight.TargetElementUtil;\nimport com.intellij.codeInsight.daemon.LineMarkerInfo;\nimport com.intellij.codeInsight.daemon.LineMarkerProvider;\nimport com.intellij.openapi.util.IconLoader;\nimport com.intellij.psi.*;\n\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.function.Consumer;\nimport javax.swing.Icon;\n\nimport com.intellij.psi.search.searches.MethodReferencesSearch;\nimport com.intellij.util.Processor;\nimport com.intellij.util.Query;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport static com.anupcowkur.herebedragons.AnnotationDetector.hasAnnotation;\nimport static com.anupcowkur.herebedragons.Constants.CLASS_SIDE_EFFECT;\nimport static com.intellij.codeHighlighting.Pass.UPDATE_ALL;\nimport static com.intellij.openapi.editor.markup.GutterIconRenderer.Alignment.LEFT;\n\npublic class SideEffectLineMarkerProvider implements LineMarkerProvider {\n    private static final Icon ICON = IconLoader.getIcon(\"/icons/dragon.png\");\n\n    /**\n     * @return a {@link com.intellij.codeInsight.daemon.GutterIconNavigationHandler} if the element\n     * is a PsiMethod annotated with @SideEffect.\n     */\n    @Nullable\n    @Override\n    public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) {\n        // Check if expression\n        if (element instanceof PsiReferenceExpression) {\n            PsiReferenceExpression referenceExpression = (PsiReferenceExpression) element;\n\n            // Check if expression has method\n            if (referenceExpression.resolve() instanceof PsiMethod) {\n                PsiMethod method = (PsiMethod) referenceExpression.resolve();\n\n                // Does it have a @SideEffect?\n                if (hasAnnotation(method, CLASS_SIDE_EFFECT)) {\n                    return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), ICON,\n                            UPDATE_ALL, null, null, LEFT);\n                }\n            }\n        }\n\n        return null;\n    }\n\n    @Override\n    public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements,\n                                       @NotNull Collection<LineMarkerInfo> lineMarkerInfos) {\n\n    }\n}"
  },
  {
    "path": "License.txt",
    "content": "Copyright (c) 2017 Anup Cowkur\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\nrights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the\nSoftware.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\nWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Deprecated\nThis project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to suit your needs.\n\n# Here Be Dragons\nHere be dragons is an Intellij/Android Studio plugin that let's you annotate your impure Java methods with the `@SideEffect` annotation and shows a little dragon icon in the gutter when you call them.\n\n![How the plugin works](here-be-dragons.gif)\n\n# Why would I want to do this?\nWhen writing functional style code, isolating impure and pure functions becomes very important. This helps you visually identify which methods are impure when a bunch of methods are being called in a code block.\n\nFor a beginner friendly introduction to functional programming in Android, please checkout out my [blog series](https://medium.freecodecamp.com/functional-programming-for-android-developers-part-1-a58d40d6e742#.z2eewm52o).\n\n# Installation\n## Install the plugin\n[Download](https://github.com/anupcowkur/here-be-dragons/releases/download/v1.0.1/here-be-dragons-1.0.1.jar) the plugin jar and select \"Install Plugin From Disk\" in IntelliJ's plugin preferences.\n\n## Add the annotation library\nAdd the jcenter repository to your gradle build file if it's not already present:\n\n```groovy\nrepositories {\n    jcenter()\n}\n```\n\nNext, add the lib containing the `@SideEffect` annotation as a dependency:\n\n```groovy\ndependencies {\n    compile 'com.anupcowkur:here-be-dragons-annotation:1.0.1'\n}\n```\n\n# Usage\nSimpy add the `@SideEffect` annotation to any method you want like this:\n\n```java\nimport com.anupcowkur.herebedragons.SideEffect;\n\npublic class Test {\n    @SideEffect\n    public void foo() {\n        // do some impure things\n    }\n}\n```\n\nAnd when you call the method anywhere, you'll see the dragon icon show up in the IDE gutter.\n\n# License\nThis project is licensed under the [MIT License](https://github.com/anupcowkur/here-be-dragons/blob/master/License.txt)\n\n"
  }
]