From 5cd666fec3c04ef534e03d1914c33680c3e3176d Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Tue, 7 Nov 2023 20:45:10 +0100 Subject: [PATCH 1/6] Include style files in logging indexable roots --- build.gradle.kts | 9 +++++---- gradle.properties | 2 +- .../index/file/LatexIndexableSetContributor.kt | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 517342b56..bf9d3c768 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,8 +10,8 @@ fun properties(key: String) = project.findProperty(key).toString() // Supersedes the use of "buildscript" block and "apply plugin:" plugins { id("org.jetbrains.intellij") version "1.16.0" - kotlin("jvm") version ("1.9.0") - kotlin("plugin.serialization") version ("1.9.0") + kotlin("jvm") version ("1.9.20") + kotlin("plugin.serialization") version ("1.9.20") // Plugin which can check for Gradle dependencies, use the help/dependencyUpdates task. id("com.github.ben-manes.versions") version "0.49.0" @@ -77,8 +77,9 @@ tasks.compileTestKotlin { dependencies { // Local dependencies implementation(files("lib/pretty-tools-JDDE-2.1.0.jar")) - implementation(files("lib/JavaDDE.dll")) - implementation(files("lib/JavaDDEx64.dll")) + // These lines can sometimes be problematic on Linux +// implementation(files("lib/JavaDDE.dll")) +// implementation(files("lib/JavaDDEx64.dll")) // D-Bus Java bindings implementation("com.github.hypfvieh:dbus-java:3.3.2") diff --git a/gradle.properties b/gradle.properties index 24d7f151a..497dd5179 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion = 0.9.2-alpha.3 +pluginVersion = 0.9.2-alpha.4 # Info about build ranges: https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html # Note that an xyz branch corresponds to version 20xy.z and a since build of xyz.* diff --git a/src/nl/hannahsten/texifyidea/index/file/LatexIndexableSetContributor.kt b/src/nl/hannahsten/texifyidea/index/file/LatexIndexableSetContributor.kt index e61f536eb..f5f4ce27f 100644 --- a/src/nl/hannahsten/texifyidea/index/file/LatexIndexableSetContributor.kt +++ b/src/nl/hannahsten/texifyidea/index/file/LatexIndexableSetContributor.kt @@ -32,7 +32,6 @@ class LatexIndexableSetContributor : IndexableSetContributor() { // Add source files val roots = LatexSdkUtil.getSdkSourceRoots(project) { sdk, homePath -> sdk.getDefaultSourcesPath(homePath) }.toMutableSet() // Check if we possibly need to extract files first - Log.debug("Indexing source roots $roots") for (root in roots) { if (root.path.contains("MiKTeX", ignoreCase = true) && !extractedFiles) { try { @@ -50,6 +49,7 @@ class LatexIndexableSetContributor : IndexableSetContributor() { // Unfortunately, since .sty is a LaTeX file type, these will all be parsed, which will take an enormous amount of time. // Note that using project-independent getAdditionalRootsToIndex does not fix this roots.addAll(LatexSdkUtil.getSdkSourceRoots(project) { sdkType, homePath -> sdkType.getDefaultStyleFilesPath(homePath) }) + Log.debug("Indexing source roots $roots") return roots } From 473a0f2c11d55a9ab9d845fce9572a882fc29a0f Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Tue, 7 Nov 2023 20:51:50 +0100 Subject: [PATCH 2/6] Updates --- CHANGELOG.md | 21 ++++++++++++++++++--- build.gradle.kts | 26 +++++++++++++------------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36cec52da..0dd504fc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,20 @@ ### Fixed +## [0.9.2-alpha.4] - 2023-11-07 + +### Added + +* Add some missing starred versions of table environments +* Add support for package indexing for native TeX Live installations + +### Fixed + +* Fix structure view nesting +* Fix some bugs in the math environment toggle intention +* Fix support for inlining commands in non-IntelliJ IDEs, by @jojo2357 +* Fix a sync issue with remote libraries + ## [0.9.2-alpha.3] - 2023-10-19 ### Added @@ -259,10 +273,11 @@ Thanks to @jojo2357 and @MisterDeenis for contributing to this release! * Fix some intention previews. ([#2796](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2796)) * Other small bug fixes and improvements. ([#2776](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2776), [#2774](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2774), [#2765](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2765)-[#2773](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2773)) -[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.2-alpha.3...HEAD -[0.9.2-alpha.2]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.2-alpha.1...v0.9.2-alpha.2 -[0.9.2-alpha.1]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.1...v0.9.2-alpha.1 +[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.2-alpha.4...HEAD [0.9.2-alpha.3]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.2-alpha.2...v0.9.2-alpha.3 +[0.9.2-alpha.1]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.1...v0.9.2-alpha.1 +[0.9.2-alpha.2]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.2-alpha.1...v0.9.2-alpha.2 +[0.9.2-alpha.4]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.2-alpha.3...v0.9.2-alpha.4 [0.9.1]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.0...v0.9.1 [0.9.0]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.7.33...v0.9.0 [0.7.33]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.7.32...v0.7.33 diff --git a/build.gradle.kts b/build.gradle.kts index bf9d3c768..b6bdc856c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,7 +29,7 @@ plugins { id("org.jlleitschuh.gradle.ktlint") version "11.3.2" // Vulnerability scanning - id("org.owasp.dependencycheck") version "8.4.0" + id("org.owasp.dependencycheck") version "8.4.2" id("org.jetbrains.changelog") version "2.2.0" @@ -88,7 +88,7 @@ dependencies { // Unzipping tar.xz/tar.bz2 files on Windows containing dtx files implementation("org.codehaus.plexus:plexus-component-api:1.0-alpha-33") implementation("org.codehaus.plexus:plexus-container-default:2.1.1") - implementation("org.codehaus.plexus:plexus-archiver:4.8.0") + implementation("org.codehaus.plexus:plexus-archiver:4.9.0") // Parsing json implementation("com.beust:klaxon:5.6") @@ -99,13 +99,13 @@ dependencies { implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.15.3") // Http requests - implementation("io.ktor:ktor-client-core:2.3.5") - implementation("io.ktor:ktor-client-cio:2.3.5") - implementation("io.ktor:ktor-client-auth:2.3.5") - implementation("io.ktor:ktor-client-content-negotiation:2.3.5") - implementation("io.ktor:ktor-server-core:2.3.5") - implementation("io.ktor:ktor-server-jetty:2.3.5") - implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.5") + implementation("io.ktor:ktor-client-core:2.3.6") + implementation("io.ktor:ktor-client-cio:2.3.6") + implementation("io.ktor:ktor-client-auth:2.3.6") + implementation("io.ktor:ktor-client-content-negotiation:2.3.6") + implementation("io.ktor:ktor-server-core:2.3.6") + implementation("io.ktor:ktor-server-jetty:2.3.6") + implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.6") // Comparing versions implementation("org.apache.maven:maven-artifact:4.0.0-alpha-7") @@ -128,14 +128,14 @@ dependencies { // Also implementation junit 4, just in case testImplementation("junit:junit:4.13.2") - testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.10.0") + testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.10.1") // Use junit 5 for test cases - testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1") // Enable use of the JUnitPlatform Runner within the IDE - testImplementation("org.junit.platform:junit-platform-runner:1.10.0") + testImplementation("org.junit.platform:junit-platform-runner:1.10.1") testImplementation("io.mockk:mockk:1.13.8") From 47a7d87a55e285fe4489ca17f23eca3691ea4577 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Wed, 8 Nov 2023 20:42:25 +0100 Subject: [PATCH 3/6] Include bib files in package location cache, as it is used for input file references in \bibliography commands --- .../probablebugs/LatexUnresolvedReferenceInspection.kt | 6 ++++-- .../texifyidea/util/files/LatexPackageLocationCache.kt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexUnresolvedReferenceInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexUnresolvedReferenceInspection.kt index 199a92e60..ef8e9d579 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexUnresolvedReferenceInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/probablebugs/LatexUnresolvedReferenceInspection.kt @@ -7,12 +7,14 @@ import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.inspections.InsightGroup import nl.hannahsten.texifyidea.inspections.TexifyInspectionBase +import nl.hannahsten.texifyidea.lang.commands.LatexGenericRegularCommand import nl.hannahsten.texifyidea.lang.magic.MagicCommentScope import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.util.files.commandsInFile import nl.hannahsten.texifyidea.util.labels.findLatexAndBibtexLabelStringsInFileSet -import nl.hannahsten.texifyidea.util.parser.firstParentOfType import nl.hannahsten.texifyidea.util.magic.CommandMagic +import nl.hannahsten.texifyidea.util.magic.cmd +import nl.hannahsten.texifyidea.util.parser.firstParentOfType import java.lang.Integer.max import java.util.* @@ -56,7 +58,7 @@ open class LatexUnresolvedReferenceInspection : TexifyInspectionBase() { if (part == "*") continue // The cleveref package allows empty items to customize enumerations - if (part.isEmpty() && (command.commandToken.text == "\\cref" || command.commandToken.text == "\\Cref")) continue + if (part.isEmpty() && (command.name == LatexGenericRegularCommand.CREF.cmd || command.name == LatexGenericRegularCommand.CREF_CAPITAL.cmd)) continue // If there is no label with this required label parameter value if (!labels.contains(part.trim())) { diff --git a/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt b/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt index cde1a39d0..70311df49 100644 --- a/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt +++ b/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt @@ -27,7 +27,7 @@ object LatexPackageLocationCache { // We cannot just fill the cache on the fly, because then we will also run kpsewhich when the user is still typing a package name, so we will run it once for every letter typed and this is already too expensive. // We cannot rely on ls-R databases because they are not always populated, and running mktexlsr may run into permission issues. val executableName = LatexSdkUtil.getExecutableName("kpsewhich", project) - val searchPaths = runCommand(executableName, "-show-path=tex") + val searchPaths = (runCommand(executableName, "-show-path=tex") ?: ".") + File.pathSeparator + (runCommand(executableName, "-show-path=bib") ?: ".") cache = runCommand(executableName, "-expand-path", searchPaths ?: ".:")?.split(File.pathSeparator) ?.flatMap { LocalFileSystem.getInstance().findFileByPath(it)?.children?.toList() ?: emptyList() } ?.filter { !it.isDirectory } From 6bce73f3054b46c7a6c17d08c9afef54eaeccfa8 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Wed, 8 Nov 2023 21:04:13 +0100 Subject: [PATCH 4/6] Ignore all non-TeXiFy indexing exceptions like #3306 --- .../texifyidea/index/IndexUtilBase.kt | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/index/IndexUtilBase.kt b/src/nl/hannahsten/texifyidea/index/IndexUtilBase.kt index 396cd0ac5..0c0b93de8 100644 --- a/src/nl/hannahsten/texifyidea/index/IndexUtilBase.kt +++ b/src/nl/hannahsten/texifyidea/index/IndexUtilBase.kt @@ -1,7 +1,6 @@ package nl.hannahsten.texifyidea.index import com.intellij.openapi.application.runReadAction -import com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement @@ -11,6 +10,7 @@ import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.stubs.StubIndex import com.intellij.psi.stubs.StubIndexKey import com.intellij.refactoring.suggested.createSmartPointer +import nl.hannahsten.texifyidea.util.Log import nl.hannahsten.texifyidea.util.files.documentClassFileInProject import nl.hannahsten.texifyidea.util.files.findRootFile import nl.hannahsten.texifyidea.util.files.referencedFileSet @@ -139,9 +139,10 @@ abstract class IndexUtilBase( try { return runReadAction { StubIndex.getElements(indexKey, name, project, scope, elementClass) } } - catch (e: RuntimeExceptionWithAttachments) { - // Ignore, because we've seen it only four times so far (#1375, #1446, #1591, #2086) but I fail to see how this would be a bug in TeXiFy. - if (e.message?.contains("PSI and index do not match") == false) throw e + catch (e: Exception) { + // For some reason, any issue from any plugin that causes an exception will be raised here and will be attributed to TeXiFy, flooding the backlog + // Hence, we just ignore all of them and hope it's not important + Log.warn(e.toString()) } return emptySet() } @@ -153,12 +154,16 @@ abstract class IndexUtilBase( * The project instance. */ private fun getKeys(project: Project): Array { - return if (!DumbService.isDumb(project) && !project.isDefault) { - runReadAction { StubIndex.getInstance().getAllKeys(indexKey, project).toTypedArray() } - } - else { - emptyArray() + if (!DumbService.isDumb(project) && !project.isDefault) { + try { + return runReadAction { StubIndex.getInstance().getAllKeys(indexKey, project).toTypedArray() } + } + catch (e: Exception) { + // See above + Log.warn(e.toString()) + } } + return emptyArray() } /** From 4fe517b73789a9102485443ea82fd9427123b277 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Fri, 24 Nov 2023 10:26:51 +0100 Subject: [PATCH 5/6] Remove unused code --- .../texifyidea/util/files/LatexPackageLocationCache.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt b/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt index 70311df49..4dd7e73c2 100644 --- a/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt +++ b/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt @@ -28,7 +28,7 @@ object LatexPackageLocationCache { // We cannot rely on ls-R databases because they are not always populated, and running mktexlsr may run into permission issues. val executableName = LatexSdkUtil.getExecutableName("kpsewhich", project) val searchPaths = (runCommand(executableName, "-show-path=tex") ?: ".") + File.pathSeparator + (runCommand(executableName, "-show-path=bib") ?: ".") - cache = runCommand(executableName, "-expand-path", searchPaths ?: ".:")?.split(File.pathSeparator) + cache = runCommand(executableName, "-expand-path", searchPaths)?.split(File.pathSeparator) ?.flatMap { LocalFileSystem.getInstance().findFileByPath(it)?.children?.toList() ?: emptyList() } ?.filter { !it.isDirectory } ?.toSet() From 8c0e226c0b11415876cc44675e8ec7432741bfb8 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Fri, 24 Nov 2023 16:10:51 +0100 Subject: [PATCH 6/6] We do need the dlls --- build.gradle.kts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index caa9729c2..dbe28fb21 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -77,9 +77,9 @@ tasks.compileTestKotlin { dependencies { // Local dependencies implementation(files("lib/pretty-tools-JDDE-2.1.0.jar")) - // These lines can sometimes be problematic on Linux -// implementation(files("lib/JavaDDE.dll")) -// implementation(files("lib/JavaDDEx64.dll")) + // These lines can sometimes be problematic on Linux, but are required for SumatraPDF + implementation(files("lib/JavaDDE.dll")) + implementation(files("lib/JavaDDEx64.dll")) // D-Bus Java bindings implementation("com.github.hypfvieh:dbus-java:3.3.2")