diff --git a/.editorconfig b/.editorconfig
index fd4d0ba38..ba2ec274b 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -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
\ No newline at end of file
+ij_java_doc_param_description_on_new_line = true
diff --git a/build.gradle.kts b/build.gradle.kts
index 9273e95b4..c95792a81 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -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
diff --git a/lib/ktlint-ruleset-0.1.jar b/lib/ktlint-ruleset-0.1.jar
deleted file mode 100644
index d2fbca1e6..000000000
Binary files a/lib/ktlint-ruleset-0.1.jar and /dev/null differ
diff --git a/lib/ktlint-ruleset-0.2.jar b/lib/ktlint-ruleset-0.2.jar
new file mode 100644
index 000000000..77f231caa
Binary files /dev/null and b/lib/ktlint-ruleset-0.2.jar differ
diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml
index b6cb433b6..93ed87fe9 100644
--- a/resources/META-INF/plugin.xml
+++ b/resources/META-INF/plugin.xml
@@ -529,6 +529,10 @@
+
+
+
@@ -727,26 +731,36 @@
-
-
-
-
- nl.hannahsten.texifyidea.intentions.LatexAddLabelIntention
+ nl.hannahsten.texifyidea.intentions.LatexAddLabelToCommandIntention
LaTeX
LatexAddLabelIntention
+
+ nl.hannahsten.texifyidea.intentions.LatexAddLabelToEnvironmentIntention
+ LaTeX
+ LatexAddLabelToEnvironmentIntention
+
+
nl.hannahsten.texifyidea.intentions.LatexDisplayMathIntention
LaTeX
diff --git a/resources/intentionDescriptions/LatexAddLabelIntention/after.tex.template b/resources/intentionDescriptions/LatexAddLabelToCommandIntention/after.tex.template
similarity index 100%
rename from resources/intentionDescriptions/LatexAddLabelIntention/after.tex.template
rename to resources/intentionDescriptions/LatexAddLabelToCommandIntention/after.tex.template
diff --git a/resources/intentionDescriptions/LatexAddLabelIntention/before.tex.template b/resources/intentionDescriptions/LatexAddLabelToCommandIntention/before.tex.template
similarity index 100%
rename from resources/intentionDescriptions/LatexAddLabelIntention/before.tex.template
rename to resources/intentionDescriptions/LatexAddLabelToCommandIntention/before.tex.template
diff --git a/resources/intentionDescriptions/LatexAddLabelIntention/description.html b/resources/intentionDescriptions/LatexAddLabelToCommandIntention/description.html
similarity index 100%
rename from resources/intentionDescriptions/LatexAddLabelIntention/description.html
rename to resources/intentionDescriptions/LatexAddLabelToCommandIntention/description.html
diff --git a/resources/intentionDescriptions/LatexAddLabelToEnvironmentIntention/after.tex.template b/resources/intentionDescriptions/LatexAddLabelToEnvironmentIntention/after.tex.template
new file mode 100644
index 000000000..84bee374e
--- /dev/null
+++ b/resources/intentionDescriptions/LatexAddLabelToEnvironmentIntention/after.tex.template
@@ -0,0 +1,2 @@
+\begin{lstlisting}[label={lst:listing}]
+\end{lstlisting}
diff --git a/resources/intentionDescriptions/LatexAddLabelToEnvironmentIntention/before.tex.template b/resources/intentionDescriptions/LatexAddLabelToEnvironmentIntention/before.tex.template
new file mode 100644
index 000000000..731d6b5d9
--- /dev/null
+++ b/resources/intentionDescriptions/LatexAddLabelToEnvironmentIntention/before.tex.template
@@ -0,0 +1,2 @@
+\begin{lstlisting}
+\end{lstlisting}
diff --git a/resources/intentionDescriptions/LatexAddLabelToEnvironmentIntention/description.html b/resources/intentionDescriptions/LatexAddLabelToEnvironmentIntention/description.html
new file mode 100644
index 000000000..8351019b8
--- /dev/null
+++ b/resources/intentionDescriptions/LatexAddLabelToEnvironmentIntention/description.html
@@ -0,0 +1,5 @@
+
+
+Add a label.
+
+
\ No newline at end of file
diff --git a/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt b/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt
index 5ff63a1f7..c4a03f215 100644
--- a/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt
+++ b/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.psi
import com.intellij.psi.PsiElement
interface LatexCommandWithParams : PsiElement {
+
val parameterList: List
val requiredParameters: List
val optionalParameterMap: Map
diff --git a/src/nl/hannahsten/texifyidea/BibtexLanguage.kt b/src/nl/hannahsten/texifyidea/BibtexLanguage.kt
index a4c1c0367..5c1b9af41 100644
--- a/src/nl/hannahsten/texifyidea/BibtexLanguage.kt
+++ b/src/nl/hannahsten/texifyidea/BibtexLanguage.kt
@@ -6,5 +6,6 @@ import com.intellij.lang.Language
* @author Hannah Schellekens
*/
object BibtexLanguage : Language("Bibtex") {
+
override fun getDisplayName(): String = "BibTeX"
}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/BibtexParserDefinition.kt b/src/nl/hannahsten/texifyidea/BibtexParserDefinition.kt
index 7ebd2ade2..748d328ed 100644
--- a/src/nl/hannahsten/texifyidea/BibtexParserDefinition.kt
+++ b/src/nl/hannahsten/texifyidea/BibtexParserDefinition.kt
@@ -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()
@@ -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)
diff --git a/src/nl/hannahsten/texifyidea/LatexLanguage.kt b/src/nl/hannahsten/texifyidea/LatexLanguage.kt
index 85542cb38..fb6f09e7b 100644
--- a/src/nl/hannahsten/texifyidea/LatexLanguage.kt
+++ b/src/nl/hannahsten/texifyidea/LatexLanguage.kt
@@ -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()
}
diff --git a/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt b/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt
index b6dbd34d6..ef9368b74 100644
--- a/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt
+++ b/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt
@@ -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()
@@ -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)
diff --git a/src/nl/hannahsten/texifyidea/TexifyIcons.kt b/src/nl/hannahsten/texifyidea/TexifyIcons.kt
index f7139b521..b5966b080 100644
--- a/src/nl/hannahsten/texifyidea/TexifyIcons.kt
+++ b/src/nl/hannahsten/texifyidea/TexifyIcons.kt
@@ -10,6 +10,7 @@ import javax.swing.Icon
*/
@Suppress("unused", "MemberVisibilityCanBePrivate")
object TexifyIcons {
+
/**
* Copyright (c) 2017 Hannah Schellekens
*/
diff --git a/src/nl/hannahsten/texifyidea/action/ClearAuxFiles.kt b/src/nl/hannahsten/texifyidea/action/ClearAuxFiles.kt
index 1fa5cabe8..9c38b8431 100644
--- a/src/nl/hannahsten/texifyidea/action/ClearAuxFiles.kt
+++ b/src/nl/hannahsten/texifyidea/action/ClearAuxFiles.kt
@@ -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
diff --git a/src/nl/hannahsten/texifyidea/action/ClearGeneratedFiles.kt b/src/nl/hannahsten/texifyidea/action/ClearGeneratedFiles.kt
index 72a8f2740..71db44825 100644
--- a/src/nl/hannahsten/texifyidea/action/ClearGeneratedFiles.kt
+++ b/src/nl/hannahsten/texifyidea/action/ClearGeneratedFiles.kt
@@ -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
diff --git a/src/nl/hannahsten/texifyidea/action/ForwardSearchActionBase.kt b/src/nl/hannahsten/texifyidea/action/ForwardSearchActionBase.kt
index 7c7947e60..5cc0f57c1 100644
--- a/src/nl/hannahsten/texifyidea/action/ForwardSearchActionBase.kt
+++ b/src/nl/hannahsten/texifyidea/action/ForwardSearchActionBase.kt
@@ -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
diff --git a/src/nl/hannahsten/texifyidea/action/NewLatexFileAction.kt b/src/nl/hannahsten/texifyidea/action/NewLatexFileAction.kt
index ed30d709b..bbff123a3 100644
--- a/src/nl/hannahsten/texifyidea/action/NewLatexFileAction.kt
+++ b/src/nl/hannahsten/texifyidea/action/NewLatexFileAction.kt
@@ -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>) {
val fileCreator = LatexFileCreator(project, psiDirectory)
val builder = CreateFileFromTemplateDialog.createDialog(project)
@@ -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 {
+
private fun openFile(virtualFile: VirtualFile) {
val fileEditorManager = FileEditorManager.getInstance(project)
fileEditorManager.openFile(virtualFile, true)
@@ -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"
diff --git a/src/nl/hannahsten/texifyidea/action/group/ZathuraActionGroup.kt b/src/nl/hannahsten/texifyidea/action/group/ZathuraActionGroup.kt
index b67aabed6..c9cf44292 100644
--- a/src/nl/hannahsten/texifyidea/action/group/ZathuraActionGroup.kt
+++ b/src/nl/hannahsten/texifyidea/action/group/ZathuraActionGroup.kt
@@ -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
diff --git a/src/nl/hannahsten/texifyidea/action/okular/ConfigureInverseSearchAction.kt b/src/nl/hannahsten/texifyidea/action/okular/ConfigureInverseSearchAction.kt
index 7f8fe3d62..634494979 100644
--- a/src/nl/hannahsten/texifyidea/action/okular/ConfigureInverseSearchAction.kt
+++ b/src/nl/hannahsten/texifyidea/action/okular/ConfigureInverseSearchAction.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.ui.OkularConfigureInverseSearchDialog
* @author Abby Berkers
*/
class ConfigureInverseSearchAction : AnAction() {
+
override fun actionPerformed(e: AnActionEvent) {
OkularConfigureInverseSearchDialog()
}
diff --git a/src/nl/hannahsten/texifyidea/action/preview/PreviewToolWindowFactory.kt b/src/nl/hannahsten/texifyidea/action/preview/PreviewToolWindowFactory.kt
index 7d70f1120..5b1c90ccb 100644
--- a/src/nl/hannahsten/texifyidea/action/preview/PreviewToolWindowFactory.kt
+++ b/src/nl/hannahsten/texifyidea/action/preview/PreviewToolWindowFactory.kt
@@ -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
}
diff --git a/src/nl/hannahsten/texifyidea/action/skim/ConfigureInverseSearchAction.kt b/src/nl/hannahsten/texifyidea/action/skim/ConfigureInverseSearchAction.kt
index a85231928..5c2821a26 100644
--- a/src/nl/hannahsten/texifyidea/action/skim/ConfigureInverseSearchAction.kt
+++ b/src/nl/hannahsten/texifyidea/action/skim/ConfigureInverseSearchAction.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.ui.SkimConfigureInverseSearchDialog
* @author Stephan Sundermann
*/
class ConfigureInverseSearchAction : AnAction() {
+
override fun actionPerformed(e: AnActionEvent) {
SkimConfigureInverseSearchDialog()
}
diff --git a/src/nl/hannahsten/texifyidea/completion/LatexBibliographyReferenceProvider.kt b/src/nl/hannahsten/texifyidea/completion/LatexBibliographyReferenceProvider.kt
index 62e38e33c..4656df0cf 100644
--- a/src/nl/hannahsten/texifyidea/completion/LatexBibliographyReferenceProvider.kt
+++ b/src/nl/hannahsten/texifyidea/completion/LatexBibliographyReferenceProvider.kt
@@ -15,6 +15,7 @@ import nl.hannahsten.texifyidea.util.findBibtexItems
import java.util.*
object LatexBibliographyReferenceProvider : CompletionProvider() {
+
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
val lookupItems = parameters.originalFile.findBibtexItems()
.map { bibtexEntry ->
diff --git a/src/nl/hannahsten/texifyidea/completion/LatexCharFilter.kt b/src/nl/hannahsten/texifyidea/completion/LatexCharFilter.kt
index 2212fb42c..96d059a58 100644
--- a/src/nl/hannahsten/texifyidea/completion/LatexCharFilter.kt
+++ b/src/nl/hannahsten/texifyidea/completion/LatexCharFilter.kt
@@ -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
@@ -20,6 +21,7 @@ class LatexCharFilter : CharFilter() {
}
companion object {
+
private fun isInLatexContext(lookup: Lookup): Boolean {
if (!lookup.isCompletion) {
return false
diff --git a/src/nl/hannahsten/texifyidea/completion/LatexCommandElementManipulators.kt b/src/nl/hannahsten/texifyidea/completion/LatexCommandElementManipulators.kt
index 52a7b3063..7542a38af 100644
--- a/src/nl/hannahsten/texifyidea/completion/LatexCommandElementManipulators.kt
+++ b/src/nl/hannahsten/texifyidea/completion/LatexCommandElementManipulators.kt
@@ -5,6 +5,7 @@ import com.intellij.psi.ElementManipulator
import nl.hannahsten.texifyidea.psi.LatexCommands
class LatexCommandElementManipulators : ElementManipulator {
+
/**
* 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
diff --git a/src/nl/hannahsten/texifyidea/completion/LatexXColorProvider.kt b/src/nl/hannahsten/texifyidea/completion/LatexXColorProvider.kt
index d4180982e..f491fb857 100644
--- a/src/nl/hannahsten/texifyidea/completion/LatexXColorProvider.kt
+++ b/src/nl/hannahsten/texifyidea/completion/LatexXColorProvider.kt
@@ -20,6 +20,7 @@ import java.util.*
import java.util.stream.Collectors
object LatexXColorProvider : CompletionProvider() {
+
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
addDefaultColors(result)
addCustomColors(parameters, result)
diff --git a/src/nl/hannahsten/texifyidea/completion/handlers/LatexCommandArgumentInsertHandler.kt b/src/nl/hannahsten/texifyidea/completion/handlers/LatexCommandArgumentInsertHandler.kt
index 45384b635..d080db373 100644
--- a/src/nl/hannahsten/texifyidea/completion/handlers/LatexCommandArgumentInsertHandler.kt
+++ b/src/nl/hannahsten/texifyidea/completion/handlers/LatexCommandArgumentInsertHandler.kt
@@ -21,6 +21,7 @@ import nl.hannahsten.texifyidea.util.parentOfType
* @author Hannah Schellekens
*/
class LatexCommandArgumentInsertHandler(val arguments: List? = null) : InsertHandler {
+
override fun handleInsert(insertionContext: InsertionContext, lookupElement: LookupElement) {
removeWhiteSpaces(insertionContext)
diff --git a/src/nl/hannahsten/texifyidea/completion/handlers/LatexReferenceInsertHandler.kt b/src/nl/hannahsten/texifyidea/completion/handlers/LatexReferenceInsertHandler.kt
index 772fd3a84..7bba259e4 100644
--- a/src/nl/hannahsten/texifyidea/completion/handlers/LatexReferenceInsertHandler.kt
+++ b/src/nl/hannahsten/texifyidea/completion/handlers/LatexReferenceInsertHandler.kt
@@ -8,6 +8,7 @@ import com.intellij.codeInsight.lookup.LookupElement
* @author Sten Wessel
*/
class LatexReferenceInsertHandler : InsertHandler {
+
override fun handleInsert(context: InsertionContext, item: LookupElement) {
val model = context.editor.caretModel
model.moveToOffset(model.offset + 1)
diff --git a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexFileProvider.kt b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexFileProvider.kt
index 8b31ca5ae..78d1a2c8d 100644
--- a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexFileProvider.kt
+++ b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexFileProvider.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.util.files.getParentDirectoryByImportPaths
* @author Hannah Schellekens
*/
class LatexFileProvider : LatexPathProviderBase() {
+
override fun selectScanRoots(file: PsiFile): List {
val searchDirs = getProjectRoots().toMutableList()
val allIncludeCommands = LatexIncludesIndex.getItems(file)
diff --git a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexFolderProvider.kt b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexFolderProvider.kt
index 02636c6a9..ad434fd2a 100644
--- a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexFolderProvider.kt
+++ b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexFolderProvider.kt
@@ -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 {
val searchDirs = getProjectRoots().toMutableList()
val allIncludeCommands = LatexIncludesIndex.getItems(file)
diff --git a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt
index ceb6a008f..236fae60f 100644
--- a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt
+++ b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexGraphicsPathProvider.kt
@@ -13,6 +13,7 @@ import java.io.File
* Autocompletion roots based on graphicspaths.
*/
class LatexGraphicsPathProvider : LatexPathProviderBase() {
+
override fun selectScanRoots(file: PsiFile): ArrayList {
val paths = getProjectRoots()
diff --git a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt
index 1770cdbf2..fb3f4f796 100644
--- a/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt
+++ b/src/nl/hannahsten/texifyidea/completion/pathcompletion/LatexPathProviderBase.kt
@@ -27,12 +27,14 @@ import java.util.regex.Pattern
* @author Lukas Heiligenbrunner
*/
abstract class LatexPathProviderBase : CompletionProvider() {
+
private var parameters: CompletionParameters? = null
private var resultSet: CompletionResultSet? = null
private var validExtensions: Set? = null
private var absolutePathSupport = true
companion object {
+
private val TRIM_SLASH = Pattern.compile("/[^/]*$")
}
diff --git a/src/nl/hannahsten/texifyidea/documentation/LatexDocumentationProvider.kt b/src/nl/hannahsten/texifyidea/documentation/LatexDocumentationProvider.kt
index 2203f04ce..3f9f5a999 100644
--- a/src/nl/hannahsten/texifyidea/documentation/LatexDocumentationProvider.kt
+++ b/src/nl/hannahsten/texifyidea/documentation/LatexDocumentationProvider.kt
@@ -22,6 +22,7 @@ import java.io.InputStream
class LatexDocumentationProvider : DocumentationProvider {
companion object {
+
private val PACKAGE_COMMANDS = setOf("usepackage", "RequirePackage", "documentclass", "LoadClass")
}
diff --git a/src/nl/hannahsten/texifyidea/editor/CommandSelectionFilter.kt b/src/nl/hannahsten/texifyidea/editor/CommandSelectionFilter.kt
index 2e541ac45..223d74265 100644
--- a/src/nl/hannahsten/texifyidea/editor/CommandSelectionFilter.kt
+++ b/src/nl/hannahsten/texifyidea/editor/CommandSelectionFilter.kt
@@ -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 {
+
override fun value(t: PsiElement?) = !(
TexifySettings.getInstance().includeBackslashInSelection && (
t?.firstParentOfType(LatexCommands::class)?.text == t?.text ||
diff --git a/src/nl/hannahsten/texifyidea/editor/InlineMathBackspaceHandler.kt b/src/nl/hannahsten/texifyidea/editor/InlineMathBackspaceHandler.kt
index 32d2f51c5..9b8a353a3 100644
--- a/src/nl/hannahsten/texifyidea/editor/InlineMathBackspaceHandler.kt
+++ b/src/nl/hannahsten/texifyidea/editor/InlineMathBackspaceHandler.kt
@@ -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()
diff --git a/src/nl/hannahsten/texifyidea/editor/LatexCommandSelectioner.kt b/src/nl/hannahsten/texifyidea/editor/LatexCommandSelectioner.kt
index 1030926ce..c68c3a32a 100644
--- a/src/nl/hannahsten/texifyidea/editor/LatexCommandSelectioner.kt
+++ b/src/nl/hannahsten/texifyidea/editor/LatexCommandSelectioner.kt
@@ -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)
}
diff --git a/src/nl/hannahsten/texifyidea/editor/MathEnvironmentEditor.kt b/src/nl/hannahsten/texifyidea/editor/MathEnvironmentEditor.kt
index 9cb250296..f7d85758e 100644
--- a/src/nl/hannahsten/texifyidea/editor/MathEnvironmentEditor.kt
+++ b/src/nl/hannahsten/texifyidea/editor/MathEnvironmentEditor.kt
@@ -14,6 +14,7 @@ class MathEnvironmentEditor(
val editor: Editor,
val environment: PsiElement
) {
+
/**
* Apply the conversion of a math environment.
*/
diff --git a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileHandler.kt b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileHandler.kt
index 4a2f9934c..87a171bc1 100644
--- a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileHandler.kt
+++ b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileHandler.kt
@@ -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) {
diff --git a/src/nl/hannahsten/texifyidea/editor/autocompile/ContinuousPreviewHandler.kt b/src/nl/hannahsten/texifyidea/editor/autocompile/ContinuousPreviewHandler.kt
index 5a224081b..c607112a3 100644
--- a/src/nl/hannahsten/texifyidea/editor/autocompile/ContinuousPreviewHandler.kt
+++ b/src/nl/hannahsten/texifyidea/editor/autocompile/ContinuousPreviewHandler.kt
@@ -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 {
diff --git a/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostFixTemplateProvider.kt b/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostFixTemplateProvider.kt
index 446a276ab..412259bf2 100644
--- a/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostFixTemplateProvider.kt
+++ b/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostFixTemplateProvider.kt
@@ -7,6 +7,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiFile
object LatexPostFixTemplateProvider : PostfixTemplateProvider, CompletionContributor() {
+
private val templates = mutableSetOf(
LatexWrapWithGroupPostfixTemplate,
LatexWrapWithOpenGroupPostfixTemplate,
diff --git a/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixExpressionSelector.kt b/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixExpressionSelector.kt
index 2f8b958c0..da654b889 100644
--- a/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixExpressionSelector.kt
+++ b/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixExpressionSelector.kt
@@ -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()
diff --git a/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixTemplateFromPackageProvider.kt b/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixTemplateFromPackageProvider.kt
index ec8fe2acf..705d053de 100644
--- a/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixTemplateFromPackageProvider.kt
+++ b/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixTemplateFromPackageProvider.kt
@@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.lang.LatexPackage
import nl.hannahsten.texifyidea.util.insertUsepackage
abstract class LatexPostfixTemplateFromPackageProvider(private val pack: LatexPackage) : PostfixTemplateProvider {
+
abstract override fun getTemplates(): MutableSet
override fun isTerminalSymbol(currentChar: Char): Boolean = (currentChar == '.' || currentChar == ',')
@@ -22,6 +23,7 @@ abstract class LatexPostfixTemplateFromPackageProvider(private val pack: LatexPa
override fun preExpand(file: PsiFile, editor: Editor) {}
companion object {
+
fun getProvider(pack: LatexPackage?): PostfixTemplateProvider {
return when (pack) {
LatexPackage.AMSMATH -> LatexPostfixTemplateFromAmsMathProvider
@@ -34,18 +36,21 @@ abstract class LatexPostfixTemplateFromPackageProvider(private val pack: LatexPa
}
object LatexPostfixTemplateFromAmsMathProvider : LatexPostfixTemplateFromPackageProvider(LatexPackage.AMSMATH) {
+
override fun getTemplates(): MutableSet = mutableSetOf(
LatexWrapWithTextPostfixTemplate
)
}
object LatexPostfixTemplateFromAmsFontsProvider : LatexPostfixTemplateFromPackageProvider(LatexPackage.AMSFONTS) {
+
override fun getTemplates(): MutableSet = mutableSetOf(
LatexWrapWithMathbbPostfixTemplate
)
}
object LatexPostfixTemplateFromBmProvider : LatexPostfixTemplateFromPackageProvider(LatexPackage.BM) {
+
override fun getTemplates(): MutableSet = mutableSetOf(
LatexWrapWithBmPostfixTemplate
)
diff --git a/src/nl/hannahsten/texifyidea/editor/postfix/LatexStringBasedPostfixTemplates.kt b/src/nl/hannahsten/texifyidea/editor/postfix/LatexStringBasedPostfixTemplates.kt
index 6e9d64788..21e2d7e0a 100644
--- a/src/nl/hannahsten/texifyidea/editor/postfix/LatexStringBasedPostfixTemplates.kt
+++ b/src/nl/hannahsten/texifyidea/editor/postfix/LatexStringBasedPostfixTemplates.kt
@@ -40,6 +40,7 @@ internal object LatexWrapWithTextPostfixTemplate : ConstantStringBasedPostfixTem
mathOnly = true,
pack = LatexPackage.AMSMATH
) {
+
override fun setVariables(template: Template, element: PsiElement) {
template.addVariable("more", "", "", true)
}
@@ -78,6 +79,7 @@ internal abstract class ConstantStringBasedPostfixTemplate(
pack: LatexPackage? = null,
provider: PostfixTemplateProvider = LatexPostfixTemplateFromPackageProvider.getProvider(pack)
) : StringBasedPostfixTemplate(name, desc, LatexPostfixExpressionSelector(mathOnly, textOnly), provider) {
+
override fun getTemplateString(element: PsiElement) = template
override fun getElementToRemove(expr: PsiElement?) = expr
diff --git a/src/nl/hannahsten/texifyidea/editor/surroundwith/LatexSurroundDescriptor.kt b/src/nl/hannahsten/texifyidea/editor/surroundwith/LatexSurroundDescriptor.kt
index 6a484eb4a..3e4e53872 100644
--- a/src/nl/hannahsten/texifyidea/editor/surroundwith/LatexSurroundDescriptor.kt
+++ b/src/nl/hannahsten/texifyidea/editor/surroundwith/LatexSurroundDescriptor.kt
@@ -6,6 +6,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
class LatexSurroundDescriptor : SurroundDescriptor {
+
/**
* Get the first and last element of the selection, as these are the only
* elements the [LatexSurrounder] uses to surround a piece of text.
diff --git a/src/nl/hannahsten/texifyidea/editor/surroundwith/LatexSurrounder.kt b/src/nl/hannahsten/texifyidea/editor/surroundwith/LatexSurrounder.kt
index 3cf23d83f..f82617b7f 100644
--- a/src/nl/hannahsten/texifyidea/editor/surroundwith/LatexSurrounder.kt
+++ b/src/nl/hannahsten/texifyidea/editor/surroundwith/LatexSurrounder.kt
@@ -13,6 +13,7 @@ import nl.hannahsten.texifyidea.util.endOffset
* Surrounds selected text with the [surroundPair].
*/
open class LatexSurrounder(private val before: String, private val after: String) : Surrounder {
+
override fun isApplicable(elements: Array): Boolean {
return true
}
diff --git a/src/nl/hannahsten/texifyidea/file/FileExtensionMatcher.kt b/src/nl/hannahsten/texifyidea/file/FileExtensionMatcher.kt
index a8e5a87cf..171ccf86f 100644
--- a/src/nl/hannahsten/texifyidea/file/FileExtensionMatcher.kt
+++ b/src/nl/hannahsten/texifyidea/file/FileExtensionMatcher.kt
@@ -5,6 +5,7 @@ package nl.hannahsten.texifyidea.file
*/
@FunctionalInterface
interface FileExtensionMatcher {
+
/**
* Checks if the given extension is supported ('matched') or not..
*
diff --git a/src/nl/hannahsten/texifyidea/file/FileNameMatcher.kt b/src/nl/hannahsten/texifyidea/file/FileNameMatcher.kt
index 56034b6f1..f88b2c6a2 100644
--- a/src/nl/hannahsten/texifyidea/file/FileNameMatcher.kt
+++ b/src/nl/hannahsten/texifyidea/file/FileNameMatcher.kt
@@ -5,6 +5,7 @@ package nl.hannahsten.texifyidea.file
*/
@FunctionalInterface
interface FileNameMatcher {
+
/**
* Checks if the given file name matches or not.
*
diff --git a/src/nl/hannahsten/texifyidea/file/listeners/VfsChangeListener.kt b/src/nl/hannahsten/texifyidea/file/listeners/VfsChangeListener.kt
index efd06e6b5..6d97b2cb1 100644
--- a/src/nl/hannahsten/texifyidea/file/listeners/VfsChangeListener.kt
+++ b/src/nl/hannahsten/texifyidea/file/listeners/VfsChangeListener.kt
@@ -6,6 +6,7 @@ import nl.hannahsten.texifyidea.util.Magic
import nl.hannahsten.texifyidea.util.files.ReferencedFileSetService
class VfsChangeListener : BulkFileListener {
+
override fun after(events: MutableList) {
// Drop cache when files are added/deleted
events.filter { event -> !event.isFromSave && event.file?.extension in Magic.File.fileTypes.map { it.defaultExtension } }
diff --git a/src/nl/hannahsten/texifyidea/folding/LatexEscapedSymbolFoldingBuilder.kt b/src/nl/hannahsten/texifyidea/folding/LatexEscapedSymbolFoldingBuilder.kt
index c655e4947..a45bcee99 100644
--- a/src/nl/hannahsten/texifyidea/folding/LatexEscapedSymbolFoldingBuilder.kt
+++ b/src/nl/hannahsten/texifyidea/folding/LatexEscapedSymbolFoldingBuilder.kt
@@ -28,6 +28,7 @@ class LatexEscapedSymbolFoldingBuilder : FoldingBuilderEx() {
}
companion object {
+
val commandsToFold = setOf("%", "#", "&", "_", "$").map { "\\" + it }
}
}
diff --git a/src/nl/hannahsten/texifyidea/folding/LatexSectionFoldingBuilder.kt b/src/nl/hannahsten/texifyidea/folding/LatexSectionFoldingBuilder.kt
index 4b01b44b3..c6d486a30 100644
--- a/src/nl/hannahsten/texifyidea/folding/LatexSectionFoldingBuilder.kt
+++ b/src/nl/hannahsten/texifyidea/folding/LatexSectionFoldingBuilder.kt
@@ -22,6 +22,7 @@ import nl.hannahsten.texifyidea.util.previousSiblingIgnoreWhitespace
open class LatexSectionFoldingBuilder : FoldingBuilderEx() {
companion object {
+
private val sectionCommandNames = arrayOf(
"part", "chapter",
"section", "subsection", "subsubsection",
diff --git a/src/nl/hannahsten/texifyidea/formatting/LatexFormattingModelBuilder.kt b/src/nl/hannahsten/texifyidea/formatting/LatexFormattingModelBuilder.kt
index aa3f4d38e..acc2f5666 100644
--- a/src/nl/hannahsten/texifyidea/formatting/LatexFormattingModelBuilder.kt
+++ b/src/nl/hannahsten/texifyidea/formatting/LatexFormattingModelBuilder.kt
@@ -9,6 +9,7 @@ import com.intellij.psi.PsiFile
* @author Sten Wessel
*/
class LatexFormattingModelBuilder : FormattingModelBuilder {
+
override fun createModel(context: FormattingContext): FormattingModel {
return FormattingModelProvider.createFormattingModelForPsiFile(
context.containingFile,
diff --git a/src/nl/hannahsten/texifyidea/formatting/LatexLanguageFormattingRestriction.kt b/src/nl/hannahsten/texifyidea/formatting/LatexLanguageFormattingRestriction.kt
index 18e434fce..2fedac058 100644
--- a/src/nl/hannahsten/texifyidea/formatting/LatexLanguageFormattingRestriction.kt
+++ b/src/nl/hannahsten/texifyidea/formatting/LatexLanguageFormattingRestriction.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.util.Magic
* Disable the formatter on files that start and end with a verbatim environment.
*/
class LatexLanguageFormattingRestriction : LanguageFormattingRestriction {
+
override fun isFormatterAllowed(context: PsiElement): Boolean = !isFormatterNotAllowed(context)
private fun isFormatterNotAllowed(context: PsiElement): Boolean {
diff --git a/src/nl/hannahsten/texifyidea/formatting/TexSpacingBuilder.kt b/src/nl/hannahsten/texifyidea/formatting/TexSpacingBuilder.kt
index 2b76369e2..f81dc2ba8 100644
--- a/src/nl/hannahsten/texifyidea/formatting/TexSpacingBuilder.kt
+++ b/src/nl/hannahsten/texifyidea/formatting/TexSpacingBuilder.kt
@@ -21,6 +21,7 @@ class TexSpacingBuilder(private val commonSettings: CommonCodeStyleSettings) {
* Generic spacing builder.
*/
private interface Builder {
+
fun getSpacing(parent: ASTBlock, left: ASTBlock, right: ASTBlock): Spacing?
}
@@ -29,6 +30,7 @@ class TexSpacingBuilder(private val commonSettings: CommonCodeStyleSettings) {
*/
@Suppress("RedundantOverride") // Abstract method has to be overridden
inner class BasicSpacingBuilder : SpacingBuilder(commonSettings), Builder {
+
override fun getSpacing(parent: ASTBlock, left: ASTBlock, right: ASTBlock): Spacing? {
return super.getSpacing(parent, left, right)
}
@@ -73,6 +75,7 @@ class TexSpacingBuilder(private val commonSettings: CommonCodeStyleSettings) {
* Build more advanced rules with [Rule] and [Condition] above.
*/
inner class CustomSpacingBuilder : Builder {
+
private val rules = ArrayList()
private var conditions = ArrayList()
diff --git a/src/nl/hannahsten/texifyidea/gutter/LatexCompileGutter.kt b/src/nl/hannahsten/texifyidea/gutter/LatexCompileGutter.kt
index 84c172085..baa2d2d70 100644
--- a/src/nl/hannahsten/texifyidea/gutter/LatexCompileGutter.kt
+++ b/src/nl/hannahsten/texifyidea/gutter/LatexCompileGutter.kt
@@ -7,7 +7,7 @@ import com.intellij.psi.PsiElement
import com.intellij.util.Function
import nl.hannahsten.texifyidea.TexifyIcons
import nl.hannahsten.texifyidea.psi.LatexBeginCommand
-import nl.hannahsten.texifyidea.psi.LatexParameterText
+import nl.hannahsten.texifyidea.psi.LatexTypes
import nl.hannahsten.texifyidea.util.isEntryPoint
import nl.hannahsten.texifyidea.util.parentOfType
@@ -19,14 +19,14 @@ import nl.hannahsten.texifyidea.util.parentOfType
class LatexCompileGutter : RunLineMarkerContributor() {
override fun getInfo(element: PsiElement): Info? {
- if (element.firstChild != null || element.parent !is LatexParameterText) return null
+ // Only show the icon on lines with `\begin` => show only one icon.
+ if (element.node.elementType != LatexTypes.BEGIN_TOKEN) return null
+ // Find the total enclosed begin command: required to easily find the first command.
val beginCommand = element.parentOfType(LatexBeginCommand::class) ?: return null
// Break when not a valid command: don't show icon.
- if (!beginCommand.isEntryPoint()) {
- return null
- }
+ if (beginCommand.isEntryPoint().not()) return null
// Lookup actions.
val actionManager = ActionManager.getInstance()
@@ -41,4 +41,4 @@ class LatexCompileGutter : RunLineMarkerContributor() {
editConfigs
)
}
-}
+}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/highlighting/LatexSyntaxHighlighter.kt b/src/nl/hannahsten/texifyidea/highlighting/LatexSyntaxHighlighter.kt
index cfcf310f1..f99d77c2f 100644
--- a/src/nl/hannahsten/texifyidea/highlighting/LatexSyntaxHighlighter.kt
+++ b/src/nl/hannahsten/texifyidea/highlighting/LatexSyntaxHighlighter.kt
@@ -13,6 +13,7 @@ import nl.hannahsten.texifyidea.psi.LatexTypes
* @author Hannah Schellekens, Sten Wessel
*/
class LatexSyntaxHighlighter : SyntaxHighlighterBase() {
+
override fun getHighlightingLexer(): Lexer {
return LatexLexerAdapter()
}
@@ -48,6 +49,7 @@ class LatexSyntaxHighlighter : SyntaxHighlighterBase() {
}
companion object {
+
/*
* TextAttributesKeys
*/
diff --git a/src/nl/hannahsten/texifyidea/highlighting/LatexTypedHandler.kt b/src/nl/hannahsten/texifyidea/highlighting/LatexTypedHandler.kt
index ae9d77e09..cd7998f07 100644
--- a/src/nl/hannahsten/texifyidea/highlighting/LatexTypedHandler.kt
+++ b/src/nl/hannahsten/texifyidea/highlighting/LatexTypedHandler.kt
@@ -20,6 +20,7 @@ import nl.hannahsten.texifyidea.util.files.isLatexFile
* @author Sten Wessel
*/
class LatexTypedHandler : TypedHandlerDelegate() {
+
/**
* When pressing $ when text is selected, surround with $ signs.
*/
diff --git a/src/nl/hannahsten/texifyidea/index/IndexKeys.kt b/src/nl/hannahsten/texifyidea/index/IndexKeys.kt
index 3b2f7d295..808d506e4 100644
--- a/src/nl/hannahsten/texifyidea/index/IndexKeys.kt
+++ b/src/nl/hannahsten/texifyidea/index/IndexKeys.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.psi.LatexMagicComment
* @author Hannah Schellekens
*/
object IndexKeys {
+
val COMMANDS_KEY =
StubIndexKey.createIndexKey("nl.hannahsten.texifyidea.commands")
val INCLUDES_KEY =
diff --git a/src/nl/hannahsten/texifyidea/index/LatexEnvironmentsIndex.kt b/src/nl/hannahsten/texifyidea/index/LatexEnvironmentsIndex.kt
index ff8fdca47..d1a853e39 100644
--- a/src/nl/hannahsten/texifyidea/index/LatexEnvironmentsIndex.kt
+++ b/src/nl/hannahsten/texifyidea/index/LatexEnvironmentsIndex.kt
@@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.psi.LatexEnvironment
* This index contains all environments
*/
class LatexEnvironmentsIndex : StringStubIndexExtension() {
+
companion object : IndexUtilBase(LatexEnvironment::class.java, IndexKeys.ENVIRONMENTS_KEY)
@Suppress("RedundantCompanionReference")
diff --git a/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt b/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt
index 7a603cf83..fd099f151 100644
--- a/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt
+++ b/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt
@@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.psi.LatexCommands
* This index contains commands that define a label in their optional parameters.
*/
class LatexParameterLabeledCommandsIndex : StringStubIndexExtension() {
+
companion object : IndexUtilBase(LatexCommands::class.java, IndexKeys.LABELED_COMMANDS_KEY)
@Suppress("RedundantCompanionReference")
diff --git a/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledEnvironmentsIndex.kt b/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledEnvironmentsIndex.kt
index 458b3ac84..598b12d64 100644
--- a/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledEnvironmentsIndex.kt
+++ b/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledEnvironmentsIndex.kt
@@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.psi.LatexEnvironment
* a label defined with an optional parameter.
*/
class LatexParameterLabeledEnvironmentsIndex : StringStubIndexExtension() {
+
companion object : IndexUtilBase(LatexEnvironment::class.java, IndexKeys.LABELED_ENVIRONMENTS_KEY)
@Suppress("RedundantCompanionReference")
diff --git a/src/nl/hannahsten/texifyidea/index/stub/BibtexEntryStub.kt b/src/nl/hannahsten/texifyidea/index/stub/BibtexEntryStub.kt
index 7909e77d4..5649f9e0f 100644
--- a/src/nl/hannahsten/texifyidea/index/stub/BibtexEntryStub.kt
+++ b/src/nl/hannahsten/texifyidea/index/stub/BibtexEntryStub.kt
@@ -5,6 +5,7 @@ import com.intellij.psi.stubs.StubElement
import nl.hannahsten.texifyidea.psi.BibtexEntry
interface BibtexEntryStub : StubElement, NamedStub {
+
val title: String
val authors: List
val year: String
diff --git a/src/nl/hannahsten/texifyidea/index/stub/BibtexEntryStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/BibtexEntryStubElementType.kt
index 3e23ca3d0..f5c2c370b 100644
--- a/src/nl/hannahsten/texifyidea/index/stub/BibtexEntryStubElementType.kt
+++ b/src/nl/hannahsten/texifyidea/index/stub/BibtexEntryStubElementType.kt
@@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.psi.BibtexEntry
import nl.hannahsten.texifyidea.psi.impl.BibtexEntryImpl
open class BibtexEntryStubElementType(debugName: String) : IStubElementType(debugName, BibtexLanguage) {
+
override fun createPsi(stub: BibtexEntryStub): BibtexEntry {
return BibtexEntryImpl(stub, this)
}
diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStub.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStub.kt
index 8af0bf3e3..160913cce 100644
--- a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStub.kt
+++ b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStub.kt
@@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.psi.LatexCommands
* @author Hannah Schellekens
*/
interface LatexCommandsStub : StubElement, NamedStub {
+
val commandToken: String
val requiredParams: List
val optionalParams: Map
diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt
index 0c99121b2..44f9faf49 100644
--- a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt
+++ b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt
@@ -20,6 +20,7 @@ import java.util.stream.Collectors
*/
class LatexCommandsStubElementType(debugName: String) :
IStubElementType(debugName, LatexLanguage.INSTANCE) {
+
override fun createPsi(latexCommandsStub: LatexCommandsStub): LatexCommands {
return object : LatexCommandsImpl(latexCommandsStub, this) {
init {
@@ -109,6 +110,7 @@ class LatexCommandsStubElementType(debugName: String) :
}
companion object {
+
private val LIST_ELEMENT_SEPARATOR =
Pattern.compile("\u1923\u9123\u2d20 hello\u0012")
private val KEY_VALUE_SEPARATOR = "=".toRegex()
diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStub.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStub.kt
index 686695758..d137aeea2 100644
--- a/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStub.kt
+++ b/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStub.kt
@@ -4,6 +4,7 @@ import com.intellij.psi.stubs.StubElement
import nl.hannahsten.texifyidea.psi.LatexEnvironment
interface LatexEnvironmentStub : StubElement {
+
val environmentName: String
val label: String
}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt
index 8ce20bb08..062c5587f 100644
--- a/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt
+++ b/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.util.Magic
import java.io.IOException
open class LatexEnvironmentStubElementType(debugName: String) : IStubElementType(debugName, LatexLanguage.INSTANCE) {
+
override fun createPsi(stub: LatexEnvironmentStub): LatexEnvironment {
return LatexEnvironmentImpl(stub, this)
}
diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexMagicCommentStub.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexMagicCommentStub.kt
index 0a54d83d0..97908b395 100644
--- a/src/nl/hannahsten/texifyidea/index/stub/LatexMagicCommentStub.kt
+++ b/src/nl/hannahsten/texifyidea/index/stub/LatexMagicCommentStub.kt
@@ -4,6 +4,7 @@ import com.intellij.psi.stubs.StubElement
import nl.hannahsten.texifyidea.psi.LatexMagicComment
interface LatexMagicCommentStub : StubElement {
+
val key: String
val value: String?
}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexMagicCommentStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexMagicCommentStubElementType.kt
index 3eb54891a..c56661e88 100644
--- a/src/nl/hannahsten/texifyidea/index/stub/LatexMagicCommentStubElementType.kt
+++ b/src/nl/hannahsten/texifyidea/index/stub/LatexMagicCommentStubElementType.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.psi.value
import java.io.IOException
open class LatexMagicCommentStubElementType(debugName: String) : IStubElementType(debugName, LatexLanguage.INSTANCE) {
+
override fun createPsi(stub: LatexMagicCommentStub): LatexMagicComment = LatexMagicCommentImpl(stub, this)
override fun createStub(psi: LatexMagicComment, parentStub: StubElement<*>): LatexMagicCommentStub {
diff --git a/src/nl/hannahsten/texifyidea/insight/LatexElementColorProvider.kt b/src/nl/hannahsten/texifyidea/insight/LatexElementColorProvider.kt
index 27310de09..6ca5fb4b6 100644
--- a/src/nl/hannahsten/texifyidea/insight/LatexElementColorProvider.kt
+++ b/src/nl/hannahsten/texifyidea/insight/LatexElementColorProvider.kt
@@ -14,6 +14,7 @@ import nl.hannahsten.texifyidea.util.usesColor
import java.awt.Color
object LatexElementColorProvider : ElementColorProvider {
+
override fun setColorTo(element: PsiElement, color: Color) {}
override fun getColorFrom(element: PsiElement): Color? {
diff --git a/src/nl/hannahsten/texifyidea/inspections/LatexGrammarCheckingStrategy.kt b/src/nl/hannahsten/texifyidea/inspections/LatexGrammarCheckingStrategy.kt
index dbab85bba..4e2082a8d 100644
--- a/src/nl/hannahsten/texifyidea/inspections/LatexGrammarCheckingStrategy.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/LatexGrammarCheckingStrategy.kt
@@ -9,6 +9,7 @@ import com.intellij.psi.PsiElement
import nl.hannahsten.texifyidea.psi.*
class LatexGrammarCheckingStrategy : GrammarCheckingStrategy {
+
private fun PsiElement.isNotInMathEnvironment() = parents().none { it is LatexMathEnvironment }
private fun PsiElement.isNotInSquareBrackets() = parents().find { it is LatexGroup || it is LatexOptionalParam }
diff --git a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexUnusedEntryInspection.kt b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexUnusedEntryInspection.kt
index f866cac4f..1ac8307a6 100644
--- a/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexUnusedEntryInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/bibtex/BibtexUnusedEntryInspection.kt
@@ -19,6 +19,7 @@ import nl.hannahsten.texifyidea.util.childrenOfType
import nl.hannahsten.texifyidea.util.previousSiblingOfType
class BibtexUnusedEntryInspection : TexifyInspectionBase() {
+
override val inspectionGroup: InsightGroup = InsightGroup.BIBTEX
override val inspectionId: String = "UnusedEntry"
@@ -39,6 +40,7 @@ class BibtexUnusedEntryInspection : TexifyInspectionBase() {
.toList()
class RemoveBibtexEntryFix(private val id: SmartPsiElementPointer) : LocalQuickFix {
+
override fun getFamilyName(): String = "Remove BibTeX entry ${id.element?.text}"
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexAbsolutePathInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexAbsolutePathInspection.kt
index 3cb2f8f25..99811171c 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexAbsolutePathInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexAbsolutePathInspection.kt
@@ -17,6 +17,7 @@ import java.io.File
* @author Thomas
*/
class LatexAbsolutePathInspection : TexifyInspectionBase() {
+
override val inspectionGroup = InsightGroup.LATEX
override val inspectionId = "AbsolutePath"
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexDocumentclassNotInRootInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexDocumentclassNotInRootInspection.kt
index 4eb4d79e8..6ad6c7c32 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexDocumentclassNotInRootInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexDocumentclassNotInRootInspection.kt
@@ -12,6 +12,7 @@ import nl.hannahsten.texifyidea.util.files.commandsInFile
import org.jetbrains.annotations.Nls
class LatexDocumentclassNotInRootInspection : TexifyInspectionBase() {
+
override val inspectionGroup: InsightGroup
get() = InsightGroup.LATEX
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexEscapeHashOutsideCommandInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexEscapeHashOutsideCommandInspection.kt
index 25a25c814..9a4503eeb 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexEscapeHashOutsideCommandInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexEscapeHashOutsideCommandInspection.kt
@@ -17,6 +17,7 @@ class LatexEscapeHashOutsideCommandInspection : TexifyRegexInspection(
quickFixName = { "escape #" },
replacement = { _, _ -> """\#""" }
) {
+
override fun checkContext(element: PsiElement): Boolean {
return super.checkContext(element) && element.parentsOfType().all { !it.isCommandDefinition() } && element.parentOfType(LatexCommands::class)?.name !in Magic.Command.urls
}
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMathOperatorEscapeInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMathOperatorEscapeInspection.kt
index ce9a479c3..58d9fb228 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMathOperatorEscapeInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMathOperatorEscapeInspection.kt
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.Nls
* @author Sten Wessel
*/
class LatexMathOperatorEscapeInspection : TexifyInspectionBase() {
+
override val inspectionGroup: InsightGroup
get() = InsightGroup.LATEX
@@ -87,6 +88,7 @@ class LatexMathOperatorEscapeInspection : TexifyInspectionBase() {
* @author Sten Wessel
*/
private class EscapeMathOperatorFix : LocalQuickFix {
+
@Nls
override fun getFamilyName(): String {
return "Escape math operator"
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMightBreakTexifyInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMightBreakTexifyInspection.kt
index 065f31daa..5511f660f 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMightBreakTexifyInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMightBreakTexifyInspection.kt
@@ -16,6 +16,7 @@ import org.jetbrains.annotations.Nls
* @author Sten Wessel
*/
class LatexMightBreakTexifyInspection : TexifyInspectionBase() {
+
override val inspectionGroup: InsightGroup
get() = InsightGroup.LATEX
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspection.kt
index c8832313d..06786e0b8 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspection.kt
@@ -34,6 +34,7 @@ import java.util.*
* @author Hannah Schellekens
*/
open class LatexMissingImportInspection : TexifyInspectionBase() {
+
override val inspectionGroup = InsightGroup.LATEX
override val inspectionId = "MissingImport"
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt
index fc7bb5623..d36ecb406 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt
@@ -6,21 +6,21 @@ import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.Project
-import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.refactoring.suggested.createSmartPointer
import nl.hannahsten.texifyidea.insight.InsightGroup
import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase
-import nl.hannahsten.texifyidea.intentions.LatexAddLabelIntention
+import nl.hannahsten.texifyidea.intentions.LatexAddLabelToCommandIntention
+import nl.hannahsten.texifyidea.intentions.LatexAddLabelToEnvironmentIntention
import nl.hannahsten.texifyidea.lang.LatexDocumentClass
import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope
import nl.hannahsten.texifyidea.psi.LatexCommands
import nl.hannahsten.texifyidea.psi.LatexEnvironment
-import nl.hannahsten.texifyidea.psi.LatexPsiHelper
import nl.hannahsten.texifyidea.settings.TexifyConfigurable
import nl.hannahsten.texifyidea.settings.TexifySettings
-import nl.hannahsten.texifyidea.util.*
+import nl.hannahsten.texifyidea.util.Magic
import nl.hannahsten.texifyidea.util.files.*
+import nl.hannahsten.texifyidea.util.hasStar
import org.jetbrains.annotations.Nls
import java.util.*
@@ -124,6 +124,7 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() {
* Open the settings page so the user can change the minimum labeled level.
*/
private class ChangeMinimumLabelLevelFix : LocalQuickFix {
+
@Nls
override fun getFamilyName(): String {
return "Change minimum sectioning level"
@@ -136,73 +137,36 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() {
}
}
- abstract class LabelQuickFix : LocalQuickFix {
- protected fun getUniqueLabelName(base: String, prefix: String?, file: PsiFile): String {
- val labelBase = "$prefix:$base"
- val allLabels = file.findLatexAndBibtexLabelStringsInFileSet()
- return appendCounter(labelBase, allLabels)
- }
-
- /**
- * Keeps adding a counter behind the label until there is no other label with that name.
- */
- private fun appendCounter(label: String, allLabels: Set): String {
- var counter = 2
- var candidate = label
-
- while (allLabels.contains(candidate)) {
- candidate = label + (counter++)
- }
-
- return candidate
- }
- }
-
/**
* This is also an intention, but in order to keep the same alt+enter+enter functionality (because we have an other
* quickfix as well) we keep it as a quickfix also.
*/
- private class InsertLabelForCommandFix : LabelQuickFix() {
+ private class InsertLabelForCommandFix : LocalQuickFix {
// It has to appear in alphabetical order before the other quickfix
override fun getFamilyName() = "Add label for this command"
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val command = descriptor.psiElement as LatexCommands
- LatexAddLabelIntention(command.createSmartPointer()).invoke(project, command.containingFile.openedEditor(), command.containingFile)
+ LatexAddLabelToCommandIntention(command.createSmartPointer()).invoke(
+ project,
+ command.containingFile.openedEditor(),
+ command.containingFile
+ )
}
}
- private class InsertLabelInEnvironmentFix : LabelQuickFix() {
+ private class InsertLabelInEnvironmentFix : LocalQuickFix {
+
override fun getFamilyName() = "Add label for this environment"
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
- val command = descriptor.psiElement as LatexEnvironment
- val helper = LatexPsiHelper(project)
- // Determine label name.
- val createdLabel = getUniqueLabelName(
- command.environmentName.formatAsLabel(),
- Magic.Environment.labeled[command.environmentName], command.containingFile
+ val environment = descriptor.psiElement as LatexEnvironment
+ LatexAddLabelToEnvironmentIntention(environment.createSmartPointer()).invoke(
+ project,
+ environment.containingFile.openedEditor(),
+ environment.containingFile
)
-
- val moveCaretAfter: PsiElement
- moveCaretAfter = if (Magic.Environment.labelAsParameter.contains(command.environmentName)) {
- helper.setOptionalParameter(command.beginCommand, "label", "{$createdLabel}")
- }
- else {
- // in a float environment the label must be inserted after a caption
- val labelCommand = helper.addToContent(
- command, helper.createLabelCommand(createdLabel),
- command.environmentContent?.childrenOfType()
- ?.findLast { c -> c.name == "\\caption" }
- )
- labelCommand
- }
-
- // Adjust caret offset
- val openedEditor = command.containingFile.openedEditor() ?: return
- val caretModel = openedEditor.caretModel
- caretModel.moveToOffset(moveCaretAfter.endOffset())
}
}
}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleGraphicsPathInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleGraphicsPathInspection.kt
index f2a3d0ec3..9e06d4125 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleGraphicsPathInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleGraphicsPathInspection.kt
@@ -51,6 +51,7 @@ class LatexMultipleGraphicsPathInspection : TexifyInspectionBase() {
* Remove the command line.
*/
class RemoveFix : LocalQuickFix {
+
override fun getFamilyName(): String {
return "Remove this Line"
}
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexOverInsteadOfFracInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexOverInsteadOfFracInspection.kt
index 664f6782d..dc67392d7 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexOverInsteadOfFracInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexOverInsteadOfFracInspection.kt
@@ -22,6 +22,7 @@ import java.util.*
* @author Hannah Schellekens
*/
class LatexOverInsteadOfFracInspection : TexifyInspectionBase() {
+
override val inspectionGroup: InsightGroup
get() = InsightGroup.LATEX
@@ -60,6 +61,7 @@ class LatexOverInsteadOfFracInspection : TexifyInspectionBase() {
}
private inner class OverToFracFix : LocalQuickFix {
+
@Nls
override fun getFamilyName(): String {
return "Convert to \\frac"
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageCouldNotBeFound.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageCouldNotBeFound.kt
index d993057b0..86c6864c9 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageCouldNotBeFound.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageCouldNotBeFound.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.psi.LatexCommands
import nl.hannahsten.texifyidea.util.*
class LatexPackageCouldNotBeFound : TexifyInspectionBase() {
+
override val inspectionGroup: InsightGroup = InsightGroup.LATEX
override val inspectionId: String =
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNameDoesNotMatchFileNameInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNameDoesNotMatchFileNameInspection.kt
index c1c519f32..93eae981f 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNameDoesNotMatchFileNameInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNameDoesNotMatchFileNameInspection.kt
@@ -13,6 +13,7 @@ import nl.hannahsten.texifyidea.psi.LatexPsiHelper
import nl.hannahsten.texifyidea.util.childrenOfType
class LatexPackageNameDoesNotMatchFileNameInspection : TexifyInspectionBase() {
+
override val inspectionGroup: InsightGroup = InsightGroup.LATEX
override val inspectionId: String =
@@ -48,6 +49,7 @@ class LatexPackageNameDoesNotMatchFileNameInspection : TexifyInspectionBase() {
}
object PackageNameMatchFileNameQuickFix : LocalQuickFix {
+
override fun getFamilyName(): String {
return "Fix package name"
}
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNotInstalledInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNotInstalledInspection.kt
index 2cb486c02..ad8954b86 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNotInstalledInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNotInstalledInspection.kt
@@ -26,6 +26,7 @@ import nl.hannahsten.texifyidea.util.*
* Check if a LaTeX package is not installed (only for TeX Live, since MiKTeX downloads them automatically).
*/
class LatexPackageNotInstalledInspection : TexifyInspectionBase() {
+
// This caches packages which are not installed, which is needed
// otherwise we are running the expensive call to tlmgr basically on
// every letter typed - exactly the same call with the same results
@@ -87,6 +88,7 @@ class LatexPackageNotInstalledInspection : TexifyInspectionBase() {
}
private class InstallPackage(val filePointer: SmartPsiElementPointer, val packageName: String, val knownNotInstalledPackages: MutableSet) : LocalQuickFix {
+
override fun getFamilyName(): String = "Install $packageName"
/**
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageSubdirectoryInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageSubdirectoryInspection.kt
index 80ab92a2e..c5c16cc10 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageSubdirectoryInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPackageSubdirectoryInspection.kt
@@ -16,6 +16,7 @@ import java.io.File
import kotlin.math.max
class LatexPackageSubdirectoryInspection : TexifyInspectionBase() {
+
override val inspectionGroup: InsightGroup = InsightGroup.LATEX
override val inspectionId: String = "PackageSubdirectoryInspection"
@@ -55,6 +56,7 @@ class LatexPackageSubdirectoryInspection : TexifyInspectionBase() {
}
inner class FixSubdirectoryQuickFix(private val oldDir: String, private val newDir: String) : LocalQuickFix {
+
override fun getFamilyName(): String =
"Change LaTeX command to match directory structure"
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveStyleInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveStyleInspection.kt
index 1516f8e21..4eeaa1fec 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveStyleInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveStyleInspection.kt
@@ -22,6 +22,7 @@ import kotlin.reflect.jvm.internal.impl.utils.SmartList
* @author Hannah Schellekens
*/
class LatexPrimitiveStyleInspection : TexifyInspectionBase() {
+
override val inspectionGroup: InsightGroup
get() = InsightGroup.LATEX
@@ -60,6 +61,7 @@ class LatexPrimitiveStyleInspection : TexifyInspectionBase() {
}
private inner class InspectionFix : LocalQuickFix {
+
@Nls
override fun getFamilyName(): String {
return "Convert to LaTeX alternative"
diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexUnicodeInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexUnicodeInspection.kt
index 3d1f7129c..5471daae8 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexUnicodeInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexUnicodeInspection.kt
@@ -50,6 +50,7 @@ import java.util.regex.Pattern
class LatexUnicodeInspection : TexifyInspectionBase() {
companion object {
+
private val BASE_PATTERN = Pattern.compile("^\\p{ASCII}*")
/**
diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt
index c616dfb5e..2d0bd0dc1 100644
--- a/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt
+++ b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt
@@ -1,103 +1,72 @@
package nl.hannahsten.texifyidea.intentions
-import com.intellij.codeInsight.template.TemplateManager
-import com.intellij.codeInsight.template.impl.TemplateImpl
-import com.intellij.codeInsight.template.impl.TextExpression
import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.editor.RangeMarker
import com.intellij.openapi.project.Project
+import com.intellij.openapi.util.TextRange
+import com.intellij.psi.PsiDocumentManager
+import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
-import com.intellij.psi.SmartPsiElementPointer
-import nl.hannahsten.texifyidea.psi.LatexCommands
+import com.intellij.psi.PsiNamedElement
+import com.intellij.psi.util.parentOfType
+import com.intellij.refactoring.rename.RenameProcessor
+import com.intellij.refactoring.rename.inplace.MemberInplaceRenamer
+import nl.hannahsten.texifyidea.psi.LatexCommandWithParams
import nl.hannahsten.texifyidea.psi.LatexPsiHelper
-import nl.hannahsten.texifyidea.util.*
-import nl.hannahsten.texifyidea.util.files.isLatexFile
+import nl.hannahsten.texifyidea.util.findLatexAndBibtexLabelStringsInFileSet
import kotlin.math.max
-/**
- * @author Hannah Schellekens
- */
-open class LatexAddLabelIntention(val command: SmartPsiElementPointer? = null) : TexifyIntentionBase("Add label") {
+abstract class LatexAddLabelIntention : TexifyIntentionBase("Add label") {
- private fun findCommand(editor: Editor?, file: PsiFile?): LatexCommands? {
- val offset = editor?.caretModel?.offset ?: return null
- val element = file?.findElementAt(offset) ?: return null
- // Also check one position back, because we want it to trigger in \section{a}
- return element as? LatexCommands ?: element.parentOfType(LatexCommands::class)
- ?: file.findElementAt(max(0, offset - 1)) as? LatexCommands
- ?: file.findElementAt(max(0, offset - 1))?.parentOfType(LatexCommands::class)
- }
-
- override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean {
- if (file?.isLatexFile() == false) {
- return false
+ /**
+ * This class handles the rename of a label parameter after insertion
+ */
+ private class LabelInplaceRenamer(
+ elementToRename: PsiNamedElement,
+ editor: Editor,
+ private val prefix: String,
+ initialName: String,
+ private val endMarker: RangeMarker
+ ) : MemberInplaceRenamer(elementToRename, null, editor, initialName, initialName) {
+
+ override fun getRangeToRename(element: PsiElement): TextRange {
+ // The label prefix is given by convention and not renamed
+ return TextRange(prefix.length, element.textLength)
}
- return findCommand(editor, file)?.name in Magic.Command.labeledPrefixes
- }
-
- override fun startInWriteAction() = true
-
- override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
- if (editor == null || file == null) {
- return
+ override fun createRenameProcessor(element: PsiElement?, newName: String?): RenameProcessor {
+ // Automatically prepend the prefix
+ return super.createRenameProcessor(element, "$prefix$newName")
}
- // When no this.command is provided, use the command at the caret as the best guess.
- val command: LatexCommands = this.command?.element
- ?: findCommand(editor, file)
- ?: return
-
- // Determine label name.
- val labelString: String? = if (Magic.Command.labelAsParameter.contains(command.name)) {
- // For parameter labeled commands we use the command name itself
- command.name!!
+ override fun moveOffsetAfter(success: Boolean) {
+ super.moveOffsetAfter(success)
+ myEditor.caretModel.moveToOffset(endMarker.endOffset)
}
- else {
- // For all other commands we use the first required parameter
- val required = command.requiredParameters
- if (required.isNotEmpty()) {
- required[0]
- }
- else {
- null
- }
- }
-
- val prefix = Magic.Command.labeledPrefixes[command.name!!]
- if (labelString != null) {
- val createdLabel = getUniqueLabelName(
- labelString.formatAsLabel(),
- prefix, command.containingFile
- )
-
- val factory = LatexPsiHelper(project)
-
- val labelCommand = if (Magic.Command.labelAsParameter.contains(command.name)) {
- factory.setOptionalParameter(command, "label", "{$createdLabel}")
+ override fun restoreCaretOffsetAfterRename() {
+ // Dispose the marker like the parent method does, but do not move the caret. We already moved it in
+ // moveOffsetAfter
+ if (myBeforeRevert != null) {
+ myBeforeRevert.dispose()
}
- else {
- // Insert label
- // command -> NoMathContent -> Content -> Container containing the command
- val commandContent = command.parent.parent
- commandContent.parent.addAfter(factory.createLabelCommand(createdLabel), commandContent)
- }
- // Adjust caret offset.
- val caret = editor.caretModel
- caret.moveToOffset(labelCommand.endOffset())
- }
- else {
- editor.caretModel.moveToOffset(command.endOffset())
- val template = TemplateImpl("", "\\label{$prefix:\$__Variable0\$}", "")
- template.addVariable(TextExpression(""), true)
- TemplateManager.getInstance(editor.project).startTemplate(editor, template)
}
}
- private fun getUniqueLabelName(base: String, prefix: String?, file: PsiFile): String {
+ protected inline fun findTarget(editor: Editor?, file: PsiFile?): T? {
+ val offset = editor?.caretModel?.offset ?: return null
+ val element = file?.findElementAt(offset) ?: return null
+ // Also check one position back, because we want it to trigger in \section{a}
+ return element as? T ?: element.parentOfType()
+ ?: file.findElementAt(max(0, offset - 1)) as? T
+ ?: file.findElementAt(max(0, offset - 1))?.parentOfType()
+ }
+
+ protected fun getUniqueLabelName(base: String, prefix: String, file: PsiFile): LabelWithPrefix {
val labelBase = "$prefix:$base"
val allLabels = file.findLatexAndBibtexLabelStringsInFileSet()
- return appendCounter(labelBase, allLabels)
+ val fullLabel = appendCounter(labelBase, allLabels)
+ return LabelWithPrefix(prefix, fullLabel.substring(prefix.length + 1))
}
/**
@@ -113,4 +82,33 @@ open class LatexAddLabelIntention(val command: SmartPsiElementPointer? = null) :
+ LatexAddLabelIntention() {
+
+ override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean {
+ if (file?.isLatexFile() == false) {
+ return false
+ }
+
+ return findTarget(editor, file)?.name in Magic.Command.labeledPrefixes
+ }
+
+ override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
+ if (editor == null || file == null) {
+ return
+ }
+
+ // When no this.command is provided, use the command at the caret as the best guess.
+ val command: LatexCommands = this.command?.element
+ ?: findTarget(editor, file)
+ ?: return
+
+ val prefix = Magic.Command.labeledPrefixes[command.name!!] ?: return
+
+ val factory = LatexPsiHelper(project)
+
+ // For sections we can infer a reasonable label name from the required parameter
+ if (Magic.Command.sectionMarkers.contains(command.name)) {
+ val required = command.requiredParameters
+
+ // Section commands should all have a required parameter
+ val labelString: String = required.getOrNull(0) ?: return
+ val createdLabel = getUniqueLabelName(
+ labelString.formatAsLabel(),
+ prefix, command.containingFile
+ )
+
+ // Insert label
+ // command -> NoMathContent -> Content -> Container containing the command
+ val commandContent = command.parent.parent
+ val labelCommand =
+ commandContent.parent.addAfter(factory.createLabelCommand(createdLabel.labelText), commandContent)
+
+ // Adjust caret offset.
+ val caret = editor.caretModel
+ caret.moveToOffset(labelCommand.endOffset())
+ }
+ else {
+ if (Magic.Command.labelAsParameter.contains(command.name)) {
+ // Create a label parameter and initiate the rename process
+ val createdLabel = getUniqueLabelName(
+ command.name!!.replace("\\", ""),
+ prefix, command.containingFile
+ )
+ val endMarker =
+ editor.document.createRangeMarker(command.startOffset, command.endOffset())
+ createLabelAndStartRename(editor, project, command, createdLabel, endMarker)
+ }
+ else {
+ // Insert and start the \label live template
+ editor.caretModel.moveToOffset(command.endOffset())
+ val template = TemplateImpl("", "\\label{$prefix:\$__Variable0\$}", "")
+ template.addVariable(TextExpression(""), true)
+ TemplateManager.getInstance(editor.project).startTemplate(editor, template)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelToEnvironmentIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelToEnvironmentIntention.kt
new file mode 100644
index 000000000..a54a345f8
--- /dev/null
+++ b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelToEnvironmentIntention.kt
@@ -0,0 +1,64 @@
+package nl.hannahsten.texifyidea.intentions
+
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.project.Project
+import com.intellij.psi.PsiFile
+import com.intellij.psi.SmartPsiElementPointer
+import com.intellij.refactoring.suggested.startOffset
+import nl.hannahsten.texifyidea.lang.LatexRegularCommand
+import nl.hannahsten.texifyidea.psi.LatexCommands
+import nl.hannahsten.texifyidea.psi.LatexEnvironment
+import nl.hannahsten.texifyidea.psi.LatexPsiHelper
+import nl.hannahsten.texifyidea.util.Magic
+import nl.hannahsten.texifyidea.util.childrenOfType
+import nl.hannahsten.texifyidea.util.endOffset
+import nl.hannahsten.texifyidea.util.files.isLatexFile
+import nl.hannahsten.texifyidea.util.formatAsLabel
+
+open class LatexAddLabelToEnvironmentIntention(val environment: SmartPsiElementPointer? = null) :
+ LatexAddLabelIntention() {
+
+ override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean {
+ if (file?.isLatexFile() == false) {
+ return false
+ }
+
+ return findTarget(editor, file)?.environmentName in Magic.Environment.labeled
+ }
+
+ override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
+ if (editor == null || file == null) {
+ return
+ }
+
+ val environment = this.environment?.element
+ ?: findTarget(editor, file)
+ ?: return
+
+ val helper = LatexPsiHelper(project)
+ // Determine label name.
+ val prefix = Magic.Environment.labeled[environment.environmentName] ?: ""
+ val createdLabel = getUniqueLabelName(
+ environment.environmentName.formatAsLabel(),
+ prefix, environment.containingFile
+ )
+
+ if (Magic.Environment.labelAsParameter.contains(environment.environmentName)) {
+ val endMarker =
+ editor.document.createRangeMarker(environment.startOffset, environment.endOffset())
+ createLabelAndStartRename(editor, project, environment.beginCommand, createdLabel, endMarker)
+ }
+ else {
+ // in a float environment the label must be inserted after a caption
+ val labelCommand = helper.addToContent(
+ environment, helper.createLabelCommand(createdLabel.labelText),
+ environment.environmentContent?.childrenOfType()
+ ?.findLast { c -> c.name == LatexRegularCommand.CAPTION.commandDisplay }
+ )
+
+ // Adjust caret offset
+ val caretModel = editor.caretModel
+ caretModel.moveToOffset(labelCommand.endOffset())
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexInsertFormatterCommentsIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexInsertFormatterCommentsIntention.kt
index 46493465c..ce4b4115b 100644
--- a/src/nl/hannahsten/texifyidea/intentions/LatexInsertFormatterCommentsIntention.kt
+++ b/src/nl/hannahsten/texifyidea/intentions/LatexInsertFormatterCommentsIntention.kt
@@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.psi.LatexBeginCommand
import nl.hannahsten.texifyidea.util.*
class LatexInsertFormatterCommentsIntention : TexifyIntentionBase("Insert comments to disable the formatter.") {
+
private val onTag = CodeStyleSettings.getDefaults().FORMATTER_ON_TAG
private val offTag = CodeStyleSettings.getDefaults().FORMATTER_OFF_TAG
diff --git a/src/nl/hannahsten/texifyidea/lang/Argument.kt b/src/nl/hannahsten/texifyidea/lang/Argument.kt
index c7e2a04e8..eed1aab34 100644
--- a/src/nl/hannahsten/texifyidea/lang/Argument.kt
+++ b/src/nl/hannahsten/texifyidea/lang/Argument.kt
@@ -8,6 +8,7 @@ abstract class Argument @JvmOverloads protected constructor(val name: String, va
abstract override fun toString(): String
enum class Type {
+
NORMAL,
FILE,
TEXT
diff --git a/src/nl/hannahsten/texifyidea/lang/CommandManager.kt b/src/nl/hannahsten/texifyidea/lang/CommandManager.kt
index f46dd6f66..80c666a04 100644
--- a/src/nl/hannahsten/texifyidea/lang/CommandManager.kt
+++ b/src/nl/hannahsten/texifyidea/lang/CommandManager.kt
@@ -31,6 +31,7 @@ import java.util.stream.StreamSupport
*/
// Currently it is a singleton, in the future this may be one instance per fileset
object CommandManager : Iterable, Serializable {
+
/**
* Maps a command to a set of aliases including the command itself.
*
diff --git a/src/nl/hannahsten/texifyidea/lang/Environment.kt b/src/nl/hannahsten/texifyidea/lang/Environment.kt
index c7d06ca4c..99b19675a 100644
--- a/src/nl/hannahsten/texifyidea/lang/Environment.kt
+++ b/src/nl/hannahsten/texifyidea/lang/Environment.kt
@@ -63,6 +63,7 @@ interface Environment : Dependend {
* @author Hannah Schellekens
*/
enum class Context {
+
NORMAL,
MATH,
COMMENT
diff --git a/src/nl/hannahsten/texifyidea/lang/LatexDocumentClass.kt b/src/nl/hannahsten/texifyidea/lang/LatexDocumentClass.kt
index d366ac182..8af790bbb 100644
--- a/src/nl/hannahsten/texifyidea/lang/LatexDocumentClass.kt
+++ b/src/nl/hannahsten/texifyidea/lang/LatexDocumentClass.kt
@@ -11,6 +11,7 @@ open class LatexDocumentClass(
) {
companion object {
+
val EXAM = LatexDocumentClass("exam")
}
diff --git a/src/nl/hannahsten/texifyidea/lang/RequiredFileArgument.kt b/src/nl/hannahsten/texifyidea/lang/RequiredFileArgument.kt
index d3ccfa87c..0839d55cf 100644
--- a/src/nl/hannahsten/texifyidea/lang/RequiredFileArgument.kt
+++ b/src/nl/hannahsten/texifyidea/lang/RequiredFileArgument.kt
@@ -18,6 +18,7 @@ import java.util.regex.Pattern
* @author Hannah Schellekens
*/
open class RequiredFileArgument(name: String?, open val isAbsolutePathSupported: Boolean = true, open val commaSeparatesArguments: Boolean, vararg extensions: String) : RequiredArgument(name!!, Type.FILE), FileNameMatcher, FileExtensionMatcher {
+
lateinit var supportedExtensions: Set
lateinit var defaultExtension: String
private set
diff --git a/src/nl/hannahsten/texifyidea/modules/intellij/JdkComboBox.kt b/src/nl/hannahsten/texifyidea/modules/intellij/JdkComboBox.kt
index 828050582..b7644412e 100644
--- a/src/nl/hannahsten/texifyidea/modules/intellij/JdkComboBox.kt
+++ b/src/nl/hannahsten/texifyidea/modules/intellij/JdkComboBox.kt
@@ -47,6 +47,7 @@ class JdkComboBox(
sdkFilter
)
) {
+
private val myOnNewSdkAdded: Consumer = Consumer { sdk: Sdk? -> onNewSdkAdded?.consume(sdk) }
override fun onModelUpdated(model: SdkListModel) {
@@ -127,6 +128,7 @@ class JdkComboBox(
private class JdkComboBoxModel(val myInnerModel: SdkListModel) :
AbstractListModel(), ComboBoxModel {
+
private var mySelectedItem: JdkComboBoxItem? = null
override fun getSize(): Int {
return myInnerModel.items.size
@@ -156,11 +158,13 @@ class JdkComboBox(
}
private interface InnerComboBoxItem {
+
val item: SdkListItem
}
private interface SelectableComboBoxItem
abstract class JdkComboBoxItem {
+
open val jdk: Sdk?
get() = null
open val sdkName: String?
@@ -168,6 +172,7 @@ class JdkComboBox(
}
private class InnerJdkComboBoxItem(override val item: SdkListItem) : JdkComboBoxItem(), InnerComboBoxItem {
+
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || javaClass != other.javaClass) return false
@@ -183,11 +188,13 @@ class JdkComboBox(
private class ActualJdkInnerItem(private val myItem: SdkItem) : ActualJdkComboBoxItem(
myItem.sdk
), InnerComboBoxItem {
+
override val item: SdkListItem
get() = myItem
}
open class ActualJdkComboBoxItem(override val jdk: Sdk) : JdkComboBoxItem(), SelectableComboBoxItem {
+
override fun toString(): String {
return jdk.name
}
@@ -208,6 +215,7 @@ class JdkComboBox(
}
class ProjectJdkComboBoxItem : JdkComboBoxItem(), InnerComboBoxItem, SelectableComboBoxItem {
+
override val item: SdkListItem
get() = ProjectSdkItem()
@@ -221,6 +229,7 @@ class JdkComboBox(
}
class NoneJdkComboBoxItem : JdkComboBoxItem(), InnerComboBoxItem, SelectableComboBoxItem {
+
override val item: SdkListItem
get() = NoneSdkItem()
@@ -238,6 +247,7 @@ class JdkComboBox(
}
companion object {
+
private val LOG = Logger.getInstance(
JdkComboBox::class.java
)
diff --git a/src/nl/hannahsten/texifyidea/modules/intellij/SdkSettingsStep.kt b/src/nl/hannahsten/texifyidea/modules/intellij/SdkSettingsStep.kt
index 745e5ee2c..37e7c92c6 100644
--- a/src/nl/hannahsten/texifyidea/modules/intellij/SdkSettingsStep.kt
+++ b/src/nl/hannahsten/texifyidea/modules/intellij/SdkSettingsStep.kt
@@ -36,6 +36,7 @@ class SdkSettingsStep(
sdkTypeIdFilter: Condition,
sdkFilter: Condition?
) : ModuleWizardStep() {
+
private val myJdkComboBox: JdkComboBox
private val myWizardContext: WizardContext
private val myModel: ProjectSdksModel
diff --git a/src/nl/hannahsten/texifyidea/parser/LatexParserUtil.kt b/src/nl/hannahsten/texifyidea/parser/LatexParserUtil.kt
index f53ecb163..0e1ba5720 100644
--- a/src/nl/hannahsten/texifyidea/parser/LatexParserUtil.kt
+++ b/src/nl/hannahsten/texifyidea/parser/LatexParserUtil.kt
@@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.util.Magic
@Suppress("FunctionName")
class LatexParserUtil : GeneratedParserUtilBase() {
+
companion object {
/**
diff --git a/src/nl/hannahsten/texifyidea/project/LatexProjectSdkSetupValidator.kt b/src/nl/hannahsten/texifyidea/project/LatexProjectSdkSetupValidator.kt
index 7acd5be42..729764e88 100644
--- a/src/nl/hannahsten/texifyidea/project/LatexProjectSdkSetupValidator.kt
+++ b/src/nl/hannahsten/texifyidea/project/LatexProjectSdkSetupValidator.kt
@@ -23,6 +23,7 @@ import nl.hannahsten.texifyidea.settings.sdk.LatexSdkUtil
* @author Thomas
*/
class LatexProjectSdkSetupValidator : ProjectSdkSetupValidator {
+
override fun isApplicableFor(project: Project, file: VirtualFile): Boolean {
// Check if setting up a LaTeX SDK would make sense
val isLatexFile = file.fileType is LatexFileType || PsiManager.getInstance(project).findFile(file)?.language?.isKindOf(LatexLanguage.INSTANCE) == true
diff --git a/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt b/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt
index 00436441d..462373c01 100644
--- a/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt
+++ b/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt
@@ -17,6 +17,7 @@ import nl.hannahsten.texifyidea.util.parentOfType
* @author Sten Wessel
*/
class LatexLanguageInjector : LanguageInjector {
+
override fun getLanguagesToInject(host: PsiLanguageInjectionHost, registrar: InjectedLanguagePlaces) {
if (host is LatexEnvironment) {
diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt
index be6735d61..4cc8add22 100644
--- a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt
+++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt
@@ -5,8 +5,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFileFactory
import com.intellij.psi.impl.source.tree.LeafPsiElement
import nl.hannahsten.texifyidea.LatexLanguage
-import nl.hannahsten.texifyidea.psi.LatexTypes.CLOSE_BRACKET
-import nl.hannahsten.texifyidea.psi.LatexTypes.EQUALS
+import nl.hannahsten.texifyidea.psi.LatexTypes.*
import nl.hannahsten.texifyidea.util.childrenOfType
import nl.hannahsten.texifyidea.util.findFirstChild
import nl.hannahsten.texifyidea.util.firstChildOfType
@@ -75,20 +74,42 @@ class LatexPsiHelper(private val project: Project) {
}
/**
- * Set the value of the optional parameter with the givevn key name. If the the parameter already exists,
- * its value is changed. If no key with the given name exists yet, a new one is created with the given value.
- *
- * @param name The name of the parameter to change
- * @param value The new parameter value. If the value is null, the parameter will have a key only.
+ * Returns the LatexOptionalParam node that is supposed to contain the label key for the command.
+ * If no such node exists yet, a new one is created at the correct position.
*/
- fun setOptionalParameter(command: LatexCommandWithParams, name: String, value: String?): PsiElement {
+ private fun getOrCreateLabelOptionalParameters(command: LatexCommandWithParams): LatexOptionalParam {
+
+ // This is only a heuristic. We would actually need detailed information on which optional parameter is
+ // supposed to hold the label key.
val existingParameters = command.optionalParameterMap
if (existingParameters.isEmpty()) {
- command.addAfter(createLatexOptionalParam(), command.parameterList[0])
+ if (command is LatexCommands) {
+ // For commands insert an optional parameter right after the command name (in case the command has a
+ // star, insert the parameter after the start)
+ command.addAfter(createLatexOptionalParam(),
+ command.childrenOfType().firstOrNull { it.elementType == STAR }
+ ?: command.commandToken)
+ }
+ else {
+ // Otherwise assume that the command belongs to an environment and insert the optional parameter after
+ // the first parameter (which is the environment name)
+ command.addAfter(createLatexOptionalParam(), command.parameterList[0])
+ }
}
- val optionalParam = command.parameterList
+ return command.parameterList
.first { p -> p.optionalParam != null }.optionalParam!!
+ }
+
+ /**
+ * Set the value of the optional parameter with the givevn key name. If the the parameter already exists,
+ * its value is changed. If no key with the given name exists yet, a new one is created with the given value.
+ *
+ * @param name The name of the parameter to change
+ * @param value The new parameter value. If the value is null, the parameter will have a key only.
+ */
+ fun setOptionalParameter(command: LatexCommandWithParams, name: String, value: String?): LatexKeyvalPair {
+ val optionalParam = getOrCreateLabelOptionalParameters(command)
val parameterText = if (value != null) {
"$name=$value"
@@ -111,12 +132,12 @@ class LatexPsiHelper(private val project: Project) {
else {
optionalParam.addBefore(createFromText(","), closeBracket)
optionalParam.addBefore(pair, closeBracket)
- closeBracket.prevSibling
+ closeBracket.prevSibling as LatexKeyvalPair
}
}
else {
optionalParam.addBefore(pair, closeBracket)
- closeBracket.prevSibling
+ closeBracket.prevSibling as LatexKeyvalPair
}
}
}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiUtil.kt
index 7a75553a7..62705c8b1 100644
--- a/src/nl/hannahsten/texifyidea/psi/LatexPsiUtil.kt
+++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiUtil.kt
@@ -10,6 +10,7 @@ import java.util.*
* @author Hannah Schellekens
*/
object LatexPsiUtil {
+
/**
* Finds the previous sibling of an element but skips over whitespace.
*
diff --git a/src/nl/hannahsten/texifyidea/refactoring/BibtexRefactoringSupportProvider.kt b/src/nl/hannahsten/texifyidea/refactoring/BibtexRefactoringSupportProvider.kt
index 04437c660..7cc2485ef 100644
--- a/src/nl/hannahsten/texifyidea/refactoring/BibtexRefactoringSupportProvider.kt
+++ b/src/nl/hannahsten/texifyidea/refactoring/BibtexRefactoringSupportProvider.kt
@@ -7,6 +7,7 @@ import com.intellij.psi.PsiElement
* This class is used to enable inline refactoring.
*/
class BibtexRefactoringSupportProvider : RefactoringSupportProvider() {
+
override fun isMemberInplaceRenameAvailable(element: PsiElement, context: PsiElement?): Boolean {
// Inline refactoring is not enabled for BibtexId because it will not handle the comma separator correctly when the bibtex id is renamed directly (not from usages).
return false
diff --git a/src/nl/hannahsten/texifyidea/refactoring/LatexNameSuggestionProvider.kt b/src/nl/hannahsten/texifyidea/refactoring/LatexNameSuggestionProvider.kt
index a2882a2c1..41009f61c 100644
--- a/src/nl/hannahsten/texifyidea/refactoring/LatexNameSuggestionProvider.kt
+++ b/src/nl/hannahsten/texifyidea/refactoring/LatexNameSuggestionProvider.kt
@@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.psi.LatexBeginCommand
import nl.hannahsten.texifyidea.util.firstParentOfType
class LatexNameSuggestionProvider : NameSuggestionProvider {
+
override fun getSuggestedNames(element: PsiElement, nameSuggestionContext: PsiElement?, result: MutableSet): SuggestedNameInfo? {
if (element.firstParentOfType(LatexBeginCommand::class) != null) {
diff --git a/src/nl/hannahsten/texifyidea/refactoring/LatexNamesValidator.kt b/src/nl/hannahsten/texifyidea/refactoring/LatexNamesValidator.kt
index ab20dd1fd..a44a66365 100644
--- a/src/nl/hannahsten/texifyidea/refactoring/LatexNamesValidator.kt
+++ b/src/nl/hannahsten/texifyidea/refactoring/LatexNamesValidator.kt
@@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.util.formatAsLabel
* Check if user provided names during refactoring are valid.
*/
class LatexNamesValidator : NamesValidator {
+
override fun isKeyword(name: String, project: Project?): Boolean {
return false
}
diff --git a/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt b/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt
index f6f0f49a5..1e9d66901 100644
--- a/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt
+++ b/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt
@@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.psi.LatexParameterText
* This class is used to enable inline refactoring.
*/
class LatexRefactoringSupportProvider : RefactoringSupportProvider() {
+
override fun isMemberInplaceRenameAvailable(element: PsiElement, context: PsiElement?): Boolean {
// Label parameters are LatexParameterText
return when (element) {
diff --git a/src/nl/hannahsten/texifyidea/reference/BibtexUsagesProvider.kt b/src/nl/hannahsten/texifyidea/reference/BibtexUsagesProvider.kt
index 9685507da..0bb1bb24c 100644
--- a/src/nl/hannahsten/texifyidea/reference/BibtexUsagesProvider.kt
+++ b/src/nl/hannahsten/texifyidea/reference/BibtexUsagesProvider.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.BibtexLexerAdapter
import nl.hannahsten.texifyidea.psi.BibtexTypes
class BibtexUsagesProvider : FindUsagesProvider {
+
override fun getWordsScanner(): WordsScanner? {
return DefaultWordsScanner(
BibtexLexerAdapter(),
diff --git a/src/nl/hannahsten/texifyidea/reference/CommandDefinitionReference.kt b/src/nl/hannahsten/texifyidea/reference/CommandDefinitionReference.kt
index ef6dd67a7..2fd9c4833 100644
--- a/src/nl/hannahsten/texifyidea/reference/CommandDefinitionReference.kt
+++ b/src/nl/hannahsten/texifyidea/reference/CommandDefinitionReference.kt
@@ -15,6 +15,7 @@ import nl.hannahsten.texifyidea.util.projectSearchScope
* @author Abby Berkers
*/
class CommandDefinitionReference(element: LatexCommands) : PsiReferenceBase(element), PsiPolyVariantReference {
+
init {
rangeInElement = ElementManipulators.getValueTextRange(element)
}
diff --git a/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt b/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt
index e4958ff53..1ac0b42e5 100644
--- a/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt
+++ b/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt
@@ -25,6 +25,7 @@ import nl.hannahsten.texifyidea.util.files.*
* @param defaultExtension Default extension of the command in which this reference is.
*/
class InputFileReference(element: LatexCommands, val range: TextRange, val extensions: Set, val defaultExtension: String) : PsiReferenceBase(element) {
+
init {
rangeInElement = range
}
diff --git a/src/nl/hannahsten/texifyidea/reference/LatexLabelReference.kt b/src/nl/hannahsten/texifyidea/reference/LatexLabelReference.kt
index 6620702e9..5f0cbeebb 100644
--- a/src/nl/hannahsten/texifyidea/reference/LatexLabelReference.kt
+++ b/src/nl/hannahsten/texifyidea/reference/LatexLabelReference.kt
@@ -17,6 +17,7 @@ import java.util.*
* @author Hannah Schellekens, Sten Wessel
*/
class LatexLabelReference(element: LatexCommands, range: TextRange?) : PsiReferenceBase(element) {
+
override fun resolve(): PsiElement? {
return null
}
diff --git a/src/nl/hannahsten/texifyidea/reference/LatexUsagesProvider.kt b/src/nl/hannahsten/texifyidea/reference/LatexUsagesProvider.kt
index a0c0d1bd2..9f6afa77c 100644
--- a/src/nl/hannahsten/texifyidea/reference/LatexUsagesProvider.kt
+++ b/src/nl/hannahsten/texifyidea/reference/LatexUsagesProvider.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.LatexLexerAdapter
import nl.hannahsten.texifyidea.psi.LatexTypes
class LatexUsagesProvider : FindUsagesProvider {
+
override fun getWordsScanner(): WordsScanner? {
return DefaultWordsScanner(
LatexLexerAdapter(),
diff --git a/src/nl/hannahsten/texifyidea/run/FileCleanupListener.kt b/src/nl/hannahsten/texifyidea/run/FileCleanupListener.kt
index 5c0e1797c..3eef8b00c 100644
--- a/src/nl/hannahsten/texifyidea/run/FileCleanupListener.kt
+++ b/src/nl/hannahsten/texifyidea/run/FileCleanupListener.kt
@@ -12,6 +12,7 @@ import java.io.File
* Clean up given files after the process is done.
*/
class FileCleanupListener(private val filesToCleanUp: MutableList) : ProcessListener {
+
override fun startNotified(event: ProcessEvent) {
}
diff --git a/src/nl/hannahsten/texifyidea/run/OpenCustomPdfViewerListener.kt b/src/nl/hannahsten/texifyidea/run/OpenCustomPdfViewerListener.kt
index e72332cf8..75558eee8 100644
--- a/src/nl/hannahsten/texifyidea/run/OpenCustomPdfViewerListener.kt
+++ b/src/nl/hannahsten/texifyidea/run/OpenCustomPdfViewerListener.kt
@@ -12,6 +12,7 @@ import java.io.IOException
* Run the given command after the process has succeeded.
*/
class OpenCustomPdfViewerListener(val command: Array, val failSilently: Boolean = false, val runConfig: LatexRunConfiguration) : ProcessListener {
+
override fun processTerminated(event: ProcessEvent) {
if (event.exitCode == 0) {
try {
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/BibtexLogMessage.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/BibtexLogMessage.kt
index e66671a9b..347aa905d 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/BibtexLogMessage.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/BibtexLogMessage.kt
@@ -5,6 +5,7 @@ import com.intellij.util.ui.MessageCategory
import nl.hannahsten.texifyidea.util.capitalizeFirst
data class BibtexLogMessage(val message: String, val fileName: String? = null, val line: Int? = -1, val type: BibtexLogMessageType, val file: VirtualFile? = null) {
+
fun toTreeViewString(): String {
val typeString = type.toString().toLowerCase().capitalizeFirst()
val lineString = if (line != null && line >= 0) "line ($line)" else ""
@@ -13,6 +14,7 @@ data class BibtexLogMessage(val message: String, val fileName: String? = null, v
}
enum class BibtexLogMessageType(val category: Int) {
+
ERROR(MessageCategory.ERROR),
WARNING(MessageCategory.WARNING);
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/BibtexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/BibtexMessageHandler.kt
index ca9e36876..22607934a 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/BibtexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/BibtexMessageHandler.kt
@@ -1,6 +1,7 @@
package nl.hannahsten.texifyidea.run.bibtex.logtab
abstract class BibtexMessageHandler {
+
/**
* Find a message from the given window, last added line is last in the list.
*
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/AuxEndErrBibtexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/AuxEndErrBibtexMessageHandler.kt
index 197a909fd..a82c0960f 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/AuxEndErrBibtexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/AuxEndErrBibtexMessageHandler.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Handle log messages which use the procedure aux_end_err in bibtex.web (line 3352).
*/
object AuxEndErrBibtexMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
BibtexLogMagicRegex.auxEndErr.find(window.lastOrNull() ?: "")?.apply {
return BibtexLogMessage(groups["message"]?.value ?: window.last(), groups["file"]?.value, null, BibtexLogMessageType.ERROR)
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/AuxErrPrintBibtexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/AuxErrPrintBibtexMessageHandler.kt
index 449505e10..993a493cd 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/AuxErrPrintBibtexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/AuxErrPrintBibtexMessageHandler.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* The actual message will probably be directly before the ---line but may be on the same or previous line.
*/
object AuxErrPrintBibtexMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
BibtexLogMagicRegex.auxErrPrint.find(window.lastOrNull() ?: "")?.apply {
if (window.size < 2) return null
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BiberErrorBibtexSubsystemMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BiberErrorBibtexSubsystemMessageHandler.kt
index 43bcefef8..c44bfaadf 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BiberErrorBibtexSubsystemMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BiberErrorBibtexSubsystemMessageHandler.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Handle biber error messages with file and line information.
*/
object BiberErrorBibtexSubsystemMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
BibtexLogMagicRegex.biberErrorBibtexSubsystem.find(window.lastOrNull() ?: "")?.apply {
// Though we have the name of the auxiliary file, we just assume it is the same as the opened bib file
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BiberErrorMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BiberErrorMessageHandler.kt
index 288de983a..ea81b62c4 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BiberErrorMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BiberErrorMessageHandler.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Handle biber error messages which do not have any information about file or line.
*/
object BiberErrorMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
BibtexLogMagicRegex.biberError.find(window.lastOrNull() ?: "")?.apply {
return BibtexLogMessage(groups["message"]?.value ?: "", currentFile, null, BibtexLogMessageType.ERROR)
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BstExWarnPrintBibtexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BstExWarnPrintBibtexMessageHandler.kt
index 2ad2695b4..43cc48013 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BstExWarnPrintBibtexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/BstExWarnPrintBibtexMessageHandler.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Even though it shows a line and file, this is from the bst file and most likely not the problem.
*/
object BstExWarnPrintBibtexMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
BibtexLogMagicRegex.bstExWarnPrint.find(window.lastOrNull() ?: "")?.apply {
if (window.size < 2) return null
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/CleanUpAndLeaveBibtexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/CleanUpAndLeaveBibtexMessageHandler.kt
index dc3fd8ba7..0b76c1b33 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/CleanUpAndLeaveBibtexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/CleanUpAndLeaveBibtexMessageHandler.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* and for which we assume the message is on the previous line.
*/
object CleanUpAndLeaveBibtexMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
BibtexLogMagicRegex.cleanUpAndLeave.find(window.lastOrNull() ?: "")?.apply {
if (window.size < 2) return null
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/NonexistentCrossReferenceBibtexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/NonexistentCrossReferenceBibtexMessageHandler.kt
index b80d5602d..98dcc79a7 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/NonexistentCrossReferenceBibtexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/errors/NonexistentCrossReferenceBibtexMessageHandler.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Note that it consists of two lines, without any indication that it does.
*/
object NonexistentCrossReferenceBibtexMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
BibtexLogMagicRegex.nonexistentCrossReferenceError.find(window.lastOrNull() ?: "")?.apply {
if (window.size < 2) return null
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BibLnNumPrintBibtexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BibLnNumPrintBibtexMessageHandler.kt
index c83177b2b..95d8b5854 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BibLnNumPrintBibtexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BibLnNumPrintBibtexMessageHandler.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Note that warnings have '--' before 'line', and errors '---' (see bib_err_print vs bib_warn_print).
*/
object BibLnNumPrintBibtexMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
if (window.size < 3) return null
// This case is handled by WarningBibtexMessageHandler
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BiberWarningBibtexSubsystemMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BiberWarningBibtexSubsystemMessageHandler.kt
index 2e91bbd5a..95ea50464 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BiberWarningBibtexSubsystemMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BiberWarningBibtexSubsystemMessageHandler.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Handle biber warning messages which do have information about the line number.
*/
object BiberWarningBibtexSubsystemMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
BibtexLogMagicRegex.biberWarningBibtexSubsystem.find(window.lastOrNull() ?: "")?.apply {
return BibtexLogMessage(groups["message"]?.value ?: "", currentFile, groups["line"]?.value?.toInt(), BibtexLogMessageType.WARNING)
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BiberWarningMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BiberWarningMessageHandler.kt
index bc6aa4129..32c9abd96 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BiberWarningMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/BiberWarningMessageHandler.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Handle biber warning messages which do not have any information about file or line.
*/
object BiberWarningMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
val regexes = listOf(BibtexLogMagicRegex.biberWarningInFile, BibtexLogMagicRegex.biberWarning)
regexes.forEach { regex ->
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/NoFieldsBibtexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/NoFieldsBibtexMessageHandler.kt
index 0c4b45892..12009de30 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/NoFieldsBibtexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/NoFieldsBibtexMessageHandler.kt
@@ -9,6 +9,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Handle log messages which use line 3937 in bibtex.web, which is a special case where 'Warning--' and '--line' appear on the same line.
*/
object NoFieldsBibtexMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
// This case is handled by WarningBibtexMessageHandler
BibtexLogMagicRegex.noFields.find(window.lastOrNull() ?: "")?.apply {
diff --git a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/WarningBibtexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/WarningBibtexMessageHandler.kt
index 53898ee67..b38265bfe 100644
--- a/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/WarningBibtexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/bibtex/logtab/messagehandlers/warnings/WarningBibtexMessageHandler.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.run.bibtex.logtab.BibtexMessageHandler
* Since --line may still appear on the next line, we catch this message in the middle of the buffer.
*/
object WarningBibtexMessageHandler : BibtexMessageHandler() {
+
override fun findMessage(window: List, currentFile: String): BibtexLogMessage? {
if (window.size < 3) return null
// Index of the middle element of the buffer (might not be fully filled)
diff --git a/src/nl/hannahsten/texifyidea/run/compiler/ExternalTool.kt b/src/nl/hannahsten/texifyidea/run/compiler/ExternalTool.kt
index 649c87daa..88548c4ac 100644
--- a/src/nl/hannahsten/texifyidea/run/compiler/ExternalTool.kt
+++ b/src/nl/hannahsten/texifyidea/run/compiler/ExternalTool.kt
@@ -6,5 +6,6 @@ package nl.hannahsten.texifyidea.run.compiler
* @author Thomas Schouten
*/
enum class ExternalTool(val executableName: String) {
+
PYTHONTEX("pythontex")
}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/run/compiler/LatexCompiler.kt b/src/nl/hannahsten/texifyidea/run/compiler/LatexCompiler.kt
index ccb3a7d06..d4220550f 100644
--- a/src/nl/hannahsten/texifyidea/run/compiler/LatexCompiler.kt
+++ b/src/nl/hannahsten/texifyidea/run/compiler/LatexCompiler.kt
@@ -381,6 +381,7 @@ enum class LatexCompiler(private val displayName: String, val executableName: St
override fun toString() = this.displayName
companion object {
+
fun byExecutableName(exe: String): LatexCompiler {
return values().firstOrNull {
it.executableName.equals(exe, true)
diff --git a/src/nl/hannahsten/texifyidea/run/compiler/MakeindexProgram.kt b/src/nl/hannahsten/texifyidea/run/compiler/MakeindexProgram.kt
index acb5a0954..265593452 100644
--- a/src/nl/hannahsten/texifyidea/run/compiler/MakeindexProgram.kt
+++ b/src/nl/hannahsten/texifyidea/run/compiler/MakeindexProgram.kt
@@ -6,6 +6,7 @@ package nl.hannahsten.texifyidea.run.compiler
* @author Thomas Schouten
*/
enum class MakeindexProgram(val executableName: String) {
+
XINDY("texindy"),
TRUEXINDY("xindy"), // requires perl
MAKEINDEX("makeindex"),
diff --git a/src/nl/hannahsten/texifyidea/run/latex/LatexConfigurationFactory.kt b/src/nl/hannahsten/texifyidea/run/latex/LatexConfigurationFactory.kt
index 3a06e3fb0..b966e70c2 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/LatexConfigurationFactory.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/LatexConfigurationFactory.kt
@@ -16,6 +16,7 @@ import nl.hannahsten.texifyidea.run.makeindex.MakeindexRunConfigurationType
class LatexConfigurationFactory(type: ConfigurationType) : ConfigurationFactory(type) {
companion object {
+
private const val factoryName = "LaTeX configuration factory"
}
diff --git a/src/nl/hannahsten/texifyidea/run/latex/LatexDistributionType.kt b/src/nl/hannahsten/texifyidea/run/latex/LatexDistributionType.kt
index aa1f7fd2e..408a905cb 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/LatexDistributionType.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/LatexDistributionType.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.settings.sdk.LatexSdkUtil
* when for example a different project SDK needs to be selected for a different language to work.
*/
enum class LatexDistributionType(val displayName: String) {
+
TEXLIVE("TeX Live"),
MIKTEX("MiKTeX"),
WSL_TEXLIVE("TeX Live using WSL"),
@@ -26,6 +27,7 @@ enum class LatexDistributionType(val displayName: String) {
override fun toString() = displayName
companion object {
+
fun valueOfIgnoreCase(value: String?): LatexDistributionType {
return values().firstOrNull { it.name.equals(value, true) } ?: TEXLIVE
}
diff --git a/src/nl/hannahsten/texifyidea/run/latex/LatexOutputPath.kt b/src/nl/hannahsten/texifyidea/run/latex/LatexOutputPath.kt
index 86f86aff1..41e184934 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/LatexOutputPath.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/LatexOutputPath.kt
@@ -30,6 +30,7 @@ import java.io.File
class LatexOutputPath(private val variant: String, var contentRoot: VirtualFile?, var mainFile: VirtualFile?, private val project: Project) {
companion object {
+
const val projectDirString = "{projectDir}"
const val mainFileString = "{mainFileParent}"
}
diff --git a/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt b/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt
index 90c12eb69..1ce3b7ef2 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt
@@ -53,6 +53,7 @@ class LatexRunConfiguration constructor(
) : RunConfigurationBase(project, factory, name), LocatableConfiguration {
companion object {
+
private const val TEXIFY_PARENT = "texify"
private const val COMPILER = "compiler"
private const val COMPILER_PATH = "compiler-path"
diff --git a/src/nl/hannahsten/texifyidea/run/latex/externaltool/RunExternalToolListener.kt b/src/nl/hannahsten/texifyidea/run/latex/externaltool/RunExternalToolListener.kt
index eb78f0fc0..53e884b25 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/externaltool/RunExternalToolListener.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/externaltool/RunExternalToolListener.kt
@@ -26,6 +26,7 @@ class RunExternalToolListener(
) : ProcessListener {
companion object {
+
/**
* Check the contents of the LaTeX fileset to find out if any external tools are needed.
*/
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMagicRegex.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMagicRegex.kt
index 0290ac244..d2fae9125 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMagicRegex.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMagicRegex.kt
@@ -4,6 +4,7 @@ package nl.hannahsten.texifyidea.run.latex.logtab
* Regex (text) every error handler and message processor can use.
*/
object LatexLogMagicRegex {
+
// Line length (including newline at the end)
const val LINE_WIDTH = 80
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMessage.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMessage.kt
index db8710245..17502865b 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMessage.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMessage.kt
@@ -5,6 +5,7 @@ import com.intellij.util.ui.MessageCategory
import nl.hannahsten.texifyidea.util.capitalizeFirst
data class LatexLogMessage(val message: String, val fileName: String? = null, val line: Int = -1, val type: LatexLogMessageType = LatexLogMessageType.ERROR, val file: VirtualFile? = null) {
+
fun toTreeViewString(): String {
val typeString = type.toString().toLowerCase().capitalizeFirst()
val lineString = if (line >= 0) "line ($line)" else ""
@@ -13,6 +14,7 @@ data class LatexLogMessage(val message: String, val fileName: String? = null, va
}
enum class LatexLogMessageType(val category: Int) {
+
ERROR(MessageCategory.ERROR),
WARNING(MessageCategory.WARNING),
}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMessageExtractor.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMessageExtractor.kt
index 638c6a034..f3492a9dd 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMessageExtractor.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexLogMessageExtractor.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.run.latex.logtab.messagehandlers.warnings.*
import nl.hannahsten.texifyidea.util.remove
object LatexLogMessageExtractor {
+
/**
* Pre-processing to check if line is worth looking at.
*/
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexMessageHandler.kt
index 9154576d0..838033cb9 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexMessageHandler.kt
@@ -1,6 +1,7 @@
package nl.hannahsten.texifyidea.run.latex.logtab
open class LatexMessageHandler(open val messageType: LatexLogMessageType, open vararg val regex: Regex) {
+
open fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
regex.forEach {
it.find(text)?.apply {
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexMessageWithLineHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexMessageWithLineHandler.kt
index 14904e0a6..8217754e2 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexMessageWithLineHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexMessageWithLineHandler.kt
@@ -4,6 +4,7 @@ package nl.hannahsten.texifyidea.run.latex.logtab
* A [LatexMessageHandler] but assuming that the last regex group is the source line number.
*/
open class LatexMessageWithLineHandler(override val messageType: LatexLogMessageType, override vararg val regex: Regex) : LatexMessageHandler(messageType, *regex) {
+
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
regex.first().find(text)?.apply {
val message = this.value
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexOutputListener.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexOutputListener.kt
index 9bdff9fa0..85ab9337b 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexOutputListener.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexOutputListener.kt
@@ -29,6 +29,7 @@ class LatexOutputListener(
// This should probably be located somewhere else
companion object {
+
/**
* Returns true if firstLine is most likely the last line of the message.
*/
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexErrorHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexErrorHandler.kt
index 7b2fff39c..799fcab11 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexErrorHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexErrorHandler.kt
@@ -16,6 +16,7 @@ object LatexErrorHandler : LatexMessageHandler(
"""^$PDFTEX_ERROR_REGEX (?.+)""".toRegex(),
directLuaError
) {
+
private val messageProcessors = listOf(LatexPackageErrorProcessor, LatexRemoveErrorTextProcessor)
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexErrorMessageProcessor.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexErrorMessageProcessor.kt
index b8c72e6e7..4c4e468a6 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexErrorMessageProcessor.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexErrorMessageProcessor.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.run.latex.logtab.messagehandlers.errors
import nl.hannahsten.texifyidea.run.latex.logtab.LatexLogMagicRegex
abstract class LatexErrorMessageProcessor(vararg val regex: Regex) {
+
abstract fun process(message: String): String?
fun postProcess(message: String?): String? = message
?.replace("See the LaTeX manual or LaTeX Companion for explanation.", "")
@@ -13,6 +14,7 @@ abstract class LatexErrorMessageProcessor(vararg val regex: Regex) {
* LaTeX Error: text -> text
*/
object LatexRemoveErrorTextProcessor : LatexErrorMessageProcessor("""LaTeX Error:""".toRegex(), """pdfTeX error:""".toRegex()) {
+
override fun process(message: String): String? {
regex.forEach {
if (it.containsMatchIn(message)) return it.replace(message, "").trim()
@@ -25,6 +27,7 @@ object LatexRemoveErrorTextProcessor : LatexErrorMessageProcessor("""LaTeX Error
* Package amsmath error: text -> amsmath: text
*/
object LatexPackageErrorProcessor : LatexErrorMessageProcessor("""^Package ${LatexLogMagicRegex.PACKAGE_REGEX} Error:""".toRegex()) {
+
override fun process(message: String): String? {
regex.forEach {
val `package` = it.find(message)?.groups?.get("package")?.value ?: return@forEach
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexFixMeErrorMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexFixMeErrorMessageHandler.kt
index b64e48fbc..7292fdcbc 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexFixMeErrorMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexFixMeErrorMessageHandler.kt
@@ -12,6 +12,7 @@ object LatexFixMeErrorMessageHandler : LatexMessageHandler(
LatexLogMessageType.ERROR,
fixMeError
) {
+
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
regex.forEach {
it.find(text)?.apply {
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexSingleLineErrorMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexSingleLineErrorMessageHandler.kt
index 944d53e89..5c31201fe 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexSingleLineErrorMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexSingleLineErrorMessageHandler.kt
@@ -12,6 +12,7 @@ object LatexSingleLineErrorMessageHandler : LatexMessageHandler(
LatexLogMessageType.ERROR,
"""^$FILE_LINE_REGEX (?.+)\s*l\.\d+""".toRegex()
) {
+
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
regex.forEach {
it.find(text)?.apply {
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexUndefinedControlSequenceHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexUndefinedControlSequenceHandler.kt
index ac8795af2..13b5a6007 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexUndefinedControlSequenceHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/errors/LatexUndefinedControlSequenceHandler.kt
@@ -13,6 +13,7 @@ object LatexUndefinedControlSequenceHandler : LatexMessageHandler(
"""^$FILE_LINE_REGEX (?Undefined control sequence.)(\s*l.\d+[\s\S]*(?\\\w+)$)?""".toRegex(),
"""^$LATEX_ERROR_REGEX (?Undefined control sequence.)\s*l.\d+\s*(?\\\w+)$""".toRegex()
) {
+
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
regex.forEach {
it.find(text)?.apply {
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexFixMeWarningMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexFixMeWarningMessageHandler.kt
index 6aa728c71..337d27d9d 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexFixMeWarningMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexFixMeWarningMessageHandler.kt
@@ -12,6 +12,7 @@ object LatexFixMeWarningMessageHandler : LatexMessageHandler(
LatexLogMessageType.WARNING,
fixMeWarning
) {
+
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
regex.forEach {
it.find(text)?.apply {
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexLineWarningHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexLineWarningHandler.kt
index 9c7948681..c71a9bb21 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexLineWarningHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexLineWarningHandler.kt
@@ -12,6 +12,7 @@ object LatexLineWarningHandler : LatexMessageHandler(
WARNING,
"""${LatexLogMagicRegex.LATEX_WARNING_REGEX}(?.+)${LatexLogMagicRegex.LINE_REGEX}""".toRegex()
) {
+
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
LatexLineWarningHandler.regex.forEach {
it.find(text)?.apply {
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexPackageWarningHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexPackageWarningHandler.kt
index f0482416a..3a9ca3656 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexPackageWarningHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexPackageWarningHandler.kt
@@ -11,6 +11,7 @@ object LatexPackageWarningHandler : LatexMessageHandler(
"""^Package $PACKAGE_REGEX Warning: (?.+) $LINE_REGEX$""".toRegex(),
"""^Package $PACKAGE_REGEX Warning: (?.+)$""".toRegex()
) {
+
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
regex.forEach {
it.find(text)?.apply {
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexPdftexWarningMessageHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexPdftexWarningMessageHandler.kt
index 281714a02..f77e29c72 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexPdftexWarningMessageHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexPdftexWarningMessageHandler.kt
@@ -12,6 +12,7 @@ object LatexPdftexWarningMessageHandler : LatexMessageHandler(
LatexLogMessageType.WARNING,
pdfTeXWarning
) {
+
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
regex.forEach {
it.find(text)?.apply {
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexReferenceCitationWarningHandler.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexReferenceCitationWarningHandler.kt
index cca78899b..efe97ecc4 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexReferenceCitationWarningHandler.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/messagehandlers/warnings/LatexReferenceCitationWarningHandler.kt
@@ -14,6 +14,7 @@ object LatexReferenceCitationWarningHandler : LatexMessageHandler(
LatexLogMessageType.WARNING,
"""^$LATEX_WARNING_REGEX (?[Reference|Citation) $REFERENCE_REGEX on page \d+ undefined $LINE_REGEX$""".toRegex()
) {
+
override fun findMessage(text: String, newText: String, currentFile: String?): LatexLogMessage? {
regex.first().find(text)?.apply {
val ref = groups["ref"]?.value
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexCompileMessageTreeView.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexCompileMessageTreeView.kt
index 7a659f811..e662ae3fd 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexCompileMessageTreeView.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexCompileMessageTreeView.kt
@@ -22,6 +22,7 @@ class LatexCompileMessageTreeView(
val bibtexMessageList: MutableList
) :
NewErrorTreeViewPanel(project, null) {
+
fun config(): LatexErrorTreeViewConfiguration = LatexErrorTreeViewConfiguration.getInstance(myProject)
override fun fillRightToolbarGroup(group: DefaultActionGroup) {
@@ -135,6 +136,7 @@ class LatexCompileMessageTreeView(
inner class FilterKeywordAction(private val keyword: LatexKeywordFilter, val project: Project) :
ToggleAction("Show $keyword messages", "Show $keyword messages", keyword.icon), DumbAware {
+
override fun isSelected(e: AnActionEvent): Boolean = config().showKeywordWarnings[keyword] ?: true
override fun setSelected(e: AnActionEvent, state: Boolean) {
@@ -145,6 +147,7 @@ class LatexCompileMessageTreeView(
inner class FilterBibtexAction(val project: Project) :
ToggleAction("Show bibtex messages by latexmk", "", TexifyIcons.DOT_BIB), DumbAware {
+
override fun isSelected(e: AnActionEvent): Boolean = config().showBibtexWarnings
override fun setSelected(e: AnActionEvent, state: Boolean) {
@@ -154,6 +157,7 @@ class LatexCompileMessageTreeView(
}
inner class ExpandAllAction : AnAction("Expand All", "", AllIcons.Actions.Expandall), DumbAware {
+
override fun actionPerformed(e: AnActionEvent) {
expandAll()
config().expanded = true
@@ -161,6 +165,7 @@ class LatexCompileMessageTreeView(
}
inner class CollapseAllAction : AnAction("Collapse All", "", AllIcons.Actions.Collapseall), DumbAware {
+
override fun actionPerformed(e: AnActionEvent) {
collapseAll()
config().expanded = false
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexErrorTreeViewConfiguration.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexErrorTreeViewConfiguration.kt
index 442cd7122..96760db65 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexErrorTreeViewConfiguration.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexErrorTreeViewConfiguration.kt
@@ -24,7 +24,9 @@ data class LatexErrorTreeViewConfiguration(
var expanded: Boolean = true // Unfortunately we cannot use this, because expandAll() apparently only works in Actions
) :
PersistentStateComponent {
+
companion object {
+
@JvmStatic
fun getInstance(project: Project): LatexErrorTreeViewConfiguration =
ServiceManager.getService(
diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexKeywordFilter.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexKeywordFilter.kt
index d909f60a3..11acc30b6 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexKeywordFilter.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/ui/LatexKeywordFilter.kt
@@ -4,6 +4,7 @@ import com.intellij.icons.AllIcons
import javax.swing.Icon
enum class LatexKeywordFilter(val triggers: List, val icon: Icon) {
+
OVERFULL_HBOX(listOf("overfull \\hbox", "underfull \\hbox", "overfull \\vbox", "underfull \\vbox"), icon = AllIcons.General.ArrowSplitCenterH);
override fun toString(): String {
diff --git a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/PdfViewer.kt b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/PdfViewer.kt
index 4d19d4d64..4563b3711 100644
--- a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/PdfViewer.kt
+++ b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/PdfViewer.kt
@@ -19,6 +19,7 @@ enum class PdfViewer(
val displayName: String,
val conversation: ViewerConversation?
) {
+
EVINCE("evince", "Evince", EvinceConversation),
OKULAR("okular", "Okular", OkularConversation),
ZATHURA("zathura", "Zathura", ZathuraConversation),
@@ -59,6 +60,7 @@ enum class PdfViewer(
override fun toString(): String = displayName
companion object {
+
private val availability: Map by lazy {
values().associateWith {
it.checkAvailability()
diff --git a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/ViewerConversation.kt b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/ViewerConversation.kt
index 1a76e7f69..485383534 100644
--- a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/ViewerConversation.kt
+++ b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/ViewerConversation.kt
@@ -3,5 +3,6 @@ package nl.hannahsten.texifyidea.run.linuxpdfviewer
import com.intellij.openapi.project.Project
abstract class ViewerConversation {
+
abstract fun forwardSearch(pdfPath: String?, sourceFilePath: String, line: Int, project: Project, focusAllowed: Boolean)
}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/ViewerForwardSearch.kt b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/ViewerForwardSearch.kt
index dcfb7d829..c48028541 100644
--- a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/ViewerForwardSearch.kt
+++ b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/ViewerForwardSearch.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.util.files.psiFile
* Provides forward search for the available pdf viewers.
*/
class ViewerForwardSearch(private val viewer: PdfViewer) {
+
/**
* Execute forward search when the process is done.
*/
diff --git a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/okular/OkularConversation.kt b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/okular/OkularConversation.kt
index bf5fc9f3e..6c6cc417e 100644
--- a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/okular/OkularConversation.kt
+++ b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/okular/OkularConversation.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.run.linuxpdfviewer.ViewerConversation
* @author Abby Berkers
*/
object OkularConversation : ViewerConversation() {
+
private var pdfFilePath: String? = null
/**
diff --git a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/skim/SkimConversation.kt b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/skim/SkimConversation.kt
index dae36e285..524b9f530 100644
--- a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/skim/SkimConversation.kt
+++ b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/skim/SkimConversation.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.run.linuxpdfviewer.ViewerConversation
* @author Stephan Sundermann
*/
object SkimConversation : ViewerConversation() {
+
private var pdfFilePath: String? = null
/**
diff --git a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/zathura/ZathuraConversation.kt b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/zathura/ZathuraConversation.kt
index 933d01720..0465627ed 100644
--- a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/zathura/ZathuraConversation.kt
+++ b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/zathura/ZathuraConversation.kt
@@ -17,6 +17,7 @@ import nl.hannahsten.texifyidea.util.files.referencedFileSet
import nl.hannahsten.texifyidea.util.selectedRunConfig
object ZathuraConversation : ViewerConversation() {
+
override fun forwardSearch(pdfPath: String?, sourceFilePath: String, line: Int, project: Project, focusAllowed: Boolean) {
val pdfPathGuess = pdfPath ?: guessPdfPath(project, sourceFilePath)
diff --git a/src/nl/hannahsten/texifyidea/settings/TexifyProjectSettings.kt b/src/nl/hannahsten/texifyidea/settings/TexifyProjectSettings.kt
index c36b0a6a5..486d3b0f0 100644
--- a/src/nl/hannahsten/texifyidea/settings/TexifyProjectSettings.kt
+++ b/src/nl/hannahsten/texifyidea/settings/TexifyProjectSettings.kt
@@ -12,6 +12,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil
class TexifyProjectSettings : PersistentStateComponent {
companion object {
+
@JvmStatic
fun getInstance(project: Project): TexifyProjectSettings = ServiceManager.getService(project, TexifyProjectSettings::class.java)
}
diff --git a/src/nl/hannahsten/texifyidea/settings/TexifySettings.kt b/src/nl/hannahsten/texifyidea/settings/TexifySettings.kt
index a07538ee2..593382ef9 100644
--- a/src/nl/hannahsten/texifyidea/settings/TexifySettings.kt
+++ b/src/nl/hannahsten/texifyidea/settings/TexifySettings.kt
@@ -14,12 +14,14 @@ import nl.hannahsten.texifyidea.run.linuxpdfviewer.PdfViewer
class TexifySettings : PersistentStateComponent {
companion object {
+
@JvmStatic
fun getInstance(): TexifySettings = ServiceManager.getService(TexifySettings::class.java)
}
// Options for smart quote replacement, in the order as they appear in the combobox
enum class QuoteReplacement {
+
NONE,
LIGATURES,
COMMANDS,
diff --git a/src/nl/hannahsten/texifyidea/settings/codestyle/BibtexCodeStyleSettingsProvider.kt b/src/nl/hannahsten/texifyidea/settings/codestyle/BibtexCodeStyleSettingsProvider.kt
index f00d024c6..893f501a9 100644
--- a/src/nl/hannahsten/texifyidea/settings/codestyle/BibtexCodeStyleSettingsProvider.kt
+++ b/src/nl/hannahsten/texifyidea/settings/codestyle/BibtexCodeStyleSettingsProvider.kt
@@ -9,6 +9,7 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsProvider
import nl.hannahsten.texifyidea.BibtexLanguage
class BibtexCodeStyleSettingsProvider : CodeStyleSettingsProvider() {
+
override fun createCustomSettings(settings: CodeStyleSettings?) = settings?.let { BibtexCodeStyleSettings(it) }
override fun getConfigurableDisplayName() = BibtexLanguage.displayName
diff --git a/src/nl/hannahsten/texifyidea/settings/codestyle/BibtexLanguageCodeStyleSettingsProvider.kt b/src/nl/hannahsten/texifyidea/settings/codestyle/BibtexLanguageCodeStyleSettingsProvider.kt
index 12f47ea77..9e61d91c9 100644
--- a/src/nl/hannahsten/texifyidea/settings/codestyle/BibtexLanguageCodeStyleSettingsProvider.kt
+++ b/src/nl/hannahsten/texifyidea/settings/codestyle/BibtexLanguageCodeStyleSettingsProvider.kt
@@ -10,7 +10,9 @@ import nl.hannahsten.texifyidea.util.Magic
import nl.hannahsten.texifyidea.util.removeHtmlTags
class BibtexLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() {
+
companion object {
+
private val demoText = Magic.General.bibtexDemoText.removeHtmlTags()
}
override fun getLanguage(): Language = BibtexLanguage
diff --git a/src/nl/hannahsten/texifyidea/settings/codestyle/LatexCodeStyleSettings.kt b/src/nl/hannahsten/texifyidea/settings/codestyle/LatexCodeStyleSettings.kt
index 2a22bb0e0..58215ac70 100644
--- a/src/nl/hannahsten/texifyidea/settings/codestyle/LatexCodeStyleSettings.kt
+++ b/src/nl/hannahsten/texifyidea/settings/codestyle/LatexCodeStyleSettings.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.LatexLanguage
*/
@Suppress("PropertyName")
class LatexCodeStyleSettings(container: CodeStyleSettings) : CustomCodeStyleSettings(LatexLanguage.INSTANCE.id, container) {
+
/**
* The number of blank lines to use before a sectioning command.
*/
@@ -24,6 +25,7 @@ class LatexCodeStyleSettings(container: CodeStyleSettings) : CustomCodeStyleSett
@JvmField var BLANK_LINES_BEFORE_SUBPARAGRAPH: Int = 1
companion object {
+
val blankLinesOptions = mapOf(
LatexCodeStyleSettings::BLANK_LINES_BEFORE_PART to "\\part",
LatexCodeStyleSettings::BLANK_LINES_BEFORE_CHAPTER to "\\chapter",
diff --git a/src/nl/hannahsten/texifyidea/settings/codestyle/LatexGenerationSettingsProvider.kt b/src/nl/hannahsten/texifyidea/settings/codestyle/LatexGenerationSettingsProvider.kt
index b1baf3ce3..02dc16459 100644
--- a/src/nl/hannahsten/texifyidea/settings/codestyle/LatexGenerationSettingsProvider.kt
+++ b/src/nl/hannahsten/texifyidea/settings/codestyle/LatexGenerationSettingsProvider.kt
@@ -19,6 +19,7 @@ import javax.swing.JPanel
* @author Abby Berkers
*/
class LatexGenerationSettingsProvider : CodeStyleSettingsProvider() {
+
override fun createConfigurable(settings: CodeStyleSettings, modelSettings: CodeStyleSettings): CodeStyleConfigurable {
return LatexCodeStyleGenerationConfigurable(settings)
}
@@ -30,6 +31,7 @@ class LatexGenerationSettingsProvider : CodeStyleSettingsProvider() {
}
class LatexCodeStyleGenerationConfigurable(private val mySettings: CodeStyleSettings) : CodeStyleConfigurable {
+
private val myCommenterForm: CommenterForm = CommenterForm(LatexLanguage.INSTANCE)
override fun getDisplayName(): String = ApplicationBundle.message("title.code.generation")
diff --git a/src/nl/hannahsten/texifyidea/settings/codestyle/LatexLanguageCodeStyleSettingsProvider.kt b/src/nl/hannahsten/texifyidea/settings/codestyle/LatexLanguageCodeStyleSettingsProvider.kt
index 92f90c794..b6ccc0802 100644
--- a/src/nl/hannahsten/texifyidea/settings/codestyle/LatexLanguageCodeStyleSettingsProvider.kt
+++ b/src/nl/hannahsten/texifyidea/settings/codestyle/LatexLanguageCodeStyleSettingsProvider.kt
@@ -20,6 +20,7 @@ import nl.hannahsten.texifyidea.util.removeHtmlTags
class LatexLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() {
companion object {
+
private val demoText = Magic.General.latexDemoText.removeHtmlTags()
}
diff --git a/src/nl/hannahsten/texifyidea/settings/sdk/DockerSdk.kt b/src/nl/hannahsten/texifyidea/settings/sdk/DockerSdk.kt
index b8fa91eb6..b0def1895 100644
--- a/src/nl/hannahsten/texifyidea/settings/sdk/DockerSdk.kt
+++ b/src/nl/hannahsten/texifyidea/settings/sdk/DockerSdk.kt
@@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.util.runCommand
class DockerSdk : LatexSdk("LaTeX Docker SDK") {
companion object {
+
val isInPath: Boolean by lazy {
"docker --version".runCommand()?.contains("Docker version") == true
}
diff --git a/src/nl/hannahsten/texifyidea/settings/sdk/LatexSdk.kt b/src/nl/hannahsten/texifyidea/settings/sdk/LatexSdk.kt
index 3573b75c2..2fb954853 100644
--- a/src/nl/hannahsten/texifyidea/settings/sdk/LatexSdk.kt
+++ b/src/nl/hannahsten/texifyidea/settings/sdk/LatexSdk.kt
@@ -11,6 +11,7 @@ import org.jdom.Element
* @author Thomas
*/
abstract class LatexSdk(name: String) : SdkType(name) {
+
override fun saveAdditionalData(additionalData: SdkAdditionalData, additional: Element) {}
override fun createAdditionalDataConfigurable(sdkModel: SdkModel, sdkModificator: SdkModificator): AdditionalDataConfigurable? {
diff --git a/src/nl/hannahsten/texifyidea/settings/sdk/NativeTexliveSdk.kt b/src/nl/hannahsten/texifyidea/settings/sdk/NativeTexliveSdk.kt
index 533e428fe..ea6a5f8ea 100644
--- a/src/nl/hannahsten/texifyidea/settings/sdk/NativeTexliveSdk.kt
+++ b/src/nl/hannahsten/texifyidea/settings/sdk/NativeTexliveSdk.kt
@@ -12,6 +12,7 @@ import nl.hannahsten.texifyidea.util.runCommand
class NativeTexliveSdk : TexliveSdk("Native TeX Live SDK") {
companion object {
+
// Path to texmf-dist
val texmfDistPath: String by lazy {
"kpsewhich article.sty".runCommand()?.substringBefore("texmf-dist") + "texmf-dist"
diff --git a/src/nl/hannahsten/texifyidea/settings/sdk/TexliveSdk.kt b/src/nl/hannahsten/texifyidea/settings/sdk/TexliveSdk.kt
index d1bd7aa90..f69131829 100644
--- a/src/nl/hannahsten/texifyidea/settings/sdk/TexliveSdk.kt
+++ b/src/nl/hannahsten/texifyidea/settings/sdk/TexliveSdk.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.util.runCommand
open class TexliveSdk(name: String = "TeX Live SDK") : LatexSdk(name) {
companion object {
+
/**
* Returns year of texlive installation, 0 if it is not texlive.
* Assumes the pdflatex version output contains something like (TeX Live 2019).
diff --git a/src/nl/hannahsten/texifyidea/startup/LoadUnloadListener.kt b/src/nl/hannahsten/texifyidea/startup/LoadUnloadListener.kt
index cd2c6ed7e..5ca072a70 100644
--- a/src/nl/hannahsten/texifyidea/startup/LoadUnloadListener.kt
+++ b/src/nl/hannahsten/texifyidea/startup/LoadUnloadListener.kt
@@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.editor.ShiftTracker
import nl.hannahsten.texifyidea.run.linuxpdfviewer.evince.EvinceInverseSearchListener
class LoadUnloadListener : DynamicPluginListener {
+
override fun beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {
super.beforePluginUnload(pluginDescriptor, isUpdate)
AnalyzeMenuRegistration().unload()
diff --git a/src/nl/hannahsten/texifyidea/startup/TexLivePackageListInitializer.kt b/src/nl/hannahsten/texifyidea/startup/TexLivePackageListInitializer.kt
index 89f530a2b..218f505ca 100644
--- a/src/nl/hannahsten/texifyidea/startup/TexLivePackageListInitializer.kt
+++ b/src/nl/hannahsten/texifyidea/startup/TexLivePackageListInitializer.kt
@@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.util.TexLivePackages
import nl.hannahsten.texifyidea.util.runCommand
class TexLivePackageListInitializer : StartupActivity {
+
override fun runActivity(project: Project) {
if (TexliveSdk.isAvailable) {
val result = "tlmgr list --only-installed".runCommand() ?: return
diff --git a/src/nl/hannahsten/texifyidea/structure/filter/LabelFilter.kt b/src/nl/hannahsten/texifyidea/structure/filter/LabelFilter.kt
index 805ff8f09..2127ba686 100644
--- a/src/nl/hannahsten/texifyidea/structure/filter/LabelFilter.kt
+++ b/src/nl/hannahsten/texifyidea/structure/filter/LabelFilter.kt
@@ -12,6 +12,7 @@ import javax.swing.Icon
* @author Hannah Schellekens
*/
class LabelFilter : Filter {
+
override fun isVisible(treeElement: TreeElement): Boolean {
if (treeElement !is LatexStructureViewCommandElement) {
return true
@@ -29,6 +30,7 @@ class LabelFilter : Filter {
* @author Hannah Schellekens
*/
private class LatexLabelFilterPresentation : ActionPresentation {
+
override fun getText(): String = "Show Labels"
override fun getDescription(): String = "Show Labels"
@@ -36,6 +38,7 @@ class LabelFilter : Filter {
override fun getIcon(): Icon = TexifyIcons.DOT_LABEL
companion object {
+
val INSTANCE = LatexLabelFilterPresentation()
}
}
diff --git a/src/nl/hannahsten/texifyidea/structure/latex/LatexPairedDelimiterPresentation.kt b/src/nl/hannahsten/texifyidea/structure/latex/LatexPairedDelimiterPresentation.kt
index d8d629fe6..7353b7c39 100644
--- a/src/nl/hannahsten/texifyidea/structure/latex/LatexPairedDelimiterPresentation.kt
+++ b/src/nl/hannahsten/texifyidea/structure/latex/LatexPairedDelimiterPresentation.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.TexifyIcons
import nl.hannahsten.texifyidea.psi.LatexCommands
class LatexPairedDelimiterPresentation(newCommand: LatexCommands) : ItemPresentation {
+
private val newCommandName: String
private val locationString: String
diff --git a/src/nl/hannahsten/texifyidea/ui/CreateFileDialog.kt b/src/nl/hannahsten/texifyidea/ui/CreateFileDialog.kt
index eaae31d94..78bb44e1a 100644
--- a/src/nl/hannahsten/texifyidea/ui/CreateFileDialog.kt
+++ b/src/nl/hannahsten/texifyidea/ui/CreateFileDialog.kt
@@ -18,6 +18,7 @@ import javax.swing.JTextField
* @param newFileFullPath The full path of the new file, without tex extension.
*/
class CreateFileDialog(private val currentFilePath: String?, private val newFileName: String, var newFileFullPath: String? = null) {
+
init {
DialogBuilder().apply {
setTitle("Create new file")
diff --git a/src/nl/hannahsten/texifyidea/ui/DetexifyToolWindowFactory.kt b/src/nl/hannahsten/texifyidea/ui/DetexifyToolWindowFactory.kt
new file mode 100644
index 000000000..de4217bfc
--- /dev/null
+++ b/src/nl/hannahsten/texifyidea/ui/DetexifyToolWindowFactory.kt
@@ -0,0 +1,35 @@
+package nl.hannahsten.texifyidea.ui
+
+import com.intellij.openapi.module.ModuleManager
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.wm.ToolWindow
+import com.intellij.openapi.wm.ToolWindowFactory
+import com.intellij.ui.content.ContentFactory
+import com.intellij.ui.jcef.JBCefBrowser
+import nl.hannahsten.texifyidea.modules.LatexModuleType
+
+class DetexifyToolWindowFactory : ToolWindowFactory {
+
+ override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
+ val detexifyToolWindow = DetexifyToolWindow()
+ val content = ContentFactory.SERVICE.getInstance().createContent(detexifyToolWindow.content, "", false)
+ toolWindow.contentManager.addContent(content)
+ }
+
+ /**
+ * Only show the Detexify tool window in a project that contains a LaTeX module.
+ */
+ override fun isApplicable(project: Project): Boolean {
+ return ModuleManager.getInstance(project).modules.any { it.moduleTypeName == LatexModuleType.ID }
+ }
+
+ class DetexifyToolWindow {
+
+ val content = JBCefBrowser(DETEXIFY_URL).component
+
+ companion object {
+
+ const val DETEXIFY_URL = "https://detexify.kirelabs.org/classify.html"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nl/hannahsten/texifyidea/ui/OkularConfigureInverseSearchDialog.kt b/src/nl/hannahsten/texifyidea/ui/OkularConfigureInverseSearchDialog.kt
index ee782cff6..5b4a12c03 100644
--- a/src/nl/hannahsten/texifyidea/ui/OkularConfigureInverseSearchDialog.kt
+++ b/src/nl/hannahsten/texifyidea/ui/OkularConfigureInverseSearchDialog.kt
@@ -11,6 +11,7 @@ import javax.swing.JPanel
* @author Abby Berkers
*/
class OkularConfigureInverseSearchDialog {
+
init {
DialogBuilder().apply {
setTitle("Configure inverse search")
diff --git a/src/nl/hannahsten/texifyidea/ui/PopupChooserCellRenderer.kt b/src/nl/hannahsten/texifyidea/ui/PopupChooserCellRenderer.kt
index 606af24c7..667679682 100644
--- a/src/nl/hannahsten/texifyidea/ui/PopupChooserCellRenderer.kt
+++ b/src/nl/hannahsten/texifyidea/ui/PopupChooserCellRenderer.kt
@@ -14,6 +14,7 @@ import javax.swing.border.EmptyBorder
* @author Abby Berkers
*/
class PopupChooserCellRenderer : ListCellRenderer {
+
override fun getListCellRendererComponent(list: JList?, value: String?, position: Int, isSelected: Boolean, hasFocus: Boolean): Component {
val renderer = DefaultListCellRenderer().getListCellRendererComponent(
list, value, position,
diff --git a/src/nl/hannahsten/texifyidea/ui/PreviewFormUpdater.kt b/src/nl/hannahsten/texifyidea/ui/PreviewFormUpdater.kt
index deb9d5eb1..6f0e11a6e 100644
--- a/src/nl/hannahsten/texifyidea/ui/PreviewFormUpdater.kt
+++ b/src/nl/hannahsten/texifyidea/ui/PreviewFormUpdater.kt
@@ -19,6 +19,7 @@ import javax.swing.SwingUtilities.invokeLater
* @author Sergei Izmailov
*/
class PreviewFormUpdater(private val previewForm: PreviewForm) {
+
/**
* The default preamble.
*
diff --git a/src/nl/hannahsten/texifyidea/ui/SkimConfigureInverseSearchDialog.kt b/src/nl/hannahsten/texifyidea/ui/SkimConfigureInverseSearchDialog.kt
index ff819032f..c1363e7e8 100644
--- a/src/nl/hannahsten/texifyidea/ui/SkimConfigureInverseSearchDialog.kt
+++ b/src/nl/hannahsten/texifyidea/ui/SkimConfigureInverseSearchDialog.kt
@@ -11,6 +11,7 @@ import javax.swing.JPanel
* @author Stephan Sundermann
*/
class SkimConfigureInverseSearchDialog {
+
init {
DialogBuilder().apply {
setTitle("Configure inverse search")
diff --git a/src/nl/hannahsten/texifyidea/util/LatexmkRcFileFinder.kt b/src/nl/hannahsten/texifyidea/util/LatexmkRcFileFinder.kt
index 3f594d40b..5411eee7f 100644
--- a/src/nl/hannahsten/texifyidea/util/LatexmkRcFileFinder.kt
+++ b/src/nl/hannahsten/texifyidea/util/LatexmkRcFileFinder.kt
@@ -10,6 +10,7 @@ import java.io.File
* Try to find a latexmkrc file (see the latexmk man page).
*/
object LatexmkRcFileFinder {
+
private val isSystemLatexmkRcFilePresent: Boolean by lazy {
// 1
if (SystemInfo.isLinux) {
diff --git a/src/nl/hannahsten/texifyidea/util/Magic.kt b/src/nl/hannahsten/texifyidea/util/Magic.kt
index bc3d1faf4..62d488f5e 100644
--- a/src/nl/hannahsten/texifyidea/util/Magic.kt
+++ b/src/nl/hannahsten/texifyidea/util/Magic.kt
@@ -946,6 +946,7 @@ object Magic {
}
object Colors {
+
/**
* All commands that have a color as an argument.
*/
diff --git a/src/nl/hannahsten/texifyidea/util/Packages.kt b/src/nl/hannahsten/texifyidea/util/Packages.kt
index 8b7e37ae9..8cb4fd5f3 100644
--- a/src/nl/hannahsten/texifyidea/util/Packages.kt
+++ b/src/nl/hannahsten/texifyidea/util/Packages.kt
@@ -304,6 +304,7 @@ object PackageUtils {
}
object TexLivePackages {
+
/**
* List of installed packages.
*/
diff --git a/src/org/gnome/evince/Daemon.kt b/src/org/gnome/evince/Daemon.kt
index e5c789279..4f8cd9bad 100644
--- a/src/org/gnome/evince/Daemon.kt
+++ b/src/org/gnome/evince/Daemon.kt
@@ -9,6 +9,7 @@ import org.freedesktop.dbus.interfaces.DBusInterface
*/
@Suppress("FunctionName")
interface Daemon : DBusInterface {
+
/**
* Find a certain document.
* This seems to be unable to handle spaces in a path: the pdf will open but the process owner will not be returned.
diff --git a/test/nl/hannahsten/texifyidea/completion/LatexAbsolutePathCompletionTest.kt b/test/nl/hannahsten/texifyidea/completion/LatexAbsolutePathCompletionTest.kt
index 4402f32ae..e645ed8e7 100644
--- a/test/nl/hannahsten/texifyidea/completion/LatexAbsolutePathCompletionTest.kt
+++ b/test/nl/hannahsten/texifyidea/completion/LatexAbsolutePathCompletionTest.kt
@@ -10,6 +10,7 @@ import java.nio.file.Path
import java.nio.file.Paths
class LatexAbsolutePathCompletionTest : BasePlatformTestCase() {
+
private lateinit var absoluteWorkingPath: String
@Throws(Exception::class)
diff --git a/test/nl/hannahsten/texifyidea/completion/LatexMagicCommentCompletionTest.kt b/test/nl/hannahsten/texifyidea/completion/LatexMagicCommentCompletionTest.kt
index ad6df4107..930d557d9 100644
--- a/test/nl/hannahsten/texifyidea/completion/LatexMagicCommentCompletionTest.kt
+++ b/test/nl/hannahsten/texifyidea/completion/LatexMagicCommentCompletionTest.kt
@@ -5,6 +5,7 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import nl.hannahsten.texifyidea.file.LatexFileType
class LatexMagicCommentCompletionTest : BasePlatformTestCase() {
+
fun `test magic comment key completion`() {
myFixture.configureByText(LatexFileType, """
%! comp
diff --git a/test/nl/hannahsten/texifyidea/completion/LatexPathCompletionRelativeToRootFile.kt b/test/nl/hannahsten/texifyidea/completion/LatexPathCompletionRelativeToRootFile.kt
index 9fcfb2dc3..c7c65488e 100644
--- a/test/nl/hannahsten/texifyidea/completion/LatexPathCompletionRelativeToRootFile.kt
+++ b/test/nl/hannahsten/texifyidea/completion/LatexPathCompletionRelativeToRootFile.kt
@@ -19,6 +19,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
*
*/
class LatexPathCompletionRelativeToRootFile : BasePlatformTestCase() {
+
override fun getTestDataPath(): String {
return "test/resources/completion/path/relativetoroot"
}
diff --git a/test/nl/hannahsten/texifyidea/completion/LatexPathCompletionWithCommandExpansion.kt b/test/nl/hannahsten/texifyidea/completion/LatexPathCompletionWithCommandExpansion.kt
index 2752ba0a3..81122ab48 100644
--- a/test/nl/hannahsten/texifyidea/completion/LatexPathCompletionWithCommandExpansion.kt
+++ b/test/nl/hannahsten/texifyidea/completion/LatexPathCompletionWithCommandExpansion.kt
@@ -5,6 +5,7 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import nl.hannahsten.texifyidea.file.LatexFileType
class LatexPathCompletionWithCommandExpansion : BasePlatformTestCase() {
+
override fun getTestDataPath(): String {
return "test/resources/completion/path/commandexpansion"
}
diff --git a/test/nl/hannahsten/texifyidea/editor/LatexMoveElementLeftRightHandlerTest.kt b/test/nl/hannahsten/texifyidea/editor/LatexMoveElementLeftRightHandlerTest.kt
index a0d6a5de3..a876d613c 100644
--- a/test/nl/hannahsten/texifyidea/editor/LatexMoveElementLeftRightHandlerTest.kt
+++ b/test/nl/hannahsten/texifyidea/editor/LatexMoveElementLeftRightHandlerTest.kt
@@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.psi.LatexPsiHelper
import nl.hannahsten.texifyidea.util.firstChildOfType
class LatexMoveElementLeftRightHandlerTest : BasePlatformTestCase() {
+
fun `test command with single required argument`() {
commandWithSubElements("""\fbox{text}""", "{text}")
}
diff --git a/test/nl/hannahsten/texifyidea/formatting/BibtexFormattingTest.kt b/test/nl/hannahsten/texifyidea/formatting/BibtexFormattingTest.kt
index 4ff375e0a..466de5917 100644
--- a/test/nl/hannahsten/texifyidea/formatting/BibtexFormattingTest.kt
+++ b/test/nl/hannahsten/texifyidea/formatting/BibtexFormattingTest.kt
@@ -6,6 +6,7 @@ import nl.hannahsten.texifyidea.file.BibtexFileType
import nl.hannahsten.texifyidea.testutils.writeCommand
class BibtexFormattingTest : BasePlatformTestCase() {
+
fun testSpacesAroundBraces() {
"""
@inproceedings {pose:alp2018densepose,
diff --git a/test/nl/hannahsten/texifyidea/formatting/TableAlignTest.kt b/test/nl/hannahsten/texifyidea/formatting/TableAlignTest.kt
index 4c9e5bb4e..ddf806919 100644
--- a/test/nl/hannahsten/texifyidea/formatting/TableAlignTest.kt
+++ b/test/nl/hannahsten/texifyidea/formatting/TableAlignTest.kt
@@ -6,6 +6,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.testutils.writeCommand
class TableAlignTest : BasePlatformTestCase() {
+
@Throws(Exception::class)
override fun setUp() {
super.setUp()
diff --git a/test/nl/hannahsten/texifyidea/gutter/LatexGutterTest.kt b/test/nl/hannahsten/texifyidea/gutter/LatexGutterTest.kt
index 706f2f724..d0f8d1d8a 100644
--- a/test/nl/hannahsten/texifyidea/gutter/LatexGutterTest.kt
+++ b/test/nl/hannahsten/texifyidea/gutter/LatexGutterTest.kt
@@ -8,6 +8,7 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import org.junit.Test
class LatexGutterTest : BasePlatformTestCase() {
+
override fun getTestDataPath(): String {
return "test/resources/gutter"
}
diff --git a/test/nl/hannahsten/texifyidea/inspections/TexifyInspectionTestBase.kt b/test/nl/hannahsten/texifyidea/inspections/TexifyInspectionTestBase.kt
index 73ab3df64..23a7d6106 100644
--- a/test/nl/hannahsten/texifyidea/inspections/TexifyInspectionTestBase.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/TexifyInspectionTestBase.kt
@@ -1,5 +1,6 @@
package nl.hannahsten.texifyidea.inspections
+import com.intellij.codeInsight.template.impl.TemplateManagerImpl
import com.intellij.codeInspection.InspectionsBundle
import com.intellij.codeInspection.LocalInspectionTool
import com.intellij.testFramework.fixtures.BasePlatformTestCase
@@ -18,7 +19,16 @@ abstract class TexifyInspectionTestBase(vararg val inspections: LocalInspectionT
myFixture.checkHighlighting()
}
- protected fun testQuickFix(before: String, after: String, numberOfFixes: Int = 1, selectedFix: Int = 1) {
+ protected fun testQuickFix(
+ before: String,
+ after: String,
+ numberOfFixes: Int = 1,
+ selectedFix: Int = 1,
+ usestemplate: Boolean = false
+ ) {
+ if (usestemplate) {
+ TemplateManagerImpl.setTemplateTesting(getTestRootDisposable())
+ }
myFixture.configureByText(LatexFileType, before)
// Collect the quick fixed before going into write action, to avoid AssertionError: Must not start highlighting from within write action.
val quickFixes = myFixture.getAllQuickFixes()
@@ -26,7 +36,10 @@ abstract class TexifyInspectionTestBase(vararg val inspections: LocalInspectionT
writeCommand(myFixture.project) {
quickFixes[selectedFix - 1]?.invoke(myFixture.project, myFixture.editor, myFixture.file)
}
-
+ if (usestemplate) {
+ val state = TemplateManagerImpl.getTemplateState(myFixture.editor)!!
+ state.gotoEnd(false)
+ }
myFixture.checkResult(after)
}
diff --git a/test/nl/hannahsten/texifyidea/inspections/TexifyRegexInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/TexifyRegexInspectionTest.kt
index 56e57e8f5..cf444c889 100644
--- a/test/nl/hannahsten/texifyidea/inspections/TexifyRegexInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/TexifyRegexInspectionTest.kt
@@ -14,6 +14,7 @@ class TexifyRegexInspectionTest {
errorMessage = { "" },
pattern = Pattern.compile("bl.b")
) {
+
// Provide dummy document contents
var dummyDocument = ""
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexAbsolutePathInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexAbsolutePathInspectionTest.kt
index 7a54d15a8..181e07686 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexAbsolutePathInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexAbsolutePathInspectionTest.kt
@@ -7,6 +7,7 @@ import java.nio.file.Path
import java.nio.file.Paths
class LatexAbsolutePathInspectionTest : TexifyInspectionTestBase(LatexAbsolutePathInspection()) {
+
var absoluteWorkingPath: String
init {
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspectionTest.kt
index 46b31ced5..d2bbc262c 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexAvoidEqnarrayInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexAvoidEqnarrayInspectionTest : TexifyInspectionTestBase(LatexAvoidEqnarrayInspection()) {
+
fun `test eqnarray warning`() = testHighlighting("""
\begin{eqnarray}
x
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexCiteBeforePeriodInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexCiteBeforePeriodInspectionTest.kt
index 09db03991..0834af539 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexCiteBeforePeriodInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexCiteBeforePeriodInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexCiteBeforePeriodInspectionTest : TexifyInspectionTestBase(LatexCiteBeforePeriodInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexCollapseCiteInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexCollapseCiteInspectionTest.kt
index 1e081d720..d7634e11d 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexCollapseCiteInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexCollapseCiteInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexCollapseCiteInspectionTest : TexifyInspectionTestBase(LatexCollapseCiteInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexCommandAlreadyDefinedInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexCommandAlreadyDefinedInspectionTest.kt
index 229d81753..1075bb86d 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexCommandAlreadyDefinedInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexCommandAlreadyDefinedInspectionTest.kt
@@ -4,6 +4,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexCommandAlreadyDefinedInspectionTest : TexifyInspectionTestBase(LatexCommandAlreadyDefinedInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDiacriticIJInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDiacriticIJInspectionTest.kt
index 0ada1880f..4bba8fbee 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDiacriticIJInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDiacriticIJInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexDiacriticIJInspectionTest : TexifyInspectionTestBase(LatexDiacriticIJInspection()) {
+
fun `test warning`() = testHighlighting("""\^i""")
fun `test no warning`() = testHighlighting("""\^{\i}""")
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDiscouragedUseOfDefInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDiscouragedUseOfDefInspectionTest.kt
index 992a3a8fd..ec5d0a362 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDiscouragedUseOfDefInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDiscouragedUseOfDefInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexDiscouragedUseOfDefInspectionTest : TexifyInspectionTestBase(LatexDiscouragedUseOfDefInspection()) {
+
fun `test warning for def`() = testHighlighting("""\def\a1""")
fun `test warning for let`() = testHighlighting("""\let\a1""")
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDocumentclassNotInRootInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDocumentclassNotInRootInspectionTest.kt
index ed81c9df0..53c51abf7 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDocumentclassNotInRootInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDocumentclassNotInRootInspectionTest.kt
@@ -4,6 +4,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexDocumentclassNotInRootInspectionTest : TexifyInspectionTestBase(LatexDocumentclassNotInRootInspection()) {
+
override fun getTestDataPath(): String {
return "test/resources/inspections/latex/documentclassnotinroot"
}
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateDefinitionInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateDefinitionInspectionTest.kt
index 3aa0aba72..468eb4633 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateDefinitionInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateDefinitionInspectionTest.kt
@@ -4,6 +4,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexDuplicateDefinitionInspectionTest : TexifyInspectionTestBase(LatexDuplicateDefinitionInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateLabelInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateLabelInspectionTest.kt
index 431219672..dde64f662 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateLabelInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexDuplicateLabelInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.lang.CommandManager
class LatexDuplicateLabelInspectionTest : TexifyInspectionTestBase(LatexDuplicateLabelInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexEncloseWithLeftRightInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexEncloseWithLeftRightInspectionTest.kt
index dbe6771a2..6963ae915 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexEncloseWithLeftRightInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexEncloseWithLeftRightInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexEncloseWithLeftRightInspectionTest : TexifyInspectionTestBase(LatexEncloseWithLeftRightInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexEquationReferenceInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexEquationReferenceInspectionTest.kt
index 34a70f887..07ec687a8 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexEquationReferenceInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexEquationReferenceInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexEquationReferenceInspectionTest : TexifyInspectionTestBase(LatexEquationReferenceInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexFileNotFoundInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexFileNotFoundInspectionTest.kt
index ea55ea1af..e0b9a5ee3 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexFileNotFoundInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexFileNotFoundInspectionTest.kt
@@ -9,6 +9,7 @@ import java.nio.file.Paths
import kotlin.test.assertFails
class LatexFileNotFoundInspectionTest : TexifyInspectionTestBase(LatexFileNotFoundInspection()) {
+
private var absoluteWorkingPath: String
init {
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexGatherEquationsInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexGatherEquationsInspectionTest.kt
index 038df84f5..993ce740b 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexGatherEquationsInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexGatherEquationsInspectionTest.kt
@@ -4,6 +4,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexGatherEquationsInspectionTest : TexifyInspectionTestBase(LatexGatherEquationsInspection()) {
+
fun `test two consecutive display math environments`() {
myFixture.configureByText(LatexFileType, """
\[
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelBeforeCaptionInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelBeforeCaptionInspectionTest.kt
index 1c409ab52..91a8fb62d 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelBeforeCaptionInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelBeforeCaptionInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.testutils.writeCommand
import org.junit.Test
class LatexLabelBeforeCaptionInspectionTest : BasePlatformTestCase() {
+
override fun getTestDataPath(): String {
return "test/resources/inspections/latex/labelaftercaption"
}
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspectionTest.kt
index 943a09342..90c4c6a0e 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspectionTest.kt
@@ -4,6 +4,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexLabelConventionInspectionTest : TexifyInspectionTestBase(LatexLabelConventionInspection()) {
+
fun testSectionLabelConventionWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspectionTest.kt
index f2e7f9c89..1bc5b5742 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexLineBreakInspectionTest : TexifyInspectionTestBase(LatexLineBreakInspection()) {
+
fun testWarning() = testHighlighting("""
Not this, but. This starts a new line.
This etc. is missing a normal space, but i.e. this etc.\ is not.
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMathOperatorEscapeInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMathOperatorEscapeInspectionTest.kt
index 107328fa2..69afee7c5 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMathOperatorEscapeInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMathOperatorEscapeInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexMathOperatorEscapeInspectionTest : TexifyInspectionTestBase(LatexMathOperatorEscapeInspection()) {
+
fun `test inspection triggered in inline math`() {
testHighlighting("""Hallo ${'$'}y = cos(x)${'$'}""")
}
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentEnvironmentInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentEnvironmentInspectionTest.kt
index e3817376d..80caaeb1a 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentEnvironmentInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentEnvironmentInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexMissingDocumentEnvironmentInspectionTest : TexifyInspectionTestBase(LatexMissingDocumentEnvironmentInspection()) {
+
fun `test missing document environment`() = testHighlighting("""
\documentclass{article}
""".trimIndent())
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentclassInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentclassInspectionTest.kt
index e52429164..df4bb1396 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentclassInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingDocumentclassInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexMissingDocumentclassInspectionTest : TexifyInspectionTestBase(LatexMissingDocumentclassInspection()) {
+
fun `test no warning`() = testHighlighting("""\documentclass{article}""")
fun `test no warning in sty file`() {
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspectionTest.kt
index 8010a78b2..125347565 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingImportInspectionTest.kt
@@ -6,6 +6,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexMissingImportInspectionTest : TexifyInspectionTestBase(LatexMissingImportInspection()) {
+
override fun getTestDataPath(): String {
return "test/resources/inspections/latex/missingimport"
}
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt
index d7725a33c..f098432ff 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.lang.CommandManager
class LatexMissingLabelInspectionTest : TexifyInspectionTestBase(LatexMissingLabelInspection()) {
+
override fun getTestDataPath(): String {
return "test/resources/inspections/latex/missinglabel"
}
@@ -136,10 +137,11 @@ class LatexMissingLabelInspectionTest : TexifyInspectionTestBase(LatexMissingLab
""".trimIndent(),
after = """
\begin{document}
- \begin{lstlisting}[label={lst:lstlisting}]
- \end{lstlisting}
+ \begin{lstlisting}[label={lst:lstlisting}]
+ \end{lstlisting}
\end{document}
- """.trimIndent()
+ """.trimIndent(),
+ usestemplate = true
)
fun `test quick fix in listings when label already exists`() = testQuickFix(
@@ -153,10 +155,11 @@ class LatexMissingLabelInspectionTest : TexifyInspectionTestBase(LatexMissingLab
after = """
\begin{document}
\label{lst:lstlisting}
- \begin{lstlisting}[label={lst:lstlisting2}]
- \end{lstlisting}
+ \begin{lstlisting}[label={lst:lstlisting2}]
+ \end{lstlisting}
\end{document}
- """.trimIndent()
+ """.trimIndent(),
+ usestemplate = true
)
fun `test quick fix in listings with other parameters`() = testQuickFix(
@@ -168,10 +171,11 @@ class LatexMissingLabelInspectionTest : TexifyInspectionTestBase(LatexMissingLab
""".trimIndent(),
after = """
\begin{document}
- \begin{lstlisting}[someoption,otheroption={with value},label={lst:lstlisting}]
- \end{lstlisting}
+ \begin{lstlisting}[someoption,otheroption={with value},label={lst:lstlisting}]
+ \end{lstlisting}
\end{document}
- """.trimIndent()
+ """.trimIndent(),
+ usestemplate = true
)
fun `test fix all missing label problems in this file`() = testQuickFixAll(
@@ -221,8 +225,23 @@ class LatexMissingLabelInspectionTest : TexifyInspectionTestBase(LatexMissingLab
""".trimIndent(),
after = """
\begin{document}
- \lstinputlisting[someoption,otheroption={with value},label={lst:lstinputlisting}]{some/file}
+ \lstinputlisting[someoption,otheroption={with value},label={lst:lstinputlisting}]{some/file}
\end{document}
- """.trimIndent()
+ """.trimIndent(),
+ usestemplate = true
+ )
+
+ fun `test quick fix in lstinputlistings creates optional parameters at correct position`() = testQuickFix(
+ before = """
+ \begin{document}
+ \lstinputlisting{some/file}
+ \end{document}
+ """.trimIndent(),
+ after = """
+ \begin{document}
+ \lstinputlisting[label={lst:lstinputlisting}]{some/file}
+ \end{document}
+ """.trimIndent(),
+ usestemplate = true
)
}
\ No newline at end of file
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleIncludesInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleIncludesInspectionTest.kt
index 76808608a..25ea786a5 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleIncludesInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMultipleIncludesInspectionTest.kt
@@ -4,6 +4,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexMultipleIncludesInspectionTest : TexifyInspectionTestBase(LatexMultipleIncludesInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspectionTest.kt
index e75b7933d..d7651e65d 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexNoExtensionInspectionTest : TexifyInspectionTestBase(LatexNoExtensionInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspectionTest.kt
index 013f9bdc6..8c985424f 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexNonBreakingSpaceInspectionTest : TexifyInspectionTestBase(LatexNonBreakingSpaceInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingEnvironmentInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingEnvironmentInspectionTest.kt
index b4c2822ea..183a4cb44 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingEnvironmentInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingEnvironmentInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexNonMatchingEnvironmentInspectionTest : TexifyInspectionTestBase(LatexNonMatchingEnvironmentInspection()) {
+
fun `test no warning`() = testHighlighting("""
\begin{center}
bla
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspectionTest.kt
index f3e0922e0..b967f71e7 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexNonMatchingIfInspectionTest : TexifyInspectionTestBase(LatexNonMatchingIfInspection()) {
+
fun `test if closed`() = testHighlighting(
"""
\if
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexOverInsteadOfFracInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexOverInsteadOfFracInspectionTest.kt
index a0ad78d2c..cb538d817 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexOverInsteadOfFracInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexOverInsteadOfFracInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexOverInsteadOfFracInspectionTest : TexifyInspectionTestBase(LatexOverInsteadOfFracInspection()) {
+
fun `test over warning`() = testHighlighting("""$1 \over 2$""")
fun `test frac no warning`() = testHighlighting("""$\frac{1}{2}$""")
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageCouldNotBeFoundInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageCouldNotBeFoundInspectionTest.kt
index ea6e73ea8..0338865b7 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageCouldNotBeFoundInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageCouldNotBeFoundInspectionTest.kt
@@ -4,6 +4,7 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import org.junit.Test
class LatexPackageCouldNotBeFoundInspectionTest : BasePlatformTestCase() {
+
override fun getTestDataPath(): String {
return "test/resources/inspections/latex/packagenotfound"
}
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNameDoesNotMatchFileNameInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNameDoesNotMatchFileNameInspectionTest.kt
index 21593f6b7..21b2394df 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNameDoesNotMatchFileNameInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNameDoesNotMatchFileNameInspectionTest.kt
@@ -4,6 +4,7 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexPackageNameDoesNotMatchFileNameInspectionTest : BasePlatformTestCase() {
+
override fun getTestDataPath(): String {
return "test/resources/inspections/latex/packagenamedoesnotmatch"
}
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNotInstalledInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNotInstalledInspectionTest.kt
index 45e693de2..0b50a138c 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNotInstalledInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexPackageNotInstalledInspectionTest.kt
@@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.settings.sdk.TexliveSdk
import nl.hannahsten.texifyidea.util.TexLivePackages
class LatexPackageNotInstalledInspectionTest : TexifyInspectionTestBase(LatexPackageNotInstalledInspection()) {
+
fun `test no warnings when not using texlive`() {
texliveWithTlmgr(texlive = false, tlmgr = false)
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveStyleInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveStyleInspectionTest.kt
index 9d20d303a..93064cb29 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveStyleInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexPrimitiveStyleInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexPrimitiveStyleInspectionTest : TexifyInspectionTestBase(LatexPrimitiveStyleInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexRedundantEscapeInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexRedundantEscapeInspectionTest.kt
index 416c87e6f..6d9fd04f6 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexRedundantEscapeInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexRedundantEscapeInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.setUnicodeSupport
class LatexRedundantEscapeInspectionTest : TexifyInspectionTestBase(LatexRedundantEscapeInspection()) {
+
fun `test no warning when no unicode support`() {
setUnicodeSupport(myFixture.project, false)
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexRequiredExtensionInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexRequiredExtensionInspectionTest.kt
index 5e09da9b3..b0b9c11cc 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexRequiredExtensionInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexRequiredExtensionInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexRequiredExtensionInspectionTest : TexifyInspectionTestBase(LatexRequiredExtensionInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspectionTest.kt
index 44f79cdc7..bde348d0c 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexSpaceAfterAbbreviationInspectionTest : TexifyInspectionTestBase(LatexSpaceAfterAbbreviationInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexTooLargeSectionInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexTooLargeSectionInspectionTest.kt
index 3650319df..440d692de 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexTooLargeSectionInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexTooLargeSectionInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexTooLargeSectionInspectionTest : TexifyInspectionTestBase(LatexTooLargeSectionInspection()) {
+
override fun getTestDataPath(): String = "test/resources/inspections/latex/toolargesection"
fun `test too large section`() {
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexTrimWhiteSpaceInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexTrimWhiteSpaceInspectionTest.kt
index 068776ea2..df418a4a3 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexTrimWhiteSpaceInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexTrimWhiteSpaceInspectionTest.kt
@@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.inspections.latex
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class LatexTrimWhiteSpaceInspectionTest : TexifyInspectionTestBase(LatexTrimWhitespaceInspection()) {
+
fun `test no warning in section command`() = testHighlighting("""\section{test}""")
fun `test no warning in non-section command`() = testHighlighting("""\box{ test}""")
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexUnicodeInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexUnicodeInspectionTest.kt
index 248e9b6cf..f6b50e293 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexUnicodeInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexUnicodeInspectionTest.kt
@@ -4,6 +4,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class OutsideMathLatexUnicodeInspectionTest : LatexUnicodeInspectionTest() {
+
fun `test illegal unicode character`() {
setUnicodeSupport(false)
@@ -31,6 +32,7 @@ class OutsideMathLatexUnicodeInspectionTest : LatexUnicodeInspectionTest() {
}
class InsideMathLatexUnicodeInspectionTest : LatexUnicodeInspectionTest() {
+
fun `test without support`() {
setUnicodeSupport(false)
@@ -56,6 +58,7 @@ class InsideMathLatexUnicodeInspectionTest : LatexUnicodeInspectionTest() {
}
class LatexUnicodeInspectionQuickFix : LatexUnicodeInspectionTest() {
+
fun `test include packages quick fix`() {
setUnicodeSupport(false)
@@ -101,5 +104,6 @@ class LatexUnicodeInspectionQuickFix : LatexUnicodeInspectionTest() {
}
abstract class LatexUnicodeInspectionTest : TexifyInspectionTestBase(LatexUnicodeInspection()) {
+
fun setUnicodeSupport(enabled: Boolean = true) = nl.hannahsten.texifyidea.testutils.setUnicodeSupport(myFixture.project, enabled)
}
\ No newline at end of file
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/NonAsciiCharactersInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/NonAsciiCharactersInspectionTest.kt
index f51ef35d5..0cc960925 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/NonAsciiCharactersInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/NonAsciiCharactersInspectionTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
class NonAsciiCharactersInspectionTest : TexifyInspectionTestBase(NonAsciiCharactersInspection()) {
+
fun testWarning() {
myFixture.configureByText(
LatexFileType,
diff --git a/test/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntentionTest.kt b/test/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntentionTest.kt
index c7befdb98..fe6fafc92 100644
--- a/test/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntentionTest.kt
+++ b/test/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntentionTest.kt
@@ -6,6 +6,7 @@ import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.testutils.writeCommand
class LatexAddLabelIntentionTest : BasePlatformTestCase() {
+
fun testMissingChapterLabel() {
myFixture.configureByText(
LatexFileType,
@@ -98,4 +99,28 @@ class LatexAddLabelIntentionTest : BasePlatformTestCase() {
""".trimIndent()
)
}
+
+ fun testAddLabelForEnvironment() {
+ myFixture.configureByText(
+ LatexFileType,
+ """
+ \begin{document}
+ \begin{lstlisting}
+ \end{lstlisting}
+ \end{document}
+ """.trimIndent()
+ )
+ val intentions = myFixture.availableIntentions
+ writeCommand(myFixture.project) {
+ intentions.first { i -> i.text == "Add label" }.invoke(myFixture.project, myFixture.editor, myFixture.file)
+ }
+ myFixture.checkResult(
+ """
+ \begin{document}
+ \begin{lstlisting}[label={lst:lstlisting}]
+ \end{lstlisting}
+ \end{document}
+ """.trimIndent()
+ )
+ }
}
\ No newline at end of file
diff --git a/test/nl/hannahsten/texifyidea/lang/CommandManagerTest.kt b/test/nl/hannahsten/texifyidea/lang/CommandManagerTest.kt
index e4cd73353..c7192dc9a 100644
--- a/test/nl/hannahsten/texifyidea/lang/CommandManagerTest.kt
+++ b/test/nl/hannahsten/texifyidea/lang/CommandManagerTest.kt
@@ -13,6 +13,7 @@ import java.util.function.Function
*/
@Suppress("unused")
class CommandManagerTest {
+
private var manager: CommandManager? = null
@Before
diff --git a/test/nl/hannahsten/texifyidea/lang/magic/MagicCommentPsiTest.kt b/test/nl/hannahsten/texifyidea/lang/magic/MagicCommentPsiTest.kt
index d136d5cec..e84efdf69 100644
--- a/test/nl/hannahsten/texifyidea/lang/magic/MagicCommentPsiTest.kt
+++ b/test/nl/hannahsten/texifyidea/lang/magic/MagicCommentPsiTest.kt
@@ -6,6 +6,7 @@ import nl.hannahsten.texifyidea.index.LatexCommandsIndex
import org.junit.jupiter.api.Assertions
class MagicCommentPsiTest : BasePlatformTestCase() {
+
fun `test get magic comment for command`() {
myFixture.configureByText(LatexFileType, "%! suppress = FileNotFound\n\\documentclass{article}")
val command = LatexCommandsIndex.getCommandsByName("\\documentclass", myFixture.file).first()
diff --git a/test/nl/hannahsten/texifyidea/psi/BibtexEntryImplUtilTest.kt b/test/nl/hannahsten/texifyidea/psi/BibtexEntryImplUtilTest.kt
index ea39514fe..1dc6776a4 100644
--- a/test/nl/hannahsten/texifyidea/psi/BibtexEntryImplUtilTest.kt
+++ b/test/nl/hannahsten/texifyidea/psi/BibtexEntryImplUtilTest.kt
@@ -11,6 +11,7 @@ import org.intellij.lang.annotations.Language
import org.junit.Test
class BibtexEntryImplUtilTest : BasePlatformTestCase() {
+
private val url = "https://github.com/hannah-sten/TeXiFy-IDEA"
@Language("Bibtex")
diff --git a/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt
index 7cf548119..3018e0917 100644
--- a/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt
+++ b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt
@@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.util.firstChildOfType
import org.junit.Test
class LatexCommandsImplUtilTest : BasePlatformTestCase() {
+
@Test
fun `test simple optional parameters map`() {
// given
diff --git a/test/nl/hannahsten/texifyidea/psi/LatexParserToPsiTest.kt b/test/nl/hannahsten/texifyidea/psi/LatexParserToPsiTest.kt
index d5a1edf2a..cd1905078 100644
--- a/test/nl/hannahsten/texifyidea/psi/LatexParserToPsiTest.kt
+++ b/test/nl/hannahsten/texifyidea/psi/LatexParserToPsiTest.kt
@@ -4,6 +4,7 @@ import com.intellij.testFramework.ParsingTestCase
import nl.hannahsten.texifyidea.LatexParserDefinition
class LatexParserToPsiTest : ParsingTestCase("", "tex", LatexParserDefinition()) {
+
override fun getTestDataPath(): String = "test/resources/psi/parser"
override fun skipSpaces(): Boolean = false
diff --git a/test/nl/hannahsten/texifyidea/psi/LatexPsiImplUtilTest.kt b/test/nl/hannahsten/texifyidea/psi/LatexPsiImplUtilTest.kt
index 9989be4d7..35065e3e1 100644
--- a/test/nl/hannahsten/texifyidea/psi/LatexPsiImplUtilTest.kt
+++ b/test/nl/hannahsten/texifyidea/psi/LatexPsiImplUtilTest.kt
@@ -11,6 +11,7 @@ import nl.hannahsten.texifyidea.util.requiredParameters
import org.junit.Test
class LatexPsiImplUtilTest : BasePlatformTestCase() {
+
private val url = "https://github.com/Hannah-Sten/TeXiFy-IDEA"
override fun getTestDataPath(): String {
diff --git a/test/nl/hannahsten/texifyidea/reference/BibtexIdCompletionTest.kt b/test/nl/hannahsten/texifyidea/reference/BibtexIdCompletionTest.kt
index 1fb07a3b4..b0faf9a1e 100644
--- a/test/nl/hannahsten/texifyidea/reference/BibtexIdCompletionTest.kt
+++ b/test/nl/hannahsten/texifyidea/reference/BibtexIdCompletionTest.kt
@@ -6,6 +6,7 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import org.junit.Test
class BibtexIdCompletionTest : BasePlatformTestCase() {
+
override fun getTestDataPath(): String {
return "test/resources/completion/cite"
}
diff --git a/test/nl/hannahsten/texifyidea/reference/InputFileReferenceTest.kt b/test/nl/hannahsten/texifyidea/reference/InputFileReferenceTest.kt
index 35e5779cc..5999cd337 100644
--- a/test/nl/hannahsten/texifyidea/reference/InputFileReferenceTest.kt
+++ b/test/nl/hannahsten/texifyidea/reference/InputFileReferenceTest.kt
@@ -4,6 +4,7 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import nl.hannahsten.texifyidea.file.LatexFileType
class InputFileReferenceTest : BasePlatformTestCase() {
+
override fun getTestDataPath(): String {
return "test/resources/reference"
}
diff --git a/test/nl/hannahsten/texifyidea/run/logtab/LatexLogFileFinderTest.kt b/test/nl/hannahsten/texifyidea/run/logtab/LatexLogFileFinderTest.kt
index 17ed66c8d..4c28d2371 100644
--- a/test/nl/hannahsten/texifyidea/run/logtab/LatexLogFileFinderTest.kt
+++ b/test/nl/hannahsten/texifyidea/run/logtab/LatexLogFileFinderTest.kt
@@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.run.latex.logtab.LatexFileStack
import nl.hannahsten.texifyidea.run.latex.logtab.LatexLogMagicRegex.LINE_WIDTH
class LatexLogFileFinderTest : BasePlatformTestCase() {
+
fun testFileIsImmediatelyClosed() {
val line =
"""(/home/abby/texlive/2019/texmf-dist/tex/latex/graphics/keyval.sty)"""
diff --git a/test/nl/hannahsten/texifyidea/run/logtab/LatexMessageExtractorTest.kt b/test/nl/hannahsten/texifyidea/run/logtab/LatexMessageExtractorTest.kt
index 31fc65081..84e0d7525 100644
--- a/test/nl/hannahsten/texifyidea/run/logtab/LatexMessageExtractorTest.kt
+++ b/test/nl/hannahsten/texifyidea/run/logtab/LatexMessageExtractorTest.kt
@@ -12,6 +12,7 @@ import nl.hannahsten.texifyidea.util.removeAll
* For message spanning multiple lines, see [LatexOutputListenerTest].
*/
class LatexMessageExtractorTest : BasePlatformTestCase() {
+
private val currentFile = "test.tex"
/*
diff --git a/test/nl/hannahsten/texifyidea/run/logtab/LatexOutputListenerTest.kt b/test/nl/hannahsten/texifyidea/run/logtab/LatexOutputListenerTest.kt
index 81996ab18..d6a3af864 100644
--- a/test/nl/hannahsten/texifyidea/run/logtab/LatexOutputListenerTest.kt
+++ b/test/nl/hannahsten/texifyidea/run/logtab/LatexOutputListenerTest.kt
@@ -14,6 +14,7 @@ import nl.hannahsten.texifyidea.run.latex.logtab.ui.LatexCompileMessageTreeView
* For messages over at most two lines, see [LatexMessageExtractorTest].
*/
class LatexOutputListenerTest : BasePlatformTestCase() {
+
private val logTextLatexmk =
"""
latexmk -pdf -file-line-error -interaction=nonstopmode -synctex=1 -output-format=pdf -output-directory=/home/abby/Documents/texify-test/out main.tex
diff --git a/test/nl/hannahsten/texifyidea/run/logtab/LatexQuickRunLogParserTest.kt b/test/nl/hannahsten/texifyidea/run/logtab/LatexQuickRunLogParserTest.kt
index 324f267c9..be8342197 100644
--- a/test/nl/hannahsten/texifyidea/run/logtab/LatexQuickRunLogParserTest.kt
+++ b/test/nl/hannahsten/texifyidea/run/logtab/LatexQuickRunLogParserTest.kt
@@ -7,6 +7,7 @@ import nl.hannahsten.texifyidea.run.latex.logtab.LatexOutputListener
import nl.hannahsten.texifyidea.run.latex.logtab.ui.LatexCompileMessageTreeView
class LatexQuickRunLogParserTest : BasePlatformTestCase() {
+
/**
* Useful regex for matching braces: \(([^(^)]+)\)
*/
diff --git a/test/nl/hannahsten/texifyidea/util/RootFileTest.kt b/test/nl/hannahsten/texifyidea/util/RootFileTest.kt
index 82d141f09..2c8e07de6 100644
--- a/test/nl/hannahsten/texifyidea/util/RootFileTest.kt
+++ b/test/nl/hannahsten/texifyidea/util/RootFileTest.kt
@@ -4,6 +4,7 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import nl.hannahsten.texifyidea.inspections.latex.LatexFileNotFoundInspection
class RootFileTest : BasePlatformTestCase() {
+
override fun getTestDataPath(): String {
return "test/resources/util/rootfile"
}
]