Skip to content

Commit

Permalink
Merge branch 'master' into paste-tables
Browse files Browse the repository at this point in the history
  • Loading branch information
HannahSchellekens committed Jan 12, 2021
2 parents 9b0de6b + e1ed167 commit fbbd066
Show file tree
Hide file tree
Showing 251 changed files with 702 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ij_kotlin_name_count_to_use_star_import = 5
ij_kotlin_name_count_to_use_star_import_for_members = 3

ij_java_doc_add_blank_line_after_description = true
ij_java_doc_param_description_on_new_line = true
ij_java_doc_param_description_on_new_line = true
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ dependencies {
testImplementation("io.mockk:mockk:1.10.2")

// Add custom ruleset from github.com/slideclimb/ktlint-ruleset
ktlintRuleset(files("lib/ktlint-ruleset-0.1.jar"))
ktlintRuleset(files("lib/ktlint-ruleset-0.2.jar"))
}

// Special resource dependencies
Expand Down
Binary file removed lib/ktlint-ruleset-0.1.jar
Binary file not shown.
Binary file added lib/ktlint-ruleset-0.2.jar
Binary file not shown.
24 changes: 19 additions & 5 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@
<lang.documentationProvider language="Latex" implementationClass="nl.hannahsten.texifyidea.documentation.LatexDocumentationProvider"/>
<lang.documentationProvider language="Bibtex" implementationClass="nl.hannahsten.texifyidea.documentation.BibtexDocumentationProvider"/>

<!-- Tool windows-->
<toolWindow factoryClass="nl.hannahsten.texifyidea.ui.DetexifyToolWindowFactory"
id="Detexify" anchor="right" secondary="false" icon="AllIcons.Actions.Search"/>

<!-- Other Services -->
<applicationService serviceInterface="nl.hannahsten.texifyidea.util.files.ReferencedFileSetService"
serviceImplementation="nl.hannahsten.texifyidea.util.files.impl.ReferencedFileSetServiceImpl"/>
Expand Down Expand Up @@ -727,26 +731,36 @@
<localInspection language="Bibtex" implementationClass="nl.hannahsten.texifyidea.inspections.bibtex.BibtexDuplicateIdInspection"
groupName="BibTeX" displayName="Duplicate ID"
enabledByDefault="true"/>
<localInspection language="Latex" implementationClass="nl.hannahsten.texifyidea.inspections.bibtex.BibtexMissingBibliographystyleInspection"
<localInspection language="Latex"
implementationClass="nl.hannahsten.texifyidea.inspections.bibtex.BibtexMissingBibliographystyleInspection"
groupName="BibTeX" displayName="Missing bibliography style"
enabledByDefault="true"/>
<localInspection language="Latex" implementationClass="nl.hannahsten.texifyidea.inspections.bibtex.BibtexDuplicateBibliographystyleInspection"
<localInspection language="Latex"
implementationClass="nl.hannahsten.texifyidea.inspections.bibtex.BibtexDuplicateBibliographystyleInspection"
groupName="BibTeX" displayName="Duplicate bibliography style commands"
enabledByDefault="true"/>
<localInspection language="Latex" implementationClass="nl.hannahsten.texifyidea.inspections.bibtex.BibtexDuplicateBibliographyInspection"
<localInspection language="Latex"
implementationClass="nl.hannahsten.texifyidea.inspections.bibtex.BibtexDuplicateBibliographyInspection"
groupName="BibTeX" displayName="Same bibliography is included multiple times"
enabledByDefault="true"/>
<localInspection language="Bibtex" implementationClass="nl.hannahsten.texifyidea.inspections.bibtex.BibtexUnusedEntryInspection"
<localInspection language="Bibtex"
implementationClass="nl.hannahsten.texifyidea.inspections.bibtex.BibtexUnusedEntryInspection"
groupName="BibTeX" displayName="Unused bib entry"
enabledByDefault="true"/>

<!-- Intentions -->
<intentionAction>
<className>nl.hannahsten.texifyidea.intentions.LatexAddLabelIntention</className>
<className>nl.hannahsten.texifyidea.intentions.LatexAddLabelToCommandIntention</className>
<category>LaTeX</category>
<descriptionDirectoryName>LatexAddLabelIntention</descriptionDirectoryName>
</intentionAction>

<intentionAction>
<className>nl.hannahsten.texifyidea.intentions.LatexAddLabelToEnvironmentIntention</className>
<category>LaTeX</category>
<descriptionDirectoryName>LatexAddLabelToEnvironmentIntention</descriptionDirectoryName>
</intentionAction>

<intentionAction>
<className>nl.hannahsten.texifyidea.intentions.LatexDisplayMathIntention</className>
<category>LaTeX</category>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
\begin{lstlisting}[label={lst:listing}]
\end{lstlisting}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
\begin{lstlisting}
\end{lstlisting}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
Add a label.
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.psi
import com.intellij.psi.PsiElement

interface LatexCommandWithParams : PsiElement {

val parameterList: List<LatexParameter>
val requiredParameters: List<String>
val optionalParameterMap: Map<LatexKeyvalKey, LatexKeyvalValue>
Expand Down
1 change: 1 addition & 0 deletions src/nl/hannahsten/texifyidea/BibtexLanguage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import com.intellij.lang.Language
* @author Hannah Schellekens
*/
object BibtexLanguage : Language("Bibtex") {

override fun getDisplayName(): String = "BibTeX"
}
2 changes: 2 additions & 0 deletions src/nl/hannahsten/texifyidea/BibtexParserDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import nl.hannahsten.texifyidea.psi.BibtexTypes
* @author Hannah Schellekens
*/
class BibtexParserDefinition : ParserDefinition {

override fun createLexer(project: Project) = BibtexLexerAdapter()

override fun createParser(project: Project) = BibtexParser()
Expand All @@ -42,6 +43,7 @@ class BibtexParserDefinition : ParserDefinition {
): SpaceRequirements = SpaceRequirements.MAY

companion object {

val WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE)
val COMMENTS = TokenSet.create(BibtexTypes.COMMENT)
val NORMAL_TEXT = TokenSet.create(BibtexTypes.NORMAL_TEXT)
Expand Down
2 changes: 2 additions & 0 deletions src/nl/hannahsten/texifyidea/LatexLanguage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import com.intellij.lang.Language
* @author Sten Wessel
*/
class LatexLanguage private constructor() : Language("Latex") {

override fun getDisplayName(): String {
return "LaTeX"
}

companion object {

@JvmField
val INSTANCE = LatexLanguage()
}
Expand Down
2 changes: 2 additions & 0 deletions src/nl/hannahsten/texifyidea/LatexParserDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import nl.hannahsten.texifyidea.psi.LatexTypes
* @author Sten Wessel
*/
class LatexParserDefinition : ParserDefinition {

override fun createLexer(project: Project): Lexer = LatexLexerAdapter()

override fun createParser(project: Project): PsiParser = LatexParser()
Expand All @@ -44,6 +45,7 @@ class LatexParserDefinition : ParserDefinition {
): SpaceRequirements = SpaceRequirements.MAY

companion object {

val WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE)
val COMMENTS = TokenSet.create(LatexTypes.COMMENT_TOKEN)
val NORMAL_TEXT = TokenSet.create(LatexTypes.NORMAL_TEXT)
Expand Down
1 change: 1 addition & 0 deletions src/nl/hannahsten/texifyidea/TexifyIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import javax.swing.Icon
*/
@Suppress("unused", "MemberVisibilityCanBePrivate")
object TexifyIcons {

/**
* Copyright (c) 2017 Hannah Schellekens
*/
Expand Down
1 change: 1 addition & 0 deletions src/nl/hannahsten/texifyidea/action/ClearAuxFiles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import java.io.File
* @author Abby Berkers
*/
class ClearAuxFiles : AnAction() {

override fun actionPerformed(e: AnActionEvent) {
val project = getEventProject(e) ?: return
val basePath = project.basePath ?: return
Expand Down
1 change: 1 addition & 0 deletions src/nl/hannahsten/texifyidea/action/ClearGeneratedFiles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import java.io.File
* Similar to [ClearAuxFiles].
*/
class ClearGeneratedFiles : AnAction() {

override fun actionPerformed(e: AnActionEvent) {
val project = getEventProject(e) ?: return
val basePath = project.basePath ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ open class ForwardSearchActionBase(val viewer: PdfViewer) : EditorAction(
name = "_ForwardSearch",
icon = TexifyIcons.RIGHT
) {

override fun actionPerformed(file: VirtualFile, project: Project, textEditor: TextEditor) {
if (!viewer.isAvailable()) {
return
Expand Down
3 changes: 3 additions & 0 deletions src/nl/hannahsten/texifyidea/action/NewLatexFileAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import nl.hannahsten.texifyidea.util.files.FileUtil.fileTypeByExtension
* @author Hannah Schellekens
*/
class NewLatexFileAction : CreateElementActionBase("LaTeX File", "Create a new LaTeX file", TexifyIcons.LATEX_FILE) {

override fun invokeDialog(project: Project, psiDirectory: PsiDirectory, elementsConsumer: java.util.function.Consumer<Array<PsiElement>>) {
val fileCreator = LatexFileCreator(project, psiDirectory)
val builder = CreateFileFromTemplateDialog.createDialog(project)
Expand All @@ -46,6 +47,7 @@ class NewLatexFileAction : CreateElementActionBase("LaTeX File", "Create a new L
}

private inner class LatexFileCreator(private val project: Project, private val directory: PsiDirectory) : FileCreator<PsiElement?> {

private fun openFile(virtualFile: VirtualFile) {
val fileEditorManager = FileEditorManager.getInstance(project)
fileEditorManager.openFile(virtualFile, true)
Expand Down Expand Up @@ -111,6 +113,7 @@ class NewLatexFileAction : CreateElementActionBase("LaTeX File", "Create a new L
}

companion object {

private const val OPTION_TEX_FILE = "tex"
private const val OPTION_STY_FILE = "sty"
private const val OPTION_CLS_FILE = "cls"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup
import nl.hannahsten.texifyidea.run.linuxpdfviewer.PdfViewer

class ZathuraActionGroup : DefaultActionGroup() {

override fun canBePerformed(context: DataContext) = PdfViewer.ZATHURA.isAvailable()

override fun hideIfNoVisibleChildren(): Boolean = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.ui.OkularConfigureInverseSearchDialog
* @author Abby Berkers
*/
class ConfigureInverseSearchAction : AnAction() {

override fun actionPerformed(e: AnActionEvent) {
OkularConfigureInverseSearchDialog()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory

class PreviewToolWindowFactory : ToolWindowFactory {

override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
// Default tool window content
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.ui.SkimConfigureInverseSearchDialog
* @author Stephan Sundermann
*/
class ConfigureInverseSearchAction : AnAction() {

override fun actionPerformed(e: AnActionEvent) {
SkimConfigureInverseSearchDialog()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import nl.hannahsten.texifyidea.util.findBibtexItems
import java.util.*

object LatexBibliographyReferenceProvider : CompletionProvider<CompletionParameters>() {

override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
val lookupItems = parameters.originalFile.findBibtexItems()
.map { bibtexEntry ->
Expand Down
2 changes: 2 additions & 0 deletions src/nl/hannahsten/texifyidea/completion/LatexCharFilter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.file.LatexFile
* @author Sten Wessel
*/
class LatexCharFilter : CharFilter() {

override fun acceptChar(c: Char, prefixLength: Int, lookup: Lookup): Result? {
return if (!isInLatexContext(lookup)) {
null
Expand All @@ -20,6 +21,7 @@ class LatexCharFilter : CharFilter() {
}

companion object {

private fun isInLatexContext(lookup: Lookup): Boolean {
if (!lookup.isCompletion) {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.psi.ElementManipulator
import nl.hannahsten.texifyidea.psi.LatexCommands

class LatexCommandElementManipulators : ElementManipulator<LatexCommands> {

/**
* Return the text range of the command token, without the text range of the
* required parameters. When this range also includes the range of the required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import java.util.*
import java.util.stream.Collectors

object LatexXColorProvider : CompletionProvider<CompletionParameters>() {

override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
addDefaultColors(result)
addCustomColors(parameters, result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import nl.hannahsten.texifyidea.util.parentOfType
* @author Hannah Schellekens
*/
class LatexCommandArgumentInsertHandler(val arguments: List<Argument>? = null) : InsertHandler<LookupElement> {

override fun handleInsert(insertionContext: InsertionContext, lookupElement: LookupElement) {
removeWhiteSpaces(insertionContext)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.intellij.codeInsight.lookup.LookupElement
* @author Sten Wessel
*/
class LatexReferenceInsertHandler : InsertHandler<LookupElement> {

override fun handleInsert(context: InsertionContext, item: LookupElement) {
val model = context.editor.caretModel
model.moveToOffset(model.offset + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.util.files.getParentDirectoryByImportPaths
* @author Hannah Schellekens
*/
class LatexFileProvider : LatexPathProviderBase() {

override fun selectScanRoots(file: PsiFile): List<VirtualFile> {
val searchDirs = getProjectRoots().toMutableList()
val allIncludeCommands = LatexIncludesIndex.getItems(file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.util.files.findRelativeSearchPathsForImportComma
* Provide base folder for autocompleting folders.
*/
class LatexFolderProvider : LatexPathProviderBase() {

override fun selectScanRoots(file: PsiFile): List<VirtualFile> {
val searchDirs = getProjectRoots().toMutableList()
val allIncludeCommands = LatexIncludesIndex.getItems(file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import java.io.File
* Autocompletion roots based on graphicspaths.
*/
class LatexGraphicsPathProvider : LatexPathProviderBase() {

override fun selectScanRoots(file: PsiFile): ArrayList<VirtualFile> {
val paths = getProjectRoots()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import java.util.regex.Pattern
* @author Lukas Heiligenbrunner
*/
abstract class LatexPathProviderBase : CompletionProvider<CompletionParameters>() {

private var parameters: CompletionParameters? = null
private var resultSet: CompletionResultSet? = null
private var validExtensions: Set<String>? = null
private var absolutePathSupport = true

companion object {

private val TRIM_SLASH = Pattern.compile("/[^/]*$")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.io.InputStream
class LatexDocumentationProvider : DocumentationProvider {

companion object {

private val PACKAGE_COMMANDS = setOf("usepackage", "RequirePackage", "documentclass", "LoadClass")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import nl.hannahsten.texifyidea.util.firstParentOfType
* Disable WordSelectioner (on by default) for LatexCommands, because we handle those in [LatexCommandSelectioner].
*/
class CommandSelectionFilter : Condition<PsiElement> {

override fun value(t: PsiElement?) = !(
TexifySettings.getInstance().includeBackslashInSelection && (
t?.firstParentOfType(LatexCommands::class)?.text == t?.text ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.util.files.isLatexFile
import nl.hannahsten.texifyidea.util.get

class InlineMathBackspaceHandler : BackspaceHandlerDelegate() {

override fun beforeCharDeleted(c: Char, file: PsiFile, editor: Editor) {
if (c == '$' && file.isLatexFile()) {
val offset = editor.caretOffset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.intellij.psi.PsiElement
* Select all of the LatexCommands, so including the backslash.
*/
class LatexCommandSelectioner : ExtendWordSelectionHandlerBase() {

override fun canSelect(e: PsiElement): Boolean {
return !CommandSelectionFilter().value(e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class MathEnvironmentEditor(
val editor: Editor,
val environment: PsiElement
) {

/**
* Apply the conversion of a math environment.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AutocompileHandler : TypedHandlerDelegate() {
}

class AutoCompileBackspacehandler : BackspaceHandlerDelegate() {

override fun beforeCharDeleted(c: Char, file: PsiFile, editor: Editor) {
val project = editor.project
if (project != null && TexifySettings.getInstance().autoCompile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ContinuousPreviewHandler : TypedHandlerDelegate() {
}

class ContinuousPreviewBackspacehandler : BackspaceHandlerDelegate() {

override fun beforeCharDeleted(c: Char, file: PsiFile, editor: Editor) {}

override fun charDeleted(c: Char, file: PsiFile, editor: Editor): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiFile

object LatexPostFixTemplateProvider : PostfixTemplateProvider, CompletionContributor() {

private val templates = mutableSetOf<PostfixTemplate>(
LatexWrapWithGroupPostfixTemplate,
LatexWrapWithOpenGroupPostfixTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.util.firstParentOfType
import nl.hannahsten.texifyidea.util.inMathContext

class LatexPostfixExpressionSelector(private val mathOnly: Boolean = false, private val textOnly: Boolean = false) : PostfixTemplateExpressionSelector {

override fun hasExpression(context: PsiElement, copyDocument: Document, newOffset: Int): Boolean {
return when {
mathOnly -> context.inMathContext()
Expand Down
Loading

0 comments on commit fbbd066

Please sign in to comment.