diff --git a/build.gradle.kts b/build.gradle.kts index c27cd465c..dbe28fb21 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.50.0" @@ -77,6 +77,7 @@ tasks.compileTestKotlin { dependencies { // Local dependencies implementation(files("lib/pretty-tools-JDDE-2.1.0.jar")) + // These lines can sometimes be problematic on Linux, but are required for SumatraPDF implementation(files("lib/JavaDDE.dll")) implementation(files("lib/JavaDDEx64.dll")) diff --git a/gradle.properties b/gradle.properties index 27c56ae65..ca6e08538 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion = 0.9.2 +pluginVersion = 0.9.3-alpha.1 # 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/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() } /** 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 } 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..4dd7e73c2 100644 --- a/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt +++ b/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt @@ -27,8 +27,8 @@ 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") - cache = runCommand(executableName, "-expand-path", searchPaths ?: ".:")?.split(File.pathSeparator) + 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 } ?.toSet()