[
  {
    "path": ".gitignore",
    "content": ".idea/\n*.iml\nout/\ngen/\nbuild/\nbuild.properties\njunit*.properties\n.gradle\n"
  },
  {
    "path": ".travis.yml",
    "content": "# Configuration for CI build at https://travis-ci.org/hsz/idea-latex\n\nlanguage: java\n\njdk:\n  - oraclejdk8\n\nenv:\n  - IDEA_VERSION=2017.2\n  - IDEA_VERSION=2017.1.5\n  - IDEA_VERSION=2016.3.7\n  - IDEA_VERSION=2016.2.5\n  - IDEA_VERSION=2016.1.4\n\n# Workaround for https://github.com/travis-ci/travis-ci/issues/5227\n# Buffer overflow in Java_java_net_Inet4AddressImpl_getLocalHostName\nbefore_install:\n  - cat /etc/hosts # optionally check the content *before*\n  - sudo hostname \"$(hostname | cut -c1-63)\"\n  - sed -e \"s/^\\\\(127\\\\.0\\\\.0\\\\.1.*\\\\)/\\\\1 $(hostname | cut -c1-63)/\" /etc/hosts | sudo tee /etc/hosts\n  - cat /etc/hosts # optionally check the content *after*\n\nbefore_cache:\n  - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock\ncache:\n  directories:\n    - $HOME/.gradle/caches/\n    - $HOME/.gradle/wrapper/\n\nafter_success:\n  - ./gradlew jacocoTestReport coveralls\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Change Log\n\n## [v0.2](https://github.com/hsz/idea-latex/tree/v0.2) (2015-01-27)\n\n[Full Changelog](https://github.com/hsz/idea-latex/compare/v0.1.1...v0.2)\n\n**Implemented enhancements:**\n\n- Toolbar actions: bold, italic, underline, align left, align center, align right\n- Color settings page\n- Sections folding\n\n## [v0.1.1](https://github.com/hsz/idea-latex/tree/v0.1.1) (2015-01-20)\n\n[Full Changelog](https://github.com/hsz/idea-latex/compare/v0.1...v0.1.1)\n\n**Fixed bugs:**\n\n- Fixed syntax highlighting (better BNF and Flex rules)\n\n**Closed issues:**\n\n- Installable release version? [\\#1](https://github.com/hsz/idea-latex/issues/1)\n\n## [v0.1](https://github.com/hsz/idea-latex/tree/v0.1) (2015-01-16)\n\n- Basic syntax highlighting\n\n\n\\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*\n\n\nLicense\n-------\n\nCopyright (c) 2017 hsz Jakub Chrzanowski. See the [LICENSE](./LICENSE) file for license rights and limitations (MIT).\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n"
  },
  {
    "path": "README.md",
    "content": "idea-latex v0.3.0\n=================\n\n[![Gitter][badge-gitter-img]][badge-gitter] [![Build Status][badge-travis-img]][badge-travis] [![Donate][badge-paypal-img]][badge-paypal]\n\n[![Version](http://phpstorm.espend.de/badge/7660/version)][plugin-website]\n[![Downloads](http://phpstorm.espend.de/badge/7660/downloads)][plugin-website]\n[![Downloads last month](http://phpstorm.espend.de/badge/7660/last-month)][plugin-website]\n\nIntroduction\n------------\n\n**LaTeX** is a plugin supporting LaTeX in your project. It supports following JetBrains IDEs:\n\n- Android Studio\n- AppCode\n- IntelliJ IDEA\n- PhpStorm\n- PyCharm\n- RubyMine\n- WebStorm\n- 0xDBE\n\n*Compiled with Java 1.6*\n\n\nFeatures\n--------\n\n- Syntax highlighting\n- Editor toolbar actions with shortcuts\n- Code folding\n\n*Feature requests:*\n\n- *suggesting functions' names*\n- *obtaining installed packages*\n- *generating PDF files*\n- *preview generated PDF files*\n- *and more...*\n\n\nInstallation\n------------\n\n- Using IDE built-in plugin system:\n  - <kbd>Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Browse repositories...</kbd> > <kbd>Search for \"LaTeX\"</kbd> > <kbd>Install Plugin</kbd>\n- Manually:\n  - Download the [latest release][latest-release] and install it manually using <kbd>Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Install plugin from disk...</kbd>\n  \nRestart IDE.\n\n\nUsage\n-----\n\n### Available shortcuts:\n\n| Action name      | Output                                                                   | Shortcut                                         |\n| ---------------- | ------------------------------------------------------------------------ | ------------------------------------------------ |\n| *Bold*           | <pre lang=\"latex\">\\textbf($SELECTION$)</pre>                             | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**B**</kbd> |\n| *Italic*         | <pre lang=\"latex\">\\textit($SELECTION$)</pre>                             | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**I**</kbd> |\n| *Underline*      | <pre lang=\"latex\">\\underline($SELECTION$)</pre>                          | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**U**</kbd> |\n| *Align left*     | <pre lang=\"latex\">\\begin{flushleft}$SELECTION$\\end{flushleft}</pre>      | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**L**</kbd> |\n| *Align center*   | <pre lang=\"latex\">\\begin{center}$SELECTION$\\end{center}</pre>            | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**C**</kbd> |\n| *Align right*    | <pre lang=\"latex\">\\begin{flushright}$SELECTION$\\end{flushright}</pre>    | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**R**</kbd> |\n\n\nChangelog\n---------\n\nVersion 0.2\n\n- Toolbar actions: bold, italic, underline, align left, align center, align right\n- Color settings page\n- Sections folding\n\nVersion 0.1.1\n\n- Fixed syntax highlighting (better BNF and Flex rules)\n\nVersion 0.1\n\n- Basic syntax highlighting\n\n\nDeveloped By\n------------\n\n[**@hsz** Jakub Chrzanowski][hsz]\n\n\n**Contributors**\n\n- *you can be first on this list*\n\n\nLicense\n-------\n\nCopyright (c) 2017 hsz Jakub Chrzanowski. See the [LICENSE](./LICENSE) file for license rights and limitations (MIT).\n\n    \n[hsz]:                    http://hsz.mobi\n[plugin-website]:         https://plugins.jetbrains.com/plugin/7660\n[latest-release]:         https://github.com/hsz/idea-latex/releases/latest\n\n[badge-gitter-img]:       https://badges.gitter.im/hsz/idea-latex.svg\n[badge-gitter]:           https://gitter.im/hsz/idea-latex\n[badge-travis-img]:       https://travis-ci.org/hsz/idea-latex.svg\n[badge-travis]:           https://travis-ci.org/hsz/idea-latex\n[badge-paypal-img]:       https://img.shields.io/badge/donate-paypal-yellow.svg\n[badge-paypal]:           https://www.paypal.me/hsz\n"
  },
  {
    "path": "build.gradle",
    "content": "plugins {\n    id 'org.jetbrains.intellij' version '0.0.43'\n    id 'de.undercouch.download' version '2.1.0'\n}\n\napply plugin: 'org.jetbrains.intellij'\napply plugin: 'java'\napply plugin: 'idea'\n\nsourceCompatibility = javaVersion\ntargetCompatibility = javaTargetVersion\n\ngroup pluginGroup\nversion = pluginVersion\n\ntasks.withType(JavaCompile) { options.encoding = 'UTF-8' }\n\nsourceSets {\n    main {\n        java.srcDirs 'src', 'gen'\n        resources.srcDir 'resources'\n    }\n}\n\nintellij {\n    version ideaVersion\n    type ideaType\n    pluginName pluginName\n    downloadSources Boolean.valueOf(sources)\n    sameSinceUntilBuild Boolean.valueOf(isEAP)\n    alternativeIdePath idePath\n    updateSinceUntilBuild false\n\n    publish {\n        username publishUsername\n        password publishPassword\n        pluginId publishPluginId\n        channel publishChannel\n    }\n}\n\nidea {\n    project {\n        jdkName         = javaVersion\n        languageLevel   = javaVersion\n    }\n\n    module {\n        generatedSourceDirs += file('gen')\n    }\n}\n\n\n// Configurations\n\nconfigurations {\n    bnf\n    jflex\n}\n\nrepositories {\n    mavenCentral()\n}\n\ntest {\n    testLogging {\n        exceptionFormat = 'full'\n    }\n}\n\ndependencies {\n    bnf files(\"$buildDir/tools/GrammarKit/lib/grammar-kit.jar\")\n    bnf files(\"$buildDir/tools/light-psi-all.jar\")\n    jflex files(\"$buildDir/tools/JFlex.jar\")\n\n    testCompile group: 'junit', name: 'junit', version: '4.11'\n}\n\n\nimport de.undercouch.gradle.tasks.download.Download\n\n// Tasks\n\ntask downloadJFlexJar(type: Download) {\n    description 'Downloads JFlex.'\n\n    src 'https://github.com/JetBrains/intellij-community/raw/master/tools/lexer/jflex-1.7.0-SNAPSHOT.jar'\n    dest \"$buildDir/tools/JFlex.jar\"\n    onlyIf { !file(\"$buildDir/tools/JFlex.jar\").exists() }\n}\n\ntask downloadJFlexSkeleton(type: Download) {\n    description 'Downloads JFlex skeleton.'\n\n    src 'https://raw.github.com/JetBrains/intellij-community/master/tools/lexer/idea-flex.skeleton'\n    dest \"$buildDir/tools/idea-flex.skeleton\"\n    onlyIf { !file(\"$buildDir/tools/idea-flex.skeleton\").exists() }\n}\n\ntask generateLexer(type: JavaExec) {\n    description 'Generates lexer sources with JFlex.'\n    dependsOn downloadJFlexJar, downloadJFlexSkeleton\n\n    main = 'jflex.Main'\n    args = [\n            '-skel',\n            \"$buildDir/tools/idea-flex.skeleton\",\n            '-d',\n            'gen/mobi/hsz/idea/latex/lexer/',\n            'src/mobi/hsz/idea/latex/lexer/Latex.flex',\n    ]\n\n    classpath = configurations.jflex\n}\n\ntask downloadGrammarKit(type: Download) {\n    description 'Downloads GrammarKit.'\n\n    src 'https://github.com/JetBrains/Grammar-Kit/releases/download/1.2.0.1/GrammarKit.zip'\n    dest \"$buildDir/tools/GrammarKit.zip\"\n    onlyIfNewer true\n}\n\ntask downloadGrammarLightPsi(type: Download) {\n    description 'Downloads GrammarKit Light Psi.'\n\n    src 'https://github.com/JetBrains/Grammar-Kit/releases/download/1.2.0.1/light-psi-all.jar'\n    dest \"$buildDir/tools/light-psi-all.jar\"\n    onlyIfNewer true\n}\n\ntask unzipGrammarKit(type: Copy) {\n    description 'Extracts GrammarKit files.'\n    dependsOn downloadGrammarKit\n\n    from zipTree(\"$buildDir/tools/GrammarKit.zip\")\n    into \"${buildDir}/tools/\"\n    include \"GrammarKit/lib/*\"\n}\n\ntask generateParser(type: JavaExec) {\n    description 'Generates parser sources with GrammarKit.'\n    dependsOn unzipGrammarKit, downloadGrammarLightPsi\n\n    main = 'org.intellij.grammar.Main'\n    args = [ 'gen', 'resources/bnf/Latex.bnf' ]\n\n    classpath = configurations.bnf + configurations.compile\n}\n\n\ntask generateSources() {\n    dependsOn generateParser, generateLexer\n}\n\nclean.doFirst {\n    delete 'gen', 'out'\n}\n\ncompileJava.dependsOn generateSources\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Mon Apr 11 22:05:01 CEST 2016\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-2.9-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "# Available idea versions:\n# https://www.jetbrains.com/intellij-repository/releases\n# https://www.jetbrains.com/intellij-repository/snapshots\n\nideaVersion = 2017.1.5\nideaType = IC\njavaVersion = 1.6\njavaTargetVersion = 1.6\njavaArguments = -agentpath:/home/hsz/IDE/yjp-2017.02/bin/linux-x86-64/libyjpagent.so\nsources = true\nisEAP = false\nrunGenerators = true\n\npluginGroup = mobi.hsz.idea\npluginName = LaTeX\npluginVersion = 0.3.0\n\npublishPluginId = 7660\npublishUsername = hsz\npublishPassword =\npublishChannel =\n\norg.gradle.jvmargs=-XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=utf-8\nJDK6_HOME=/usr/lib/jvm/java-6-jdk/\n\nidePath =\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\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\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\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\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\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\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\" ] ; 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\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\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%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "resources/META-INF/plugin.xml",
    "content": "<idea-plugin version=\"2\">\n    <id>mobi.hsz.idea.latex</id>\n    <name>LaTeX</name>\n    <version>0.3.0</version>\n    <vendor email=\"jakub@hsz.mobi\" url=\"http://www.hsz.mobi\">hsz</vendor>\n\n    <description><![CDATA[\n      <h1>LaTeX plugin for IntelliJ IDEA</h1>\n      <br/>\n\n      <a href=\"https://github.com/hsz/idea-latex\">GitHub</a> |\n      <a href=\"https://github.com/hsz/idea-latex/issues\">Issues</a> | Donate (\n      <a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=V6QCW4DR2XWY4\">PayPal</a> or\n      <a href=\"https://blockchain.info/address/1BUbqKrUBmGGSnMybzGCsJyAWJbh4CcwE1\">BTC</a> )\n      <br/>\n      <br/>\n\n      <b>Features</b>\n      <ul>\n        <li>Syntax highlighting</li>\n        <li>Editor toolbar actions with shortcuts</li>\n        <li>Code folding</li>\n      </ul>\n\n      <b><i>Feature requests:</i></b>\n      <ul>\n        <li><i>suggesting functions' names</i></li>\n        <li><i>obtaining installed packages</i></li>\n        <li><i>generating PDF files</i></li>\n        <li><i>preview generated PDF files</i></li>\n        <li><i>and more...</i></li>\n      </ul>\n\n      <br/>\n      <br/>\n\n      <i>Compiled with Java 1.6</i>\n      <br/>\n      <br/>\n\n    ]]></description>\n\n    <change-notes><![CDATA[\n      Version 0.2\n      <ul>\n        <li>Toolbar actions: bold, italic, underline, align left, align center, align right</li>\n        <li>Color settings page</li>\n        <li>Sections folding</li>\n      </ul>\n\n      Version 0.1.1\n      <ul>\n        <li>Fixed syntax highlighting (better BNF and Flex rules)</li>\n      </ul>\n\n      Version 0.1\n      <ul>\n        <li>Basic syntax highlighting</li>\n      </ul>\n    ]]>\n    </change-notes>\n\n    <idea-version since-build=\"123.72\"/>\n    <depends>com.intellij.modules.lang</depends>\n    <resource-bundle>messages.LatexBundle</resource-bundle>\n\n    <extensions defaultExtensionNs=\"com.intellij\">\n\n        <additionalTextAttributes\n                file=\"colorSchemes/LatexDefault.xml\"\n                scheme=\"Default\"/>\n        <additionalTextAttributes\n                file=\"colorSchemes/LatexDarcula.xml\"\n                scheme=\"Darcula\"/>\n\n        <applicationService\n                serviceInterface=\"mobi.hsz.idea.latex.settings.LatexSettings\"\n                serviceImplementation=\"mobi.hsz.idea.latex.settings.LatexSettings\"/>\n\n        <codeStyleSettingsProvider\n                implementation=\"mobi.hsz.idea.latex.codeStyle.LatexCodeStyleSettingsProvider\"/>\n\n        <colorSettingsPage\n                implementation=\"mobi.hsz.idea.latex.highlighter.LatexColorSettingsPage\"/>\n\n        <fileTemplateGroup\n                implementation=\"mobi.hsz.idea.latex.actions.LatexTemplatesFactory\"/>\n        <fileTypeFactory\n                implementation=\"mobi.hsz.idea.latex.file.LatexFileTypeFactory\"/>\n\n        <lang.braceMatcher\n                implementationClass=\"mobi.hsz.idea.latex.lang.LatexBraceMatcher\"\n                language=\"LaTeX\"/>\n        <lang.commenter\n                implementationClass=\"mobi.hsz.idea.latex.lang.LatexCommenter\"\n                language=\"LaTeX\"/>\n        <lang.foldingBuilder\n                implementationClass=\"mobi.hsz.idea.latex.folding.LatexFoldingBuilder\"\n                language=\"LaTeX\"/>\n        <lang.parserDefinition\n                implementationClass=\"mobi.hsz.idea.latex.lang.LatexParserDefinition\"\n                language=\"LaTeX\"/>\n        <lang.syntaxHighlighterFactory\n                implementationClass=\"mobi.hsz.idea.latex.highlighter.LatexHighlighterFactory\"\n                key=\"LaTeX\"/>\n\n        <langCodeStyleSettingsProvider\n                implementation=\"mobi.hsz.idea.latex.codeStyle.LatexLanguageCodeStyleSettingsProvider\"/>\n\n        <psi.referenceContributor\n                implementation=\"mobi.hsz.idea.latex.reference.LatexReferenceContributor\"\n                language=\"LaTeX\"/>\n\n        <spellchecker.support\n                implementationClass=\"mobi.hsz.idea.latex.inspections.LatexSpellcheckingStrategy\"\n                language=\"LaTeX\"/>\n\n    </extensions>\n\n    <application-components>\n        <component>\n            <implementation-class>mobi.hsz.idea.latex.LatexApplicationComponent</implementation-class>\n        </component>\n    </application-components>\n\n    <project-components>\n        <component>\n            <implementation-class>mobi.hsz.idea.latex.editor.LatexEditorActionsLoaderComponent</implementation-class>\n            <skipForDefaultProject/>\n        </component>\n        <component>\n            <implementation-class>mobi.hsz.idea.latex.LatexUpdateComponent</implementation-class>\n        </component>\n    </project-components>\n\n    <actions>\n        <group id=\"latex.new\" text=\"LaTeX\">\n            <action id=\"latex.new.file\" class=\"mobi.hsz.idea.latex.actions.CreateLatexFileAction\"/>\n            <add-to-group group-id=\"NewGroup\" anchor=\"before\" relative-to-action=\"NewFromTemplate\"/>\n        </group>\n\n        <group id=\"latex.editor\" text=\"LaTeX\">\n            <action id=\"latex.editor.bold\" class=\"mobi.hsz.idea.latex.actions.editor.BoldAction\">\n                <keyboard-shortcut keymap=\"$default\" first-keystroke=\"ctrl L\" second-keystroke=\"B\"/>\n            </action>\n            <action id=\"latex.editor.italic\" class=\"mobi.hsz.idea.latex.actions.editor.ItalicAction\">\n                <keyboard-shortcut keymap=\"$default\" first-keystroke=\"ctrl L\" second-keystroke=\"I\"/>\n            </action>\n            <action id=\"latex.editor.underline\" class=\"mobi.hsz.idea.latex.actions.editor.UnderlineAction\">\n                <keyboard-shortcut keymap=\"$default\" first-keystroke=\"ctrl L\" second-keystroke=\"U\"/>\n            </action>\n            <action id=\"latex.editor.align_left\" class=\"mobi.hsz.idea.latex.actions.editor.AlignLeftAction\">\n                <keyboard-shortcut keymap=\"$default\" first-keystroke=\"ctrl L\" second-keystroke=\"L\"/>\n            </action>\n            <action id=\"latex.editor.align_center\" class=\"mobi.hsz.idea.latex.actions.editor.AlignCenterAction\">\n                <keyboard-shortcut keymap=\"$default\" first-keystroke=\"ctrl L\" second-keystroke=\"C\"/>\n            </action>\n            <action id=\"latex.editor.align_right\" class=\"mobi.hsz.idea.latex.actions.editor.AlignRightAction\">\n                <keyboard-shortcut keymap=\"$default\" first-keystroke=\"ctrl L\" second-keystroke=\"R\"/>\n            </action>\n            <action id=\"latex.editor.image\" class=\"mobi.hsz.idea.latex.actions.editor.ImageAction\"/>\n            <action id=\"latex.editor.matrix\" class=\"mobi.hsz.idea.latex.actions.editor.MatrixAction\"/>\n            <action id=\"latex.editor.table\" class=\"mobi.hsz.idea.latex.actions.editor.TableAction\"/>\n        </group>\n    </actions>\n</idea-plugin>\n"
  },
  {
    "path": "resources/bnf/Latex.bnf",
    "content": "{\n  parserClass               = \"mobi.hsz.idea.latex.parser.LatexParser\"\n  parserUtilClass           = \"mobi.hsz.idea.latex.parser.LatexParserUtil\"\n\n  extends                   = \"mobi.hsz.idea.latex.psi.LatexElementImpl\"\n\n  psiClassPrefix            = \"Latex\"\n  psiImplClassSuffix        = \"Impl\"\n  psiPackage                = \"mobi.hsz.idea.latex.psi\"\n  psiImplPackage            = \"mobi.hsz.idea.latex.psi.impl\"\n\n  elementTypeHolderClass    = \"mobi.hsz.idea.latex.psi.LatexTypes\"\n  elementTypeClass          = \"mobi.hsz.idea.latex.psi.LatexElementType\"\n  tokenTypeClass            = \"mobi.hsz.idea.latex.psi.LatexTokenType\"\n\n  tokens = [\n    LBRACE                  = \"{\"\n    RBRACE                  = \"}\"\n    LBRACKET                = \"[\"\n    RBRACKET                = \"]\"\n    LPAREN                  = \"(\"\n    RPAREN                  = \")\"\n    COMMA                   = \",\"\n    COLON                   = \":\"\n    ASTERISK                = \"*\"\n    LINE_BREAK              = '\\\\'\n\n    IDENTIFIER_BEGIN        = '\\begin'\n    IDENTIFIER_END          = '\\end'\n    IDENTIFIER              = \"regexp:\\\\\\p{Alpha}+\"\n\n    ARG                     = \"regexp:\\b([^\\[\\]\\{\\}\\(\\),\\\\])+\\b\"\n    COMMENT                 = \"regexp:%.*\"\n\n    SPECIAL                 = \"regexp:[\\S]|\\\\.\"\n    CRLF                    = \"regexp:[\\s\\r\\n]+\"\n  ]\n\n  extends(\"instruction.*\")  = instruction\n  name(\"instruction.*\")     = instruction\n  mixin(\"instruction.*\")    = \"mobi.hsz.idea.latex.psi.impl.LatexInstructionExtImpl\"\n  mixin(\"section\")          = \"mobi.hsz.idea.latex.psi.impl.LatexSectionExtImpl\"\n\n  mixin(\"argument\")         = \"mobi.hsz.idea.latex.psi.impl.LatexArgumentExtImpl\"\n  implements(\"argument\")    = \"mobi.hsz.idea.latex.psi.LatexArgumentElement\"\n}\n\n\nlatexFile                       ::= item_ *\nprivate item_                   ::= !<<eof>> expr * { pin = 1 }\nprivate expr                    ::= section\n                                  | instruction\n                                  | argument_group\n                                  | text\n                                  | SPECIAL\n                                  | CRLF\n                                  | LINE_BREAK\n\nsection                         ::= instruction_begin expr * instruction_end { pin = 1 }\n\ninstruction_begin               ::= IDENTIFIER_BEGIN argument_brace argument_brace * { pin = 1 }\ninstruction_end                 ::= IDENTIFIER_END   argument_brace { pin = 1 }\ninstruction                     ::= IDENTIFIER       ASTERISK ? argument_group * { pin = 1 }\n\ntext                            ::= ( ARG special_expr ? ) +\n\nprivate argument_group          ::= argument_bracket | argument_brace | argument_paren\nprivate argument_expr           ::= ( special_expr * ( ARG | section | instruction ) special_expr * ) * { pin(\".*\") = 2 }\nprivate special_expr            ::= SPECIAL | COLON | COMMA | LINE_BREAK | CRLF\n\nmeta argument_bracket           ::= LBRACKET argument ? RBRACKET { pin(\".*\") = 1 elementType = argument }\nmeta argument_brace             ::= LBRACE   argument ? RBRACE   { pin(\".*\") = 1 elementType = argument }\nmeta argument_paren             ::= LPAREN   argument ? RPAREN   { pin(\".*\") = 1 elementType = argument }\nmeta argument                   ::= <<sequence argument_expr special_expr>>\n\nprivate meta sequence           ::= <<p>> (<<q>> <<p>>) * { pin(\".*\") = 1 }\n"
  },
  {
    "path": "resources/codeStyle/preview/blank_lines_settings.tex.ft",
    "content": "blank_lines_settings file"
  },
  {
    "path": "resources/codeStyle/preview/indent_settings.tex.ft",
    "content": "indent_settings file"
  },
  {
    "path": "resources/codeStyle/preview/spacing_settings.tex.ft",
    "content": "spacing_settings file"
  },
  {
    "path": "resources/codeStyle/preview/wrapping_and_braces_settings.tex.ft",
    "content": "wrapping_and_braces_settings file"
  },
  {
    "path": "resources/colorSchemes/LatexDarcula.xml",
    "content": "<?xml version='1.0'?>\n<list>\n    <option name=\"LATEX.COMMENT\">\n        <value>\n            <option name=\"FOREGROUND\" value=\"808080\" />\n        </value>\n    </option>\n    <option name=\"LATEX.INSTRUCTION\">\n        <value>\n            <option name=\"FOREGROUND\" value=\"ED7600\" />\n        </value>\n    </option>\n    <option name=\"LATEX.ARGUMENT\">\n        <value>\n            <option name=\"FOREGROUND\" value=\"668AA1\" />\n        </value>\n    </option>\n    <option name=\"LATEX.BRACKET\">\n        <value>\n            <option name=\"FOREGROUND\" value=\"365A71\" />\n        </value>\n    </option>\n</list>"
  },
  {
    "path": "resources/colorSchemes/LatexDefault.xml",
    "content": "<?xml version='1.0'?>\n<list>\n    <option name=\"LATEX.COMMENT\">\n        <value>\n            <option name=\"FOREGROUND\" value=\"808080\" />\n        </value>\n    </option>\n    <option name=\"LATEX.INSTRUCTION\">\n        <value>\n            <option name=\"FOREGROUND\" value=\"8A4A0B\" />\n        </value>\n    </option>\n    <option name=\"LATEX.ARGUMENT\">\n        <value>\n            <option name=\"FOREGROUND\" value=\"4486B0\" />\n        </value>\n    </option>\n    <option name=\"LATEX.BRACKET\">\n        <value>\n            <option name=\"FOREGROUND\" value=\"145680\" />\n        </value>\n    </option>\n</list>"
  },
  {
    "path": "resources/fileTemplates/j2ee/article.tex.ft",
    "content": "\\documentclass[a4paper,11pt]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\title{}\n\\author{}\n\n\\begin{document}\n\n\\maketitle\n\\tableofcontents\n\n\\begin{abstract}\n\\end{abstract}\n\n\\section{}\n\n\\end{document}"
  },
  {
    "path": "resources/fileTemplates/j2ee/book.tex.ft",
    "content": "\\documentclass[a4paper,11pt]{book}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\title{}\n\\author{}\n\n\\begin{document}\n\n\\maketitle\n\\tableofcontents\n\n\\chapter{}\n\n\\end{document}"
  },
  {
    "path": "resources/fileTemplates/j2ee/empty.tex.ft",
    "content": ""
  },
  {
    "path": "resources/fileTemplates/j2ee/letter.tex.ft",
    "content": "\\documentclass[a4paper,11pt]{letter}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\address{Your name\\\\Your address\\\\Your phone number}\n\\signature{Your name}\n\n\\begin{document}\n\n\\begin{letter}{Destination\\\\Address of the destination\\\\Phone number of the destination}\n\n\\opening{Dear Sir,}\n\n% corps of the letter\n\n\\closing{Yours sincerely,}\n\n%\\cc{Other destination}\n%\\ps{PS: PostScriptum}\n%\\encl{Enclosures}\n\n\\end{letter}\n\\end{document}"
  },
  {
    "path": "resources/fileTemplates/j2ee/presentation.tex.ft",
    "content": "\\documentclass{beamer}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\title{}\n\\author{}\n\n\\begin{document}\n\n\\begin{frame}\n\\titlepage\n\\end{frame}\n\n\\end{document}"
  },
  {
    "path": "resources/fileTemplates/j2ee/report.tex.ft",
    "content": "\\documentclass[a4paper,11pt]{report}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\title{}\n\\author{}\n\n\\begin{document}\n\n\\maketitle\n\\tableofcontents\n\n\\begin{abstract}\n\\end{abstract}\n\n\\chapter{}\n\n\\end{document}"
  },
  {
    "path": "resources/messages/LatexBundle.properties",
    "content": "editor.align_left=Align left\neditor.align_right=Align right\neditor.align_center=Align center\neditor.bold=Bold\neditor.image=Insert image\neditor.image.dialog.browse=LaTeX - Browse Image\neditor.image.dialog.title=LaTeX - Insert Image\neditor.italic=Italic\neditor.matrix=Insert matrix\neditor.matrix.dialog.title=LaTeX - Insert Matrix\neditor.table=Insert table\neditor.table.dialog.title=LaTeX - Insert Table\neditor.underline=Underline\ncolorSettings.displayName=LaTeX\nhighlighter.instruction=Instruction\nhighlighter.argument=Argument\nhighlighter.bracket=Brackets\nhighlighter.comment=Comment\nfolding.placeholder=...\nform.rows=Rows\\:\nform.columns=Columns\\:\nform.alignment=Alignment\\:\nform.alignment.left=left\nform.alignment.center=center\nform.alignment.right=right\nform.border=Border\\:\nform.border.none=none\nform.border.table=table\nform.border.cell=cell\nform.bracket=Bracket\\:\nform.bracket.none=none\nform.bracket.parentheses=parentheses\nform.bracket.brackets=brackets\nform.bracket.braces=braces\nform.bracket.single_line=single line\nform.bracket.double_line=double line\naction.create.file=LaTeX file\naction.create.file.description=Creates new LaTeX file\naction.create.file.kind.empty=empty\naction.create.file.kind.article=article\naction.create.file.kind.report=report\naction.create.file.kind.book=book\naction.create.file.kind.letter=letter\naction.create.file.kind.presentation=presentation\nfile.template.group.title=LaTeX\nupdate.title=<b>LaTeX</b> plugin updated to v{0}\nnotification.update.content=<br/>\\\n  If you find my plugin helpful, <b><a href=\"https://www.paypal.me/hsz\">Donate with PayPal</a></b><br/><br/>\\\nFeatures:<br/>\\\n- ... (<a href=\"https://github.com/hsz/idea-latex/issues/0\">0</a>)<br/>\\\n<br/>\\\nFixes:<br/>\\\n- ... (<a href=\"https://github.com/hsz/idea-latex/issues/0\">0</a>)<br/>\\\n<br/>\\\nIf you find my plugin helpful, donate me using <br/><b><a href=\"https://www.paypal.me/hsz\">Donate with PayPal</a></b>\n"
  },
  {
    "path": "resources/sample.tex",
    "content": "\\documentclass[12pt]{article}\n\\usepackage{amsmath}\n\\title{\\LaTeX}\n\\date{}\n\\begin{document}\n  \\maketitle\n  \\LaTeX{} is a document preparation system for the \\TeX{}\n  typesetting program. It offers programmable desktop\n  publishing features and extensive facilities for\n  automating most aspects of typesetting and desktop\n  publishing, including numbering and cross-referencing,\n  tables and figures, page layout, bibliographies, and\n  much more. \\LaTeX{} was originally written in 1984 by\n  Leslie Lamport and has become the dominant method for\n  using \\TeX; few people write in plain \\TeX{} anymore.\n  The current version is \\LaTeXe.\n\n  % This is a comment, not shown in final output.\n  % The following shows typesetting power of LaTeX:\n  \\begin{align}\n    E_0 &= mc^2                              \\\\\n    E &= \\frac{mc^2}{\\sqrt{1-\\frac{v^2}{c^2}}}\n  \\end{align}\n\\end{document}"
  },
  {
    "path": "settings.gradle",
    "content": "rootProject.name = 'idea-latex'\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/LatexApplicationComponent.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex;\n\nimport com.intellij.openapi.application.ApplicationManager;\nimport com.intellij.openapi.components.ApplicationComponent;\nimport mobi.hsz.idea.latex.settings.LatexSettings;\nimport mobi.hsz.idea.latex.util.Utils;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3.0\n */\npublic class LatexApplicationComponent implements ApplicationComponent {\n    /** Plugin has been updated with the current run. */\n    private boolean updated;\n\n    /** Plugin update notification has been shown. */\n    private boolean updateNotificationShown;\n\n    /**\n     * Get Ignore Application Component\n     *\n     * @return Ignore Application Component\n     */\n    @NotNull\n    public static LatexApplicationComponent getInstance() {\n        return ApplicationManager.getApplication().getComponent(LatexApplicationComponent.class);\n    }\n\n    /** Component initialization method. */\n    @Override\n    public void initComponent() {\n        /* The settings storage object. */\n        LatexSettings settings = LatexSettings.getInstance();\n        updated = !Utils.getVersion().equals(settings.getVersion());\n        if (updated) {\n            settings.setVersion(Utils.getVersion());\n        }\n    }\n\n    /** Component dispose method. */\n    @Override\n    public void disposeComponent() {\n    }\n\n    /**\n     * Returns component's name.\n     *\n     * @return component's name\n     */\n    @NotNull\n    @Override\n    public String getComponentName() {\n        return \"LatexApplicationComponent\";\n    }\n\n    /**\n     * Checks if plugin was updated in the current run.\n     *\n     * @return plugin was updated\n     */\n    public boolean isUpdated() {\n        return updated;\n    }\n\n    /**\n     * Checks if update notification was shown.\n     *\n     * @return notification shown\n     */\n    public boolean isUpdateNotificationShown() {\n        return updateNotificationShown;\n    }\n\n    /**\n     * Sets update notification shown status.\n     *\n     * @param shown notification\n     */\n    public void setUpdateNotificationShown(boolean shown) {\n        this.updateNotificationShown = shown;\n    }\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/LatexBundle.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex;\n\nimport com.intellij.CommonBundle;\nimport org.jetbrains.annotations.NonNls;\nimport org.jetbrains.annotations.PropertyKey;\n\nimport java.util.ResourceBundle;\n\n/**\n * {@link java.util.ResourceBundle}/localization utils for the LaTeX plugin.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexBundle {\n\n    /** Gitignore plugin ID. */\n    @NonNls\n    public static final String PLUGIN_ID = \"mobi.hsz.idea.latex\";\n    \n    /** The {@link java.util.ResourceBundle} path. */\n    @NonNls\n    private static final String BUNDLE_NAME = \"messages.LatexBundle\";\n\n    /** The {@link java.util.ResourceBundle} instance. */\n    private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);\n\n    /** Plugin name. */\n    @NonNls\n    public static final String NAME = \"LaTeX\";\n\n    /** {@link LatexBundle} is a non-instantiable static class. */\n    private LatexBundle() {\n    }\n\n    /**\n     * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.\n     *\n     * @param key    the key of the resource\n     * @param params the optional parameters for the specific resource\n     * @return the {@link String} value or {@code null} if no resource found for the key\n     */\n    public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {\n        return CommonBundle.message(BUNDLE, key, params);\n    }\n\n    /**\n     * Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.\n     *\n     * @param key          the key of the resource\n     * @param defaultValue the default value that will be returned if there is nothing set\n     * @param params       the optional parameters for the specific resource\n     * @return the {@link String} value or {@code null} if no resource found for the key\n     */\n    public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {\n        return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/LatexUpdateComponent.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex;\n\nimport com.intellij.notification.*;\nimport com.intellij.openapi.components.AbstractProjectComponent;\nimport com.intellij.openapi.components.ProjectComponent;\nimport com.intellij.openapi.project.Project;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport mobi.hsz.idea.latex.util.Utils;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * {@link ProjectComponent} instance to display plugin's update information.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3.0\n */\npublic class LatexUpdateComponent extends AbstractProjectComponent {\n    /** {@link LatexApplicationComponent} instance. */\n    private LatexApplicationComponent application;\n\n    /** Constructor. */\n    protected LatexUpdateComponent(Project project) {\n        super(project);\n    }\n\n    /** Component initialization method. */\n    @Override\n    public void initComponent() {\n        application = LatexApplicationComponent.getInstance();\n    }\n\n    /** Component dispose method. */\n    @Override\n    public void disposeComponent() {\n    }\n\n    /**\n     * Returns component's name.\n     *\n     * @return component's name\n     */\n    @NotNull\n    @Override\n    public String getComponentName() {\n        return \"LatexUpdateComponent\";\n    }\n\n    /** Method called when project is opened. */\n    @Override\n    public void projectOpened() {\n        if (application.isUpdated() && !application.isUpdateNotificationShown()) {\n            application.setUpdateNotificationShown(true);\n            NotificationGroup group = new NotificationGroup(LatexLanguage.GROUP, NotificationDisplayType.TOOL_WINDOW, true);\n            Notification notification = group.createNotification(\n                    LatexBundle.message(\"update.title\", Utils.getVersion()),\n                    LatexBundle.message(\"update.content\"),\n                    NotificationType.INFORMATION,\n                    NotificationListener.URL_OPENING_LISTENER\n            );\n            Notifications.Bus.notify(notification, myProject);\n        }\n    }\n\n    /** Method called when project is closed. */\n    @Override\n    public void projectClosed() {\n    }\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions;\n\nimport com.intellij.ide.actions.CreateFileFromTemplateDialog;\nimport com.intellij.ide.actions.CreateFromTemplateAction;\nimport com.intellij.openapi.project.DumbAware;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.psi.PsiDirectory;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport mobi.hsz.idea.latex.psi.LatexFile;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n * New file action\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class CreateLatexFileAction extends CreateFromTemplateAction<LatexFile> implements DumbAware {\n\n    public CreateLatexFileAction() {\n        super(LatexBundle.message(\"action.create.file\"), LatexBundle.message(\"action.create.file.description\"), Icons.FILE);\n    }\n\n    @Override\n    protected String getDefaultTemplateProperty() {\n        return LatexTemplates.LATEX_EMPTY;\n    }\n\n    @Nullable\n    @Override\n    protected LatexFile createFile(String name, String templateName, PsiDirectory dir) {\n        String filename = name.endsWith(\".\" + LatexLanguage.EXTENSION) ? name : name + \".\" + LatexLanguage.EXTENSION;\n        return LatexTemplatesFactory.createFromTemplate(dir, name, filename, templateName, true);\n    }\n\n    @Override\n    protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {\n        builder\n                .setTitle(LatexBundle.message(\"action.create.file\"))\n                .addKind(LatexBundle.message(\"action.create.file.kind.empty\"), Icons.FILE, LatexTemplates.LATEX_EMPTY)\n                .addKind(LatexBundle.message(\"action.create.file.kind.article\"), Icons.FILE, LatexTemplates.LATEX_ARTICLE)\n                .addKind(LatexBundle.message(\"action.create.file.kind.report\"), Icons.FILE, LatexTemplates.LATEX_REPORT)\n                .addKind(LatexBundle.message(\"action.create.file.kind.book\"), Icons.FILE, LatexTemplates.LATEX_BOOK)\n                .addKind(LatexBundle.message(\"action.create.file.kind.letter\"), Icons.FILE, LatexTemplates.LATEX_LETTER)\n                .addKind(LatexBundle.message(\"action.create.file.kind.presentation\"), Icons.FILE, LatexTemplates.LATEX_PRESENTATION);\n    }\n\n    @Override\n    protected String getActionName(PsiDirectory directory, String newName, String templateName) {\n        return LatexBundle.message(\"action.create.file\");\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        return obj instanceof CreateLatexFileAction;\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/LatexTemplates.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions;\n\nimport org.jetbrains.annotations.NonNls;\n\n/**\n * LaTeX files templates.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexTemplates {\n\n    @NonNls public static final String LATEX_EMPTY = \"empty.tex\";\n    @NonNls public static final String LATEX_ARTICLE = \"article.tex\";\n    @NonNls public static final String LATEX_REPORT = \"report.tex\";\n    @NonNls public static final String LATEX_BOOK = \"book.tex\";\n    @NonNls public static final String LATEX_LETTER = \"letter.tex\";\n    @NonNls public static final String LATEX_PRESENTATION = \"presentation.tex\";\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/LatexTemplatesFactory.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions;\n\nimport com.intellij.codeInsight.actions.ReformatCodeProcessor;\nimport com.intellij.ide.fileTemplates.*;\nimport com.intellij.openapi.fileTypes.FileTypeManager;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.psi.PsiDirectory;\nimport com.intellij.psi.PsiFile;\nimport com.intellij.psi.PsiFileFactory;\nimport com.intellij.util.ArrayUtil;\nimport com.intellij.util.IncorrectOperationException;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.file.LatexFileType;\nimport mobi.hsz.idea.latex.psi.LatexFile;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NonNls;\nimport org.jetbrains.annotations.NotNull;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Properties;\n\n/**\n * LaTeX files templates factory.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexTemplatesFactory implements FileTemplateGroupDescriptorFactory {\n\n    @NonNls\n    public static final String[] TEMPLATES = {\n            LatexTemplates.LATEX_EMPTY, LatexTemplates.LATEX_ARTICLE, LatexTemplates.LATEX_REPORT,\n            LatexTemplates.LATEX_BOOK, LatexTemplates.LATEX_LETTER, LatexTemplates.LATEX_PRESENTATION,\n    };\n\n    private final ArrayList<String> myCustomTemplates = new ArrayList<String>();\n\n    private static class LatexTemplatesFactoryHolder {\n        private static final LatexTemplatesFactory myInstance = new LatexTemplatesFactory();\n    }\n\n    public static LatexTemplatesFactory getInstance() {\n        return LatexTemplatesFactoryHolder.myInstance;\n    }\n\n    public void registerCustromTemplates(String... templates) {\n        Collections.addAll(myCustomTemplates, templates);\n    }\n\n    @Override\n    public FileTemplateGroupDescriptor getFileTemplatesDescriptor() {\n        final FileTemplateGroupDescriptor group = new FileTemplateGroupDescriptor(LatexBundle.message(\"file.template.group.title\"), Icons.FILE);\n        final FileTypeManager fileTypeManager = FileTypeManager.getInstance();\n\n        for (String template : TEMPLATES) {\n            group.addTemplate(new FileTemplateDescriptor(template, fileTypeManager.getFileTypeByFileName(template).getIcon()));\n        }\n\n        // register custom templates\n        for (String template : getInstance().getCustomTemplates()) {\n            group.addTemplate(new FileTemplateDescriptor(template, fileTypeManager.getFileTypeByFileName(template).getIcon()));\n        }\n\n        return group;\n    }\n\n    public static LatexFile createFromTemplate(@NotNull final PsiDirectory directory, @NotNull final String name,\n                                               @NotNull String fileName, @NotNull String templateName, boolean allowReformatting,\n                                               @NonNls String... parameters) throws IncorrectOperationException {\n        final FileTemplate template = FileTemplateManager.getInstance(directory.getProject()).getInternalTemplate(templateName);\n\n        Project project = directory.getProject();\n\n        Properties properties = new Properties(FileTemplateManager.getInstance(project).getDefaultProperties());\n//        JavaTemplateUtil.setPackageNameAttribute(properties, directory);\n//        properties.setProperty(NAME_TEMPLATE_PROPERTY, name);\n//        properties.setProperty(LOW_CASE_NAME_TEMPLATE_PROPERTY, name.substring(0, 1).toLowerCase() + name.substring(1));\n        for (int i = 0; i < parameters.length; i += 2) {\n            properties.setProperty(parameters[i], parameters[i + 1]);\n        }\n\n        String text;\n        try {\n            text = template.getText(properties);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Unable to load template for \" + FileTemplateManager.getInstance(project).internalTemplateToSubject(templateName), e);\n        }\n\n        final PsiFileFactory factory = PsiFileFactory.getInstance(project);\n        PsiFile file = factory.createFileFromText(fileName, LatexFileType.INSTANCE, text);\n\n        file = (PsiFile) directory.add(file);\n        if (file != null && allowReformatting && template.isReformatCode()) {\n            new ReformatCodeProcessor(project, file, null, false).run();\n        }\n\n        return (LatexFile) file;\n    }\n\n    public String[] getCustomTemplates() {\n        return ArrayUtil.toStringArray(myCustomTemplates);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/AlignCenterAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor;\n\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Editor action - align center.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic class AlignCenterAction extends WrapEditorAction {\n\n    /** Builds a new instance of {@link AlignCenterAction}. */\n    public AlignCenterAction() {\n        super(Type.ALIGN_CENTER, LatexBundle.message(\"editor.align_center\"), Icons.Editor.ALIGN_CENTER);\n    }\n\n    @NotNull\n    @Override\n    public String getLeftText() {\n        return \"\\\\begin{center}\";\n    }\n\n    @NotNull\n    @Override\n    public String getRightText() {\n        return \"\\\\end{center}\";\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/AlignLeftAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor;\n\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Editor action - align left.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic class AlignLeftAction extends WrapEditorAction {\n\n    /** Builds a new instance of {@link AlignLeftAction}. */\n    public AlignLeftAction() {\n        super(Type.ALIGN_LEFT, LatexBundle.message(\"editor.align_left\"), Icons.Editor.ALIGN_LEFT);\n    }\n\n    @NotNull\n    @Override\n    public String getLeftText() {\n        return \"\\\\begin{flushleft}\";\n    }\n\n    @NotNull\n    @Override\n    public String getRightText() {\n        return \"\\\\end{flushleft}\";\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/AlignRightAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor;\n\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Editor action - align right.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic class AlignRightAction extends WrapEditorAction {\n\n    /** Builds a new instance of {@link AlignRightAction}. */\n    public AlignRightAction() {\n        super(Type.ALIGN_RIGHT, LatexBundle.message(\"editor.align_right\"), Icons.Editor.ALIGN_RIGHT);\n    }\n\n    @NotNull\n    @Override\n    public String getLeftText() {\n        return \"\\\\begin{flushright}\";\n    }\n\n    @NotNull\n    @Override\n    public String getRightText() {\n        return \"\\\\end{flushright}\";\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/BoldAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor;\n\nimport com.intellij.psi.PsiElement;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;\nimport mobi.hsz.idea.latex.psi.LatexInstruction;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Editor action - bold text.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic class BoldAction extends WrapEditorAction {\n\n    private static final String IDENTIFIER = \"\\\\textbf\";\n\n    /** Builds a new instance of {@link BoldAction}. */\n    public BoldAction() {\n        super(Type.BOLD, LatexBundle.message(\"editor.bold\"), Icons.Editor.BOLD);\n    }\n\n    @Override\n    public boolean isMatching(@NotNull PsiElement element) {\n        return element instanceof LatexInstruction && ((LatexInstruction) element).getIdentifier().getText().equals(IDENTIFIER);\n    }\n\n    @NotNull\n    @Override\n    public String getLeftText() {\n        return IDENTIFIER + \"{\";\n    }\n\n    @NotNull\n    @Override\n    public String getRightText() {\n        return \"}\";\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/ImageAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor;\n\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.text.StringUtil;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.actions.editor.base.DialogEditorAction;\nimport mobi.hsz.idea.latex.ui.ImageEditorActionDialog;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Editor action - insert image.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class ImageAction extends DialogEditorAction<ImageEditorActionDialog> {\n\n    /** Builds a new instance of {@link ImageAction}. */\n    public ImageAction() {\n        super(Type.IMAGE, LatexBundle.message(\"editor.image\"), Icons.Editor.IMAGE);\n    }\n\n    @NotNull\n    @Override\n    protected ImageEditorActionDialog getDialog(@NotNull Project project) {\n        return new ImageEditorActionDialog(project);\n    }\n\n    @NotNull\n    @Override\n    protected String getContent(@NotNull ImageEditorActionDialog dialog) {\n        StringBuilder sb = new StringBuilder();\n        String path = dialog.getPath();\n        String caption = dialog.getCaption();\n        String label = dialog.getLabel();\n\n        sb.append(\"\\\\begin{figure}\\n\");\n        sb.append(\"\\\\centering\\n\");\n        sb.append(\"\\\\includegraphics\");\n        sb.append(String.format(\"{%s}\\n\", path));\n\n        if (!StringUtil.isEmpty(caption)) {\n            sb.append(String.format(\"\\\\caption{%s}\\n\", caption));\n        }\n        if (!StringUtil.isEmpty(label)) {\n            sb.append(String.format(\"\\\\label{%s}\\n\", label));\n        }\n\n        sb.append(\"\\\\end{figure}\");\n\n        return sb.toString();\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/ItalicAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor;\n\nimport com.intellij.psi.PsiElement;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;\nimport mobi.hsz.idea.latex.psi.LatexInstruction;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Editor action - italicize text.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic class ItalicAction extends WrapEditorAction {\n\n    private static final String IDENTIFIER = \"\\\\textit\";\n\n    /** Builds a new instance of {@link ItalicAction}. */\n    public ItalicAction() {\n        super(Type.ITALIC, LatexBundle.message(\"editor.italic\"), Icons.Editor.ITALIC);\n    }\n\n    @Override\n    public boolean isMatching(@NotNull PsiElement element) {\n        return element instanceof LatexInstruction && ((LatexInstruction) element).getIdentifier().getText().equals(IDENTIFIER);\n    }\n\n    @NotNull\n    @Override\n    public String getLeftText() {\n        return IDENTIFIER + \"{\";\n    }\n\n    @NotNull\n    @Override\n    public String getRightText() {\n        return \"}\";\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/MatrixAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor;\n\nimport com.intellij.openapi.project.Project;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.actions.editor.base.DialogEditorAction;\nimport mobi.hsz.idea.latex.ui.MatrixEditorActionDialog;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Editor action - insert matrix.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class MatrixAction extends DialogEditorAction<MatrixEditorActionDialog> {\n\n    /** Builds a new instance of {@link MatrixAction}. */\n    public MatrixAction() {\n        super(Type.MATRIX, LatexBundle.message(\"editor.matrix\"), Icons.Editor.MATRIX);\n    }\n\n    @NotNull\n    @Override\n    protected MatrixEditorActionDialog getDialog(@NotNull Project project) {\n        return new MatrixEditorActionDialog(project);\n    }\n\n    @NotNull\n    @Override\n    protected String getContent(@NotNull MatrixEditorActionDialog dialog) {\n        StringBuilder sb = new StringBuilder();\n        int rows = dialog.getRows();\n        int columns = dialog.getColumns();\n        char bracket = dialog.getBracket().getValue();\n\n        sb.append(String.format(\"$\\\\begin{%cmatrix}\\n\", bracket));\n        for (int i = 1; i <= rows; i++) {\n            for (int j = 1; j <= columns; j++) {\n                sb.append(String.format(\"%d%d%s\", i, j, j == columns ? \"\\\\\\\\\\n\" : \" & \"));\n            }\n        }\n        sb.append(String.format(\"\\\\end{%cmatrix}\", bracket));\n\n        return sb.toString();\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/TableAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor;\n\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.text.StringUtil;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.actions.editor.base.DialogEditorAction;\nimport mobi.hsz.idea.latex.ui.TableEditorActionDialog;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Editor action - insert table.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class TableAction extends DialogEditorAction<TableEditorActionDialog> {\n\n    /**\n     * Builds a new instance of {@link TableAction}.\n     */\n    public TableAction() {\n        super(Type.TABLE, LatexBundle.message(\"editor.table\"), Icons.Editor.TABLE);\n    }\n\n    @NotNull\n    @Override\n    protected TableEditorActionDialog getDialog(@NotNull Project project) {\n        return new TableEditorActionDialog(project);\n    }\n\n    @NotNull\n    @Override\n    protected String getContent(@NotNull TableEditorActionDialog dialog) {\n        StringBuilder sb = new StringBuilder();\n        int rows = dialog.getRows();\n        int columns = dialog.getColumns();\n        String alignmentValue = StringUtil.repeatSymbol(dialog.getAlignment().getValue(), columns);\n        String tableBorder = dialog.getBorder().isNone() ? \"\" : \"|\";\n        String cellBorder = dialog.getBorder().isCell() ? \"\\\\hline\\n\" : \"\";\n\n        sb.append(String.format(\"\\\\begin{tabular}{%s%s%s}\\n\", tableBorder, alignmentValue, tableBorder));\n        sb.append(cellBorder);\n        for (int i = 1; i <= rows; i++) {\n            for (int j = 1; j <= columns; j++) {\n                sb.append(String.format(\"%d%d%s\", i, j, j == columns ? \"\\\\\\\\\\n\" : \" & \"));\n            }\n            sb.append(cellBorder);\n        }\n        sb.append(\"\\\\end{tabular}\");\n\n        return sb.toString();\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/UnderlineAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor;\n\nimport com.intellij.psi.PsiElement;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;\nimport mobi.hsz.idea.latex.psi.LatexInstruction;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Editor action - underline text.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic class UnderlineAction extends WrapEditorAction {\n\n    private static final String IDENTIFIER = \"\\\\underline\";\n\n    /** Builds a new instance of {@link UnderlineAction}. */\n    public UnderlineAction() {\n        super(Type.UNDERLINE, LatexBundle.message(\"editor.underline\"), Icons.Editor.UNDERLINE);\n    }\n\n    @Override\n    public boolean isMatching(@NotNull PsiElement element) {\n        return element instanceof LatexInstruction && ((LatexInstruction) element).getIdentifier().getText().equals(IDENTIFIER);\n    }\n\n    @NotNull\n    @Override\n    public String getLeftText() {\n        return IDENTIFIER + \"{\";\n    }\n\n    @NotNull\n    @Override\n    public String getRightText() {\n        return \"}\";\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/base/DialogEditorAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor.base;\n\nimport com.intellij.openapi.actionSystem.AnActionEvent;\nimport com.intellij.openapi.actionSystem.Toggleable;\nimport com.intellij.openapi.editor.CaretModel;\nimport com.intellij.openapi.editor.Document;\nimport com.intellij.openapi.fileEditor.TextEditor;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.ui.DialogWrapper;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport org.jetbrains.annotations.NotNull;\n\nimport javax.swing.*;\n\n/**\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic abstract class DialogEditorAction<T extends DialogWrapper> extends EditorAction implements Toggleable {\n\n    /** Builds a new instance of {@link DialogEditorAction}. */\n    public DialogEditorAction(@NotNull Type type, @NotNull String name, @NotNull Icon icon) {\n        super(type, name, icon);\n    }\n\n    @Override\n    protected void actionPerformed(@NotNull AnActionEvent event, @NotNull final Project project, @NotNull VirtualFile virtualFile, @NotNull final TextEditor editor) {\n        final T dialog = getDialog(project);\n        if (dialog.showAndGet()) {\n            runWriteAction(project, getDialogAction(dialog, editor));\n        }\n    }\n\n    @NotNull\n    protected abstract T getDialog(@NotNull Project project);\n\n    @NotNull\n    protected abstract String getContent(@NotNull T dialog);\n\n    @NotNull\n    protected Runnable getDialogAction(@NotNull final T dialog, @NotNull final TextEditor editor) {\n        return new Runnable() {\n            @Override\n            public void run() {\n                final Document document = editor.getEditor().getDocument();\n                final CaretModel caretModel = editor.getEditor().getCaretModel();\n                final String content = getContent(dialog);\n\n                int offset = caretModel.getOffset();\n\n                document.insertString(offset, content);\n                caretModel.moveToOffset(offset + content.length());\n            }\n        };\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/base/EditorAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor.base;\n\nimport com.intellij.openapi.actionSystem.AnAction;\nimport com.intellij.openapi.actionSystem.AnActionEvent;\nimport com.intellij.openapi.actionSystem.CommonDataKeys;\nimport com.intellij.openapi.actionSystem.PlatformDataKeys;\nimport com.intellij.openapi.application.ApplicationManager;\nimport com.intellij.openapi.command.CommandProcessor;\nimport com.intellij.openapi.fileEditor.FileEditor;\nimport com.intellij.openapi.fileEditor.FileEditorManager;\nimport com.intellij.openapi.fileEditor.TextEditor;\nimport com.intellij.openapi.project.DumbAware;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiFile;\nimport com.intellij.psi.PsiManager;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.psi.LatexFile;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport javax.swing.*;\n\n/**\n * Editor action - abstract wrap selection action.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic abstract class EditorAction extends AnAction implements DumbAware {\n\n    /**\n     * Available editor's types.\n     */\n    public enum Type {\n        BOLD, ITALIC, UNDERLINE,\n        ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT,\n        IMAGE, MATRIX, TABLE,\n    }\n\n    /**\n     * Editor action's type.\n     */\n    private final Type type;\n\n    /**\n     * Editor action's name.\n     */\n    private final String name;\n\n    /**\n     * Builds a new instance of {@link EditorAction}.\n     */\n    EditorAction(@NotNull Type type, @NotNull String name, @NotNull Icon icon) {\n        super(name, null, icon);\n        this.type = type;\n        this.name = name;\n    }\n\n    /**\n     * Action handler.\n     *\n     * @param event Carries information on the invocation place\n     */\n    @Override\n    final public void actionPerformed(AnActionEvent event) {\n        final VirtualFile virtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE);\n        final Project project = event.getData(CommonDataKeys.PROJECT);\n        final TextEditor editor = getEditor(event);\n\n        if (virtualFile == null || project == null || editor == null) {\n            return;\n        }\n\n        actionPerformed(event, project, virtualFile, editor);\n    }\n\n    /**\n     * Handles actionPerformed event of the editor action item.\n     *\n     * @param event       action event\n     * @param project     current project\n     * @param virtualFile current file\n     * @param editor      current editor\n     */\n    protected void actionPerformed(@NotNull AnActionEvent event, @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull TextEditor editor) {\n    }\n\n    @Override\n    final public void update(AnActionEvent event) {\n        final VirtualFile virtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE);\n        final Project project = event.getData(CommonDataKeys.PROJECT);\n        final TextEditor editor = getEditor(event);\n\n        if (virtualFile == null || project == null || editor == null) {\n            return;\n        }\n\n        update(event, project, virtualFile, editor);\n    }\n\n    /**\n     * Handles update event of the editor action item.\n     *\n     * @param event       action event\n     * @param project     current project\n     * @param virtualFile current file\n     * @param editor      current editor\n     */\n    protected void update(AnActionEvent event, @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull TextEditor editor) {\n    }\n\n    /**\n     * Returns current active {@link TextEditor} instance or null.\n     *\n     * @param project current project\n     * @return active {@link TextEditor}\n     */\n    @Nullable\n    private static TextEditor getActiveEditor(Project project) {\n        if (project != null) {\n            FileEditor[] fileEditors = FileEditorManager.getInstance(project).getSelectedEditors();\n            for (FileEditor fileEditor : fileEditors) {\n                if (fileEditor instanceof TextEditor) {\n                    return (TextEditor) fileEditor;\n                }\n            }\n        }\n        return null;\n    }\n\n    /**\n     * Returns {@link TextEditor} from witch action was called or null.\n     *\n     * @param e action event\n     * @return active {@link TextEditor}\n     */\n    @Nullable\n    private static TextEditor getEditor(AnActionEvent e) {\n        FileEditor fileEditor = e.getData(PlatformDataKeys.FILE_EDITOR);\n        if (fileEditor instanceof TextEditor) {\n            return (TextEditor) fileEditor;\n        } else {\n            return getActiveEditor(e.getProject());\n        }\n    }\n\n    /**\n     * Returns the currently selected {@link PsiElement}.\n     *\n     * @param virtualFile Current file.\n     * @param project     Current project.\n     * @param editor      Current editor.\n     * @return Currently selected {@link PsiElement}.\n     */\n    @Nullable\n    protected PsiElement getCurrentElement(@Nullable final VirtualFile virtualFile, @Nullable final Project project, @Nullable TextEditor editor) {\n        if (virtualFile == null || project == null || editor == null) {\n            return null;\n        }\n\n        PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);\n        if (file == null || !(file instanceof LatexFile)) {\n            return null;\n        }\n\n        int offset = editor.getEditor().getCaretModel().getOffset();\n        return file.findElementAt(offset);\n    }\n\n    /**\n     * Checks if element matches to the related one.\n     *\n     * @param element to check\n     * @return action's element type\n     */\n    public boolean isMatching(@NotNull PsiElement element) {\n        return false;\n    }\n\n    /**\n     * Checks if action related type matched to the given element in document.\n     *\n     * @param element to check\n     * @return element matches to the action related type\n     */\n    @Nullable\n    protected PsiElement getMatchedElement(@Nullable PsiElement element) {\n        while (element != null && !(element instanceof LatexFile)) {\n            if (isMatching(element)) {\n                return element;\n            }\n            element = element.getParent();\n        }\n        return null;\n    }\n\n    /**\n     * Runs write action.\n     *\n     * @param project current project\n     * @param action to run\n     */\n    final protected void runWriteAction(@NotNull final Project project, @NotNull final Runnable action) {\n        ApplicationManager.getApplication().runWriteAction(new Runnable() {\n            @Override\n            public void run() {\n                CommandProcessor.getInstance().executeCommand(project, action, getName(), LatexBundle.NAME);\n            }\n        });\n    }\n\n    /**\n     * Returns current editor action's type.\n     */\n    @NotNull\n    public Type getType() {\n        return type;\n    }\n\n    /**\n     * Returns current editor action's name.\n     */\n    @NotNull\n    public String getName() {\n        return name;\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/base/EditorActionsFactory.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor.base;\n\nimport mobi.hsz.idea.latex.actions.editor.*;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n * Factory for creating LaTeX editor's actions.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic final class EditorActionsFactory {\n\n    /**\n     * Creates proper {@link EditorAction} instance basing on given {@link EditorAction.Type}.\n     *\n     * @return LaTeX editor toolbar action.\n     */\n    @Nullable\n    public static EditorAction create(@NotNull EditorAction.Type type) {\n        switch (type) {\n            case BOLD:          return new BoldAction();\n            case ITALIC:        return new ItalicAction();\n            case UNDERLINE:     return new UnderlineAction();\n            case ALIGN_LEFT:    return new AlignLeftAction();\n            case ALIGN_CENTER:  return new AlignCenterAction();\n            case ALIGN_RIGHT:   return new AlignRightAction();\n            case IMAGE:         return new ImageAction();\n            case MATRIX:        return new MatrixAction();\n            case TABLE:         return new TableAction();\n        }\n        return null;\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/base/InsertEditorAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor.base;\n\nimport com.intellij.openapi.actionSystem.AnActionEvent;\nimport com.intellij.openapi.actionSystem.Toggleable;\nimport com.intellij.openapi.editor.CaretModel;\nimport com.intellij.openapi.editor.Document;\nimport com.intellij.openapi.fileEditor.TextEditor;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport org.jetbrains.annotations.NotNull;\n\nimport javax.swing.*;\n\n/**\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic abstract class InsertEditorAction extends EditorAction implements Toggleable {\n\n    /** Builds a new instance of {@link InsertEditorAction}. */\n    public InsertEditorAction(@NotNull Type type, @NotNull String name, @NotNull Icon icon) {\n        super(type, name, icon);\n    }\n\n    @Override\n    protected void actionPerformed(@NotNull AnActionEvent event, @NotNull final Project project, @NotNull VirtualFile virtualFile, @NotNull final TextEditor editor) {\n        runWriteAction(project, new Runnable() {\n            @Override\n            public void run() {\n                final Document document = editor.getEditor().getDocument();\n                final CaretModel caretModel = editor.getEditor().getCaretModel();\n                int offset = caretModel.getOffset();\n                String text = getText();\n\n                document.insertString(offset, text);\n                caretModel.moveToOffset(offset + text.length());\n            }\n        });\n    }\n\n    /**\n     * Returns text to insert.\n     *\n     * @return text to insert\n     */\n    @NotNull\n    protected abstract String getText();\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/actions/editor/base/WrapEditorAction.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.actions.editor.base;\n\nimport com.intellij.openapi.actionSystem.AnActionEvent;\nimport com.intellij.openapi.actionSystem.Toggleable;\nimport com.intellij.openapi.editor.CaretModel;\nimport com.intellij.openapi.editor.Document;\nimport com.intellij.openapi.editor.SelectionModel;\nimport com.intellij.openapi.fileEditor.TextEditor;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.text.StringUtil;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport com.intellij.psi.PsiElement;\nimport org.jetbrains.annotations.NotNull;\n\nimport javax.swing.*;\n\n/**\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic abstract class WrapEditorAction extends EditorAction implements Toggleable {\n\n    /**\n     * Builds a new instance of {@link WrapEditorAction}.\n     */\n    public WrapEditorAction(@NotNull Type type, @NotNull String name, @NotNull Icon icon) {\n        super(type, name, icon);\n    }\n\n    /**\n     * Writes content to the current document.\n     *\n     * @param event       action event\n     * @param project     current project\n     * @param virtualFile current file\n     * @param editor      current editor\n     */\n    @Override\n    protected void actionPerformed(@NotNull AnActionEvent event, @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull final TextEditor editor) {\n        PsiElement element = getCurrentElement(virtualFile, project, editor);\n        final PsiElement matched = getMatchedElement(element);\n        runWriteAction(project, new Runnable() {\n            @Override\n            public void run() {\n                if (matched == null) {\n                    wrap(editor);\n                } else {\n                    unwrap(editor, matched);\n                }\n            }\n        });\n    }\n\n    /**\n     * Updates the state of the action.\n     *\n     * @param event Carries information on the invocation place and data available\n     */\n    @Override\n    protected void update(AnActionEvent event, @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull TextEditor editor) {\n        PsiElement element = getCurrentElement(virtualFile, project, editor);\n        PsiElement matched = getMatchedElement(element);\n\n        event.getPresentation().putClientProperty(SELECTED_PROPERTY, matched != null);\n    }\n\n    /**\n     * Wraps selection.\n     *\n     * @param editor Current editor.\n     */\n    private void wrap(@NotNull TextEditor editor) {\n        final Document document = editor.getEditor().getDocument();\n        final SelectionModel selectionModel = editor.getEditor().getSelectionModel();\n        final CaretModel caretModel = editor.getEditor().getCaretModel();\n\n        final int start = selectionModel.getSelectionStart();\n        final int end = selectionModel.getSelectionEnd();\n        final String text = StringUtil.notNullize(selectionModel.getSelectedText());\n\n        String newText = getLeftText() + text + getRightText();\n        int newStart = start + getLeftText().length();\n        int newEnd = StringUtil.isEmpty(text) ? newStart : end + getLeftText().length();\n\n        document.replaceString(start, end, newText);\n        selectionModel.setSelection(newStart, newEnd);\n        caretModel.moveToOffset(newEnd);\n    }\n\n    /**\n     * Unwraps selection.\n     *\n     * @param editor  Current editor.\n     * @param matched Matched PSI element.\n     */\n    private void unwrap(@NotNull final TextEditor editor, @NotNull final PsiElement matched) {\n        final Document document = editor.getEditor().getDocument();\n        final SelectionModel selectionModel = editor.getEditor().getSelectionModel();\n        final CaretModel caretModel = editor.getEditor().getCaretModel();\n\n        final int start = matched.getTextRange().getStartOffset();\n        final int end = matched.getTextRange().getEndOffset();\n        final String text = StringUtil.notNullize(matched.getText());\n\n        String newText = StringUtil.trimEnd(StringUtil.trimStart(text, getLeftText()), getRightText());\n        int newStart = selectionModel.getSelectionStart() - getLeftText().length();\n        int newEnd = selectionModel.getSelectionEnd() - getLeftText().length();\n\n        document.replaceString(start, end, newText);\n\n        selectionModel.setSelection(newStart, newEnd);\n        caretModel.moveToOffset(newEnd);\n    }\n\n    /**\n     * Returns left part of the wrapping text.\n     *\n     * @return left part\n     */\n    @NotNull\n    public abstract String getLeftText();\n\n    /**\n     * Returns right part of the wrapping text.\n     *\n     * @return right part\n     */\n    @NotNull\n    public abstract String getRightText();\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleMainPanel.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.codeStyle;\n\nimport com.intellij.application.options.TabbedLanguageCodeStylePanel;\nimport com.intellij.psi.codeStyle.CodeStyleSettings;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\n\n/**\n * LaTeX {@link TabbedLanguageCodeStylePanel} implementation of the main panel.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexCodeStyleMainPanel extends TabbedLanguageCodeStylePanel {\n\n    protected LatexCodeStyleMainPanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) {\n        super(LatexLanguage.INSTANCE, currentSettings, settings);\n    }\n\n    @Override\n    protected void initTabs(CodeStyleSettings settings) {\n        super.initTabs(settings);\n//        addTab(new GrCodeStyleImportsPanelWrapper(settings));\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleSettings.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.codeStyle;\n\nimport com.intellij.psi.codeStyle.CodeStyleSettings;\nimport com.intellij.psi.codeStyle.CustomCodeStyleSettings;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * LaTeX {@link CustomCodeStyleSettings} implementation.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexCodeStyleSettings extends CustomCodeStyleSettings {\n\n    protected LatexCodeStyleSettings(@NotNull CodeStyleSettings container) {\n        super(\"LatexCodeStyleSettings\", container);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleSettingsProvider.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.codeStyle;\n\nimport com.intellij.application.options.CodeStyleAbstractConfigurable;\nimport com.intellij.application.options.CodeStyleAbstractPanel;\nimport com.intellij.openapi.options.Configurable;\nimport com.intellij.psi.codeStyle.CodeStyleSettings;\nimport com.intellij.psi.codeStyle.CodeStyleSettingsProvider;\nimport com.intellij.psi.codeStyle.CustomCodeStyleSettings;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n * LaTeX {@link CodeStyleSettingsProvider} implementation.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexCodeStyleSettingsProvider extends CodeStyleSettingsProvider {\n\n    @NotNull\n    @Override\n    public Configurable createSettingsPage(CodeStyleSettings settings, CodeStyleSettings originalSettings) {\n        return new CodeStyleAbstractConfigurable(settings, originalSettings, LatexLanguage.NAME) {\n            @Override\n            protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) {\n                return new LatexCodeStyleMainPanel(getCurrentSettings(), settings);\n            }\n\n            @Override\n            public String getHelpTopic() {\n                return \"reference.settingsdialog.codestyle.\" + LatexLanguage.NAME.toLowerCase();\n            }\n        };\n    }\n\n    @Nullable\n    @Override\n    public String getConfigurableDisplayName() {\n        return LatexLanguage.NAME;\n    }\n\n    @Nullable\n    @Override\n    public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {\n        return new LatexCodeStyleSettings(settings);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/codeStyle/LatexLanguageCodeStyleSettingsProvider.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.codeStyle;\n\nimport com.intellij.application.options.IndentOptionsEditor;\nimport com.intellij.application.options.SmartIndentOptionsEditor;\nimport com.intellij.lang.Language;\nimport com.intellij.psi.codeStyle.CommonCodeStyleSettings;\nimport com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport mobi.hsz.idea.latex.util.Resources;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * LaTeX {@link LanguageCodeStyleSettingsProvider} implementation.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {\n\n    @NotNull\n    @Override\n    public Language getLanguage() {\n        return LatexLanguage.INSTANCE;\n    }\n\n    @Override\n    public CommonCodeStyleSettings getDefaultCommonSettings() {\n        CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(LatexLanguage.INSTANCE);\n        defaultSettings.initIndentOptions();\n//        defaultSettings.SPACE_WITHIN_BRACES = true;\n//        defaultSettings.KEEP_SIMPLE_CLASSES_IN_ONE_LINE = true;\n//        defaultSettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;\n        return defaultSettings;\n    }\n\n    @Override\n    public String getCodeSample(@NotNull SettingsType settingsType) {\n        switch (settingsType) {\n            case INDENT_SETTINGS:\n            case SPACING_SETTINGS:\n            case WRAPPING_AND_BRACES_SETTINGS:\n            case BLANK_LINES_SETTINGS:\n                return Resources.getResourceContent(\"/codeStyle/preview/\" + settingsType.name().toLowerCase() + \".tex.ft\");\n            default: return \"foo\";\n        }\n    }\n\n    @Override\n    public IndentOptionsEditor getIndentOptionsEditor() {\n        return new SmartIndentOptionsEditor();\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/editor/LatexEditorActionsLoaderComponent.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.editor;\n\nimport com.intellij.openapi.Disposable;\nimport com.intellij.openapi.components.AbstractProjectComponent;\nimport com.intellij.openapi.fileEditor.*;\nimport com.intellij.openapi.fileTypes.FileType;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.Disposer;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport mobi.hsz.idea.latex.file.LatexFileType;\nimport org.jetbrains.annotations.NonNls;\nimport org.jetbrains.annotations.NotNull;\n\nimport javax.swing.*;\n\n/**\n * Component loader for editor actions toolbar.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexEditorActionsLoaderComponent extends AbstractProjectComponent {\n\n    /** Constructor. */\n    public LatexEditorActionsLoaderComponent(@NotNull final Project project) {\n        super(project);\n    }\n\n    /**\n     * Returns component name.\n     *\n     * @return component name\n     */\n    @Override\n    @NonNls\n    @NotNull\n    public String getComponentName() {\n        return \"LatexEditorActionsLoaderComponent\";\n    }\n\n    /** Initializes component. */\n    @Override\n    public void initComponent() {\n        myProject.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new LatexEditorManagerListener());\n    }\n\n    /** Listener for LaTeX editor manager. */\n    private static class LatexEditorManagerListener extends FileEditorManagerAdapter {\n        /**\n         * Handles file opening event and attaches LaTeX editor component.\n         *\n         * @param source editor manager\n         * @param file   current file\n         */\n        @Override\n        public void fileOpened(@NotNull final FileEditorManager source, @NotNull final VirtualFile file) {\n            FileType fileType = file.getFileType();\n            if (!(fileType instanceof LatexFileType)) {\n                return;\n            }\n\n            for (final FileEditor fileEditor : source.getEditors(file)) {\n                if (fileEditor instanceof TextEditor) {\n                    final LatexEditorActionsWrapper wrapper = new LatexEditorActionsWrapper(fileEditor);\n                    final JComponent c = wrapper.getComponent();\n                    source.addTopComponent(fileEditor, c);\n\n                    Disposer.register(fileEditor, wrapper);\n                    Disposer.register(fileEditor, new Disposable() {\n                        @Override\n                        public void dispose() {\n                            source.removeTopComponent(fileEditor, c);\n                        }\n                    });\n                }\n            }\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/editor/LatexEditorActionsWrapper.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.editor;\n\nimport com.intellij.openapi.Disposable;\nimport com.intellij.openapi.actionSystem.*;\nimport com.intellij.openapi.fileEditor.FileEditor;\nimport mobi.hsz.idea.latex.actions.editor.base.EditorActionsFactory;\nimport org.jetbrains.annotations.NotNull;\n\nimport javax.swing.*;\n\nimport static mobi.hsz.idea.latex.actions.editor.base.EditorAction.Type.*;\n\n/**\n * Wrapper that creates bottom editor component for displaying outer ignore rules.\n * \n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\nclass LatexEditorActionsWrapper implements Disposable {\n\n    private final ActionToolbar actionToolbar;\n\n    LatexEditorActionsWrapper(@NotNull FileEditor fileEditor) {\n        DefaultActionGroup actions = new DefaultActionGroup();\n\n        actions.addAll(\n                EditorActionsFactory.create(BOLD),\n                EditorActionsFactory.create(ITALIC),\n                EditorActionsFactory.create(UNDERLINE),\n                Separator.getInstance(),\n                EditorActionsFactory.create(ALIGN_LEFT),\n                EditorActionsFactory.create(ALIGN_CENTER),\n                EditorActionsFactory.create(ALIGN_RIGHT),\n                Separator.getInstance(),\n                EditorActionsFactory.create(IMAGE),\n                EditorActionsFactory.create(TABLE),\n                EditorActionsFactory.create(MATRIX)\n        );\n\n        actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.EDITOR_TAB, actions, true);\n        actionToolbar.setMinimumButtonSize(ActionToolbar.NAVBAR_MINIMUM_BUTTON_SIZE);\n        actionToolbar.setTargetComponent(fileEditor.getComponent());\n    }\n\n    /**\n     * Returns outer panel.\n     * \n     * @return outer panel\n     */\n    @NotNull\n    JComponent getComponent() {\n        return actionToolbar.getComponent();\n    }\n\n    @Override\n    public void dispose() {\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/file/LatexFileType.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.file;\n\nimport com.intellij.openapi.fileTypes.LanguageFileType;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport mobi.hsz.idea.latex.util.Icons;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport javax.swing.*;\n\n/**\n * Describes LaTeX file type.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexFileType extends LanguageFileType {\n\n    /** Contains {@link LatexFileType} singleton. */\n    public static final LatexFileType INSTANCE = new LatexFileType();\n\n    /** Private constructor to prevent direct object creation. */\n    private LatexFileType() {\n        super(LatexLanguage.INSTANCE);\n    }\n\n    /**\n     * Returns the name of the file type. The name must be unique among all file types registered in the system.\n     *\n     * @return The file type name.\n     */\n    @NotNull\n    @Override\n    public String getName() {\n        return LatexLanguage.NAME + \" file\";\n    }\n\n    /**\n     * Returns the user-readable description of the file type.\n     *\n     * @return The file type description.\n     */\n    @NotNull\n    @Override\n    public String getDescription() {\n        return LatexLanguage.NAME + \" file\";\n    }\n\n    /**\n     * Returns the default extension for files of the type.\n     *\n     * @return The extension, not including the leading '.'.\n     */\n    @NotNull\n    @Override\n    public String getDefaultExtension() {\n        return LatexLanguage.EXTENSION;\n    }\n\n    /**\n     * Returns the icon used for showing files of the type.\n     *\n     * @return The icon instance, or null if no icon should be shown.\n     */\n    @Nullable\n    @Override\n    public Icon getIcon() {\n        return Icons.FILE;\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/file/LatexFileTypeFactory.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.file;\n\nimport com.intellij.openapi.fileTypes.FileTypeConsumer;\nimport com.intellij.openapi.fileTypes.FileTypeFactory;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Class that assigns file types with languages.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexFileTypeFactory extends FileTypeFactory {\n\n    /**\n     * Assigns file types with languages.\n     *\n     * @param consumer file types consumer\n     */\n    @Override\n    public void createFileTypes(@NotNull FileTypeConsumer consumer) {\n        consumer.consume(LatexFileType.INSTANCE, LatexLanguage.EXTENSION);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/folding/LatexFoldingBuilder.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.folding;\n\nimport com.intellij.lang.ASTNode;\nimport com.intellij.lang.folding.FoldingBuilder;\nimport com.intellij.lang.folding.FoldingDescriptor;\nimport com.intellij.openapi.editor.Document;\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiElementVisitor;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.psi.*;\nimport mobi.hsz.idea.latex.psi.impl.LatexSectionExtImpl;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * LaTeX folding builder. Handles {@link LatexTypes#SECTION} folding.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic class LatexFoldingBuilder implements FoldingBuilder {\n\n    /** Descriptors collection. */\n    private final List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();\n\n    /** {@link LatexVisitor} instance to walk over all sections in the {@link PsiElement}. */\n    private final PsiElementVisitor visitor = new LatexVisitor() {\n        @Override\n        public void visitSection(@NotNull LatexSection section) {\n            LatexInstructionBegin begin = ((LatexSectionExtImpl) section).getBeginInstruction();\n            LatexInstructionEnd end = ((LatexSectionExtImpl) section).getEndInstruction();\n\n            if (begin == null || end == null) {\n                return;\n            }\n\n            int startOffset = begin.getTextOffset();\n            int endOffset = end.getTextOffset() + end.getTextLength();\n            if (endOffset - startOffset > 0) {\n                descriptors.add(new FoldingDescriptor(section, new TextRange(startOffset, endOffset)));\n            }\n\n            section.acceptChildren(visitor);\n        }\n    };\n\n    /**\n     * Builds the folding regions for the specified node in the AST tree and its children.\n     * Note that you can have several folding regions for one AST node, i.e. several {@link FoldingDescriptor} with similar AST node.\n     *\n     * @param node     the node for which folding is requested.\n     * @param document the document for which folding is built. Can be used to retrieve line\n     *                 numbers for folding regions.\n     * @return the array of folding descriptors.\n     */\n    @NotNull\n    public FoldingDescriptor[] buildFoldRegions(@NotNull final ASTNode node, @NotNull final Document document) {\n        descriptors.clear();\n        node.getPsi().acceptChildren(visitor);\n\n        return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);\n    }\n\n    /**\n     * Returns the text which is displayed in the editor for the folding region related to the\n     * specified node when the folding region is collapsed.\n     *\n     * @param node the node for which the placeholder text is requested.\n     * @return the placeholder text.\n     */\n    @Nullable\n    @Override\n    public String getPlaceholderText(@NotNull ASTNode node) {\n        return node.getFirstChildNode().getText() + LatexBundle.message(\"folding.placeholder\");\n    }\n\n    /**\n     * Returns the default collapsed state for the folding region related to the specified node.\n     *\n     * @param node the node for which the collapsed state is requested.\n     * @return true if the region is collapsed by default, false otherwise.\n     */\n    @Override\n    public boolean isCollapsedByDefault(@NotNull ASTNode node) {\n        return false;\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/highlighter/LatexColorSettingsPage.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.highlighter;\n\nimport com.intellij.openapi.editor.colors.TextAttributesKey;\nimport com.intellij.openapi.fileTypes.SyntaxHighlighter;\nimport com.intellij.openapi.options.colors.AttributesDescriptor;\nimport com.intellij.openapi.options.colors.ColorDescriptor;\nimport com.intellij.openapi.options.colors.ColorSettingsPage;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.util.Icons;\nimport mobi.hsz.idea.latex.util.Resources;\nimport org.jetbrains.annotations.NonNls;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport javax.swing.*;\nimport java.util.Map;\n\n/**\n * {@link ColorSettingsPage} that allows to modify color scheme.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic class LatexColorSettingsPage implements ColorSettingsPage {\n\n    /** The path to the sample LaTeX file. */\n    @NonNls\n    private static final String SAMPLE_LATEX_PATH = \"/sample.tex\";\n\n    /** Display name for Color Settings Page. */\n    @NonNls\n    private static final String DISPLAY_NAME = LatexBundle.message(\"colorSettings.displayName\");\n\n    /**\n     * The sample LaTeX document shown in the colors settings dialog.\n     *\n     * @see #loadSampleLatex()\n     */\n    private static final String SAMPLE_LATEX = loadSampleLatex();\n\n    /** Attributes descriptor list. */\n    private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[]{\n            new AttributesDescriptor(LatexBundle.message(\"highlighter.instruction\"), LatexHighlighterColors.INSTRUCTION),\n            new AttributesDescriptor(LatexBundle.message(\"highlighter.argument\"), LatexHighlighterColors.ARGUMENT),\n            new AttributesDescriptor(LatexBundle.message(\"highlighter.bracket\"), LatexHighlighterColors.BRACKET),\n            new AttributesDescriptor(LatexBundle.message(\"highlighter.comment\"), LatexHighlighterColors.COMMENT),\n    };\n\n    /**\n     * Returns the icon for the page, shown in the dialog tab.\n     *\n     * @return the icon for the page, or null if the page does not have a custom icon.\n     */\n    @Nullable\n    @Override\n    public Icon getIcon() {\n        return Icons.FILE;\n    }\n\n    /**\n     * Returns the syntax highlighter which is used to highlight the text shown in the preview\n     * pane of the page.\n     *\n     * @return the syntax highlighter instance.\n     */\n    @NotNull\n    @Override\n    public SyntaxHighlighter getHighlighter() {\n        return new LatexHighlighter(null, null);\n    }\n\n    /**\n     * Returns the text shown in the preview pane.\n     *\n     * @return demo text\n     */\n    @NotNull\n    @Override\n    public String getDemoText() {\n        return SAMPLE_LATEX;\n    }\n\n    /**\n     * Returns the mapping from special tag names surrounding the regions to be highlighted\n     * in the preview text.\n     *\n     * @return <code>null</code>\n     */\n    @Nullable\n    @Override\n    public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {\n        return null;\n    }\n\n    /**\n     * Returns the list of descriptors specifying the {@link TextAttributesKey} instances\n     * for which colors are specified in the page. For such attribute keys, the user can choose\n     * all highlighting attributes (font type, background color, foreground color, error stripe color and\n     * effects).\n     *\n     * @return the list of attribute descriptors.\n     */\n    @NotNull\n    @Override\n    public AttributesDescriptor[] getAttributeDescriptors() {\n        return DESCRIPTORS;\n    }\n\n    /**\n     * Returns the list of descriptors specifying the {@link com.intellij.openapi.editor.colors.ColorKey}\n     * instances for which colors are specified in the page. For such color keys, the user can\n     * choose only the background or foreground color.\n     *\n     * @return the list of color descriptors.\n     */\n    @NotNull\n    @Override\n    public ColorDescriptor[] getColorDescriptors() {\n        return ColorDescriptor.EMPTY_ARRAY;\n    }\n\n    /**\n     * Returns the title of the page, shown as text in the dialog tab.\n     *\n     * @return the title of the custom page.\n     */\n    @NotNull\n    @Override\n    public String getDisplayName() {\n        return DISPLAY_NAME;\n    }\n\n    /**\n     * Loads sample .gitignore file\n     *\n     * @return the text loaded from {@link #SAMPLE_LATEX_PATH}\n     * @see #getDemoText()\n     * @see #SAMPLE_LATEX_PATH\n     * @see #SAMPLE_LATEX\n     */\n    private static String loadSampleLatex() {\n        return Resources.getResourceContent(SAMPLE_LATEX_PATH);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/highlighter/LatexHighlighter.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.highlighter;\n\nimport com.intellij.lexer.Lexer;\nimport com.intellij.openapi.editor.colors.TextAttributesKey;\nimport com.intellij.openapi.fileTypes.SyntaxHighlighterBase;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport com.intellij.psi.tree.IElementType;\nimport com.intellij.util.containers.ContainerUtil;\nimport mobi.hsz.idea.latex.lang.LatexParserDefinition;\nimport mobi.hsz.idea.latex.lexer.LatexLexerAdapter;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.Map;\n\n/**\n * Syntax highlighter definition.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\nclass LatexHighlighter extends SyntaxHighlighterBase {\n\n    /** Attributes map. */\n    private static final Map<IElementType, TextAttributesKey> ATTRIBUTES = ContainerUtil.newHashMap();\n\n    /** Binds parser definitions with highlighter colors. */\n    static {\n        SyntaxHighlighterBase.fillMap(ATTRIBUTES, LatexParserDefinition.COMMENTS, LatexHighlighterColors.COMMENT);\n        SyntaxHighlighterBase.fillMap(ATTRIBUTES, LatexParserDefinition.INSTRUCTIONS, LatexHighlighterColors.INSTRUCTION);\n        SyntaxHighlighterBase.fillMap(ATTRIBUTES, LatexParserDefinition.BRACKETS, LatexHighlighterColors.BRACKET);\n        SyntaxHighlighterBase.fillMap(ATTRIBUTES, LatexParserDefinition.ARGUMENTS, LatexHighlighterColors.ARGUMENT);\n    }\n\n    /** Current project. */\n    private final Project project;\n\n    /** Current file. */\n    private final VirtualFile virtualFile;\n\n    /** Builds a new instance of {@link LatexHighlighter}. */\n    LatexHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile) {\n        this.project = project;\n        this.virtualFile = virtualFile;\n    }\n\n    /**\n     * Creates lexer adapter.\n     *\n     * @return lexer adapter\n     */\n    @NotNull\n    @Override\n    public Lexer getHighlightingLexer() {\n        return new LatexLexerAdapter(project, virtualFile);\n    }\n\n    /**\n     * Gets highlighter text {@link TextAttributesKey} list using {@link IElementType} token.\n     *\n     * @param tokenType element type\n     * @return attributes list\n     */\n    @NotNull\n    @Override\n    public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {\n        return pack(ATTRIBUTES.get(tokenType));\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/highlighter/LatexHighlighterColors.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.highlighter;\n\nimport com.intellij.openapi.editor.DefaultLanguageHighlighterColors;\nimport com.intellij.openapi.editor.colors.TextAttributesKey;\n\n/**\n * Contains highlighter attributes definitions.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\nclass LatexHighlighterColors {\n\n    /** Default style for regular comment started with # */\n    public static final TextAttributesKey COMMENT = TextAttributesKey.createTextAttributesKey(\"LATEX.COMMENT\", DefaultLanguageHighlighterColors.LINE_COMMENT);\n\n    /** Default style for Latex instruction started with \\ */\n    static final TextAttributesKey INSTRUCTION = TextAttributesKey.createTextAttributesKey(\"LATEX.INSTRUCTION\", DefaultLanguageHighlighterColors.FUNCTION_CALL);\n\n    /** Default style for bracket: [](){} */\n    static final TextAttributesKey BRACKET = TextAttributesKey.createTextAttributesKey(\"LATEX.BRACKET\", DefaultLanguageHighlighterColors.BRACKETS);\n\n    /** Default style for Latex instruction's argument */\n    static final TextAttributesKey ARGUMENT = TextAttributesKey.createTextAttributesKey(\"LATEX.ARGUMENT\", DefaultLanguageHighlighterColors.PARAMETER);\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/highlighter/LatexHighlighterFactory.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.highlighter;\n\nimport com.intellij.openapi.fileTypes.SyntaxHighlighter;\nimport com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n * {@link SyntaxHighlighterFactory} class definition.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexHighlighterFactory extends SyntaxHighlighterFactory {\n\n    /**\n     * Override this method to provide syntax highlighting (coloring) capabilities for your language implementation.\n     * By syntax highlighting we mean highlighting of keywords, comments, braces etc. where lexing the file content is enough\n     * to identify proper highlighting attributes.\n     * <p/>\n     * Default implementation doesn't highlight anything.\n     *\n     * @param project     might be necessary to gather various project settings from.\n     * @param virtualFile might be necessary to collect file specific settings\n     * @return <code>SyntaxHighlighter</code> interface implementation for this particular language.\n     */\n    @NotNull\n    @Override\n    public SyntaxHighlighter getSyntaxHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile) {\n        return new LatexHighlighter(project, virtualFile);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/inspections/LatexSpellcheckingStrategy.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.inspections;\n\nimport com.intellij.psi.PsiElement;\nimport com.intellij.spellchecker.tokenizer.SpellcheckingStrategy;\nimport com.intellij.spellchecker.tokenizer.Tokenizer;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport mobi.hsz.idea.latex.psi.LatexText;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * {@link SpellcheckingStrategy} implementation for LaTeX language.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexSpellcheckingStrategy extends SpellcheckingStrategy {\n\n    /**\n     * Checks if elements is supported.\n     *\n     * @param element to check\n     * @return element is {@link LatexLanguage} instance\n     */\n    @Override\n    public boolean isMyContext(@NotNull PsiElement element) {\n        return LatexLanguage.INSTANCE.is(element.getLanguage());\n    }\n\n    /**\n     * Provides {@link #TEXT_TOKENIZER} for {@link LatexText} elements.\n     *\n     * @param element to check\n     * @return {@link #TEXT_TOKENIZER} for {@link LatexText} or {@link #EMPTY_TOKENIZER}.\n     */\n    @NotNull\n    @Override\n    public Tokenizer getTokenizer(PsiElement element) {\n        if (element instanceof LatexText) {\n            return TEXT_TOKENIZER;\n        }\n        return EMPTY_TOKENIZER;\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/lang/LatexBraceMatcher.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.lang;\n\nimport com.intellij.lang.BracePair;\nimport com.intellij.lang.PairedBraceMatcher;\nimport com.intellij.psi.PsiFile;\nimport com.intellij.psi.tree.IElementType;\nimport mobi.hsz.idea.latex.psi.LatexTypes;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n * Definition of {@link PairedBraceMatcher} class.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexBraceMatcher implements PairedBraceMatcher {\n\n    /** Array of definitions for brace pairs. */\n    private static final BracePair[] PAIRS = new BracePair[]{\n            new BracePair(LatexTypes.LBRACE, LatexTypes.RBRACE, false),\n            new BracePair(LatexTypes.LBRACKET, LatexTypes.RBRACKET, false),\n            new BracePair(LatexTypes.LPAREN, LatexTypes.RPAREN, false)\n    };\n\n    /**\n     * Returns the array of definitions for brace pairs that need to be matched when\n     * editing code in the language.\n     *\n     * @return the array of brace pair definitions.\n     */\n    @Override\n    public BracePair[] getPairs() {\n        return PAIRS;\n    }\n\n    /**\n     * Returns true if paired rbrace should be inserted after lbrace of given type when lbrace is encountered before contextType token.\n     * It is safe to always return true, then paired brace will be inserted anyway.\n     *\n     * @param lbraceType  lbrace for which information is queried\n     * @param contextType token type that follows lbrace\n     * @return true / false as described\n     */\n    @Override\n    public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType contextType) {\n        return true;\n    }\n\n    /**\n     * Returns the start offset of the code construct which owns the opening structural brace at the specified offset. For example,\n     * if the opening brace belongs to an 'if' statement, returns the start offset of the 'if' statement.\n     *\n     * @param file               the file in which brace matching is performed.\n     * @param openingBraceOffset the offset of an opening structural brace.\n     * @return the offset of corresponding code construct, or the same offset if not defined.\n     */\n    @Override\n    public int getCodeConstructStart(PsiFile file, int openingBraceOffset) {\n        return openingBraceOffset;\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/lang/LatexCommenter.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.lang;\n\nimport com.intellij.lang.Commenter;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n * Defines the support for \"Comment with Line Comment\" and \"Comment with Block Comment\"\n * actions in a custom language.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexCommenter implements Commenter {\n\n    /**\n     * Returns the string which prefixes a line comment in the language, or null if the language\n     * does not support line comments.\n     *\n     * @return the line comment text, or null.\n     */\n    @Nullable\n    @Override\n    public String getLineCommentPrefix() {\n        return \"%\";\n    }\n\n    /**\n     * Returns the string which marks the beginning of a block comment in the language,\n     * or null if the language does not support block comments.\n     *\n     * @return the block comment start text, or null.\n     */\n    @Nullable\n    @Override\n    public String getBlockCommentPrefix() {\n        return null;\n    }\n\n    /**\n     * Returns the string which marks the end of a block comment in the language,\n     * or null if the language does not support block comments.\n     *\n     * @return the block comment end text, or null.\n     */\n    @Nullable\n    @Override\n    public String getBlockCommentSuffix() {\n        return null;\n    }\n\n    /**\n     * Returns the string which marks the commented beginning of a block comment in the language,\n     * or null if the language does not support block comments.\n     *\n     * @return the commented block comment start text, or null.\n     */\n    @Nullable\n    @Override\n    public String getCommentedBlockCommentPrefix() {\n        return null;\n    }\n\n    /**\n     * Returns the string which marks the commented end of a block comment in the language,\n     * or null if the language does not support block comments.\n     *\n     * @return the commented block comment end text, or null.\n     */\n    @Nullable\n    @Override\n    public String getCommentedBlockCommentSuffix() {\n        return null;\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/lang/LatexLanguage.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.lang;\n\nimport com.intellij.lang.Language;\nimport org.jetbrains.annotations.NonNls;\n\n/**\n * LaTeX {@link Language} definition.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexLanguage extends Language {\n\n    /** The {@link LatexLanguage} instance. */\n    public static final LatexLanguage INSTANCE = new LatexLanguage();\n\n    /** The LaTeX language name. */\n    @NonNls\n    public static final String NAME = \"LaTeX\";\n\n    /** The LaTeX file extension suffix. */\n    @NonNls\n    public static final String EXTENSION = \"tex\";\n\n    /** LaTeX languages group name. */\n    @NonNls\n    public static final String GROUP = \"LATEX_GROUP\";\n\n    /** {@link LatexLanguage} is a non-instantiable static class. */\n    private LatexLanguage() {\n        super(NAME);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/lang/LatexParserDefinition.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.lang;\n\nimport com.intellij.lang.ASTNode;\nimport com.intellij.lang.Language;\nimport com.intellij.lang.ParserDefinition;\nimport com.intellij.lang.PsiParser;\nimport com.intellij.lexer.Lexer;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.psi.FileViewProvider;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiFile;\nimport com.intellij.psi.TokenType;\nimport com.intellij.psi.tree.IFileElementType;\nimport com.intellij.psi.tree.TokenSet;\nimport mobi.hsz.idea.latex.lexer.LatexLexerAdapter;\nimport mobi.hsz.idea.latex.parser.LatexParser;\nimport mobi.hsz.idea.latex.psi.LatexFile;\nimport mobi.hsz.idea.latex.psi.LatexTypes;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Defines the implementation of a parser for a custom language.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexParserDefinition implements ParserDefinition {\n\n    /** Whitespaces. */\n    public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);\n\n    /** Regular comment started with # */\n    public static final TokenSet COMMENTS = TokenSet.create(LatexTypes.COMMENT);\n\n    /** Latex instruction started with \\ */\n    public static final TokenSet INSTRUCTIONS = TokenSet.create(LatexTypes.IDENTIFIER, LatexTypes.IDENTIFIER_BEGIN, LatexTypes.IDENTIFIER_END);\n\n    /** Latex instruction's argument */\n    public static final TokenSet ARGUMENTS = TokenSet.create(LatexTypes.ARG);\n\n    /** All brackets: braces, brackets, parenthesis */\n    public static final TokenSet BRACKETS = TokenSet.create(\n            LatexTypes.LBRACE, LatexTypes.RBRACE,\n            LatexTypes.LBRACKET, LatexTypes.RBRACKET,\n            LatexTypes.LPAREN, LatexTypes.RPAREN\n    );\n\n    /** Element type of the node describing a file in the specified language. */\n    public static final IFileElementType FILE = new IFileElementType(Language.findInstance(LatexLanguage.class));\n\n    /**\n     * Returns the lexer for lexing files in the specified project. This lexer does not need to support incremental relexing - it is always\n     * called for the entire file.\n     *\n     * @param project the project to which the lexer is connected.\n     * @return the lexer instance.\n     */\n    @NotNull\n    @Override\n    public Lexer createLexer(Project project) {\n        return new LatexLexerAdapter(project);\n    }\n\n    /**\n     * Returns the parser for parsing files in the specified project.\n     *\n     * @param project the project to which the parser is connected.\n     * @return the parser instance.\n     */\n    @Override\n    public PsiParser createParser(Project project) {\n        return new LatexParser();\n    }\n\n    /**\n     * Returns the element type of the node describing a file in the specified language.\n     *\n     * @return the file node element type.\n     */\n    @Override\n    public IFileElementType getFileNodeType() {\n        return FILE;\n    }\n\n    /**\n     * Returns the set of token types which are treated as whitespace by the PSI builder.\n     * Tokens of those types are automatically skipped by PsiBuilder. Whitespace elements\n     * on the bounds of nodes built by PsiBuilder are automatically excluded from the text\n     * range of the nodes.\n     * <p><strong>It is strongly advised you return TokenSet that only contains {@link com.intellij.psi.TokenType#WHITE_SPACE},\n     * which is suitable for all the languages unless you really need to use special whitespace token</strong>\n     *\n     * @return the set of whitespace token types.\n     */\n    @NotNull\n    @Override\n    public TokenSet getWhitespaceTokens() {\n        return WHITE_SPACES;\n    }\n\n    /**\n     * Returns the set of token types which are treated as comments by the PSI builder.\n     * Tokens of those types are automatically skipped by PsiBuilder. Also, To Do patterns\n     * are searched in the text of tokens of those types.\n     *\n     * @return the set of comment token types.\n     */\n    @NotNull\n    @Override\n    public TokenSet getCommentTokens() {\n        return COMMENTS;\n    }\n\n    /**\n     * Returns the set of token types which are treated as argument by the PSI builder.\n     *\n     * @return the set of argument token types.\n     */\n    @NotNull\n    public TokenSet getArgumentTokens() {\n        return ARGUMENTS;\n    }\n\n    /**\n     * Returns the set of token types which are treated as instructions by the PSI builder.\n     *\n     * @return the set of instruction token types.\n     */\n    @NotNull\n    public TokenSet getInstructionTokens() {\n        return INSTRUCTIONS;\n    }\n\n    /**\n     * Returns the set of token types which are treated as brackets by the PSI builder: [](){}\n     *\n     * @return the set of instruction token types.\n     */\n    @NotNull\n    public TokenSet getBracketTokens() {\n        return BRACKETS;\n    }\n\n    /**\n     * Returns the set of element types which are treated as string literals. \"Search in strings\"\n     * option in refactorings is applied to the contents of such tokens.\n     *\n     * @return the set of string literal element types.\n     */\n    @NotNull\n    @Override\n    public TokenSet getStringLiteralElements() {\n        return TokenSet.EMPTY;\n    }\n\n    /**\n     * Creates a PSI element for the specified AST node. The AST tree is a simple, semantic-free\n     * tree of AST nodes which is built during the PsiBuilder parsing pass. The PSI tree is built\n     * over the AST tree and includes elements of different types for different language constructs.\n     *\n     * @param node the node for which the PSI element should be returned.\n     * @return the PSI element matching the element type of the AST node.\n     */\n    @NotNull\n    @Override\n    public PsiElement createElement(ASTNode node) {\n        return LatexTypes.Factory.createElement(node);\n    }\n\n    /**\n     * Creates a PSI element for the specified virtual file.\n     *\n     * @param viewProvider virtual file.\n     * @return the PSI file element.\n     */\n    @Override\n    public PsiFile createFile(FileViewProvider viewProvider) {\n        return new LatexFile(viewProvider);\n    }\n\n    /**\n     * Checks if the specified two token types need to be separated by a space according to the language grammar.\n     * For example, in Java two keywords are always separated by a space; a keyword and an opening parenthesis may\n     * be separated or not separated. This is used for automatic whitespace insertion during AST modification operations.\n     *\n     * @param left  the first token to check.\n     * @param right the second token to check.\n     * @return the spacing requirements.\n     */\n    @Override\n    public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {\n        return SpaceRequirements.MAY;\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/lexer/Latex.flex",
    "content": "package mobi.hsz.idea.latex.lexer;\n\nimport java.io.File;\nimport java.util.List;\nimport com.intellij.lexer.*;\nimport com.intellij.psi.tree.IElementType;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport static mobi.hsz.idea.latex.psi.LatexTypes.*;\nimport static com.intellij.psi.TokenType.*;\n%%\n\n%{\n  public LatexLexer() {\n    this((java.io.Reader)null);\n  }\n%}\n\n%public\n%class LatexLexer\n%implements FlexLexer\n%function advance\n%type IElementType\n%unicode\n\nEOL                 = \"\\r\"|\"\\n\"|\"\\r\\n\"\nLINE_WS             = [\\ \\t\\f]\nWHITE_SPACE         = ({LINE_WS}|{EOL})+\n\nIDENTIFIER          = \\\\[:letter:]+\nCOMMENT             = %.*\nARG                 = [^\\(\\)\\{\\}\\[\\]\\\\,]\nTEXT                = [^\\(\\)\\{\\}\\[\\]\\\\\\%\\ \\t\\f\\r\\n]|\"\\\\\\%\"|(\"\\\\\"{SPECIAL})\nSPECIAL             = \"$\"|\"&\"|\"#\"|\"_\"|\"~\"|\"^\"|\"\\\\\"\n%state IN_ARGUMENT\n\n%%\n\n// brackets\n<YYINITIAL> \"(\"             { yybegin(IN_ARGUMENT); return LPAREN; }\n<YYINITIAL> \")\"             { return RPAREN; }\n<YYINITIAL> \"[\"             { yybegin(IN_ARGUMENT); return LBRACKET; }\n<YYINITIAL> \"]\"             { return RBRACKET; }\n<YYINITIAL> \"{\"             { yybegin(IN_ARGUMENT); return LBRACE; }\n<YYINITIAL> \"}\"             { return RBRACE; }\n\n<IN_ARGUMENT> {\n    {ARG}+                  { return ARG; }\n    \",\"                     { return COMMA; }\n    .                       { yypushback(1); yybegin(YYINITIAL); }\n}\n\n// special characters\n<YYINITIAL> \":\"             { return COLON; }\n<YYINITIAL> \"*\"             { return ASTERISK; }\n<YYINITIAL> \"\\\\\\\\\"          { return LINE_BREAK; }\n<YYINITIAL> {SPECIAL}       { return SPECIAL; }\n<YYINITIAL> \"\\\\\".           { return SPECIAL; }\n\n<YYINITIAL> {WHITE_SPACE}+  { return WHITE_SPACE; }\n<YYINITIAL> \"\\\\begin\"       { return IDENTIFIER_BEGIN; }\n<YYINITIAL> \"\\\\end\"         { return IDENTIFIER_END; }\n<YYINITIAL> {IDENTIFIER}    { return IDENTIFIER; }\n<YYINITIAL> {COMMENT}       { return COMMENT; }\n<YYINITIAL> {TEXT}+         { return ARG; }\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/lexer/LatexLexerAdapter.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.lexer;\n\nimport com.intellij.lexer.FlexAdapter;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n * Definition of {@link FlexAdapter}.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexLexerAdapter extends FlexAdapter {\n\n    /** Builds a new instance of {@link LatexLexerAdapter}. */\n    public LatexLexerAdapter(Project project) {\n        this(project, null);\n    }\n\n    /** Builds a new instance of {@link LatexLexerAdapter}. */\n    public LatexLexerAdapter(Project project, @Nullable VirtualFile virtualFile) {\n        super(new LatexLexer());\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/parser/LatexParserUtil.java",
    "content": "package mobi.hsz.idea.latex.parser;\n\nimport com.intellij.lang.parser.GeneratedParserUtilBase;\n\n/**\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexParserUtil extends GeneratedParserUtilBase {\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/psi/LatexArgumentElement.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.psi;\n\nimport com.intellij.psi.PsiElement;\nimport org.jetbrains.annotations.Nullable;\n\npublic interface LatexArgumentElement extends PsiElement {\n\n    @Nullable\n    String getValue();\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/psi/LatexElementImpl.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.psi;\n\nimport com.intellij.extapi.psi.ASTWrapperPsiElement;\nimport com.intellij.lang.ASTNode;\nimport com.intellij.psi.PsiReference;\nimport com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Definition of {@link ASTWrapperPsiElement}.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexElementImpl extends ASTWrapperPsiElement {\n\n    public LatexElementImpl(ASTNode node) {\n        super(node);\n    }\n\n    /**\n     * Gets {@link PsiReference} list for given element.\n     *\n     * @return {@link PsiReference} list\n     */\n    @NotNull\n    @Override\n    public PsiReference[] getReferences() {\n        return ReferenceProvidersRegistry.getReferencesFromProviders(this);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/psi/LatexElementType.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.psi;\n\nimport com.intellij.psi.tree.IElementType;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport org.jetbrains.annotations.NonNls;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Latex element type.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexElementType extends IElementType {\n\n    /** Build a new instance of @{link IgnoreElementType} */\n    public LatexElementType(@NotNull @NonNls String debugName) {\n        super(debugName, LatexLanguage.INSTANCE);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/psi/LatexFile.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.psi;\n\nimport com.intellij.extapi.psi.PsiFileBase;\nimport com.intellij.openapi.fileTypes.FileType;\nimport com.intellij.psi.FileViewProvider;\nimport mobi.hsz.idea.latex.file.LatexFileType;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Base plugin file.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexFile extends PsiFileBase {\n\n    /** Current file type. */\n    private final LatexFileType fileType;\n\n    /** Builds a new instance of {@link LatexFile}. */\n    public LatexFile(@NotNull FileViewProvider viewProvider) {\n        super(viewProvider, LatexLanguage.INSTANCE);\n        fileType = LatexFileType.INSTANCE;\n    }\n\n    /**\n     * Returns the file type for the file.\n     *\n     * @return the file type instance.\n     */\n    @NotNull\n    @Override\n    public FileType getFileType() {\n        return fileType;\n    }\n\n    /**\n     * Returns @{link IgnoreFileType} string interpretation.\n     *\n     * @return string interpretation\n     */\n    @Override\n    public String toString() {\n        return fileType.getName();\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/psi/LatexTokenType.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.psi;\n\nimport com.intellij.psi.tree.IElementType;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport mobi.hsz.idea.latex.lang.LatexLanguage;\nimport org.jetbrains.annotations.NonNls;\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Token type definition.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class LatexTokenType extends IElementType {\n\n    /** Token debug name. */\n    private final String debugName;\n\n    /** Builds a new instance of @{link IgnoreTokenType}. */\n    LatexTokenType(@NotNull @NonNls String debugName) {\n        super(debugName, LatexLanguage.INSTANCE);\n        this.debugName = debugName;\n    }\n\n    /**\n     * String interpretation of the token type.\n     *\n     * @return string representation\n     */\n    @Override\n    public String toString() {\n        return LatexBundle.messageOrDefault(\"tokenType.\" + debugName, getLanguage().getDisplayName() + \"TokenType.\" + super.toString());\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/psi/impl/LatexArgumentExtImpl.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.psi.impl;\n\nimport com.intellij.lang.ASTNode;\nimport com.intellij.psi.PsiElement;\nimport mobi.hsz.idea.latex.psi.LatexArgument;\nimport mobi.hsz.idea.latex.psi.LatexArgumentElement;\nimport mobi.hsz.idea.latex.psi.LatexElementImpl;\n\n/**\n * Abstract LatexArgument implementation.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic abstract class LatexArgumentExtImpl extends LatexElementImpl implements LatexArgumentElement {\n\n    LatexArgumentExtImpl(ASTNode node) {\n        super(node);\n    }\n\n    /**\n     * Returns the Argument element value ignoring the parentheses.\n     *\n     * @return Argument value.\n     */\n    @Override\n    public String getValue() {\n        for (PsiElement child : getChildren()) {\n            if (child instanceof LatexArgument) {\n                return ((LatexArgument) child).getValue();\n            }\n        }\n        return getText();\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/psi/impl/LatexInstructionExtImpl.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.psi.impl;\n\nimport com.intellij.lang.ASTNode;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.tree.TokenSet;\nimport com.intellij.psi.util.PsiTreeUtil;\nimport mobi.hsz.idea.latex.psi.LatexArgument;\nimport mobi.hsz.idea.latex.psi.LatexElementImpl;\nimport mobi.hsz.idea.latex.psi.LatexInstruction;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.List;\n\nimport static mobi.hsz.idea.latex.psi.LatexTypes.IDENTIFIER;\nimport static mobi.hsz.idea.latex.psi.LatexTypes.IDENTIFIER_BEGIN;\nimport static mobi.hsz.idea.latex.psi.LatexTypes.IDENTIFIER_END;\n\n/**\n * Abstract {@link LatexInstruction} implementation to handle {@link #getIdentifier()} in instruction subtypes.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic abstract class LatexInstructionExtImpl extends LatexElementImpl implements LatexInstruction {\n\n    /** {@link TokenSet} containing all identifier types. */\n    private static final TokenSet IDENTIFIERS = TokenSet.create(IDENTIFIER, IDENTIFIER_BEGIN, IDENTIFIER_END);\n\n    /** Default constructor. */\n    LatexInstructionExtImpl(ASTNode node) {\n        super(node);\n    }\n\n    /** Returns list of identifiers and identifiers subtypes. */\n    @NotNull\n    public PsiElement getIdentifier() {\n        return findNotNullChildByType(IDENTIFIERS);\n    }\n\n    /**\n     * Returns the {@link LatexInstruction} arguments list.\n     *\n     * @return {@link LatexArgument} instances list.\n     */\n    @Override\n    @NotNull\n    public List<LatexArgument> getArgumentList() {\n        return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexArgument.class);\n    }\n\n    /**\n     * Returns the {@link LatexInstruction} argument.\n     *\n     * @return {@link LatexArgument} instance.\n     */\n    @Nullable\n    public LatexArgument getArgument() {\n        return findChildByClass(LatexArgument.class);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/psi/impl/LatexSectionExtImpl.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.psi.impl;\n\nimport com.intellij.lang.ASTNode;\nimport com.intellij.psi.util.PsiTreeUtil;\nimport mobi.hsz.idea.latex.psi.*;\nimport org.jetbrains.annotations.Nullable;\n\n/**\n * Abstract {@link LatexSection} implementation to provide shorthands for accessing {@link LatexInstructionBegin}\n * and {@link LatexInstructionEnd}.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic abstract class LatexSectionExtImpl extends LatexElementImpl implements LatexSection {\n\n    LatexSectionExtImpl(ASTNode node) {\n        super(node);\n    }\n\n    /**\n     * Returns {@link LatexInstructionBegin} instance from given {@link LatexTypes#SECTION} element.\n     *\n     * @return begin instruction\n     */\n    @Nullable\n    public LatexInstructionBegin getBeginInstruction() {\n        return PsiTreeUtil.getChildOfType(this, LatexInstructionBegin.class);\n    }\n\n    /**\n     * Returns {@link LatexInstructionEnd} instance from given {@link LatexTypes#SECTION} element.\n     *\n     * @return end instruction\n     */\n    @Nullable\n    public LatexInstructionEnd getEndInstruction() {\n        return PsiTreeUtil.getChildOfType(this, LatexInstructionEnd.class);\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/reference/LatexReferenceContributor.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.reference;\n\nimport com.intellij.psi.*;\nimport com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;\nimport com.intellij.util.ProcessingContext;\nimport mobi.hsz.idea.latex.psi.LatexArgument;\nimport mobi.hsz.idea.latex.psi.LatexFile;\nimport mobi.hsz.idea.latex.psi.LatexInstruction;\nimport mobi.hsz.idea.latex.psi.impl.LatexInstructionExtImpl;\nimport org.jetbrains.annotations.NotNull;\n\nimport java.util.Arrays;\n\nimport static com.intellij.patterns.PlatformPatterns.psiElement;\nimport static com.intellij.patterns.PlatformPatterns.psiFile;\n\n/**\n * PSI elements references contributor.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3\n */\npublic class LatexReferenceContributor extends PsiReferenceContributor {\n\n    /**\n     * Registers new references provider for PSI element.\n     *\n     * @param psiReferenceRegistrar reference provider\n     */\n    @Override\n    public void registerReferenceProviders(@NotNull PsiReferenceRegistrar psiReferenceRegistrar) {\n        psiReferenceRegistrar.registerReferenceProvider(psiElement().inFile(psiFile(LatexFile.class)), new LatexReferenceProvider());\n    }\n\n    /** Reference provider definition.  */\n    private static class LatexReferenceProvider extends PsiReferenceProvider {\n        private static final String[] IDENTIFIERS = {\"\\\\input\", \"\\\\include\", \"\\\\includeonly\"};\n\n        /**\n         * Returns references for given @{link PsiElement}.\n         *\n         * @param psiElement        current element\n         * @param processingContext context\n         * @return {@link PsiReference} list\n         */\n        @NotNull\n        @Override\n        public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {\n            if (psiElement instanceof LatexInstruction) {\n                LatexInstructionExtImpl instruction = (LatexInstructionExtImpl) psiElement;\n                String identifier = instruction.getIdentifier().getText();\n                if (Arrays.asList(IDENTIFIERS).contains(identifier)) {\n                    LatexArgument arg = instruction.getArgument();\n                    if (arg != null && arg.getValue() != null) {\n                        return new FileReferenceSet(arg.getValue(), instruction, arg.getStartOffsetInParent() + 1, this, true).getAllReferences();\n                    }\n                }\n            }\n            return PsiReference.EMPTY_ARRAY;\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/settings/LatexSettings.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.settings;\n\nimport com.intellij.openapi.components.PersistentStateComponent;\nimport com.intellij.openapi.components.ServiceManager;\nimport com.intellij.openapi.components.State;\nimport com.intellij.openapi.components.Storage;\nimport com.intellij.util.containers.ContainerUtil;\nimport mobi.hsz.idea.latex.util.Listenable;\nimport org.jdom.Element;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.List;\n\n/**\n * Persistent global settings object for the LaTeX plugin.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3.0\n */\n@State(\n        name = \"LatexSettings\",\n        storages = @Storage(id = \"other\", file = \"$APP_CONFIG$/latex.xml\")\n)\npublic class LatexSettings implements PersistentStateComponent<Element>, Listenable<LatexSettings.Listener> {\n    /** Settings keys. */\n    public enum KEY {\n        ROOT(\"LatexSettings\"), VERSION(\"version\");\n\n        private final String key;\n\n        KEY(@NotNull String key) {\n            this.key = key;\n        }\n\n        @Override\n        public String toString() {\n            return this.key;\n        }\n    }\n\n    /** Plugin version. */\n    private String version;\n\n    /** Listeners list. */\n    private final List<Listener> listeners = ContainerUtil.newArrayList();\n\n    /**\n     * Get the instance of this service.\n     *\n     * @return the unique {@link LatexSettings} instance.\n     */\n    public static LatexSettings getInstance() {\n        return ServiceManager.getService(LatexSettings.class);\n    }\n\n    /**\n     * Get the settings state as a DOM element.\n     *\n     * @return an ready to serialize DOM {@link Element}.\n     * @see {@link #loadState(Element)}\n     */\n    @Nullable\n    @Override\n    public Element getState() {\n        final Element element = new Element(KEY.ROOT.toString());\n        element.setAttribute(KEY.VERSION.toString(), version);\n\n        return element;\n    }\n\n    /**\n     * Load the settings state from the DOM {@link Element}.\n     *\n     * @param element the {@link Element} to load values from.\n     * @see {@link #getState()}\n     */\n    @Override\n    public void loadState(Element element) {\n        String value = element.getAttributeValue(KEY.VERSION.toString());\n        if (value != null) version = value;\n    }\n\n    /**\n     * Returns plugin version.\n     *\n     * @return version\n     */\n    public String getVersion() {\n        return version;\n    }\n\n    /**\n     * Sets plugin version.\n     *\n     * @param version of the plugin\n     */\n    public void setVersion(@NotNull String version) {\n        this.notifyOnChange(KEY.VERSION, this.version, version);\n        this.version = version;\n    }\n\n    /**\n     * Add the given listener. The listener will be executed in the containing instance's thread.\n     *\n     * @param listener listener to add\n     */\n    @Override\n    public void addListener(@NotNull Listener listener) {\n        listeners.add(listener);\n    }\n\n    /**\n     * Remove the given listener.\n     *\n     * @param listener listener to remove\n     */\n    @Override\n    public void removeListener(@NotNull Listener listener) {\n        listeners.remove(listener);\n    }\n\n    /**\n     * Notifies listeners about the changes.\n     *\n     * @param key      changed property key\n     * @param oldValue new value\n     * @param newValue new value\n     */\n    private void notifyOnChange(KEY key, Object oldValue, Object newValue) {\n        if (!newValue.equals(oldValue)) {\n            for (Listener listener : listeners) {\n                listener.onChange(key, newValue);\n            }\n        }\n    }\n\n    /** Listener interface for onChange event. */\n    public interface Listener {\n        void onChange(@NotNull KEY key, Object value);\n    }\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/ui/ImageEditorActionDialog.form",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<form xmlns=\"http://www.intellij.com/uidesigner/form/\" version=\"1\" bind-to-class=\"mobi.hsz.idea.latex.ui.ImageEditorActionDialog\">\n  <grid id=\"cbd77\" binding=\"panel\" layout-manager=\"GridLayoutManager\" row-count=\"3\" column-count=\"2\" same-size-horizontally=\"false\" same-size-vertically=\"false\" hgap=\"-1\" vgap=\"-1\">\n    <margin top=\"10\" left=\"10\" bottom=\"10\" right=\"10\"/>\n    <constraints>\n      <xy x=\"48\" y=\"54\" width=\"436\" height=\"297\"/>\n    </constraints>\n    <properties/>\n    <border type=\"none\"/>\n    <children>\n      <component id=\"7e4ad\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"0\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text value=\"Image path:\"/>\n        </properties>\n      </component>\n      <component id=\"cca3f\" class=\"com.intellij.openapi.ui.TextFieldWithBrowseButton\" binding=\"path\">\n        <constraints>\n          <grid row=\"0\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"3\" hsize-policy=\"7\" anchor=\"0\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties/>\n      </component>\n      <component id=\"1648f\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"1\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text value=\"Caption:\"/>\n        </properties>\n      </component>\n      <component id=\"e8cf0\" class=\"javax.swing.JTextField\" binding=\"caption\">\n        <constraints>\n          <grid row=\"1\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\">\n            <preferred-size width=\"150\" height=\"-1\"/>\n          </grid>\n        </constraints>\n        <properties/>\n      </component>\n      <component id=\"91bf4\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"2\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text value=\"Label:\"/>\n        </properties>\n      </component>\n      <component id=\"4ed9e\" class=\"javax.swing.JTextField\" binding=\"label\">\n        <constraints>\n          <grid row=\"2\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\">\n            <preferred-size width=\"150\" height=\"-1\"/>\n          </grid>\n        </constraints>\n        <properties/>\n      </component>\n    </children>\n  </grid>\n</form>\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/ui/ImageEditorActionDialog.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.ui;\n\nimport com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.ui.DialogWrapper;\nimport com.intellij.openapi.ui.TextFieldWithBrowseButton;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport javax.swing.*;\n\npublic class ImageEditorActionDialog extends DialogWrapper {\n\n    private JPanel panel;\n    private TextFieldWithBrowseButton path;\n    private JTextField caption;\n    private JTextField label;\n\n    public ImageEditorActionDialog(@NotNull Project project) {\n        super(project);\n\n        path.addBrowseFolderListener(LatexBundle.message(\"editor.image.dialog.browse\"), null, project, FileChooserDescriptorFactory.createSingleFileDescriptor());\n        setTitle(LatexBundle.message(\"editor.image.dialog.title\"));\n        init();\n    }\n\n    @Nullable\n    @Override\n    protected JComponent createCenterPanel() {\n        return panel;\n    }\n\n    @NotNull\n    public String getPath() {\n        return path.getText().trim();\n    }\n\n    @NotNull\n    public String getCaption() {\n        return caption.getText().trim();\n    }\n\n    @NotNull\n    public String getLabel() {\n        return label.getText().trim();\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/ui/MatrixEditorActionDialog.form",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<form xmlns=\"http://www.intellij.com/uidesigner/form/\" version=\"1\" bind-to-class=\"mobi.hsz.idea.latex.ui.MatrixEditorActionDialog\">\n  <grid id=\"cbd77\" binding=\"panel\" layout-manager=\"GridLayoutManager\" row-count=\"3\" column-count=\"2\" same-size-horizontally=\"false\" same-size-vertically=\"false\" hgap=\"-1\" vgap=\"-1\">\n    <margin top=\"10\" left=\"10\" bottom=\"10\" right=\"10\"/>\n    <constraints>\n      <xy x=\"48\" y=\"54\" width=\"436\" height=\"297\"/>\n    </constraints>\n    <properties/>\n    <border type=\"none\"/>\n    <children>\n      <component id=\"36934\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"0\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text resource-bundle=\"messages/LatexBundle\" key=\"form.rows\"/>\n        </properties>\n      </component>\n      <component id=\"2f233\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"1\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text resource-bundle=\"messages/LatexBundle\" key=\"form.columns\"/>\n        </properties>\n      </component>\n      <component id=\"ab7f7\" class=\"javax.swing.JSpinner\" binding=\"rows\">\n        <constraints>\n          <grid row=\"0\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties/>\n      </component>\n      <component id=\"de253\" class=\"javax.swing.JSpinner\" binding=\"columns\">\n        <constraints>\n          <grid row=\"1\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties/>\n      </component>\n      <component id=\"d2f87\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"2\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text resource-bundle=\"messages/LatexBundle\" key=\"form.bracket\"/>\n        </properties>\n      </component>\n      <component id=\"7df83\" class=\"javax.swing.JComboBox\" binding=\"bracket\">\n        <constraints>\n          <grid row=\"2\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"2\" anchor=\"8\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties/>\n      </component>\n    </children>\n  </grid>\n</form>\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/ui/MatrixEditorActionDialog.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.ui;\n\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.ui.DialogWrapper;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport javax.swing.*;\n\npublic class MatrixEditorActionDialog extends DialogWrapper {\n\n    public enum Bracket {\n        NONE('\\0'), PARENTHESES('p'), BRACKETS('b'), BRACES('B'), SINGLE_LINE('v'), DOUBLE_LINE('V');\n\n        private final char value;\n\n        Bracket(char value) {\n            this.value = value;\n        }\n\n        public char getValue() {\n            return value;\n        }\n\n        @Override\n        public String toString() {\n            return LatexBundle.message(\"form.bracket.\" + name().toLowerCase());\n        }\n    }\n\n    private JPanel panel;\n    private JSpinner rows;\n    private JSpinner columns;\n    private JComboBox<Bracket> bracket;\n\n    public MatrixEditorActionDialog(@NotNull Project project) {\n        super(project);\n        setTitle(LatexBundle.message(\"editor.matrix.dialog.title\"));\n\n        rows.setModel(new SpinnerNumberModel(2, 1, null, 1));\n        columns.setModel(new SpinnerNumberModel(2, 1, null, 1));\n        bracket.setModel(new DefaultComboBoxModel<Bracket>(Bracket.values()));\n\n        init();\n    }\n\n    @Nullable\n    @Override\n    protected JComponent createCenterPanel() {\n        return panel;\n    }\n\n    public int getRows() {\n        return (Integer) rows.getValue();\n    }\n\n    public int getColumns() {\n        return (Integer) columns.getValue();\n    }\n\n    @NotNull\n    public Bracket getBracket() {\n        return (Bracket) bracket.getSelectedItem();\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/ui/TableEditorActionDialog.form",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<form xmlns=\"http://www.intellij.com/uidesigner/form/\" version=\"1\" bind-to-class=\"mobi.hsz.idea.latex.ui.TableEditorActionDialog\">\n  <grid id=\"cbd77\" binding=\"panel\" layout-manager=\"GridLayoutManager\" row-count=\"4\" column-count=\"2\" same-size-horizontally=\"false\" same-size-vertically=\"false\" hgap=\"-1\" vgap=\"-1\">\n    <margin top=\"10\" left=\"10\" bottom=\"10\" right=\"10\"/>\n    <constraints>\n      <xy x=\"48\" y=\"54\" width=\"436\" height=\"297\"/>\n    </constraints>\n    <properties/>\n    <border type=\"none\"/>\n    <children>\n      <component id=\"79b8a\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"0\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text value=\"Rows:\"/>\n        </properties>\n      </component>\n      <component id=\"8ef49\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"1\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text value=\"Columns:\"/>\n        </properties>\n      </component>\n      <component id=\"26823\" class=\"javax.swing.JSpinner\" binding=\"rows\">\n        <constraints>\n          <grid row=\"0\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties/>\n      </component>\n      <component id=\"cdd1e\" class=\"javax.swing.JSpinner\" binding=\"columns\">\n        <constraints>\n          <grid row=\"1\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties/>\n      </component>\n      <component id=\"ef28c\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"2\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text resource-bundle=\"messages/LatexBundle\" key=\"form.alignment\"/>\n        </properties>\n      </component>\n      <component id=\"b31f0\" class=\"javax.swing.JComboBox\" binding=\"alignment\">\n        <constraints>\n          <grid row=\"2\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"2\" anchor=\"8\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties/>\n      </component>\n      <component id=\"2860a\" class=\"javax.swing.JLabel\">\n        <constraints>\n          <grid row=\"3\" column=\"0\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties>\n          <text resource-bundle=\"messages/LatexBundle\" key=\"form.border\"/>\n        </properties>\n      </component>\n      <component id=\"256fd\" class=\"javax.swing.JComboBox\" binding=\"border\">\n        <constraints>\n          <grid row=\"3\" column=\"1\" row-span=\"1\" col-span=\"1\" vsize-policy=\"0\" hsize-policy=\"2\" anchor=\"8\" fill=\"1\" indent=\"0\" use-parent-layout=\"false\"/>\n        </constraints>\n        <properties/>\n      </component>\n    </children>\n  </grid>\n</form>\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/ui/TableEditorActionDialog.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.ui;\n\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.ui.DialogWrapper;\nimport mobi.hsz.idea.latex.LatexBundle;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport javax.swing.*;\n\npublic class TableEditorActionDialog extends DialogWrapper {\n\n    public enum Alignment {\n        LEFT('l'), CENTER('c'), RIGHT('r');\n\n        private final char value;\n\n        Alignment(char value) {\n            this.value = value;\n        }\n\n        public char getValue() {\n            return value;\n        }\n\n        @Override\n        public String toString() {\n            return LatexBundle.message(\"form.alignment.\" + name().toLowerCase());\n        }\n    }\n\n    public enum Border {\n        NONE, TABLE, CELL;\n\n        public boolean isNone() {\n            return this.equals(NONE);\n        }\n\n        public boolean isTable() {\n            return this.equals(TABLE);\n        }\n\n        public boolean isCell() {\n            return this.equals(CELL);\n        }\n\n        @Override\n        public String toString() {\n            return LatexBundle.message(\"form.border.\" + name().toLowerCase());\n        }\n    }\n\n    private JPanel panel;\n    private JSpinner rows;\n    private JSpinner columns;\n    private JComboBox<Alignment> alignment;\n    private JComboBox<Border> border;\n\n    public TableEditorActionDialog(@NotNull Project project) {\n        super(project);\n        setTitle(LatexBundle.message(\"editor.table.dialog.title\"));\n\n        rows.setModel(new SpinnerNumberModel(2, 1, null, 1));\n        columns.setModel(new SpinnerNumberModel(2, 1, null, 1));\n        alignment.setModel(new DefaultComboBoxModel<Alignment>(Alignment.values()));\n        border.setModel(new DefaultComboBoxModel<Border>(Border.values()));\n\n        init();\n    }\n\n    @Nullable\n    @Override\n    protected JComponent createCenterPanel() {\n        return panel;\n    }\n\n    public int getRows() {\n        return (Integer) rows.getValue();\n    }\n\n    public int getColumns() {\n        return (Integer) columns.getValue();\n    }\n\n    @NotNull\n    public Alignment getAlignment() {\n        return (Alignment) alignment.getSelectedItem();\n    }\n\n    @NotNull\n    public Border getBorder() {\n        return (Border) border.getSelectedItem();\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/util/Icons.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.util;\n\nimport com.intellij.openapi.util.IconLoader;\n\nimport javax.swing.*;\n\n/**\n * {@link Icons} class that holds icon resources.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.1\n */\npublic class Icons {\n\n    public static final Icon FILE = IconLoader.getIcon(\"/icons/tex.png\");\n\n    public static class Editor {\n\n        public static final Icon ALIGN_LEFT = IconLoader.getIcon(\"/icons/editor/align_left.png\");\n        public static final Icon ALIGN_CENTER = IconLoader.getIcon(\"/icons/editor/align_center.png\");\n        public static final Icon ALIGN_RIGHT = IconLoader.getIcon(\"/icons/editor/align_right.png\");\n        public static final Icon BOLD = IconLoader.getIcon(\"/icons/editor/bold.png\");\n        public static final Icon IMAGE = IconLoader.getIcon(\"/icons/editor/image.png\");\n        public static final Icon ITALIC = IconLoader.getIcon(\"/icons/editor/italic.png\");\n        public static final Icon MATRIX = IconLoader.getIcon(\"/icons/editor/matrix.png\");\n        public static final Icon TABLE = IconLoader.getIcon(\"/icons/editor/table.png\");\n        public static final Icon UNDERLINE = IconLoader.getIcon(\"/icons/editor/underline.png\");\n\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/util/Listenable.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.util;\n\nimport org.jetbrains.annotations.NotNull;\n\n/**\n * Abstracts a listenable object.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3.0\n */\npublic interface Listenable<T> {\n    /**\n     * Add the given listener. The listener will be executed in the containing instance's thread.\n     *\n     * @param listener listener to add\n     */\n    void addListener(@NotNull T listener);\n\n    /**\n     * Remove the given listener.\n     *\n     * @param listener listener to remove\n     */\n    void removeListener(@NotNull T listener);\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/util/Resources.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.util;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.io.File;\nimport java.io.InputStream;\nimport java.net.URL;\nimport java.util.Scanner;\n\n/**\n * {@link Resources} util class that contains methods that work on plugin's resources.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.2\n */\npublic class Resources {\n\n    /** Private constructor to prevent creating {@link Resources} instance. */\n    private Resources() {\n    }\n\n    /**\n     * Returns gitignore templates directory\n     *\n     * @return Resources directory\n     */\n    @NotNull\n    public static File getResource(@Nullable String path) {\n        URL resource = Resources.class.getResource(path);\n        assert resource != null;\n        return new File(resource.getPath());\n    }\n\n    /**\n     * Reads resource file and returns its content as a String\n     *\n     * @param path Resource path\n     * @return Content\n     */\n    @NotNull\n    public static String getResourceContent(@Nullable String path) {\n        return convertStreamToString(Resources.class.getResourceAsStream(path));\n    }\n\n    /**\n     * Converts InputStream resource to String\n     *\n     * @param inputStream Input stream\n     * @return Content\n     */\n    @NotNull\n    private static String convertStreamToString(InputStream inputStream) {\n        Scanner s = new Scanner(inputStream).useDelimiter(\"\\\\A\");\n        return s.hasNext() ? s.next() : \"\";\n    }\n\n}\n"
  },
  {
    "path": "src/mobi/hsz/idea/latex/util/Utils.java",
    "content": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\npackage mobi.hsz.idea.latex.util;\n\nimport com.intellij.ide.plugins.IdeaPluginDescriptor;\nimport com.intellij.ide.plugins.PluginManager;\nimport com.intellij.openapi.extensions.PluginId;\nimport com.intellij.openapi.util.text.StringUtil;\nimport mobi.hsz.idea.latex.LatexBundle;\n\n/**\n * {@link Utils} class that contains various methods.\n *\n * @author Jakub Chrzanowski <jakub@hsz.mobi>\n * @since 0.3.0\n */\npublic class Utils {\n    /** Private constructor to prevent creating {@link Utils} instance. */\n    private Utils() {\n    }\n\n    /**\n     * Returns Gitignore plugin information.\n     *\n     * @return {@link IdeaPluginDescriptor}\n     */\n    public static IdeaPluginDescriptor getPlugin() {\n        return PluginManager.getPlugin(PluginId.getId(LatexBundle.PLUGIN_ID));\n    }\n\n    /**\n     * Returns plugin major version.\n     *\n     * @return major version\n     */\n    public static String getMajorVersion() {\n        return getVersion().split(\"\\\\.\")[0];\n    }\n\n    /**\n     * Returns plugin minor version.\n     *\n     * @return minor version\n     */\n    public static String getMinorVersion() {\n        return StringUtil.join(getVersion().split(\"\\\\.\"), 0, 2, \".\");\n    }\n\n    /**\n     * Returns plugin version.\n     *\n     * @return version\n     */\n    public static String getVersion() {\n        return getPlugin().getVersion();\n    }\n}\n"
  }
]