Showing preview only (234K chars total). Download the full file or copy to clipboard to get everything.
Repository: hsz/idea-latex
Branch: master
Commit: a84ec8e09acb
Files: 89
Total size: 209.4 KB
Directory structure:
gitextract_dd7s0pn4/
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.gradle
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── resources/
│ ├── META-INF/
│ │ └── plugin.xml
│ ├── bnf/
│ │ └── Latex.bnf
│ ├── codeStyle/
│ │ └── preview/
│ │ ├── blank_lines_settings.tex.ft
│ │ ├── indent_settings.tex.ft
│ │ ├── spacing_settings.tex.ft
│ │ └── wrapping_and_braces_settings.tex.ft
│ ├── colorSchemes/
│ │ ├── LatexDarcula.xml
│ │ └── LatexDefault.xml
│ ├── fileTemplates/
│ │ └── j2ee/
│ │ ├── article.tex.ft
│ │ ├── book.tex.ft
│ │ ├── empty.tex.ft
│ │ ├── letter.tex.ft
│ │ ├── presentation.tex.ft
│ │ └── report.tex.ft
│ ├── messages/
│ │ └── LatexBundle.properties
│ └── sample.tex
├── settings.gradle
└── src/
└── mobi/
└── hsz/
└── idea/
└── latex/
├── LatexApplicationComponent.java
├── LatexBundle.java
├── LatexUpdateComponent.java
├── actions/
│ ├── CreateLatexFileAction.java
│ ├── LatexTemplates.java
│ ├── LatexTemplatesFactory.java
│ └── editor/
│ ├── AlignCenterAction.java
│ ├── AlignLeftAction.java
│ ├── AlignRightAction.java
│ ├── BoldAction.java
│ ├── ImageAction.java
│ ├── ItalicAction.java
│ ├── MatrixAction.java
│ ├── TableAction.java
│ ├── UnderlineAction.java
│ └── base/
│ ├── DialogEditorAction.java
│ ├── EditorAction.java
│ ├── EditorActionsFactory.java
│ ├── InsertEditorAction.java
│ └── WrapEditorAction.java
├── codeStyle/
│ ├── LatexCodeStyleMainPanel.java
│ ├── LatexCodeStyleSettings.java
│ ├── LatexCodeStyleSettingsProvider.java
│ └── LatexLanguageCodeStyleSettingsProvider.java
├── editor/
│ ├── LatexEditorActionsLoaderComponent.java
│ └── LatexEditorActionsWrapper.java
├── file/
│ ├── LatexFileType.java
│ └── LatexFileTypeFactory.java
├── folding/
│ └── LatexFoldingBuilder.java
├── highlighter/
│ ├── LatexColorSettingsPage.java
│ ├── LatexHighlighter.java
│ ├── LatexHighlighterColors.java
│ └── LatexHighlighterFactory.java
├── inspections/
│ └── LatexSpellcheckingStrategy.java
├── lang/
│ ├── LatexBraceMatcher.java
│ ├── LatexCommenter.java
│ ├── LatexLanguage.java
│ └── LatexParserDefinition.java
├── lexer/
│ ├── Latex.flex
│ └── LatexLexerAdapter.java
├── parser/
│ └── LatexParserUtil.java
├── psi/
│ ├── LatexArgumentElement.java
│ ├── LatexElementImpl.java
│ ├── LatexElementType.java
│ ├── LatexFile.java
│ ├── LatexTokenType.java
│ └── impl/
│ ├── LatexArgumentExtImpl.java
│ ├── LatexInstructionExtImpl.java
│ └── LatexSectionExtImpl.java
├── reference/
│ └── LatexReferenceContributor.java
├── settings/
│ └── LatexSettings.java
├── ui/
│ ├── ImageEditorActionDialog.form
│ ├── ImageEditorActionDialog.java
│ ├── MatrixEditorActionDialog.form
│ ├── MatrixEditorActionDialog.java
│ ├── TableEditorActionDialog.form
│ └── TableEditorActionDialog.java
└── util/
├── Icons.java
├── Listenable.java
├── Resources.java
└── Utils.java
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.idea/
*.iml
out/
gen/
build/
build.properties
junit*.properties
.gradle
================================================
FILE: .travis.yml
================================================
# Configuration for CI build at https://travis-ci.org/hsz/idea-latex
language: java
jdk:
- oraclejdk8
env:
- IDEA_VERSION=2017.2
- IDEA_VERSION=2017.1.5
- IDEA_VERSION=2016.3.7
- IDEA_VERSION=2016.2.5
- IDEA_VERSION=2016.1.4
# Workaround for https://github.com/travis-ci/travis-ci/issues/5227
# Buffer overflow in Java_java_net_Inet4AddressImpl_getLocalHostName
before_install:
- cat /etc/hosts # optionally check the content *before*
- sudo hostname "$(hostname | cut -c1-63)"
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
- cat /etc/hosts # optionally check the content *after*
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
after_success:
- ./gradlew jacocoTestReport coveralls
================================================
FILE: CHANGELOG.md
================================================
# Change Log
## [v0.2](https://github.com/hsz/idea-latex/tree/v0.2) (2015-01-27)
[Full Changelog](https://github.com/hsz/idea-latex/compare/v0.1.1...v0.2)
**Implemented enhancements:**
- Toolbar actions: bold, italic, underline, align left, align center, align right
- Color settings page
- Sections folding
## [v0.1.1](https://github.com/hsz/idea-latex/tree/v0.1.1) (2015-01-20)
[Full Changelog](https://github.com/hsz/idea-latex/compare/v0.1...v0.1.1)
**Fixed bugs:**
- Fixed syntax highlighting (better BNF and Flex rules)
**Closed issues:**
- Installable release version? [\#1](https://github.com/hsz/idea-latex/issues/1)
## [v0.1](https://github.com/hsz/idea-latex/tree/v0.1) (2015-01-16)
- Basic syntax highlighting
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
License
-------
Copyright (c) 2017 hsz Jakub Chrzanowski. See the [LICENSE](./LICENSE) file for license rights and limitations (MIT).
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
idea-latex v0.3.0
=================
[![Gitter][badge-gitter-img]][badge-gitter] [![Build Status][badge-travis-img]][badge-travis] [![Donate][badge-paypal-img]][badge-paypal]
[][plugin-website]
[][plugin-website]
[][plugin-website]
Introduction
------------
**LaTeX** is a plugin supporting LaTeX in your project. It supports following JetBrains IDEs:
- Android Studio
- AppCode
- IntelliJ IDEA
- PhpStorm
- PyCharm
- RubyMine
- WebStorm
- 0xDBE
*Compiled with Java 1.6*
Features
--------
- Syntax highlighting
- Editor toolbar actions with shortcuts
- Code folding
*Feature requests:*
- *suggesting functions' names*
- *obtaining installed packages*
- *generating PDF files*
- *preview generated PDF files*
- *and more...*
Installation
------------
- Using IDE built-in plugin system:
- <kbd>Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Browse repositories...</kbd> > <kbd>Search for "LaTeX"</kbd> > <kbd>Install Plugin</kbd>
- Manually:
- Download the [latest release][latest-release] and install it manually using <kbd>Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Install plugin from disk...</kbd>
Restart IDE.
Usage
-----
### Available shortcuts:
| Action name | Output | Shortcut |
| ---------------- | ------------------------------------------------------------------------ | ------------------------------------------------ |
| *Bold* | <pre lang="latex">\textbf($SELECTION$)</pre> | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**B**</kbd> |
| *Italic* | <pre lang="latex">\textit($SELECTION$)</pre> | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**I**</kbd> |
| *Underline* | <pre lang="latex">\underline($SELECTION$)</pre> | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**U**</kbd> |
| *Align left* | <pre lang="latex">\begin{flushleft}$SELECTION$\end{flushleft}</pre> | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**L**</kbd> |
| *Align center* | <pre lang="latex">\begin{center}$SELECTION$\end{center}</pre> | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**C**</kbd> |
| *Align right* | <pre lang="latex">\begin{flushright}$SELECTION$\end{flushright}</pre> | <kbd>Ctrl</kbd> + <kbd>L</kbd>, <kbd>**R**</kbd> |
Changelog
---------
Version 0.2
- Toolbar actions: bold, italic, underline, align left, align center, align right
- Color settings page
- Sections folding
Version 0.1.1
- Fixed syntax highlighting (better BNF and Flex rules)
Version 0.1
- Basic syntax highlighting
Developed By
------------
[**@hsz** Jakub Chrzanowski][hsz]
**Contributors**
- *you can be first on this list*
License
-------
Copyright (c) 2017 hsz Jakub Chrzanowski. See the [LICENSE](./LICENSE) file for license rights and limitations (MIT).
[hsz]: http://hsz.mobi
[plugin-website]: https://plugins.jetbrains.com/plugin/7660
[latest-release]: https://github.com/hsz/idea-latex/releases/latest
[badge-gitter-img]: https://badges.gitter.im/hsz/idea-latex.svg
[badge-gitter]: https://gitter.im/hsz/idea-latex
[badge-travis-img]: https://travis-ci.org/hsz/idea-latex.svg
[badge-travis]: https://travis-ci.org/hsz/idea-latex
[badge-paypal-img]: https://img.shields.io/badge/donate-paypal-yellow.svg
[badge-paypal]: https://www.paypal.me/hsz
================================================
FILE: build.gradle
================================================
plugins {
id 'org.jetbrains.intellij' version '0.0.43'
id 'de.undercouch.download' version '2.1.0'
}
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = javaVersion
targetCompatibility = javaTargetVersion
group pluginGroup
version = pluginVersion
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
sourceSets {
main {
java.srcDirs 'src', 'gen'
resources.srcDir 'resources'
}
}
intellij {
version ideaVersion
type ideaType
pluginName pluginName
downloadSources Boolean.valueOf(sources)
sameSinceUntilBuild Boolean.valueOf(isEAP)
alternativeIdePath idePath
updateSinceUntilBuild false
publish {
username publishUsername
password publishPassword
pluginId publishPluginId
channel publishChannel
}
}
idea {
project {
jdkName = javaVersion
languageLevel = javaVersion
}
module {
generatedSourceDirs += file('gen')
}
}
// Configurations
configurations {
bnf
jflex
}
repositories {
mavenCentral()
}
test {
testLogging {
exceptionFormat = 'full'
}
}
dependencies {
bnf files("$buildDir/tools/GrammarKit/lib/grammar-kit.jar")
bnf files("$buildDir/tools/light-psi-all.jar")
jflex files("$buildDir/tools/JFlex.jar")
testCompile group: 'junit', name: 'junit', version: '4.11'
}
import de.undercouch.gradle.tasks.download.Download
// Tasks
task downloadJFlexJar(type: Download) {
description 'Downloads JFlex.'
src 'https://github.com/JetBrains/intellij-community/raw/master/tools/lexer/jflex-1.7.0-SNAPSHOT.jar'
dest "$buildDir/tools/JFlex.jar"
onlyIf { !file("$buildDir/tools/JFlex.jar").exists() }
}
task downloadJFlexSkeleton(type: Download) {
description 'Downloads JFlex skeleton.'
src 'https://raw.github.com/JetBrains/intellij-community/master/tools/lexer/idea-flex.skeleton'
dest "$buildDir/tools/idea-flex.skeleton"
onlyIf { !file("$buildDir/tools/idea-flex.skeleton").exists() }
}
task generateLexer(type: JavaExec) {
description 'Generates lexer sources with JFlex.'
dependsOn downloadJFlexJar, downloadJFlexSkeleton
main = 'jflex.Main'
args = [
'-skel',
"$buildDir/tools/idea-flex.skeleton",
'-d',
'gen/mobi/hsz/idea/latex/lexer/',
'src/mobi/hsz/idea/latex/lexer/Latex.flex',
]
classpath = configurations.jflex
}
task downloadGrammarKit(type: Download) {
description 'Downloads GrammarKit.'
src 'https://github.com/JetBrains/Grammar-Kit/releases/download/1.2.0.1/GrammarKit.zip'
dest "$buildDir/tools/GrammarKit.zip"
onlyIfNewer true
}
task downloadGrammarLightPsi(type: Download) {
description 'Downloads GrammarKit Light Psi.'
src 'https://github.com/JetBrains/Grammar-Kit/releases/download/1.2.0.1/light-psi-all.jar'
dest "$buildDir/tools/light-psi-all.jar"
onlyIfNewer true
}
task unzipGrammarKit(type: Copy) {
description 'Extracts GrammarKit files.'
dependsOn downloadGrammarKit
from zipTree("$buildDir/tools/GrammarKit.zip")
into "${buildDir}/tools/"
include "GrammarKit/lib/*"
}
task generateParser(type: JavaExec) {
description 'Generates parser sources with GrammarKit.'
dependsOn unzipGrammarKit, downloadGrammarLightPsi
main = 'org.intellij.grammar.Main'
args = [ 'gen', 'resources/bnf/Latex.bnf' ]
classpath = configurations.bnf + configurations.compile
}
task generateSources() {
dependsOn generateParser, generateLexer
}
clean.doFirst {
delete 'gen', 'out'
}
compileJava.dependsOn generateSources
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Mon Apr 11 22:05:01 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
================================================
FILE: gradle.properties
================================================
# Available idea versions:
# https://www.jetbrains.com/intellij-repository/releases
# https://www.jetbrains.com/intellij-repository/snapshots
ideaVersion = 2017.1.5
ideaType = IC
javaVersion = 1.6
javaTargetVersion = 1.6
javaArguments = -agentpath:/home/hsz/IDE/yjp-2017.02/bin/linux-x86-64/libyjpagent.so
sources = true
isEAP = false
runGenerators = true
pluginGroup = mobi.hsz.idea
pluginName = LaTeX
pluginVersion = 0.3.0
publishPluginId = 7660
publishUsername = hsz
publishPassword =
publishChannel =
org.gradle.jvmargs=-XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=utf-8
JDK6_HOME=/usr/lib/jvm/java-6-jdk/
idePath =
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: resources/META-INF/plugin.xml
================================================
<idea-plugin version="2">
<id>mobi.hsz.idea.latex</id>
<name>LaTeX</name>
<version>0.3.0</version>
<vendor email="jakub@hsz.mobi" url="http://www.hsz.mobi">hsz</vendor>
<description><![CDATA[
<h1>LaTeX plugin for IntelliJ IDEA</h1>
<br/>
<a href="https://github.com/hsz/idea-latex">GitHub</a> |
<a href="https://github.com/hsz/idea-latex/issues">Issues</a> | Donate (
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=V6QCW4DR2XWY4">PayPal</a> or
<a href="https://blockchain.info/address/1BUbqKrUBmGGSnMybzGCsJyAWJbh4CcwE1">BTC</a> )
<br/>
<br/>
<b>Features</b>
<ul>
<li>Syntax highlighting</li>
<li>Editor toolbar actions with shortcuts</li>
<li>Code folding</li>
</ul>
<b><i>Feature requests:</i></b>
<ul>
<li><i>suggesting functions' names</i></li>
<li><i>obtaining installed packages</i></li>
<li><i>generating PDF files</i></li>
<li><i>preview generated PDF files</i></li>
<li><i>and more...</i></li>
</ul>
<br/>
<br/>
<i>Compiled with Java 1.6</i>
<br/>
<br/>
]]></description>
<change-notes><![CDATA[
Version 0.2
<ul>
<li>Toolbar actions: bold, italic, underline, align left, align center, align right</li>
<li>Color settings page</li>
<li>Sections folding</li>
</ul>
Version 0.1.1
<ul>
<li>Fixed syntax highlighting (better BNF and Flex rules)</li>
</ul>
Version 0.1
<ul>
<li>Basic syntax highlighting</li>
</ul>
]]>
</change-notes>
<idea-version since-build="123.72"/>
<depends>com.intellij.modules.lang</depends>
<resource-bundle>messages.LatexBundle</resource-bundle>
<extensions defaultExtensionNs="com.intellij">
<additionalTextAttributes
file="colorSchemes/LatexDefault.xml"
scheme="Default"/>
<additionalTextAttributes
file="colorSchemes/LatexDarcula.xml"
scheme="Darcula"/>
<applicationService
serviceInterface="mobi.hsz.idea.latex.settings.LatexSettings"
serviceImplementation="mobi.hsz.idea.latex.settings.LatexSettings"/>
<codeStyleSettingsProvider
implementation="mobi.hsz.idea.latex.codeStyle.LatexCodeStyleSettingsProvider"/>
<colorSettingsPage
implementation="mobi.hsz.idea.latex.highlighter.LatexColorSettingsPage"/>
<fileTemplateGroup
implementation="mobi.hsz.idea.latex.actions.LatexTemplatesFactory"/>
<fileTypeFactory
implementation="mobi.hsz.idea.latex.file.LatexFileTypeFactory"/>
<lang.braceMatcher
implementationClass="mobi.hsz.idea.latex.lang.LatexBraceMatcher"
language="LaTeX"/>
<lang.commenter
implementationClass="mobi.hsz.idea.latex.lang.LatexCommenter"
language="LaTeX"/>
<lang.foldingBuilder
implementationClass="mobi.hsz.idea.latex.folding.LatexFoldingBuilder"
language="LaTeX"/>
<lang.parserDefinition
implementationClass="mobi.hsz.idea.latex.lang.LatexParserDefinition"
language="LaTeX"/>
<lang.syntaxHighlighterFactory
implementationClass="mobi.hsz.idea.latex.highlighter.LatexHighlighterFactory"
key="LaTeX"/>
<langCodeStyleSettingsProvider
implementation="mobi.hsz.idea.latex.codeStyle.LatexLanguageCodeStyleSettingsProvider"/>
<psi.referenceContributor
implementation="mobi.hsz.idea.latex.reference.LatexReferenceContributor"
language="LaTeX"/>
<spellchecker.support
implementationClass="mobi.hsz.idea.latex.inspections.LatexSpellcheckingStrategy"
language="LaTeX"/>
</extensions>
<application-components>
<component>
<implementation-class>mobi.hsz.idea.latex.LatexApplicationComponent</implementation-class>
</component>
</application-components>
<project-components>
<component>
<implementation-class>mobi.hsz.idea.latex.editor.LatexEditorActionsLoaderComponent</implementation-class>
<skipForDefaultProject/>
</component>
<component>
<implementation-class>mobi.hsz.idea.latex.LatexUpdateComponent</implementation-class>
</component>
</project-components>
<actions>
<group id="latex.new" text="LaTeX">
<action id="latex.new.file" class="mobi.hsz.idea.latex.actions.CreateLatexFileAction"/>
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFromTemplate"/>
</group>
<group id="latex.editor" text="LaTeX">
<action id="latex.editor.bold" class="mobi.hsz.idea.latex.actions.editor.BoldAction">
<keyboard-shortcut keymap="$default" first-keystroke="ctrl L" second-keystroke="B"/>
</action>
<action id="latex.editor.italic" class="mobi.hsz.idea.latex.actions.editor.ItalicAction">
<keyboard-shortcut keymap="$default" first-keystroke="ctrl L" second-keystroke="I"/>
</action>
<action id="latex.editor.underline" class="mobi.hsz.idea.latex.actions.editor.UnderlineAction">
<keyboard-shortcut keymap="$default" first-keystroke="ctrl L" second-keystroke="U"/>
</action>
<action id="latex.editor.align_left" class="mobi.hsz.idea.latex.actions.editor.AlignLeftAction">
<keyboard-shortcut keymap="$default" first-keystroke="ctrl L" second-keystroke="L"/>
</action>
<action id="latex.editor.align_center" class="mobi.hsz.idea.latex.actions.editor.AlignCenterAction">
<keyboard-shortcut keymap="$default" first-keystroke="ctrl L" second-keystroke="C"/>
</action>
<action id="latex.editor.align_right" class="mobi.hsz.idea.latex.actions.editor.AlignRightAction">
<keyboard-shortcut keymap="$default" first-keystroke="ctrl L" second-keystroke="R"/>
</action>
<action id="latex.editor.image" class="mobi.hsz.idea.latex.actions.editor.ImageAction"/>
<action id="latex.editor.matrix" class="mobi.hsz.idea.latex.actions.editor.MatrixAction"/>
<action id="latex.editor.table" class="mobi.hsz.idea.latex.actions.editor.TableAction"/>
</group>
</actions>
</idea-plugin>
================================================
FILE: resources/bnf/Latex.bnf
================================================
{
parserClass = "mobi.hsz.idea.latex.parser.LatexParser"
parserUtilClass = "mobi.hsz.idea.latex.parser.LatexParserUtil"
extends = "mobi.hsz.idea.latex.psi.LatexElementImpl"
psiClassPrefix = "Latex"
psiImplClassSuffix = "Impl"
psiPackage = "mobi.hsz.idea.latex.psi"
psiImplPackage = "mobi.hsz.idea.latex.psi.impl"
elementTypeHolderClass = "mobi.hsz.idea.latex.psi.LatexTypes"
elementTypeClass = "mobi.hsz.idea.latex.psi.LatexElementType"
tokenTypeClass = "mobi.hsz.idea.latex.psi.LatexTokenType"
tokens = [
LBRACE = "{"
RBRACE = "}"
LBRACKET = "["
RBRACKET = "]"
LPAREN = "("
RPAREN = ")"
COMMA = ","
COLON = ":"
ASTERISK = "*"
LINE_BREAK = '\\'
IDENTIFIER_BEGIN = '\begin'
IDENTIFIER_END = '\end'
IDENTIFIER = "regexp:\\\p{Alpha}+"
ARG = "regexp:\b([^\[\]\{\}\(\),\\])+\b"
COMMENT = "regexp:%.*"
SPECIAL = "regexp:[\S]|\\."
CRLF = "regexp:[\s\r\n]+"
]
extends("instruction.*") = instruction
name("instruction.*") = instruction
mixin("instruction.*") = "mobi.hsz.idea.latex.psi.impl.LatexInstructionExtImpl"
mixin("section") = "mobi.hsz.idea.latex.psi.impl.LatexSectionExtImpl"
mixin("argument") = "mobi.hsz.idea.latex.psi.impl.LatexArgumentExtImpl"
implements("argument") = "mobi.hsz.idea.latex.psi.LatexArgumentElement"
}
latexFile ::= item_ *
private item_ ::= !<<eof>> expr * { pin = 1 }
private expr ::= section
| instruction
| argument_group
| text
| SPECIAL
| CRLF
| LINE_BREAK
section ::= instruction_begin expr * instruction_end { pin = 1 }
instruction_begin ::= IDENTIFIER_BEGIN argument_brace argument_brace * { pin = 1 }
instruction_end ::= IDENTIFIER_END argument_brace { pin = 1 }
instruction ::= IDENTIFIER ASTERISK ? argument_group * { pin = 1 }
text ::= ( ARG special_expr ? ) +
private argument_group ::= argument_bracket | argument_brace | argument_paren
private argument_expr ::= ( special_expr * ( ARG | section | instruction ) special_expr * ) * { pin(".*") = 2 }
private special_expr ::= SPECIAL | COLON | COMMA | LINE_BREAK | CRLF
meta argument_bracket ::= LBRACKET argument ? RBRACKET { pin(".*") = 1 elementType = argument }
meta argument_brace ::= LBRACE argument ? RBRACE { pin(".*") = 1 elementType = argument }
meta argument_paren ::= LPAREN argument ? RPAREN { pin(".*") = 1 elementType = argument }
meta argument ::= <<sequence argument_expr special_expr>>
private meta sequence ::= <<p>> (<<q>> <<p>>) * { pin(".*") = 1 }
================================================
FILE: resources/codeStyle/preview/blank_lines_settings.tex.ft
================================================
blank_lines_settings file
================================================
FILE: resources/codeStyle/preview/indent_settings.tex.ft
================================================
indent_settings file
================================================
FILE: resources/codeStyle/preview/spacing_settings.tex.ft
================================================
spacing_settings file
================================================
FILE: resources/codeStyle/preview/wrapping_and_braces_settings.tex.ft
================================================
wrapping_and_braces_settings file
================================================
FILE: resources/colorSchemes/LatexDarcula.xml
================================================
<?xml version='1.0'?>
<list>
<option name="LATEX.COMMENT">
<value>
<option name="FOREGROUND" value="808080" />
</value>
</option>
<option name="LATEX.INSTRUCTION">
<value>
<option name="FOREGROUND" value="ED7600" />
</value>
</option>
<option name="LATEX.ARGUMENT">
<value>
<option name="FOREGROUND" value="668AA1" />
</value>
</option>
<option name="LATEX.BRACKET">
<value>
<option name="FOREGROUND" value="365A71" />
</value>
</option>
</list>
================================================
FILE: resources/colorSchemes/LatexDefault.xml
================================================
<?xml version='1.0'?>
<list>
<option name="LATEX.COMMENT">
<value>
<option name="FOREGROUND" value="808080" />
</value>
</option>
<option name="LATEX.INSTRUCTION">
<value>
<option name="FOREGROUND" value="8A4A0B" />
</value>
</option>
<option name="LATEX.ARGUMENT">
<value>
<option name="FOREGROUND" value="4486B0" />
</value>
</option>
<option name="LATEX.BRACKET">
<value>
<option name="FOREGROUND" value="145680" />
</value>
</option>
</list>
================================================
FILE: resources/fileTemplates/j2ee/article.tex.ft
================================================
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\title{}
\author{}
\begin{document}
\maketitle
\tableofcontents
\begin{abstract}
\end{abstract}
\section{}
\end{document}
================================================
FILE: resources/fileTemplates/j2ee/book.tex.ft
================================================
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\title{}
\author{}
\begin{document}
\maketitle
\tableofcontents
\chapter{}
\end{document}
================================================
FILE: resources/fileTemplates/j2ee/empty.tex.ft
================================================
================================================
FILE: resources/fileTemplates/j2ee/letter.tex.ft
================================================
\documentclass[a4paper,11pt]{letter}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\address{Your name\\Your address\\Your phone number}
\signature{Your name}
\begin{document}
\begin{letter}{Destination\\Address of the destination\\Phone number of the destination}
\opening{Dear Sir,}
% corps of the letter
\closing{Yours sincerely,}
%\cc{Other destination}
%\ps{PS: PostScriptum}
%\encl{Enclosures}
\end{letter}
\end{document}
================================================
FILE: resources/fileTemplates/j2ee/presentation.tex.ft
================================================
\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\title{}
\author{}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}
================================================
FILE: resources/fileTemplates/j2ee/report.tex.ft
================================================
\documentclass[a4paper,11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\title{}
\author{}
\begin{document}
\maketitle
\tableofcontents
\begin{abstract}
\end{abstract}
\chapter{}
\end{document}
================================================
FILE: resources/messages/LatexBundle.properties
================================================
editor.align_left=Align left
editor.align_right=Align right
editor.align_center=Align center
editor.bold=Bold
editor.image=Insert image
editor.image.dialog.browse=LaTeX - Browse Image
editor.image.dialog.title=LaTeX - Insert Image
editor.italic=Italic
editor.matrix=Insert matrix
editor.matrix.dialog.title=LaTeX - Insert Matrix
editor.table=Insert table
editor.table.dialog.title=LaTeX - Insert Table
editor.underline=Underline
colorSettings.displayName=LaTeX
highlighter.instruction=Instruction
highlighter.argument=Argument
highlighter.bracket=Brackets
highlighter.comment=Comment
folding.placeholder=...
form.rows=Rows\:
form.columns=Columns\:
form.alignment=Alignment\:
form.alignment.left=left
form.alignment.center=center
form.alignment.right=right
form.border=Border\:
form.border.none=none
form.border.table=table
form.border.cell=cell
form.bracket=Bracket\:
form.bracket.none=none
form.bracket.parentheses=parentheses
form.bracket.brackets=brackets
form.bracket.braces=braces
form.bracket.single_line=single line
form.bracket.double_line=double line
action.create.file=LaTeX file
action.create.file.description=Creates new LaTeX file
action.create.file.kind.empty=empty
action.create.file.kind.article=article
action.create.file.kind.report=report
action.create.file.kind.book=book
action.create.file.kind.letter=letter
action.create.file.kind.presentation=presentation
file.template.group.title=LaTeX
update.title=<b>LaTeX</b> plugin updated to v{0}
notification.update.content=<br/>\
If you find my plugin helpful, <b><a href="https://www.paypal.me/hsz">Donate with PayPal</a></b><br/><br/>\
Features:<br/>\
- ... (<a href="https://github.com/hsz/idea-latex/issues/0">0</a>)<br/>\
<br/>\
Fixes:<br/>\
- ... (<a href="https://github.com/hsz/idea-latex/issues/0">0</a>)<br/>\
<br/>\
If you find my plugin helpful, donate me using <br/><b><a href="https://www.paypal.me/hsz">Donate with PayPal</a></b>
================================================
FILE: resources/sample.tex
================================================
\documentclass[12pt]{article}
\usepackage{amsmath}
\title{\LaTeX}
\date{}
\begin{document}
\maketitle
\LaTeX{} is a document preparation system for the \TeX{}
typesetting program. It offers programmable desktop
publishing features and extensive facilities for
automating most aspects of typesetting and desktop
publishing, including numbering and cross-referencing,
tables and figures, page layout, bibliographies, and
much more. \LaTeX{} was originally written in 1984 by
Leslie Lamport and has become the dominant method for
using \TeX; few people write in plain \TeX{} anymore.
The current version is \LaTeXe.
% This is a comment, not shown in final output.
% The following shows typesetting power of LaTeX:
\begin{align}
E_0 &= mc^2 \\
E &= \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}}
\end{align}
\end{document}
================================================
FILE: settings.gradle
================================================
rootProject.name = 'idea-latex'
================================================
FILE: src/mobi/hsz/idea/latex/LatexApplicationComponent.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
import mobi.hsz.idea.latex.settings.LatexSettings;
import mobi.hsz.idea.latex.util.Utils;
import org.jetbrains.annotations.NotNull;
/**
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
public class LatexApplicationComponent implements ApplicationComponent {
/** Plugin has been updated with the current run. */
private boolean updated;
/** Plugin update notification has been shown. */
private boolean updateNotificationShown;
/**
* Get Ignore Application Component
*
* @return Ignore Application Component
*/
@NotNull
public static LatexApplicationComponent getInstance() {
return ApplicationManager.getApplication().getComponent(LatexApplicationComponent.class);
}
/** Component initialization method. */
@Override
public void initComponent() {
/* The settings storage object. */
LatexSettings settings = LatexSettings.getInstance();
updated = !Utils.getVersion().equals(settings.getVersion());
if (updated) {
settings.setVersion(Utils.getVersion());
}
}
/** Component dispose method. */
@Override
public void disposeComponent() {
}
/**
* Returns component's name.
*
* @return component's name
*/
@NotNull
@Override
public String getComponentName() {
return "LatexApplicationComponent";
}
/**
* Checks if plugin was updated in the current run.
*
* @return plugin was updated
*/
public boolean isUpdated() {
return updated;
}
/**
* Checks if update notification was shown.
*
* @return notification shown
*/
public boolean isUpdateNotificationShown() {
return updateNotificationShown;
}
/**
* Sets update notification shown status.
*
* @param shown notification
*/
public void setUpdateNotificationShown(boolean shown) {
this.updateNotificationShown = shown;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/LatexBundle.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex;
import com.intellij.CommonBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.PropertyKey;
import java.util.ResourceBundle;
/**
* {@link java.util.ResourceBundle}/localization utils for the LaTeX plugin.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexBundle {
/** Gitignore plugin ID. */
@NonNls
public static final String PLUGIN_ID = "mobi.hsz.idea.latex";
/** The {@link java.util.ResourceBundle} path. */
@NonNls
private static final String BUNDLE_NAME = "messages.LatexBundle";
/** The {@link java.util.ResourceBundle} instance. */
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
/** Plugin name. */
@NonNls
public static final String NAME = "LaTeX";
/** {@link LatexBundle} is a non-instantiable static class. */
private LatexBundle() {
}
/**
* Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
*
* @param key the key of the resource
* @param params the optional parameters for the specific resource
* @return the {@link String} value or {@code null} if no resource found for the key
*/
public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
return CommonBundle.message(BUNDLE, key, params);
}
/**
* Loads a {@link String} from the {@link #BUNDLE} {@link java.util.ResourceBundle}.
*
* @param key the key of the resource
* @param defaultValue the default value that will be returned if there is nothing set
* @param params the optional parameters for the specific resource
* @return the {@link String} value or {@code null} if no resource found for the key
*/
public static String messageOrDefault(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, String defaultValue, Object... params) {
return CommonBundle.messageOrDefault(BUNDLE, key, defaultValue, params);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/LatexUpdateComponent.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex;
import com.intellij.notification.*;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.project.Project;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.util.Utils;
import org.jetbrains.annotations.NotNull;
/**
* {@link ProjectComponent} instance to display plugin's update information.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
public class LatexUpdateComponent extends AbstractProjectComponent {
/** {@link LatexApplicationComponent} instance. */
private LatexApplicationComponent application;
/** Constructor. */
protected LatexUpdateComponent(Project project) {
super(project);
}
/** Component initialization method. */
@Override
public void initComponent() {
application = LatexApplicationComponent.getInstance();
}
/** Component dispose method. */
@Override
public void disposeComponent() {
}
/**
* Returns component's name.
*
* @return component's name
*/
@NotNull
@Override
public String getComponentName() {
return "LatexUpdateComponent";
}
/** Method called when project is opened. */
@Override
public void projectOpened() {
if (application.isUpdated() && !application.isUpdateNotificationShown()) {
application.setUpdateNotificationShown(true);
NotificationGroup group = new NotificationGroup(LatexLanguage.GROUP, NotificationDisplayType.TOOL_WINDOW, true);
Notification notification = group.createNotification(
LatexBundle.message("update.title", Utils.getVersion()),
LatexBundle.message("update.content"),
NotificationType.INFORMATION,
NotificationListener.URL_OPENING_LISTENER
);
Notifications.Bus.notify(notification, myProject);
}
}
/** Method called when project is closed. */
@Override
public void projectClosed() {
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions;
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.ide.actions.CreateFromTemplateAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.Nullable;
/**
* New file action
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class CreateLatexFileAction extends CreateFromTemplateAction<LatexFile> implements DumbAware {
public CreateLatexFileAction() {
super(LatexBundle.message("action.create.file"), LatexBundle.message("action.create.file.description"), Icons.FILE);
}
@Override
protected String getDefaultTemplateProperty() {
return LatexTemplates.LATEX_EMPTY;
}
@Nullable
@Override
protected LatexFile createFile(String name, String templateName, PsiDirectory dir) {
String filename = name.endsWith("." + LatexLanguage.EXTENSION) ? name : name + "." + LatexLanguage.EXTENSION;
return LatexTemplatesFactory.createFromTemplate(dir, name, filename, templateName, true);
}
@Override
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
builder
.setTitle(LatexBundle.message("action.create.file"))
.addKind(LatexBundle.message("action.create.file.kind.empty"), Icons.FILE, LatexTemplates.LATEX_EMPTY)
.addKind(LatexBundle.message("action.create.file.kind.article"), Icons.FILE, LatexTemplates.LATEX_ARTICLE)
.addKind(LatexBundle.message("action.create.file.kind.report"), Icons.FILE, LatexTemplates.LATEX_REPORT)
.addKind(LatexBundle.message("action.create.file.kind.book"), Icons.FILE, LatexTemplates.LATEX_BOOK)
.addKind(LatexBundle.message("action.create.file.kind.letter"), Icons.FILE, LatexTemplates.LATEX_LETTER)
.addKind(LatexBundle.message("action.create.file.kind.presentation"), Icons.FILE, LatexTemplates.LATEX_PRESENTATION);
}
@Override
protected String getActionName(PsiDirectory directory, String newName, String templateName) {
return LatexBundle.message("action.create.file");
}
@Override
public boolean equals(Object obj) {
return obj instanceof CreateLatexFileAction;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/LatexTemplates.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions;
import org.jetbrains.annotations.NonNls;
/**
* LaTeX files templates.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexTemplates {
@NonNls public static final String LATEX_EMPTY = "empty.tex";
@NonNls public static final String LATEX_ARTICLE = "article.tex";
@NonNls public static final String LATEX_REPORT = "report.tex";
@NonNls public static final String LATEX_BOOK = "book.tex";
@NonNls public static final String LATEX_LETTER = "letter.tex";
@NonNls public static final String LATEX_PRESENTATION = "presentation.tex";
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/LatexTemplatesFactory.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions;
import com.intellij.codeInsight.actions.ReformatCodeProcessor;
import com.intellij.ide.fileTemplates.*;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiFileFactory;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.file.LatexFileType;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Properties;
/**
* LaTeX files templates factory.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexTemplatesFactory implements FileTemplateGroupDescriptorFactory {
@NonNls
public static final String[] TEMPLATES = {
LatexTemplates.LATEX_EMPTY, LatexTemplates.LATEX_ARTICLE, LatexTemplates.LATEX_REPORT,
LatexTemplates.LATEX_BOOK, LatexTemplates.LATEX_LETTER, LatexTemplates.LATEX_PRESENTATION,
};
private final ArrayList<String> myCustomTemplates = new ArrayList<String>();
private static class LatexTemplatesFactoryHolder {
private static final LatexTemplatesFactory myInstance = new LatexTemplatesFactory();
}
public static LatexTemplatesFactory getInstance() {
return LatexTemplatesFactoryHolder.myInstance;
}
public void registerCustromTemplates(String... templates) {
Collections.addAll(myCustomTemplates, templates);
}
@Override
public FileTemplateGroupDescriptor getFileTemplatesDescriptor() {
final FileTemplateGroupDescriptor group = new FileTemplateGroupDescriptor(LatexBundle.message("file.template.group.title"), Icons.FILE);
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
for (String template : TEMPLATES) {
group.addTemplate(new FileTemplateDescriptor(template, fileTypeManager.getFileTypeByFileName(template).getIcon()));
}
// register custom templates
for (String template : getInstance().getCustomTemplates()) {
group.addTemplate(new FileTemplateDescriptor(template, fileTypeManager.getFileTypeByFileName(template).getIcon()));
}
return group;
}
public static LatexFile createFromTemplate(@NotNull final PsiDirectory directory, @NotNull final String name,
@NotNull String fileName, @NotNull String templateName, boolean allowReformatting,
@NonNls String... parameters) throws IncorrectOperationException {
final FileTemplate template = FileTemplateManager.getInstance(directory.getProject()).getInternalTemplate(templateName);
Project project = directory.getProject();
Properties properties = new Properties(FileTemplateManager.getInstance(project).getDefaultProperties());
// JavaTemplateUtil.setPackageNameAttribute(properties, directory);
// properties.setProperty(NAME_TEMPLATE_PROPERTY, name);
// properties.setProperty(LOW_CASE_NAME_TEMPLATE_PROPERTY, name.substring(0, 1).toLowerCase() + name.substring(1));
for (int i = 0; i < parameters.length; i += 2) {
properties.setProperty(parameters[i], parameters[i + 1]);
}
String text;
try {
text = template.getText(properties);
} catch (Exception e) {
throw new RuntimeException("Unable to load template for " + FileTemplateManager.getInstance(project).internalTemplateToSubject(templateName), e);
}
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
PsiFile file = factory.createFileFromText(fileName, LatexFileType.INSTANCE, text);
file = (PsiFile) directory.add(file);
if (file != null && allowReformatting && template.isReformatCode()) {
new ReformatCodeProcessor(project, file, null, false).run();
}
return (LatexFile) file;
}
public String[] getCustomTemplates() {
return ArrayUtil.toStringArray(myCustomTemplates);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/AlignCenterAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
/**
* Editor action - align center.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public class AlignCenterAction extends WrapEditorAction {
/** Builds a new instance of {@link AlignCenterAction}. */
public AlignCenterAction() {
super(Type.ALIGN_CENTER, LatexBundle.message("editor.align_center"), Icons.Editor.ALIGN_CENTER);
}
@NotNull
@Override
public String getLeftText() {
return "\\begin{center}";
}
@NotNull
@Override
public String getRightText() {
return "\\end{center}";
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/AlignLeftAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
/**
* Editor action - align left.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public class AlignLeftAction extends WrapEditorAction {
/** Builds a new instance of {@link AlignLeftAction}. */
public AlignLeftAction() {
super(Type.ALIGN_LEFT, LatexBundle.message("editor.align_left"), Icons.Editor.ALIGN_LEFT);
}
@NotNull
@Override
public String getLeftText() {
return "\\begin{flushleft}";
}
@NotNull
@Override
public String getRightText() {
return "\\end{flushleft}";
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/AlignRightAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
/**
* Editor action - align right.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public class AlignRightAction extends WrapEditorAction {
/** Builds a new instance of {@link AlignRightAction}. */
public AlignRightAction() {
super(Type.ALIGN_RIGHT, LatexBundle.message("editor.align_right"), Icons.Editor.ALIGN_RIGHT);
}
@NotNull
@Override
public String getLeftText() {
return "\\begin{flushright}";
}
@NotNull
@Override
public String getRightText() {
return "\\end{flushright}";
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/BoldAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor;
import com.intellij.psi.PsiElement;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;
import mobi.hsz.idea.latex.psi.LatexInstruction;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
/**
* Editor action - bold text.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public class BoldAction extends WrapEditorAction {
private static final String IDENTIFIER = "\\textbf";
/** Builds a new instance of {@link BoldAction}. */
public BoldAction() {
super(Type.BOLD, LatexBundle.message("editor.bold"), Icons.Editor.BOLD);
}
@Override
public boolean isMatching(@NotNull PsiElement element) {
return element instanceof LatexInstruction && ((LatexInstruction) element).getIdentifier().getText().equals(IDENTIFIER);
}
@NotNull
@Override
public String getLeftText() {
return IDENTIFIER + "{";
}
@NotNull
@Override
public String getRightText() {
return "}";
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/ImageAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.actions.editor.base.DialogEditorAction;
import mobi.hsz.idea.latex.ui.ImageEditorActionDialog;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
/**
* Editor action - insert image.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class ImageAction extends DialogEditorAction<ImageEditorActionDialog> {
/** Builds a new instance of {@link ImageAction}. */
public ImageAction() {
super(Type.IMAGE, LatexBundle.message("editor.image"), Icons.Editor.IMAGE);
}
@NotNull
@Override
protected ImageEditorActionDialog getDialog(@NotNull Project project) {
return new ImageEditorActionDialog(project);
}
@NotNull
@Override
protected String getContent(@NotNull ImageEditorActionDialog dialog) {
StringBuilder sb = new StringBuilder();
String path = dialog.getPath();
String caption = dialog.getCaption();
String label = dialog.getLabel();
sb.append("\\begin{figure}\n");
sb.append("\\centering\n");
sb.append("\\includegraphics");
sb.append(String.format("{%s}\n", path));
if (!StringUtil.isEmpty(caption)) {
sb.append(String.format("\\caption{%s}\n", caption));
}
if (!StringUtil.isEmpty(label)) {
sb.append(String.format("\\label{%s}\n", label));
}
sb.append("\\end{figure}");
return sb.toString();
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/ItalicAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor;
import com.intellij.psi.PsiElement;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;
import mobi.hsz.idea.latex.psi.LatexInstruction;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
/**
* Editor action - italicize text.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public class ItalicAction extends WrapEditorAction {
private static final String IDENTIFIER = "\\textit";
/** Builds a new instance of {@link ItalicAction}. */
public ItalicAction() {
super(Type.ITALIC, LatexBundle.message("editor.italic"), Icons.Editor.ITALIC);
}
@Override
public boolean isMatching(@NotNull PsiElement element) {
return element instanceof LatexInstruction && ((LatexInstruction) element).getIdentifier().getText().equals(IDENTIFIER);
}
@NotNull
@Override
public String getLeftText() {
return IDENTIFIER + "{";
}
@NotNull
@Override
public String getRightText() {
return "}";
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/MatrixAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor;
import com.intellij.openapi.project.Project;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.actions.editor.base.DialogEditorAction;
import mobi.hsz.idea.latex.ui.MatrixEditorActionDialog;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
/**
* Editor action - insert matrix.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class MatrixAction extends DialogEditorAction<MatrixEditorActionDialog> {
/** Builds a new instance of {@link MatrixAction}. */
public MatrixAction() {
super(Type.MATRIX, LatexBundle.message("editor.matrix"), Icons.Editor.MATRIX);
}
@NotNull
@Override
protected MatrixEditorActionDialog getDialog(@NotNull Project project) {
return new MatrixEditorActionDialog(project);
}
@NotNull
@Override
protected String getContent(@NotNull MatrixEditorActionDialog dialog) {
StringBuilder sb = new StringBuilder();
int rows = dialog.getRows();
int columns = dialog.getColumns();
char bracket = dialog.getBracket().getValue();
sb.append(String.format("$\\begin{%cmatrix}\n", bracket));
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= columns; j++) {
sb.append(String.format("%d%d%s", i, j, j == columns ? "\\\\\n" : " & "));
}
}
sb.append(String.format("\\end{%cmatrix}", bracket));
return sb.toString();
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/TableAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.actions.editor.base.DialogEditorAction;
import mobi.hsz.idea.latex.ui.TableEditorActionDialog;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
/**
* Editor action - insert table.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class TableAction extends DialogEditorAction<TableEditorActionDialog> {
/**
* Builds a new instance of {@link TableAction}.
*/
public TableAction() {
super(Type.TABLE, LatexBundle.message("editor.table"), Icons.Editor.TABLE);
}
@NotNull
@Override
protected TableEditorActionDialog getDialog(@NotNull Project project) {
return new TableEditorActionDialog(project);
}
@NotNull
@Override
protected String getContent(@NotNull TableEditorActionDialog dialog) {
StringBuilder sb = new StringBuilder();
int rows = dialog.getRows();
int columns = dialog.getColumns();
String alignmentValue = StringUtil.repeatSymbol(dialog.getAlignment().getValue(), columns);
String tableBorder = dialog.getBorder().isNone() ? "" : "|";
String cellBorder = dialog.getBorder().isCell() ? "\\hline\n" : "";
sb.append(String.format("\\begin{tabular}{%s%s%s}\n", tableBorder, alignmentValue, tableBorder));
sb.append(cellBorder);
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= columns; j++) {
sb.append(String.format("%d%d%s", i, j, j == columns ? "\\\\\n" : " & "));
}
sb.append(cellBorder);
}
sb.append("\\end{tabular}");
return sb.toString();
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/UnderlineAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor;
import com.intellij.psi.PsiElement;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.actions.editor.base.WrapEditorAction;
import mobi.hsz.idea.latex.psi.LatexInstruction;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
/**
* Editor action - underline text.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public class UnderlineAction extends WrapEditorAction {
private static final String IDENTIFIER = "\\underline";
/** Builds a new instance of {@link UnderlineAction}. */
public UnderlineAction() {
super(Type.UNDERLINE, LatexBundle.message("editor.underline"), Icons.Editor.UNDERLINE);
}
@Override
public boolean isMatching(@NotNull PsiElement element) {
return element instanceof LatexInstruction && ((LatexInstruction) element).getIdentifier().getText().equals(IDENTIFIER);
}
@NotNull
@Override
public String getLeftText() {
return IDENTIFIER + "{";
}
@NotNull
@Override
public String getRightText() {
return "}";
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/base/DialogEditorAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor.base;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Toggleable;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public abstract class DialogEditorAction<T extends DialogWrapper> extends EditorAction implements Toggleable {
/** Builds a new instance of {@link DialogEditorAction}. */
public DialogEditorAction(@NotNull Type type, @NotNull String name, @NotNull Icon icon) {
super(type, name, icon);
}
@Override
protected void actionPerformed(@NotNull AnActionEvent event, @NotNull final Project project, @NotNull VirtualFile virtualFile, @NotNull final TextEditor editor) {
final T dialog = getDialog(project);
if (dialog.showAndGet()) {
runWriteAction(project, getDialogAction(dialog, editor));
}
}
@NotNull
protected abstract T getDialog(@NotNull Project project);
@NotNull
protected abstract String getContent(@NotNull T dialog);
@NotNull
protected Runnable getDialogAction(@NotNull final T dialog, @NotNull final TextEditor editor) {
return new Runnable() {
@Override
public void run() {
final Document document = editor.getEditor().getDocument();
final CaretModel caretModel = editor.getEditor().getCaretModel();
final String content = getContent(dialog);
int offset = caretModel.getOffset();
document.insertString(offset, content);
caretModel.moveToOffset(offset + content.length());
}
};
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/base/EditorAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor.base;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.psi.LatexFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* Editor action - abstract wrap selection action.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public abstract class EditorAction extends AnAction implements DumbAware {
/**
* Available editor's types.
*/
public enum Type {
BOLD, ITALIC, UNDERLINE,
ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT,
IMAGE, MATRIX, TABLE,
}
/**
* Editor action's type.
*/
private final Type type;
/**
* Editor action's name.
*/
private final String name;
/**
* Builds a new instance of {@link EditorAction}.
*/
EditorAction(@NotNull Type type, @NotNull String name, @NotNull Icon icon) {
super(name, null, icon);
this.type = type;
this.name = name;
}
/**
* Action handler.
*
* @param event Carries information on the invocation place
*/
@Override
final public void actionPerformed(AnActionEvent event) {
final VirtualFile virtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE);
final Project project = event.getData(CommonDataKeys.PROJECT);
final TextEditor editor = getEditor(event);
if (virtualFile == null || project == null || editor == null) {
return;
}
actionPerformed(event, project, virtualFile, editor);
}
/**
* Handles actionPerformed event of the editor action item.
*
* @param event action event
* @param project current project
* @param virtualFile current file
* @param editor current editor
*/
protected void actionPerformed(@NotNull AnActionEvent event, @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull TextEditor editor) {
}
@Override
final public void update(AnActionEvent event) {
final VirtualFile virtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE);
final Project project = event.getData(CommonDataKeys.PROJECT);
final TextEditor editor = getEditor(event);
if (virtualFile == null || project == null || editor == null) {
return;
}
update(event, project, virtualFile, editor);
}
/**
* Handles update event of the editor action item.
*
* @param event action event
* @param project current project
* @param virtualFile current file
* @param editor current editor
*/
protected void update(AnActionEvent event, @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull TextEditor editor) {
}
/**
* Returns current active {@link TextEditor} instance or null.
*
* @param project current project
* @return active {@link TextEditor}
*/
@Nullable
private static TextEditor getActiveEditor(Project project) {
if (project != null) {
FileEditor[] fileEditors = FileEditorManager.getInstance(project).getSelectedEditors();
for (FileEditor fileEditor : fileEditors) {
if (fileEditor instanceof TextEditor) {
return (TextEditor) fileEditor;
}
}
}
return null;
}
/**
* Returns {@link TextEditor} from witch action was called or null.
*
* @param e action event
* @return active {@link TextEditor}
*/
@Nullable
private static TextEditor getEditor(AnActionEvent e) {
FileEditor fileEditor = e.getData(PlatformDataKeys.FILE_EDITOR);
if (fileEditor instanceof TextEditor) {
return (TextEditor) fileEditor;
} else {
return getActiveEditor(e.getProject());
}
}
/**
* Returns the currently selected {@link PsiElement}.
*
* @param virtualFile Current file.
* @param project Current project.
* @param editor Current editor.
* @return Currently selected {@link PsiElement}.
*/
@Nullable
protected PsiElement getCurrentElement(@Nullable final VirtualFile virtualFile, @Nullable final Project project, @Nullable TextEditor editor) {
if (virtualFile == null || project == null || editor == null) {
return null;
}
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
if (file == null || !(file instanceof LatexFile)) {
return null;
}
int offset = editor.getEditor().getCaretModel().getOffset();
return file.findElementAt(offset);
}
/**
* Checks if element matches to the related one.
*
* @param element to check
* @return action's element type
*/
public boolean isMatching(@NotNull PsiElement element) {
return false;
}
/**
* Checks if action related type matched to the given element in document.
*
* @param element to check
* @return element matches to the action related type
*/
@Nullable
protected PsiElement getMatchedElement(@Nullable PsiElement element) {
while (element != null && !(element instanceof LatexFile)) {
if (isMatching(element)) {
return element;
}
element = element.getParent();
}
return null;
}
/**
* Runs write action.
*
* @param project current project
* @param action to run
*/
final protected void runWriteAction(@NotNull final Project project, @NotNull final Runnable action) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
CommandProcessor.getInstance().executeCommand(project, action, getName(), LatexBundle.NAME);
}
});
}
/**
* Returns current editor action's type.
*/
@NotNull
public Type getType() {
return type;
}
/**
* Returns current editor action's name.
*/
@NotNull
public String getName() {
return name;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/base/EditorActionsFactory.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor.base;
import mobi.hsz.idea.latex.actions.editor.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Factory for creating LaTeX editor's actions.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public final class EditorActionsFactory {
/**
* Creates proper {@link EditorAction} instance basing on given {@link EditorAction.Type}.
*
* @return LaTeX editor toolbar action.
*/
@Nullable
public static EditorAction create(@NotNull EditorAction.Type type) {
switch (type) {
case BOLD: return new BoldAction();
case ITALIC: return new ItalicAction();
case UNDERLINE: return new UnderlineAction();
case ALIGN_LEFT: return new AlignLeftAction();
case ALIGN_CENTER: return new AlignCenterAction();
case ALIGN_RIGHT: return new AlignRightAction();
case IMAGE: return new ImageAction();
case MATRIX: return new MatrixAction();
case TABLE: return new TableAction();
}
return null;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/base/InsertEditorAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor.base;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Toggleable;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public abstract class InsertEditorAction extends EditorAction implements Toggleable {
/** Builds a new instance of {@link InsertEditorAction}. */
public InsertEditorAction(@NotNull Type type, @NotNull String name, @NotNull Icon icon) {
super(type, name, icon);
}
@Override
protected void actionPerformed(@NotNull AnActionEvent event, @NotNull final Project project, @NotNull VirtualFile virtualFile, @NotNull final TextEditor editor) {
runWriteAction(project, new Runnable() {
@Override
public void run() {
final Document document = editor.getEditor().getDocument();
final CaretModel caretModel = editor.getEditor().getCaretModel();
int offset = caretModel.getOffset();
String text = getText();
document.insertString(offset, text);
caretModel.moveToOffset(offset + text.length());
}
});
}
/**
* Returns text to insert.
*
* @return text to insert
*/
@NotNull
protected abstract String getText();
}
================================================
FILE: src/mobi/hsz/idea/latex/actions/editor/base/WrapEditorAction.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.actions.editor.base;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Toggleable;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public abstract class WrapEditorAction extends EditorAction implements Toggleable {
/**
* Builds a new instance of {@link WrapEditorAction}.
*/
public WrapEditorAction(@NotNull Type type, @NotNull String name, @NotNull Icon icon) {
super(type, name, icon);
}
/**
* Writes content to the current document.
*
* @param event action event
* @param project current project
* @param virtualFile current file
* @param editor current editor
*/
@Override
protected void actionPerformed(@NotNull AnActionEvent event, @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull final TextEditor editor) {
PsiElement element = getCurrentElement(virtualFile, project, editor);
final PsiElement matched = getMatchedElement(element);
runWriteAction(project, new Runnable() {
@Override
public void run() {
if (matched == null) {
wrap(editor);
} else {
unwrap(editor, matched);
}
}
});
}
/**
* Updates the state of the action.
*
* @param event Carries information on the invocation place and data available
*/
@Override
protected void update(AnActionEvent event, @NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull TextEditor editor) {
PsiElement element = getCurrentElement(virtualFile, project, editor);
PsiElement matched = getMatchedElement(element);
event.getPresentation().putClientProperty(SELECTED_PROPERTY, matched != null);
}
/**
* Wraps selection.
*
* @param editor Current editor.
*/
private void wrap(@NotNull TextEditor editor) {
final Document document = editor.getEditor().getDocument();
final SelectionModel selectionModel = editor.getEditor().getSelectionModel();
final CaretModel caretModel = editor.getEditor().getCaretModel();
final int start = selectionModel.getSelectionStart();
final int end = selectionModel.getSelectionEnd();
final String text = StringUtil.notNullize(selectionModel.getSelectedText());
String newText = getLeftText() + text + getRightText();
int newStart = start + getLeftText().length();
int newEnd = StringUtil.isEmpty(text) ? newStart : end + getLeftText().length();
document.replaceString(start, end, newText);
selectionModel.setSelection(newStart, newEnd);
caretModel.moveToOffset(newEnd);
}
/**
* Unwraps selection.
*
* @param editor Current editor.
* @param matched Matched PSI element.
*/
private void unwrap(@NotNull final TextEditor editor, @NotNull final PsiElement matched) {
final Document document = editor.getEditor().getDocument();
final SelectionModel selectionModel = editor.getEditor().getSelectionModel();
final CaretModel caretModel = editor.getEditor().getCaretModel();
final int start = matched.getTextRange().getStartOffset();
final int end = matched.getTextRange().getEndOffset();
final String text = StringUtil.notNullize(matched.getText());
String newText = StringUtil.trimEnd(StringUtil.trimStart(text, getLeftText()), getRightText());
int newStart = selectionModel.getSelectionStart() - getLeftText().length();
int newEnd = selectionModel.getSelectionEnd() - getLeftText().length();
document.replaceString(start, end, newText);
selectionModel.setSelection(newStart, newEnd);
caretModel.moveToOffset(newEnd);
}
/**
* Returns left part of the wrapping text.
*
* @return left part
*/
@NotNull
public abstract String getLeftText();
/**
* Returns right part of the wrapping text.
*
* @return right part
*/
@NotNull
public abstract String getRightText();
}
================================================
FILE: src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleMainPanel.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.codeStyle;
import com.intellij.application.options.TabbedLanguageCodeStylePanel;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import mobi.hsz.idea.latex.lang.LatexLanguage;
/**
* LaTeX {@link TabbedLanguageCodeStylePanel} implementation of the main panel.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexCodeStyleMainPanel extends TabbedLanguageCodeStylePanel {
protected LatexCodeStyleMainPanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) {
super(LatexLanguage.INSTANCE, currentSettings, settings);
}
@Override
protected void initTabs(CodeStyleSettings settings) {
super.initTabs(settings);
// addTab(new GrCodeStyleImportsPanelWrapper(settings));
}
}
================================================
FILE: src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleSettings.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.codeStyle;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CustomCodeStyleSettings;
import org.jetbrains.annotations.NotNull;
/**
* LaTeX {@link CustomCodeStyleSettings} implementation.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexCodeStyleSettings extends CustomCodeStyleSettings {
protected LatexCodeStyleSettings(@NotNull CodeStyleSettings container) {
super("LatexCodeStyleSettings", container);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleSettingsProvider.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.codeStyle;
import com.intellij.application.options.CodeStyleAbstractConfigurable;
import com.intellij.application.options.CodeStyleAbstractPanel;
import com.intellij.openapi.options.Configurable;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider;
import com.intellij.psi.codeStyle.CustomCodeStyleSettings;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* LaTeX {@link CodeStyleSettingsProvider} implementation.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
@NotNull
@Override
public Configurable createSettingsPage(CodeStyleSettings settings, CodeStyleSettings originalSettings) {
return new CodeStyleAbstractConfigurable(settings, originalSettings, LatexLanguage.NAME) {
@Override
protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) {
return new LatexCodeStyleMainPanel(getCurrentSettings(), settings);
}
@Override
public String getHelpTopic() {
return "reference.settingsdialog.codestyle." + LatexLanguage.NAME.toLowerCase();
}
};
}
@Nullable
@Override
public String getConfigurableDisplayName() {
return LatexLanguage.NAME;
}
@Nullable
@Override
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
return new LatexCodeStyleSettings(settings);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/codeStyle/LatexLanguageCodeStyleSettingsProvider.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.codeStyle;
import com.intellij.application.options.IndentOptionsEditor;
import com.intellij.application.options.SmartIndentOptionsEditor;
import com.intellij.lang.Language;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.util.Resources;
import org.jetbrains.annotations.NotNull;
/**
* LaTeX {@link LanguageCodeStyleSettingsProvider} implementation.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
@NotNull
@Override
public Language getLanguage() {
return LatexLanguage.INSTANCE;
}
@Override
public CommonCodeStyleSettings getDefaultCommonSettings() {
CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(LatexLanguage.INSTANCE);
defaultSettings.initIndentOptions();
// defaultSettings.SPACE_WITHIN_BRACES = true;
// defaultSettings.KEEP_SIMPLE_CLASSES_IN_ONE_LINE = true;
// defaultSettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
return defaultSettings;
}
@Override
public String getCodeSample(@NotNull SettingsType settingsType) {
switch (settingsType) {
case INDENT_SETTINGS:
case SPACING_SETTINGS:
case WRAPPING_AND_BRACES_SETTINGS:
case BLANK_LINES_SETTINGS:
return Resources.getResourceContent("/codeStyle/preview/" + settingsType.name().toLowerCase() + ".tex.ft");
default: return "foo";
}
}
@Override
public IndentOptionsEditor getIndentOptionsEditor() {
return new SmartIndentOptionsEditor();
}
}
================================================
FILE: src/mobi/hsz/idea/latex/editor/LatexEditorActionsLoaderComponent.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.editor;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import mobi.hsz.idea.latex.file.LatexFileType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* Component loader for editor actions toolbar.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexEditorActionsLoaderComponent extends AbstractProjectComponent {
/** Constructor. */
public LatexEditorActionsLoaderComponent(@NotNull final Project project) {
super(project);
}
/**
* Returns component name.
*
* @return component name
*/
@Override
@NonNls
@NotNull
public String getComponentName() {
return "LatexEditorActionsLoaderComponent";
}
/** Initializes component. */
@Override
public void initComponent() {
myProject.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new LatexEditorManagerListener());
}
/** Listener for LaTeX editor manager. */
private static class LatexEditorManagerListener extends FileEditorManagerAdapter {
/**
* Handles file opening event and attaches LaTeX editor component.
*
* @param source editor manager
* @param file current file
*/
@Override
public void fileOpened(@NotNull final FileEditorManager source, @NotNull final VirtualFile file) {
FileType fileType = file.getFileType();
if (!(fileType instanceof LatexFileType)) {
return;
}
for (final FileEditor fileEditor : source.getEditors(file)) {
if (fileEditor instanceof TextEditor) {
final LatexEditorActionsWrapper wrapper = new LatexEditorActionsWrapper(fileEditor);
final JComponent c = wrapper.getComponent();
source.addTopComponent(fileEditor, c);
Disposer.register(fileEditor, wrapper);
Disposer.register(fileEditor, new Disposable() {
@Override
public void dispose() {
source.removeTopComponent(fileEditor, c);
}
});
}
}
}
}
}
================================================
FILE: src/mobi/hsz/idea/latex/editor/LatexEditorActionsWrapper.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.editor;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.fileEditor.FileEditor;
import mobi.hsz.idea.latex.actions.editor.base.EditorActionsFactory;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import static mobi.hsz.idea.latex.actions.editor.base.EditorAction.Type.*;
/**
* Wrapper that creates bottom editor component for displaying outer ignore rules.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
class LatexEditorActionsWrapper implements Disposable {
private final ActionToolbar actionToolbar;
LatexEditorActionsWrapper(@NotNull FileEditor fileEditor) {
DefaultActionGroup actions = new DefaultActionGroup();
actions.addAll(
EditorActionsFactory.create(BOLD),
EditorActionsFactory.create(ITALIC),
EditorActionsFactory.create(UNDERLINE),
Separator.getInstance(),
EditorActionsFactory.create(ALIGN_LEFT),
EditorActionsFactory.create(ALIGN_CENTER),
EditorActionsFactory.create(ALIGN_RIGHT),
Separator.getInstance(),
EditorActionsFactory.create(IMAGE),
EditorActionsFactory.create(TABLE),
EditorActionsFactory.create(MATRIX)
);
actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.EDITOR_TAB, actions, true);
actionToolbar.setMinimumButtonSize(ActionToolbar.NAVBAR_MINIMUM_BUTTON_SIZE);
actionToolbar.setTargetComponent(fileEditor.getComponent());
}
/**
* Returns outer panel.
*
* @return outer panel
*/
@NotNull
JComponent getComponent() {
return actionToolbar.getComponent();
}
@Override
public void dispose() {
}
}
================================================
FILE: src/mobi/hsz/idea/latex/file/LatexFileType.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.file;
import com.intellij.openapi.fileTypes.LanguageFileType;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.util.Icons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* Describes LaTeX file type.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexFileType extends LanguageFileType {
/** Contains {@link LatexFileType} singleton. */
public static final LatexFileType INSTANCE = new LatexFileType();
/** Private constructor to prevent direct object creation. */
private LatexFileType() {
super(LatexLanguage.INSTANCE);
}
/**
* Returns the name of the file type. The name must be unique among all file types registered in the system.
*
* @return The file type name.
*/
@NotNull
@Override
public String getName() {
return LatexLanguage.NAME + " file";
}
/**
* Returns the user-readable description of the file type.
*
* @return The file type description.
*/
@NotNull
@Override
public String getDescription() {
return LatexLanguage.NAME + " file";
}
/**
* Returns the default extension for files of the type.
*
* @return The extension, not including the leading '.'.
*/
@NotNull
@Override
public String getDefaultExtension() {
return LatexLanguage.EXTENSION;
}
/**
* Returns the icon used for showing files of the type.
*
* @return The icon instance, or null if no icon should be shown.
*/
@Nullable
@Override
public Icon getIcon() {
return Icons.FILE;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/file/LatexFileTypeFactory.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.file;
import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import org.jetbrains.annotations.NotNull;
/**
* Class that assigns file types with languages.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexFileTypeFactory extends FileTypeFactory {
/**
* Assigns file types with languages.
*
* @param consumer file types consumer
*/
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
consumer.consume(LatexFileType.INSTANCE, LatexLanguage.EXTENSION);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/folding/LatexFoldingBuilder.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.folding;
import com.intellij.lang.ASTNode;
import com.intellij.lang.folding.FoldingBuilder;
import com.intellij.lang.folding.FoldingDescriptor;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.psi.*;
import mobi.hsz.idea.latex.psi.impl.LatexSectionExtImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* LaTeX folding builder. Handles {@link LatexTypes#SECTION} folding.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public class LatexFoldingBuilder implements FoldingBuilder {
/** Descriptors collection. */
private final List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();
/** {@link LatexVisitor} instance to walk over all sections in the {@link PsiElement}. */
private final PsiElementVisitor visitor = new LatexVisitor() {
@Override
public void visitSection(@NotNull LatexSection section) {
LatexInstructionBegin begin = ((LatexSectionExtImpl) section).getBeginInstruction();
LatexInstructionEnd end = ((LatexSectionExtImpl) section).getEndInstruction();
if (begin == null || end == null) {
return;
}
int startOffset = begin.getTextOffset();
int endOffset = end.getTextOffset() + end.getTextLength();
if (endOffset - startOffset > 0) {
descriptors.add(new FoldingDescriptor(section, new TextRange(startOffset, endOffset)));
}
section.acceptChildren(visitor);
}
};
/**
* Builds the folding regions for the specified node in the AST tree and its children.
* Note that you can have several folding regions for one AST node, i.e. several {@link FoldingDescriptor} with similar AST node.
*
* @param node the node for which folding is requested.
* @param document the document for which folding is built. Can be used to retrieve line
* numbers for folding regions.
* @return the array of folding descriptors.
*/
@NotNull
public FoldingDescriptor[] buildFoldRegions(@NotNull final ASTNode node, @NotNull final Document document) {
descriptors.clear();
node.getPsi().acceptChildren(visitor);
return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
}
/**
* Returns the text which is displayed in the editor for the folding region related to the
* specified node when the folding region is collapsed.
*
* @param node the node for which the placeholder text is requested.
* @return the placeholder text.
*/
@Nullable
@Override
public String getPlaceholderText(@NotNull ASTNode node) {
return node.getFirstChildNode().getText() + LatexBundle.message("folding.placeholder");
}
/**
* Returns the default collapsed state for the folding region related to the specified node.
*
* @param node the node for which the collapsed state is requested.
* @return true if the region is collapsed by default, false otherwise.
*/
@Override
public boolean isCollapsedByDefault(@NotNull ASTNode node) {
return false;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/highlighter/LatexColorSettingsPage.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.highlighter;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.options.colors.AttributesDescriptor;
import com.intellij.openapi.options.colors.ColorDescriptor;
import com.intellij.openapi.options.colors.ColorSettingsPage;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.util.Icons;
import mobi.hsz.idea.latex.util.Resources;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Map;
/**
* {@link ColorSettingsPage} that allows to modify color scheme.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.2
*/
public class LatexColorSettingsPage implements ColorSettingsPage {
/** The path to the sample LaTeX file. */
@NonNls
private static final String SAMPLE_LATEX_PATH = "/sample.tex";
/** Display name for Color Settings Page. */
@NonNls
private static final String DISPLAY_NAME = LatexBundle.message("colorSettings.displayName");
/**
* The sample LaTeX document shown in the colors settings dialog.
*
* @see #loadSampleLatex()
*/
private static final String SAMPLE_LATEX = loadSampleLatex();
/** Attributes descriptor list. */
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[]{
new AttributesDescriptor(LatexBundle.message("highlighter.instruction"), LatexHighlighterColors.INSTRUCTION),
new AttributesDescriptor(LatexBundle.message("highlighter.argument"), LatexHighlighterColors.ARGUMENT),
new AttributesDescriptor(LatexBundle.message("highlighter.bracket"), LatexHighlighterColors.BRACKET),
new AttributesDescriptor(LatexBundle.message("highlighter.comment"), LatexHighlighterColors.COMMENT),
};
/**
* Returns the icon for the page, shown in the dialog tab.
*
* @return the icon for the page, or null if the page does not have a custom icon.
*/
@Nullable
@Override
public Icon getIcon() {
return Icons.FILE;
}
/**
* Returns the syntax highlighter which is used to highlight the text shown in the preview
* pane of the page.
*
* @return the syntax highlighter instance.
*/
@NotNull
@Override
public SyntaxHighlighter getHighlighter() {
return new LatexHighlighter(null, null);
}
/**
* Returns the text shown in the preview pane.
*
* @return demo text
*/
@NotNull
@Override
public String getDemoText() {
return SAMPLE_LATEX;
}
/**
* Returns the mapping from special tag names surrounding the regions to be highlighted
* in the preview text.
*
* @return <code>null</code>
*/
@Nullable
@Override
public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
return null;
}
/**
* Returns the list of descriptors specifying the {@link TextAttributesKey} instances
* for which colors are specified in the page. For such attribute keys, the user can choose
* all highlighting attributes (font type, background color, foreground color, error stripe color and
* effects).
*
* @return the list of attribute descriptors.
*/
@NotNull
@Override
public AttributesDescriptor[] getAttributeDescriptors() {
return DESCRIPTORS;
}
/**
* Returns the list of descriptors specifying the {@link com.intellij.openapi.editor.colors.ColorKey}
* instances for which colors are specified in the page. For such color keys, the user can
* choose only the background or foreground color.
*
* @return the list of color descriptors.
*/
@NotNull
@Override
public ColorDescriptor[] getColorDescriptors() {
return ColorDescriptor.EMPTY_ARRAY;
}
/**
* Returns the title of the page, shown as text in the dialog tab.
*
* @return the title of the custom page.
*/
@NotNull
@Override
public String getDisplayName() {
return DISPLAY_NAME;
}
/**
* Loads sample .gitignore file
*
* @return the text loaded from {@link #SAMPLE_LATEX_PATH}
* @see #getDemoText()
* @see #SAMPLE_LATEX_PATH
* @see #SAMPLE_LATEX
*/
private static String loadSampleLatex() {
return Resources.getResourceContent(SAMPLE_LATEX_PATH);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/highlighter/LatexHighlighter.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.highlighter;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.ContainerUtil;
import mobi.hsz.idea.latex.lang.LatexParserDefinition;
import mobi.hsz.idea.latex.lexer.LatexLexerAdapter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
/**
* Syntax highlighter definition.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
class LatexHighlighter extends SyntaxHighlighterBase {
/** Attributes map. */
private static final Map<IElementType, TextAttributesKey> ATTRIBUTES = ContainerUtil.newHashMap();
/** Binds parser definitions with highlighter colors. */
static {
SyntaxHighlighterBase.fillMap(ATTRIBUTES, LatexParserDefinition.COMMENTS, LatexHighlighterColors.COMMENT);
SyntaxHighlighterBase.fillMap(ATTRIBUTES, LatexParserDefinition.INSTRUCTIONS, LatexHighlighterColors.INSTRUCTION);
SyntaxHighlighterBase.fillMap(ATTRIBUTES, LatexParserDefinition.BRACKETS, LatexHighlighterColors.BRACKET);
SyntaxHighlighterBase.fillMap(ATTRIBUTES, LatexParserDefinition.ARGUMENTS, LatexHighlighterColors.ARGUMENT);
}
/** Current project. */
private final Project project;
/** Current file. */
private final VirtualFile virtualFile;
/** Builds a new instance of {@link LatexHighlighter}. */
LatexHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile) {
this.project = project;
this.virtualFile = virtualFile;
}
/**
* Creates lexer adapter.
*
* @return lexer adapter
*/
@NotNull
@Override
public Lexer getHighlightingLexer() {
return new LatexLexerAdapter(project, virtualFile);
}
/**
* Gets highlighter text {@link TextAttributesKey} list using {@link IElementType} token.
*
* @param tokenType element type
* @return attributes list
*/
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
return pack(ATTRIBUTES.get(tokenType));
}
}
================================================
FILE: src/mobi/hsz/idea/latex/highlighter/LatexHighlighterColors.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.highlighter;
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
/**
* Contains highlighter attributes definitions.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
class LatexHighlighterColors {
/** Default style for regular comment started with # */
public static final TextAttributesKey COMMENT = TextAttributesKey.createTextAttributesKey("LATEX.COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
/** Default style for Latex instruction started with \ */
static final TextAttributesKey INSTRUCTION = TextAttributesKey.createTextAttributesKey("LATEX.INSTRUCTION", DefaultLanguageHighlighterColors.FUNCTION_CALL);
/** Default style for bracket: [](){} */
static final TextAttributesKey BRACKET = TextAttributesKey.createTextAttributesKey("LATEX.BRACKET", DefaultLanguageHighlighterColors.BRACKETS);
/** Default style for Latex instruction's argument */
static final TextAttributesKey ARGUMENT = TextAttributesKey.createTextAttributesKey("LATEX.ARGUMENT", DefaultLanguageHighlighterColors.PARAMETER);
}
================================================
FILE: src/mobi/hsz/idea/latex/highlighter/LatexHighlighterFactory.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.highlighter;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* {@link SyntaxHighlighterFactory} class definition.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexHighlighterFactory extends SyntaxHighlighterFactory {
/**
* Override this method to provide syntax highlighting (coloring) capabilities for your language implementation.
* By syntax highlighting we mean highlighting of keywords, comments, braces etc. where lexing the file content is enough
* to identify proper highlighting attributes.
* <p/>
* Default implementation doesn't highlight anything.
*
* @param project might be necessary to gather various project settings from.
* @param virtualFile might be necessary to collect file specific settings
* @return <code>SyntaxHighlighter</code> interface implementation for this particular language.
*/
@NotNull
@Override
public SyntaxHighlighter getSyntaxHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile) {
return new LatexHighlighter(project, virtualFile);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/inspections/LatexSpellcheckingStrategy.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.inspections;
import com.intellij.psi.PsiElement;
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy;
import com.intellij.spellchecker.tokenizer.Tokenizer;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import mobi.hsz.idea.latex.psi.LatexText;
import org.jetbrains.annotations.NotNull;
/**
* {@link SpellcheckingStrategy} implementation for LaTeX language.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexSpellcheckingStrategy extends SpellcheckingStrategy {
/**
* Checks if elements is supported.
*
* @param element to check
* @return element is {@link LatexLanguage} instance
*/
@Override
public boolean isMyContext(@NotNull PsiElement element) {
return LatexLanguage.INSTANCE.is(element.getLanguage());
}
/**
* Provides {@link #TEXT_TOKENIZER} for {@link LatexText} elements.
*
* @param element to check
* @return {@link #TEXT_TOKENIZER} for {@link LatexText} or {@link #EMPTY_TOKENIZER}.
*/
@NotNull
@Override
public Tokenizer getTokenizer(PsiElement element) {
if (element instanceof LatexText) {
return TEXT_TOKENIZER;
}
return EMPTY_TOKENIZER;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/lang/LatexBraceMatcher.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.lang;
import com.intellij.lang.BracePair;
import com.intellij.lang.PairedBraceMatcher;
import com.intellij.psi.PsiFile;
import com.intellij.psi.tree.IElementType;
import mobi.hsz.idea.latex.psi.LatexTypes;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Definition of {@link PairedBraceMatcher} class.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexBraceMatcher implements PairedBraceMatcher {
/** Array of definitions for brace pairs. */
private static final BracePair[] PAIRS = new BracePair[]{
new BracePair(LatexTypes.LBRACE, LatexTypes.RBRACE, false),
new BracePair(LatexTypes.LBRACKET, LatexTypes.RBRACKET, false),
new BracePair(LatexTypes.LPAREN, LatexTypes.RPAREN, false)
};
/**
* Returns the array of definitions for brace pairs that need to be matched when
* editing code in the language.
*
* @return the array of brace pair definitions.
*/
@Override
public BracePair[] getPairs() {
return PAIRS;
}
/**
* Returns true if paired rbrace should be inserted after lbrace of given type when lbrace is encountered before contextType token.
* It is safe to always return true, then paired brace will be inserted anyway.
*
* @param lbraceType lbrace for which information is queried
* @param contextType token type that follows lbrace
* @return true / false as described
*/
@Override
public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType contextType) {
return true;
}
/**
* Returns the start offset of the code construct which owns the opening structural brace at the specified offset. For example,
* if the opening brace belongs to an 'if' statement, returns the start offset of the 'if' statement.
*
* @param file the file in which brace matching is performed.
* @param openingBraceOffset the offset of an opening structural brace.
* @return the offset of corresponding code construct, or the same offset if not defined.
*/
@Override
public int getCodeConstructStart(PsiFile file, int openingBraceOffset) {
return openingBraceOffset;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/lang/LatexCommenter.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.lang;
import com.intellij.lang.Commenter;
import org.jetbrains.annotations.Nullable;
/**
* Defines the support for "Comment with Line Comment" and "Comment with Block Comment"
* actions in a custom language.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexCommenter implements Commenter {
/**
* Returns the string which prefixes a line comment in the language, or null if the language
* does not support line comments.
*
* @return the line comment text, or null.
*/
@Nullable
@Override
public String getLineCommentPrefix() {
return "%";
}
/**
* Returns the string which marks the beginning of a block comment in the language,
* or null if the language does not support block comments.
*
* @return the block comment start text, or null.
*/
@Nullable
@Override
public String getBlockCommentPrefix() {
return null;
}
/**
* Returns the string which marks the end of a block comment in the language,
* or null if the language does not support block comments.
*
* @return the block comment end text, or null.
*/
@Nullable
@Override
public String getBlockCommentSuffix() {
return null;
}
/**
* Returns the string which marks the commented beginning of a block comment in the language,
* or null if the language does not support block comments.
*
* @return the commented block comment start text, or null.
*/
@Nullable
@Override
public String getCommentedBlockCommentPrefix() {
return null;
}
/**
* Returns the string which marks the commented end of a block comment in the language,
* or null if the language does not support block comments.
*
* @return the commented block comment end text, or null.
*/
@Nullable
@Override
public String getCommentedBlockCommentSuffix() {
return null;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.lang;
import com.intellij.lang.Language;
import org.jetbrains.annotations.NonNls;
/**
* LaTeX {@link Language} definition.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexLanguage extends Language {
/** The {@link LatexLanguage} instance. */
public static final LatexLanguage INSTANCE = new LatexLanguage();
/** The LaTeX language name. */
@NonNls
public static final String NAME = "LaTeX";
/** The LaTeX file extension suffix. */
@NonNls
public static final String EXTENSION = "tex";
/** LaTeX languages group name. */
@NonNls
public static final String GROUP = "LATEX_GROUP";
/** {@link LatexLanguage} is a non-instantiable static class. */
private LatexLanguage() {
super(NAME);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/lang/LatexParserDefinition.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.lang;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.lang.ParserDefinition;
import com.intellij.lang.PsiParser;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.project.Project;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IFileElementType;
import com.intellij.psi.tree.TokenSet;
import mobi.hsz.idea.latex.lexer.LatexLexerAdapter;
import mobi.hsz.idea.latex.parser.LatexParser;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.psi.LatexTypes;
import org.jetbrains.annotations.NotNull;
/**
* Defines the implementation of a parser for a custom language.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexParserDefinition implements ParserDefinition {
/** Whitespaces. */
public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
/** Regular comment started with # */
public static final TokenSet COMMENTS = TokenSet.create(LatexTypes.COMMENT);
/** Latex instruction started with \ */
public static final TokenSet INSTRUCTIONS = TokenSet.create(LatexTypes.IDENTIFIER, LatexTypes.IDENTIFIER_BEGIN, LatexTypes.IDENTIFIER_END);
/** Latex instruction's argument */
public static final TokenSet ARGUMENTS = TokenSet.create(LatexTypes.ARG);
/** All brackets: braces, brackets, parenthesis */
public static final TokenSet BRACKETS = TokenSet.create(
LatexTypes.LBRACE, LatexTypes.RBRACE,
LatexTypes.LBRACKET, LatexTypes.RBRACKET,
LatexTypes.LPAREN, LatexTypes.RPAREN
);
/** Element type of the node describing a file in the specified language. */
public static final IFileElementType FILE = new IFileElementType(Language.findInstance(LatexLanguage.class));
/**
* Returns the lexer for lexing files in the specified project. This lexer does not need to support incremental relexing - it is always
* called for the entire file.
*
* @param project the project to which the lexer is connected.
* @return the lexer instance.
*/
@NotNull
@Override
public Lexer createLexer(Project project) {
return new LatexLexerAdapter(project);
}
/**
* Returns the parser for parsing files in the specified project.
*
* @param project the project to which the parser is connected.
* @return the parser instance.
*/
@Override
public PsiParser createParser(Project project) {
return new LatexParser();
}
/**
* Returns the element type of the node describing a file in the specified language.
*
* @return the file node element type.
*/
@Override
public IFileElementType getFileNodeType() {
return FILE;
}
/**
* Returns the set of token types which are treated as whitespace by the PSI builder.
* Tokens of those types are automatically skipped by PsiBuilder. Whitespace elements
* on the bounds of nodes built by PsiBuilder are automatically excluded from the text
* range of the nodes.
* <p><strong>It is strongly advised you return TokenSet that only contains {@link com.intellij.psi.TokenType#WHITE_SPACE},
* which is suitable for all the languages unless you really need to use special whitespace token</strong>
*
* @return the set of whitespace token types.
*/
@NotNull
@Override
public TokenSet getWhitespaceTokens() {
return WHITE_SPACES;
}
/**
* Returns the set of token types which are treated as comments by the PSI builder.
* Tokens of those types are automatically skipped by PsiBuilder. Also, To Do patterns
* are searched in the text of tokens of those types.
*
* @return the set of comment token types.
*/
@NotNull
@Override
public TokenSet getCommentTokens() {
return COMMENTS;
}
/**
* Returns the set of token types which are treated as argument by the PSI builder.
*
* @return the set of argument token types.
*/
@NotNull
public TokenSet getArgumentTokens() {
return ARGUMENTS;
}
/**
* Returns the set of token types which are treated as instructions by the PSI builder.
*
* @return the set of instruction token types.
*/
@NotNull
public TokenSet getInstructionTokens() {
return INSTRUCTIONS;
}
/**
* Returns the set of token types which are treated as brackets by the PSI builder: [](){}
*
* @return the set of instruction token types.
*/
@NotNull
public TokenSet getBracketTokens() {
return BRACKETS;
}
/**
* Returns the set of element types which are treated as string literals. "Search in strings"
* option in refactorings is applied to the contents of such tokens.
*
* @return the set of string literal element types.
*/
@NotNull
@Override
public TokenSet getStringLiteralElements() {
return TokenSet.EMPTY;
}
/**
* Creates a PSI element for the specified AST node. The AST tree is a simple, semantic-free
* tree of AST nodes which is built during the PsiBuilder parsing pass. The PSI tree is built
* over the AST tree and includes elements of different types for different language constructs.
*
* @param node the node for which the PSI element should be returned.
* @return the PSI element matching the element type of the AST node.
*/
@NotNull
@Override
public PsiElement createElement(ASTNode node) {
return LatexTypes.Factory.createElement(node);
}
/**
* Creates a PSI element for the specified virtual file.
*
* @param viewProvider virtual file.
* @return the PSI file element.
*/
@Override
public PsiFile createFile(FileViewProvider viewProvider) {
return new LatexFile(viewProvider);
}
/**
* Checks if the specified two token types need to be separated by a space according to the language grammar.
* For example, in Java two keywords are always separated by a space; a keyword and an opening parenthesis may
* be separated or not separated. This is used for automatic whitespace insertion during AST modification operations.
*
* @param left the first token to check.
* @param right the second token to check.
* @return the spacing requirements.
*/
@Override
public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
return SpaceRequirements.MAY;
}
}
================================================
FILE: src/mobi/hsz/idea/latex/lexer/Latex.flex
================================================
package mobi.hsz.idea.latex.lexer;
import java.io.File;
import java.util.List;
import com.intellij.lexer.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import static mobi.hsz.idea.latex.psi.LatexTypes.*;
import static com.intellij.psi.TokenType.*;
%%
%{
public LatexLexer() {
this((java.io.Reader)null);
}
%}
%public
%class LatexLexer
%implements FlexLexer
%function advance
%type IElementType
%unicode
EOL = "\r"|"\n"|"\r\n"
LINE_WS = [\ \t\f]
WHITE_SPACE = ({LINE_WS}|{EOL})+
IDENTIFIER = \\[:letter:]+
COMMENT = %.*
ARG = [^\(\)\{\}\[\]\\,]
TEXT = [^\(\)\{\}\[\]\\\%\ \t\f\r\n]|"\\\%"|("\\"{SPECIAL})
SPECIAL = "$"|"&"|"#"|"_"|"~"|"^"|"\\"
%state IN_ARGUMENT
%%
// brackets
<YYINITIAL> "(" { yybegin(IN_ARGUMENT); return LPAREN; }
<YYINITIAL> ")" { return RPAREN; }
<YYINITIAL> "[" { yybegin(IN_ARGUMENT); return LBRACKET; }
<YYINITIAL> "]" { return RBRACKET; }
<YYINITIAL> "{" { yybegin(IN_ARGUMENT); return LBRACE; }
<YYINITIAL> "}" { return RBRACE; }
<IN_ARGUMENT> {
{ARG}+ { return ARG; }
"," { return COMMA; }
. { yypushback(1); yybegin(YYINITIAL); }
}
// special characters
<YYINITIAL> ":" { return COLON; }
<YYINITIAL> "*" { return ASTERISK; }
<YYINITIAL> "\\\\" { return LINE_BREAK; }
<YYINITIAL> {SPECIAL} { return SPECIAL; }
<YYINITIAL> "\\". { return SPECIAL; }
<YYINITIAL> {WHITE_SPACE}+ { return WHITE_SPACE; }
<YYINITIAL> "\\begin" { return IDENTIFIER_BEGIN; }
<YYINITIAL> "\\end" { return IDENTIFIER_END; }
<YYINITIAL> {IDENTIFIER} { return IDENTIFIER; }
<YYINITIAL> {COMMENT} { return COMMENT; }
<YYINITIAL> {TEXT}+ { return ARG; }
================================================
FILE: src/mobi/hsz/idea/latex/lexer/LatexLexerAdapter.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.lexer;
import com.intellij.lexer.FlexAdapter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nullable;
/**
* Definition of {@link FlexAdapter}.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexLexerAdapter extends FlexAdapter {
/** Builds a new instance of {@link LatexLexerAdapter}. */
public LatexLexerAdapter(Project project) {
this(project, null);
}
/** Builds a new instance of {@link LatexLexerAdapter}. */
public LatexLexerAdapter(Project project, @Nullable VirtualFile virtualFile) {
super(new LatexLexer());
}
}
================================================
FILE: src/mobi/hsz/idea/latex/parser/LatexParserUtil.java
================================================
package mobi.hsz.idea.latex.parser;
import com.intellij.lang.parser.GeneratedParserUtilBase;
/**
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexParserUtil extends GeneratedParserUtilBase {
}
================================================
FILE: src/mobi/hsz/idea/latex/psi/LatexArgumentElement.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
public interface LatexArgumentElement extends PsiElement {
@Nullable
String getValue();
}
================================================
FILE: src/mobi/hsz/idea/latex/psi/LatexElementImpl.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiReference;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
import org.jetbrains.annotations.NotNull;
/**
* Definition of {@link ASTWrapperPsiElement}.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexElementImpl extends ASTWrapperPsiElement {
public LatexElementImpl(ASTNode node) {
super(node);
}
/**
* Gets {@link PsiReference} list for given element.
*
* @return {@link PsiReference} list
*/
@NotNull
@Override
public PsiReference[] getReferences() {
return ReferenceProvidersRegistry.getReferencesFromProviders(this);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/psi/LatexElementType.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi;
import com.intellij.psi.tree.IElementType;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* Latex element type.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexElementType extends IElementType {
/** Build a new instance of @{link IgnoreElementType} */
public LatexElementType(@NotNull @NonNls String debugName) {
super(debugName, LatexLanguage.INSTANCE);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/psi/LatexFile.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi;
import com.intellij.extapi.psi.PsiFileBase;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.psi.FileViewProvider;
import mobi.hsz.idea.latex.file.LatexFileType;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import org.jetbrains.annotations.NotNull;
/**
* Base plugin file.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexFile extends PsiFileBase {
/** Current file type. */
private final LatexFileType fileType;
/** Builds a new instance of {@link LatexFile}. */
public LatexFile(@NotNull FileViewProvider viewProvider) {
super(viewProvider, LatexLanguage.INSTANCE);
fileType = LatexFileType.INSTANCE;
}
/**
* Returns the file type for the file.
*
* @return the file type instance.
*/
@NotNull
@Override
public FileType getFileType() {
return fileType;
}
/**
* Returns @{link IgnoreFileType} string interpretation.
*
* @return string interpretation
*/
@Override
public String toString() {
return fileType.getName();
}
}
================================================
FILE: src/mobi/hsz/idea/latex/psi/LatexTokenType.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi;
import com.intellij.psi.tree.IElementType;
import mobi.hsz.idea.latex.LatexBundle;
import mobi.hsz.idea.latex.lang.LatexLanguage;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* Token type definition.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.1
*/
public class LatexTokenType extends IElementType {
/** Token debug name. */
private final String debugName;
/** Builds a new instance of @{link IgnoreTokenType}. */
LatexTokenType(@NotNull @NonNls String debugName) {
super(debugName, LatexLanguage.INSTANCE);
this.debugName = debugName;
}
/**
* String interpretation of the token type.
*
* @return string representation
*/
@Override
public String toString() {
return LatexBundle.messageOrDefault("tokenType." + debugName, getLanguage().getDisplayName() + "TokenType." + super.toString());
}
}
================================================
FILE: src/mobi/hsz/idea/latex/psi/impl/LatexArgumentExtImpl.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import mobi.hsz.idea.latex.psi.LatexArgument;
import mobi.hsz.idea.latex.psi.LatexArgumentElement;
import mobi.hsz.idea.latex.psi.LatexElementImpl;
/**
* Abstract LatexArgument implementation.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public abstract class LatexArgumentExtImpl extends LatexElementImpl implements LatexArgumentElement {
LatexArgumentExtImpl(ASTNode node) {
super(node);
}
/**
* Returns the Argument element value ignoring the parentheses.
*
* @return Argument value.
*/
@Override
public String getValue() {
for (PsiElement child : getChildren()) {
if (child instanceof LatexArgument) {
return ((LatexArgument) child).getValue();
}
}
return getText();
}
}
================================================
FILE: src/mobi/hsz/idea/latex/psi/impl/LatexInstructionExtImpl.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.TokenSet;
import com.intellij.psi.util.PsiTreeUtil;
import mobi.hsz.idea.latex.psi.LatexArgument;
import mobi.hsz.idea.latex.psi.LatexElementImpl;
import mobi.hsz.idea.latex.psi.LatexInstruction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import static mobi.hsz.idea.latex.psi.LatexTypes.IDENTIFIER;
import static mobi.hsz.idea.latex.psi.LatexTypes.IDENTIFIER_BEGIN;
import static mobi.hsz.idea.latex.psi.LatexTypes.IDENTIFIER_END;
/**
* Abstract {@link LatexInstruction} implementation to handle {@link #getIdentifier()} in instruction subtypes.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public abstract class LatexInstructionExtImpl extends LatexElementImpl implements LatexInstruction {
/** {@link TokenSet} containing all identifier types. */
private static final TokenSet IDENTIFIERS = TokenSet.create(IDENTIFIER, IDENTIFIER_BEGIN, IDENTIFIER_END);
/** Default constructor. */
LatexInstructionExtImpl(ASTNode node) {
super(node);
}
/** Returns list of identifiers and identifiers subtypes. */
@NotNull
public PsiElement getIdentifier() {
return findNotNullChildByType(IDENTIFIERS);
}
/**
* Returns the {@link LatexInstruction} arguments list.
*
* @return {@link LatexArgument} instances list.
*/
@Override
@NotNull
public List<LatexArgument> getArgumentList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexArgument.class);
}
/**
* Returns the {@link LatexInstruction} argument.
*
* @return {@link LatexArgument} instance.
*/
@Nullable
public LatexArgument getArgument() {
return findChildByClass(LatexArgument.class);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/psi/impl/LatexSectionExtImpl.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.util.PsiTreeUtil;
import mobi.hsz.idea.latex.psi.*;
import org.jetbrains.annotations.Nullable;
/**
* Abstract {@link LatexSection} implementation to provide shorthands for accessing {@link LatexInstructionBegin}
* and {@link LatexInstructionEnd}.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public abstract class LatexSectionExtImpl extends LatexElementImpl implements LatexSection {
LatexSectionExtImpl(ASTNode node) {
super(node);
}
/**
* Returns {@link LatexInstructionBegin} instance from given {@link LatexTypes#SECTION} element.
*
* @return begin instruction
*/
@Nullable
public LatexInstructionBegin getBeginInstruction() {
return PsiTreeUtil.getChildOfType(this, LatexInstructionBegin.class);
}
/**
* Returns {@link LatexInstructionEnd} instance from given {@link LatexTypes#SECTION} element.
*
* @return end instruction
*/
@Nullable
public LatexInstructionEnd getEndInstruction() {
return PsiTreeUtil.getChildOfType(this, LatexInstructionEnd.class);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/reference/LatexReferenceContributor.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.reference;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;
import com.intellij.util.ProcessingContext;
import mobi.hsz.idea.latex.psi.LatexArgument;
import mobi.hsz.idea.latex.psi.LatexFile;
import mobi.hsz.idea.latex.psi.LatexInstruction;
import mobi.hsz.idea.latex.psi.impl.LatexInstructionExtImpl;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import static com.intellij.patterns.PlatformPatterns.psiElement;
import static com.intellij.patterns.PlatformPatterns.psiFile;
/**
* PSI elements references contributor.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3
*/
public class LatexReferenceContributor extends PsiReferenceContributor {
/**
* Registers new references provider for PSI element.
*
* @param psiReferenceRegistrar reference provider
*/
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar psiReferenceRegistrar) {
psiReferenceRegistrar.registerReferenceProvider(psiElement().inFile(psiFile(LatexFile.class)), new LatexReferenceProvider());
}
/** Reference provider definition. */
private static class LatexReferenceProvider extends PsiReferenceProvider {
private static final String[] IDENTIFIERS = {"\\input", "\\include", "\\includeonly"};
/**
* Returns references for given @{link PsiElement}.
*
* @param psiElement current element
* @param processingContext context
* @return {@link PsiReference} list
*/
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
if (psiElement instanceof LatexInstruction) {
LatexInstructionExtImpl instruction = (LatexInstructionExtImpl) psiElement;
String identifier = instruction.getIdentifier().getText();
if (Arrays.asList(IDENTIFIERS).contains(identifier)) {
LatexArgument arg = instruction.getArgument();
if (arg != null && arg.getValue() != null) {
return new FileReferenceSet(arg.getValue(), instruction, arg.getStartOffsetInParent() + 1, this, true).getAllReferences();
}
}
}
return PsiReference.EMPTY_ARRAY;
}
}
}
================================================
FILE: src/mobi/hsz/idea/latex/settings/LatexSettings.java
================================================
/*
* The MIT License (MIT)
*
* Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package mobi.hsz.idea.latex.settings;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.containers.ContainerUtil;
import mobi.hsz.idea.latex.util.Listenable;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* Persistent global settings object for the LaTeX plugin.
*
* @author Jakub Chrzanowski <jakub@hsz.mobi>
* @since 0.3.0
*/
@State(
name = "LatexSettings",
storages = @Storage(id = "other", file = "$APP_CONFIG$/latex.xml")
)
public class LatexSettings implements PersistentStateComponent<Element>, Listenable<LatexSettings.Listener> {
/** Settings keys. */
public enum KEY {
ROOT("LatexSettings"), VERSION("version");
private final String key;
KEY(@NotNull String key) {
this.key = key;
}
@Override
public String toString() {
return this.key;
}
}
/** Plugin version. */
private String version;
/** Listeners list. */
private final List<Listener> listeners = ContainerUtil.newArrayList();
/**
* Get the instance of this service.
*
* @return the unique {@link LatexSettings} instance.
*/
public static LatexSettings getInstance() {
return ServiceManager.getService(LatexSettings.class);
}
/**
* Get the settings state as a DOM element.
*
* @return an ready to serialize DOM {@link Element}.
* @see {@link #loadState(Element)}
*/
@Nullable
@Override
public Element getState() {
final Element element = new Element(KEY.ROOT.toString());
element.setAttribute(KEY.VERSION.toString(), version);
return element;
}
/**
* Load the settings state from the DOM {@link Element}.
*
* @param element the {@link Element} to load values from.
* @see {@link #getState()}
*/
@Override
public void loadState(Element element) {
String value = element.getAttributeValue(KEY.VERSION.toString());
if (value != null) version = value;
}
/**
* Returns plugin version.
*
* @return version
*/
public String getVersion() {
return version;
}
/**
* Sets plugin version.
*
* @param version of the plugin
*/
public void setVersion(@NotNull String version) {
this.notifyOnChange(KEY.VERSION, this.version, version);
this.version = version;
}
/**
* Add the given listener. The listener will be executed in the containing instance's thread.
*
* @param listener listener to add
*/
@Override
public void addListener(@NotNull Listener listener) {
listeners.add(listener);
}
/**
* Remove the given listener.
*
* @param listener listener to remove
*/
@Override
public void removeListener(@NotNull Listener listener) {
listeners.remove(listener);
}
/**
* Notifies listeners about the changes.
*
* @param key changed property key
* @param oldValue new value
* @param newValue new value
*/
private void notifyOnChange(KEY key, Object oldValue, Object newValue) {
if (!newValue.equals(oldValue)) {
for (Listener listener : listeners) {
listener.onChange(key, newValue);
}
}
}
/** Listener interface for onChange event. */
public interface Listener {
void onChange(@NotNull KEY key, Object value);
}
}
================================================
FILE: src/mobi/hsz/idea/latex/ui/ImageEditorActionDialog.form
================================================
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="mobi.hsz.idea.latex.ui.ImageEditorActionDialog">
<grid id="cbd77" binding="panel" layout-manager="GridLayoutManage
gitextract_dd7s0pn4/
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.gradle
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── resources/
│ ├── META-INF/
│ │ └── plugin.xml
│ ├── bnf/
│ │ └── Latex.bnf
│ ├── codeStyle/
│ │ └── preview/
│ │ ├── blank_lines_settings.tex.ft
│ │ ├── indent_settings.tex.ft
│ │ ├── spacing_settings.tex.ft
│ │ └── wrapping_and_braces_settings.tex.ft
│ ├── colorSchemes/
│ │ ├── LatexDarcula.xml
│ │ └── LatexDefault.xml
│ ├── fileTemplates/
│ │ └── j2ee/
│ │ ├── article.tex.ft
│ │ ├── book.tex.ft
│ │ ├── empty.tex.ft
│ │ ├── letter.tex.ft
│ │ ├── presentation.tex.ft
│ │ └── report.tex.ft
│ ├── messages/
│ │ └── LatexBundle.properties
│ └── sample.tex
├── settings.gradle
└── src/
└── mobi/
└── hsz/
└── idea/
└── latex/
├── LatexApplicationComponent.java
├── LatexBundle.java
├── LatexUpdateComponent.java
├── actions/
│ ├── CreateLatexFileAction.java
│ ├── LatexTemplates.java
│ ├── LatexTemplatesFactory.java
│ └── editor/
│ ├── AlignCenterAction.java
│ ├── AlignLeftAction.java
│ ├── AlignRightAction.java
│ ├── BoldAction.java
│ ├── ImageAction.java
│ ├── ItalicAction.java
│ ├── MatrixAction.java
│ ├── TableAction.java
│ ├── UnderlineAction.java
│ └── base/
│ ├── DialogEditorAction.java
│ ├── EditorAction.java
│ ├── EditorActionsFactory.java
│ ├── InsertEditorAction.java
│ └── WrapEditorAction.java
├── codeStyle/
│ ├── LatexCodeStyleMainPanel.java
│ ├── LatexCodeStyleSettings.java
│ ├── LatexCodeStyleSettingsProvider.java
│ └── LatexLanguageCodeStyleSettingsProvider.java
├── editor/
│ ├── LatexEditorActionsLoaderComponent.java
│ └── LatexEditorActionsWrapper.java
├── file/
│ ├── LatexFileType.java
│ └── LatexFileTypeFactory.java
├── folding/
│ └── LatexFoldingBuilder.java
├── highlighter/
│ ├── LatexColorSettingsPage.java
│ ├── LatexHighlighter.java
│ ├── LatexHighlighterColors.java
│ └── LatexHighlighterFactory.java
├── inspections/
│ └── LatexSpellcheckingStrategy.java
├── lang/
│ ├── LatexBraceMatcher.java
│ ├── LatexCommenter.java
│ ├── LatexLanguage.java
│ └── LatexParserDefinition.java
├── lexer/
│ ├── Latex.flex
│ └── LatexLexerAdapter.java
├── parser/
│ └── LatexParserUtil.java
├── psi/
│ ├── LatexArgumentElement.java
│ ├── LatexElementImpl.java
│ ├── LatexElementType.java
│ ├── LatexFile.java
│ ├── LatexTokenType.java
│ └── impl/
│ ├── LatexArgumentExtImpl.java
│ ├── LatexInstructionExtImpl.java
│ └── LatexSectionExtImpl.java
├── reference/
│ └── LatexReferenceContributor.java
├── settings/
│ └── LatexSettings.java
├── ui/
│ ├── ImageEditorActionDialog.form
│ ├── ImageEditorActionDialog.java
│ ├── MatrixEditorActionDialog.form
│ ├── MatrixEditorActionDialog.java
│ ├── TableEditorActionDialog.form
│ └── TableEditorActionDialog.java
└── util/
├── Icons.java
├── Listenable.java
├── Resources.java
└── Utils.java
SYMBOL INDEX (285 symbols across 57 files)
FILE: src/mobi/hsz/idea/latex/LatexApplicationComponent.java
class LatexApplicationComponent (line 37) | public class LatexApplicationComponent implements ApplicationComponent {
method getInstance (line 49) | @NotNull
method initComponent (line 55) | @Override
method disposeComponent (line 66) | @Override
method getComponentName (line 75) | @NotNull
method isUpdated (line 86) | public boolean isUpdated() {
method isUpdateNotificationShown (line 95) | public boolean isUpdateNotificationShown() {
method setUpdateNotificationShown (line 104) | public void setUpdateNotificationShown(boolean shown) {
FILE: src/mobi/hsz/idea/latex/LatexBundle.java
class LatexBundle (line 39) | public class LatexBundle {
method LatexBundle (line 57) | private LatexBundle() {
method message (line 67) | public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME...
method messageOrDefault (line 79) | public static String messageOrDefault(@PropertyKey(resourceBundle = BU...
FILE: src/mobi/hsz/idea/latex/LatexUpdateComponent.java
class LatexUpdateComponent (line 41) | public class LatexUpdateComponent extends AbstractProjectComponent {
method LatexUpdateComponent (line 46) | protected LatexUpdateComponent(Project project) {
method initComponent (line 51) | @Override
method disposeComponent (line 57) | @Override
method getComponentName (line 66) | @NotNull
method projectOpened (line 73) | @Override
method projectClosed (line 89) | @Override
FILE: src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java
class CreateLatexFileAction (line 44) | public class CreateLatexFileAction extends CreateFromTemplateAction<Late...
method CreateLatexFileAction (line 46) | public CreateLatexFileAction() {
method getDefaultTemplateProperty (line 50) | @Override
method createFile (line 55) | @Nullable
method buildDialog (line 62) | @Override
method getActionName (line 74) | @Override
method equals (line 79) | @Override
FILE: src/mobi/hsz/idea/latex/actions/LatexTemplates.java
class LatexTemplates (line 35) | public class LatexTemplates {
FILE: src/mobi/hsz/idea/latex/actions/LatexTemplatesFactory.java
class LatexTemplatesFactory (line 53) | public class LatexTemplatesFactory implements FileTemplateGroupDescripto...
class LatexTemplatesFactoryHolder (line 63) | private static class LatexTemplatesFactoryHolder {
method getInstance (line 67) | public static LatexTemplatesFactory getInstance() {
method registerCustromTemplates (line 71) | public void registerCustromTemplates(String... templates) {
method getFileTemplatesDescriptor (line 75) | @Override
method createFromTemplate (line 92) | public static LatexFile createFromTemplate(@NotNull final PsiDirectory...
method getCustomTemplates (line 125) | public String[] getCustomTemplates() {
FILE: src/mobi/hsz/idea/latex/actions/editor/AlignCenterAction.java
class AlignCenterAction (line 38) | public class AlignCenterAction extends WrapEditorAction {
method AlignCenterAction (line 41) | public AlignCenterAction() {
method getLeftText (line 45) | @NotNull
method getRightText (line 51) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/AlignLeftAction.java
class AlignLeftAction (line 38) | public class AlignLeftAction extends WrapEditorAction {
method AlignLeftAction (line 41) | public AlignLeftAction() {
method getLeftText (line 45) | @NotNull
method getRightText (line 51) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/AlignRightAction.java
class AlignRightAction (line 38) | public class AlignRightAction extends WrapEditorAction {
method AlignRightAction (line 41) | public AlignRightAction() {
method getLeftText (line 45) | @NotNull
method getRightText (line 51) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/BoldAction.java
class BoldAction (line 40) | public class BoldAction extends WrapEditorAction {
method BoldAction (line 45) | public BoldAction() {
method isMatching (line 49) | @Override
method getLeftText (line 54) | @NotNull
method getRightText (line 60) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/ImageAction.java
class ImageAction (line 41) | public class ImageAction extends DialogEditorAction<ImageEditorActionDia...
method ImageAction (line 44) | public ImageAction() {
method getDialog (line 48) | @NotNull
method getContent (line 54) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/ItalicAction.java
class ItalicAction (line 40) | public class ItalicAction extends WrapEditorAction {
method ItalicAction (line 45) | public ItalicAction() {
method isMatching (line 49) | @Override
method getLeftText (line 54) | @NotNull
method getRightText (line 60) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/MatrixAction.java
class MatrixAction (line 40) | public class MatrixAction extends DialogEditorAction<MatrixEditorActionD...
method MatrixAction (line 43) | public MatrixAction() {
method getDialog (line 47) | @NotNull
method getContent (line 53) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/TableAction.java
class TableAction (line 41) | public class TableAction extends DialogEditorAction<TableEditorActionDia...
method TableAction (line 46) | public TableAction() {
method getDialog (line 50) | @NotNull
method getContent (line 56) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/UnderlineAction.java
class UnderlineAction (line 40) | public class UnderlineAction extends WrapEditorAction {
method UnderlineAction (line 45) | public UnderlineAction() {
method isMatching (line 49) | @Override
method getLeftText (line 54) | @NotNull
method getRightText (line 60) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/base/DialogEditorAction.java
class DialogEditorAction (line 43) | public abstract class DialogEditorAction<T extends DialogWrapper> extend...
method DialogEditorAction (line 46) | public DialogEditorAction(@NotNull Type type, @NotNull String name, @N...
method actionPerformed (line 50) | @Override
method getDialog (line 58) | @NotNull
method getContent (line 61) | @NotNull
method getDialogAction (line 64) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/base/EditorAction.java
class EditorAction (line 55) | public abstract class EditorAction extends AnAction implements DumbAware {
type Type (line 60) | public enum Type {
method EditorAction (line 79) | EditorAction(@NotNull Type type, @NotNull String name, @NotNull Icon i...
method actionPerformed (line 90) | @Override
method actionPerformed (line 111) | protected void actionPerformed(@NotNull AnActionEvent event, @NotNull ...
method update (line 114) | @Override
method update (line 135) | protected void update(AnActionEvent event, @NotNull Project project, @...
method getActiveEditor (line 144) | @Nullable
method getEditor (line 163) | @Nullable
method getCurrentElement (line 181) | @Nullable
method isMatching (line 202) | public boolean isMatching(@NotNull PsiElement element) {
method getMatchedElement (line 212) | @Nullable
method runWriteAction (line 229) | final protected void runWriteAction(@NotNull final Project project, @N...
method getType (line 241) | @NotNull
method getName (line 249) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/base/EditorActionsFactory.java
class EditorActionsFactory (line 37) | public final class EditorActionsFactory {
method create (line 44) | @Nullable
FILE: src/mobi/hsz/idea/latex/actions/editor/base/InsertEditorAction.java
class InsertEditorAction (line 42) | public abstract class InsertEditorAction extends EditorAction implements...
method InsertEditorAction (line 45) | public InsertEditorAction(@NotNull Type type, @NotNull String name, @N...
method actionPerformed (line 49) | @Override
method getText (line 70) | @NotNull
FILE: src/mobi/hsz/idea/latex/actions/editor/base/WrapEditorAction.java
class WrapEditorAction (line 45) | public abstract class WrapEditorAction extends EditorAction implements T...
method WrapEditorAction (line 50) | public WrapEditorAction(@NotNull Type type, @NotNull String name, @Not...
method actionPerformed (line 62) | @Override
method update (line 83) | @Override
method wrap (line 96) | private void wrap(@NotNull TextEditor editor) {
method unwrap (line 120) | private void unwrap(@NotNull final TextEditor editor, @NotNull final P...
method getLeftText (line 144) | @NotNull
method getRightText (line 152) | @NotNull
FILE: src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleMainPanel.java
class LatexCodeStyleMainPanel (line 37) | public class LatexCodeStyleMainPanel extends TabbedLanguageCodeStylePanel {
method LatexCodeStyleMainPanel (line 39) | protected LatexCodeStyleMainPanel(CodeStyleSettings currentSettings, C...
method initTabs (line 43) | @Override
FILE: src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleSettings.java
class LatexCodeStyleSettings (line 37) | public class LatexCodeStyleSettings extends CustomCodeStyleSettings {
method LatexCodeStyleSettings (line 39) | protected LatexCodeStyleSettings(@NotNull CodeStyleSettings container) {
FILE: src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleSettingsProvider.java
class LatexCodeStyleSettingsProvider (line 43) | public class LatexCodeStyleSettingsProvider extends CodeStyleSettingsPro...
method createSettingsPage (line 45) | @NotNull
method getConfigurableDisplayName (line 61) | @Nullable
method createCustomSettings (line 67) | @Nullable
FILE: src/mobi/hsz/idea/latex/codeStyle/LatexLanguageCodeStyleSettingsProvider.java
class LatexLanguageCodeStyleSettingsProvider (line 42) | public class LatexLanguageCodeStyleSettingsProvider extends LanguageCode...
method getLanguage (line 44) | @NotNull
method getDefaultCommonSettings (line 50) | @Override
method getCodeSample (line 60) | @Override
method getIndentOptionsEditor (line 72) | @Override
FILE: src/mobi/hsz/idea/latex/editor/LatexEditorActionsLoaderComponent.java
class LatexEditorActionsLoaderComponent (line 46) | public class LatexEditorActionsLoaderComponent extends AbstractProjectCo...
method LatexEditorActionsLoaderComponent (line 49) | public LatexEditorActionsLoaderComponent(@NotNull final Project projec...
method getComponentName (line 58) | @Override
method initComponent (line 66) | @Override
class LatexEditorManagerListener (line 72) | private static class LatexEditorManagerListener extends FileEditorMana...
method fileOpened (line 79) | @Override
FILE: src/mobi/hsz/idea/latex/editor/LatexEditorActionsWrapper.java
class LatexEditorActionsWrapper (line 43) | class LatexEditorActionsWrapper implements Disposable {
method LatexEditorActionsWrapper (line 47) | LatexEditorActionsWrapper(@NotNull FileEditor fileEditor) {
method getComponent (line 74) | @NotNull
method dispose (line 79) | @Override
FILE: src/mobi/hsz/idea/latex/file/LatexFileType.java
class LatexFileType (line 41) | public class LatexFileType extends LanguageFileType {
method LatexFileType (line 47) | private LatexFileType() {
method getName (line 56) | @NotNull
method getDescription (line 67) | @NotNull
method getDefaultExtension (line 78) | @NotNull
method getIcon (line 89) | @Nullable
FILE: src/mobi/hsz/idea/latex/file/LatexFileTypeFactory.java
class LatexFileTypeFactory (line 38) | public class LatexFileTypeFactory extends FileTypeFactory {
method createFileTypes (line 45) | @Override
FILE: src/mobi/hsz/idea/latex/folding/LatexFoldingBuilder.java
class LatexFoldingBuilder (line 49) | public class LatexFoldingBuilder implements FoldingBuilder {
method visitSection (line 56) | @Override
method buildFoldRegions (line 84) | @NotNull
method getPlaceholderText (line 99) | @Nullable
method isCollapsedByDefault (line 111) | @Override
FILE: src/mobi/hsz/idea/latex/highlighter/LatexColorSettingsPage.java
class LatexColorSettingsPage (line 48) | public class LatexColorSettingsPage implements ColorSettingsPage {
method getIcon (line 78) | @Nullable
method getHighlighter (line 90) | @NotNull
method getDemoText (line 101) | @NotNull
method getAdditionalHighlightingTagToDescriptorMap (line 113) | @Nullable
method getAttributeDescriptors (line 127) | @NotNull
method getColorDescriptors (line 140) | @NotNull
method getDisplayName (line 151) | @NotNull
method loadSampleLatex (line 165) | private static String loadSampleLatex() {
FILE: src/mobi/hsz/idea/latex/highlighter/LatexHighlighter.java
class LatexHighlighter (line 47) | class LatexHighlighter extends SyntaxHighlighterBase {
method LatexHighlighter (line 67) | LatexHighlighter(@Nullable Project project, @Nullable VirtualFile virt...
method getHighlightingLexer (line 77) | @NotNull
method getTokenHighlights (line 89) | @NotNull
FILE: src/mobi/hsz/idea/latex/highlighter/LatexHighlighterColors.java
class LatexHighlighterColors (line 36) | class LatexHighlighterColors {
FILE: src/mobi/hsz/idea/latex/highlighter/LatexHighlighterFactory.java
class LatexHighlighterFactory (line 40) | public class LatexHighlighterFactory extends SyntaxHighlighterFactory {
method getSyntaxHighlighter (line 53) | @NotNull
FILE: src/mobi/hsz/idea/latex/inspections/LatexSpellcheckingStrategy.java
class LatexSpellcheckingStrategy (line 40) | public class LatexSpellcheckingStrategy extends SpellcheckingStrategy {
method isMyContext (line 48) | @Override
method getTokenizer (line 59) | @NotNull
FILE: src/mobi/hsz/idea/latex/lang/LatexBraceMatcher.java
class LatexBraceMatcher (line 41) | public class LatexBraceMatcher implements PairedBraceMatcher {
method getPairs (line 56) | @Override
method isPairedBracesAllowedBeforeType (line 69) | @Override
method getCodeConstructStart (line 82) | @Override
FILE: src/mobi/hsz/idea/latex/lang/LatexCommenter.java
class LatexCommenter (line 37) | public class LatexCommenter implements Commenter {
method getLineCommentPrefix (line 45) | @Nullable
method getBlockCommentPrefix (line 57) | @Nullable
method getBlockCommentSuffix (line 69) | @Nullable
method getCommentedBlockCommentPrefix (line 81) | @Nullable
method getCommentedBlockCommentSuffix (line 93) | @Nullable
FILE: src/mobi/hsz/idea/latex/lang/LatexLanguage.java
class LatexLanguage (line 36) | public class LatexLanguage extends Language {
method LatexLanguage (line 54) | private LatexLanguage() {
FILE: src/mobi/hsz/idea/latex/lang/LatexParserDefinition.java
class LatexParserDefinition (line 51) | public class LatexParserDefinition implements ParserDefinition {
method createLexer (line 82) | @NotNull
method createParser (line 94) | @Override
method getFileNodeType (line 104) | @Override
method getWhitespaceTokens (line 119) | @NotNull
method getCommentTokens (line 132) | @NotNull
method getArgumentTokens (line 143) | @NotNull
method getInstructionTokens (line 153) | @NotNull
method getBracketTokens (line 163) | @NotNull
method getStringLiteralElements (line 174) | @NotNull
method createElement (line 188) | @NotNull
method createFile (line 200) | @Override
method spaceExistanceTypeBetweenTokens (line 214) | @Override
FILE: src/mobi/hsz/idea/latex/lexer/LatexLexerAdapter.java
class LatexLexerAdapter (line 38) | public class LatexLexerAdapter extends FlexAdapter {
method LatexLexerAdapter (line 41) | public LatexLexerAdapter(Project project) {
method LatexLexerAdapter (line 46) | public LatexLexerAdapter(Project project, @Nullable VirtualFile virtua...
FILE: src/mobi/hsz/idea/latex/parser/LatexParserUtil.java
class LatexParserUtil (line 9) | public class LatexParserUtil extends GeneratedParserUtilBase {
FILE: src/mobi/hsz/idea/latex/psi/LatexArgumentElement.java
type LatexArgumentElement (line 30) | public interface LatexArgumentElement extends PsiElement {
method getValue (line 32) | @Nullable
FILE: src/mobi/hsz/idea/latex/psi/LatexElementImpl.java
class LatexElementImpl (line 39) | public class LatexElementImpl extends ASTWrapperPsiElement {
method LatexElementImpl (line 41) | public LatexElementImpl(ASTNode node) {
method getReferences (line 50) | @NotNull
FILE: src/mobi/hsz/idea/latex/psi/LatexElementType.java
class LatexElementType (line 38) | public class LatexElementType extends IElementType {
method LatexElementType (line 41) | public LatexElementType(@NotNull @NonNls String debugName) {
FILE: src/mobi/hsz/idea/latex/psi/LatexFile.java
class LatexFile (line 40) | public class LatexFile extends PsiFileBase {
method LatexFile (line 46) | public LatexFile(@NotNull FileViewProvider viewProvider) {
method getFileType (line 56) | @NotNull
method toString (line 67) | @Override
FILE: src/mobi/hsz/idea/latex/psi/LatexTokenType.java
class LatexTokenType (line 39) | public class LatexTokenType extends IElementType {
method LatexTokenType (line 45) | LatexTokenType(@NotNull @NonNls String debugName) {
method toString (line 55) | @Override
FILE: src/mobi/hsz/idea/latex/psi/impl/LatexArgumentExtImpl.java
class LatexArgumentExtImpl (line 39) | public abstract class LatexArgumentExtImpl extends LatexElementImpl impl...
method LatexArgumentExtImpl (line 41) | LatexArgumentExtImpl(ASTNode node) {
method getValue (line 50) | @Override
FILE: src/mobi/hsz/idea/latex/psi/impl/LatexInstructionExtImpl.java
class LatexInstructionExtImpl (line 49) | public abstract class LatexInstructionExtImpl extends LatexElementImpl i...
method LatexInstructionExtImpl (line 55) | LatexInstructionExtImpl(ASTNode node) {
method getIdentifier (line 60) | @NotNull
method getArgumentList (line 70) | @Override
method getArgument (line 81) | @Nullable
FILE: src/mobi/hsz/idea/latex/psi/impl/LatexSectionExtImpl.java
class LatexSectionExtImpl (line 39) | public abstract class LatexSectionExtImpl extends LatexElementImpl imple...
method LatexSectionExtImpl (line 41) | LatexSectionExtImpl(ASTNode node) {
method getBeginInstruction (line 50) | @Nullable
method getEndInstruction (line 60) | @Nullable
FILE: src/mobi/hsz/idea/latex/reference/LatexReferenceContributor.java
class LatexReferenceContributor (line 47) | public class LatexReferenceContributor extends PsiReferenceContributor {
method registerReferenceProviders (line 54) | @Override
class LatexReferenceProvider (line 60) | private static class LatexReferenceProvider extends PsiReferenceProvid...
method getReferencesByElement (line 70) | @NotNull
FILE: src/mobi/hsz/idea/latex/settings/LatexSettings.java
class LatexSettings (line 45) | @State(
type KEY (line 51) | public enum KEY {
method KEY (line 56) | KEY(@NotNull String key) {
method toString (line 60) | @Override
method getInstance (line 77) | public static LatexSettings getInstance() {
method getState (line 87) | @Nullable
method loadState (line 102) | @Override
method getVersion (line 113) | public String getVersion() {
method setVersion (line 122) | public void setVersion(@NotNull String version) {
method addListener (line 132) | @Override
method removeListener (line 142) | @Override
method notifyOnChange (line 154) | private void notifyOnChange(KEY key, Object oldValue, Object newValue) {
type Listener (line 163) | public interface Listener {
method onChange (line 164) | void onChange(@NotNull KEY key, Object value);
FILE: src/mobi/hsz/idea/latex/ui/ImageEditorActionDialog.java
class ImageEditorActionDialog (line 37) | public class ImageEditorActionDialog extends DialogWrapper {
method ImageEditorActionDialog (line 44) | public ImageEditorActionDialog(@NotNull Project project) {
method createCenterPanel (line 52) | @Nullable
method getPath (line 58) | @NotNull
method getCaption (line 63) | @NotNull
method getLabel (line 68) | @NotNull
FILE: src/mobi/hsz/idea/latex/ui/MatrixEditorActionDialog.java
class MatrixEditorActionDialog (line 35) | public class MatrixEditorActionDialog extends DialogWrapper {
type Bracket (line 37) | public enum Bracket {
method Bracket (line 42) | Bracket(char value) {
method getValue (line 46) | public char getValue() {
method toString (line 50) | @Override
method MatrixEditorActionDialog (line 61) | public MatrixEditorActionDialog(@NotNull Project project) {
method createCenterPanel (line 72) | @Nullable
method getRows (line 78) | public int getRows() {
method getColumns (line 82) | public int getColumns() {
method getBracket (line 86) | @NotNull
FILE: src/mobi/hsz/idea/latex/ui/TableEditorActionDialog.java
class TableEditorActionDialog (line 35) | public class TableEditorActionDialog extends DialogWrapper {
type Alignment (line 37) | public enum Alignment {
method Alignment (line 42) | Alignment(char value) {
method getValue (line 46) | public char getValue() {
method toString (line 50) | @Override
type Border (line 56) | public enum Border {
method isNone (line 59) | public boolean isNone() {
method isTable (line 63) | public boolean isTable() {
method isCell (line 67) | public boolean isCell() {
method toString (line 71) | @Override
method TableEditorActionDialog (line 83) | public TableEditorActionDialog(@NotNull Project project) {
method createCenterPanel (line 95) | @Nullable
method getRows (line 101) | public int getRows() {
method getColumns (line 105) | public int getColumns() {
method getAlignment (line 109) | @NotNull
method getBorder (line 114) | @NotNull
FILE: src/mobi/hsz/idea/latex/util/Icons.java
class Icons (line 37) | public class Icons {
class Editor (line 41) | public static class Editor {
FILE: src/mobi/hsz/idea/latex/util/Listenable.java
type Listenable (line 35) | public interface Listenable<T> {
method addListener (line 41) | void addListener(@NotNull T listener);
method removeListener (line 48) | void removeListener(@NotNull T listener);
FILE: src/mobi/hsz/idea/latex/util/Resources.java
class Resources (line 41) | public class Resources {
method Resources (line 44) | private Resources() {
method getResource (line 52) | @NotNull
method getResourceContent (line 65) | @NotNull
method convertStreamToString (line 76) | @NotNull
FILE: src/mobi/hsz/idea/latex/util/Utils.java
class Utils (line 39) | public class Utils {
method Utils (line 41) | private Utils() {
method getPlugin (line 49) | public static IdeaPluginDescriptor getPlugin() {
method getMajorVersion (line 58) | public static String getMajorVersion() {
method getMinorVersion (line 67) | public static String getMinorVersion() {
method getVersion (line 76) | public static String getVersion() {
Condensed preview — 89 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (229K chars).
[
{
"path": ".gitignore",
"chars": 73,
"preview": ".idea/\n*.iml\nout/\ngen/\nbuild/\nbuild.properties\njunit*.properties\n.gradle\n"
},
{
"path": ".travis.yml",
"chars": 866,
"preview": "# Configuration for CI build at https://travis-ci.org/hsz/idea-latex\n\nlanguage: java\n\njdk:\n - oraclejdk8\n\nenv:\n - IDEA"
},
{
"path": "CHANGELOG.md",
"chars": 1011,
"preview": "# 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/h"
},
{
"path": "LICENSE",
"chars": 1106,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n\nPermission is hereby granted, free of "
},
{
"path": "README.md",
"chars": 3652,
"preview": "idea-latex v0.3.0\n=================\n\n[![Gitter][badge-gitter-img]][badge-gitter] [![Build Status][badge-travis-img]][bad"
},
{
"path": "build.gradle",
"chars": 3699,
"preview": "plugins {\n id 'org.jetbrains.intellij' version '0.0.43'\n id 'de.undercouch.download' version '2.1.0'\n}\n\napply plug"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 231,
"preview": "#Mon Apr 11 22:05:01 CEST 2016\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER"
},
{
"path": "gradle.properties",
"chars": 720,
"preview": "# Available idea versions:\n# https://www.jetbrains.com/intellij-repository/releases\n# https://www.jetbrains.com/intellij"
},
{
"path": "gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "resources/META-INF/plugin.xml",
"chars": 6673,
"preview": "<idea-plugin version=\"2\">\n <id>mobi.hsz.idea.latex</id>\n <name>LaTeX</name>\n <version>0.3.0</version>\n <vend"
},
{
"path": "resources/bnf/Latex.bnf",
"chars": 3346,
"preview": "{\n parserClass = \"mobi.hsz.idea.latex.parser.LatexParser\"\n parserUtilClass = \"mobi.hsz.idea.la"
},
{
"path": "resources/codeStyle/preview/blank_lines_settings.tex.ft",
"chars": 25,
"preview": "blank_lines_settings file"
},
{
"path": "resources/codeStyle/preview/indent_settings.tex.ft",
"chars": 20,
"preview": "indent_settings file"
},
{
"path": "resources/codeStyle/preview/spacing_settings.tex.ft",
"chars": 21,
"preview": "spacing_settings file"
},
{
"path": "resources/codeStyle/preview/wrapping_and_braces_settings.tex.ft",
"chars": 33,
"preview": "wrapping_and_braces_settings file"
},
{
"path": "resources/colorSchemes/LatexDarcula.xml",
"chars": 589,
"preview": "<?xml version='1.0'?>\n<list>\n <option name=\"LATEX.COMMENT\">\n <value>\n <option name=\"FOREGROUND\" val"
},
{
"path": "resources/colorSchemes/LatexDefault.xml",
"chars": 589,
"preview": "<?xml version='1.0'?>\n<list>\n <option name=\"LATEX.COMMENT\">\n <value>\n <option name=\"FOREGROUND\" val"
},
{
"path": "resources/fileTemplates/j2ee/article.tex.ft",
"chars": 239,
"preview": "\\documentclass[a4paper,11pt]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\title{"
},
{
"path": "resources/fileTemplates/j2ee/book.tex.ft",
"chars": 203,
"preview": "\\documentclass[a4paper,11pt]{book}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\title{}\n\\"
},
{
"path": "resources/fileTemplates/j2ee/empty.tex.ft",
"chars": 0,
"preview": ""
},
{
"path": "resources/fileTemplates/j2ee/letter.tex.ft",
"chars": 462,
"preview": "\\documentclass[a4paper,11pt]{letter}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\address"
},
{
"path": "resources/fileTemplates/j2ee/presentation.tex.ft",
"chars": 188,
"preview": "\\documentclass{beamer}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\title{}\n\\author{}\n\n\\b"
},
{
"path": "resources/fileTemplates/j2ee/report.tex.ft",
"chars": 238,
"preview": "\\documentclass[a4paper,11pt]{report}\n\\usepackage[T1]{fontenc}\n\\usepackage[utf8]{inputenc}\n\\usepackage{lmodern}\n\n\\title{}"
},
{
"path": "resources/messages/LatexBundle.properties",
"chars": 1913,
"preview": "editor.align_left=Align left\neditor.align_right=Align right\neditor.align_center=Align center\neditor.bold=Bold\neditor.ima"
},
{
"path": "resources/sample.tex",
"chars": 877,
"preview": "\\documentclass[12pt]{article}\n\\usepackage{amsmath}\n\\title{\\LaTeX}\n\\date{}\n\\begin{document}\n \\maketitle\n \\LaTeX{} is a "
},
{
"path": "settings.gradle",
"chars": 32,
"preview": "rootProject.name = 'idea-latex'\n"
},
{
"path": "src/mobi/hsz/idea/latex/LatexApplicationComponent.java",
"chars": 3324,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/LatexBundle.java",
"chars": 3257,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/LatexUpdateComponent.java",
"chars": 3303,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/CreateLatexFileAction.java",
"chars": 3744,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/LatexTemplates.java",
"chars": 1799,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/LatexTemplatesFactory.java",
"chars": 5527,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/AlignCenterAction.java",
"chars": 1980,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/AlignLeftAction.java",
"chars": 1972,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/AlignRightAction.java",
"chars": 1981,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/BoldAction.java",
"chars": 2273,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/ImageAction.java",
"chars": 2835,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/ItalicAction.java",
"chars": 2290,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/MatrixAction.java",
"chars": 2701,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/TableAction.java",
"chars": 3021,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/UnderlineAction.java",
"chars": 2311,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/base/DialogEditorAction.java",
"chars": 3182,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/base/EditorAction.java",
"chars": 8160,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/base/EditorActionsFactory.java",
"chars": 2370,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/base/InsertEditorAction.java",
"chars": 2812,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/actions/editor/base/WrapEditorAction.java",
"chars": 5821,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleMainPanel.java",
"chars": 1966,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleSettings.java",
"chars": 1704,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/codeStyle/LatexCodeStyleSettingsProvider.java",
"chars": 2846,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/codeStyle/LatexLanguageCodeStyleSettingsProvider.java",
"chars": 3005,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/editor/LatexEditorActionsLoaderComponent.java",
"chars": 3808,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/editor/LatexEditorActionsWrapper.java",
"chars": 3053,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/file/LatexFileType.java",
"chars": 2909,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/file/LatexFileTypeFactory.java",
"chars": 1865,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/folding/LatexFoldingBuilder.java",
"chars": 4641,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/highlighter/LatexColorSettingsPage.java",
"chars": 5725,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/highlighter/LatexHighlighter.java",
"chars": 3534,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/highlighter/LatexHighlighterColors.java",
"chars": 2346,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/highlighter/LatexHighlighterFactory.java",
"chars": 2571,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/inspections/LatexSpellcheckingStrategy.java",
"chars": 2442,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/lang/LatexBraceMatcher.java",
"chars": 3511,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/lang/LatexCommenter.java",
"chars": 3195,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/lang/LatexLanguage.java",
"chars": 1996,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/lang/LatexParserDefinition.java",
"chars": 7900,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/lexer/Latex.flex",
"chars": 1982,
"preview": "package mobi.hsz.idea.latex.lexer;\n\nimport java.io.File;\nimport java.util.List;\nimport com.intellij.lexer.*;\nimport com."
},
{
"path": "src/mobi/hsz/idea/latex/lexer/LatexLexerAdapter.java",
"chars": 1879,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/parser/LatexParserUtil.java",
"chars": 229,
"preview": "package mobi.hsz.idea.latex.parser;\n\nimport com.intellij.lang.parser.GeneratedParserUtilBase;\n\n/**\n * @author Jakub Chrz"
},
{
"path": "src/mobi/hsz/idea/latex/psi/LatexArgumentElement.java",
"chars": 1386,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/psi/LatexElementImpl.java",
"chars": 1985,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/psi/LatexElementType.java",
"chars": 1713,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/psi/LatexFile.java",
"chars": 2319,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/psi/LatexTokenType.java",
"chars": 2144,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/psi/impl/LatexArgumentExtImpl.java",
"chars": 2099,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/psi/impl/LatexInstructionExtImpl.java",
"chars": 3091,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/psi/impl/LatexSectionExtImpl.java",
"chars": 2366,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/reference/LatexReferenceContributor.java",
"chars": 3655,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/settings/LatexSettings.java",
"chars": 4922,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/ui/ImageEditorActionDialog.form",
"chars": 2764,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<form xmlns=\"http://www.intellij.com/uidesigner/form/\" version=\"1\" bind-to-class="
},
{
"path": "src/mobi/hsz/idea/latex/ui/ImageEditorActionDialog.java",
"chars": 2488,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/ui/MatrixEditorActionDialog.form",
"chars": 2712,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<form xmlns=\"http://www.intellij.com/uidesigner/form/\" version=\"1\" bind-to-class="
},
{
"path": "src/mobi/hsz/idea/latex/ui/MatrixEditorActionDialog.java",
"chars": 2847,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/ui/TableEditorActionDialog.form",
"chars": 3341,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<form xmlns=\"http://www.intellij.com/uidesigner/form/\" version=\"1\" bind-to-class="
},
{
"path": "src/mobi/hsz/idea/latex/ui/TableEditorActionDialog.java",
"chars": 3479,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/util/Icons.java",
"chars": 2376,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/util/Listenable.java",
"chars": 1741,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/util/Resources.java",
"chars": 2656,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2016 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
},
{
"path": "src/mobi/hsz/idea/latex/util/Utils.java",
"chars": 2514,
"preview": "/*\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 hsz Jakub Chrzanowski <jakub@hsz.mobi>\n *\n * Permission is hereby g"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the hsz/idea-latex GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 89 files (209.4 KB), approximately 52.1k tokens, and a symbol index with 285 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.