Skip to content

Commit

Permalink
Merge pull request #3805 from Hannah-Sten/243
Browse files Browse the repository at this point in the history
Update to IDEA 243
  • Loading branch information
PHPirates authored Dec 15, 2024
2 parents a3d271f + 12512a2 commit e536848
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ dependencies {
testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.Plugin.Java)

intellijIdeaCommunity("2024.2.3")
intellijIdeaCommunity("2024.3.1")

// Docs: https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
// All snapshot versions: https://www.jetbrains.com/intellij-repository/snapshots/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nl.hannahsten.texifyidea.run.bibtex

import com.intellij.execution.configuration.EnvironmentVariablesComponent
import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.fileChooser.FileTypeDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.options.SettingsEditor
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
Expand Down Expand Up @@ -108,7 +108,9 @@ class BibtexSettingsEditor(private val project: Project) : SettingsEditor<Bibtex
val mainFileField = TextFieldWithBrowseButton().apply {
addBrowseFolderListener(
TextBrowseFolderListener(
FileTypeDescriptor("Choose the Main .tex File", "tex")
FileChooserDescriptorFactory.createSingleFileDescriptor()
.withTitle("Choose the Main .tex File")
.withExtensionFilter("tex")
.withRoots(*ProjectRootManager.getInstance(project).contentRootsFromAllModules.toSet().toTypedArray())
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nl.hannahsten.texifyidea.run.latex.externaltool

import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.fileChooser.FileTypeDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.options.SettingsEditor
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
Expand Down Expand Up @@ -53,7 +53,9 @@ class ExternalToolSettingsEditor(private val project: Project) : SettingsEditor<
val mainFileField = TextFieldWithBrowseButton().apply {
addBrowseFolderListener(
TextBrowseFolderListener(
FileTypeDescriptor("Choose Main LaTeX File", "tex")
FileChooserDescriptorFactory.createSingleFileDescriptor()
.withTitle("Choose Main LaTeX File")
.withExtensionFilter("tex")
.withRoots(*ProjectRootManager.getInstance(project).contentRootsFromAllModules.toSet().toTypedArray())
)
)
Expand Down
17 changes: 10 additions & 7 deletions src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nl.hannahsten.texifyidea.run.latex.ui

import com.intellij.execution.configuration.EnvironmentVariablesComponent
import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.fileChooser.FileTypeDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.fileTypes.PlainTextFileType
import com.intellij.openapi.options.ConfigurationException
import com.intellij.openapi.options.SettingsEditor
Expand Down Expand Up @@ -33,7 +33,11 @@ import nl.hannahsten.texifyidea.run.sumatra.SumatraAvailabilityChecker
import nl.hannahsten.texifyidea.settings.sdk.LatexSdkUtil
import nl.hannahsten.texifyidea.util.runInBackground
import java.awt.event.ItemEvent
import javax.swing.*
import javax.swing.InputVerifier
import javax.swing.JComponent
import javax.swing.JLabel
import javax.swing.JPanel
import kotlin.Throws

/**
* @author Sten Wessel
Expand Down Expand Up @@ -302,11 +306,10 @@ class LatexSettingsEditor(private var project: Project?) : SettingsEditor<LatexR
val mainFileField = TextFieldWithBrowseButton()
mainFileField.addBrowseFolderListener(
TextBrowseFolderListener(
FileTypeDescriptor("Choose a File to Compile", "tex")
.withRoots(
*ProjectRootManager.getInstance(project!!)
.contentRootsFromAllModules.toSet().toTypedArray()
)
FileChooserDescriptorFactory.createSingleFileDescriptor()
.withTitle("Choose a File to Compile")
.withExtensionFilter("tex")
.withRoots(*ProjectRootManager.getInstance(project!!).contentRootsFromAllModules.toSet().toTypedArray())
)
)
mainFile = LabeledComponent.create(mainFileField, "Main file to compile")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nl.hannahsten.texifyidea.run.makeindex

import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.fileChooser.FileTypeDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.options.SettingsEditor
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
Expand Down Expand Up @@ -57,7 +57,9 @@ class MakeindexSettingsEditor(private val project: Project) : SettingsEditor<Mak
val mainFileField = TextFieldWithBrowseButton().apply {
addBrowseFolderListener(
TextBrowseFolderListener(
FileTypeDescriptor("Choose the Main .tex File", "tex")
FileChooserDescriptorFactory.createSingleFileDescriptor()
.withTitle("Choose the Main .tex File")
.withExtensionFilter("tex")
.withRoots(*ProjectRootManager.getInstance(project).contentRootsFromAllModules.toSet().toTypedArray())
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package nl.hannahsten.texifyidea.inspections.latex.probablebugs

import com.intellij.openapi.util.SystemInfo
import io.mockk.every
import io.mockk.mockkStatic
import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.gutter.LatexNavigationGutter
import nl.hannahsten.texifyidea.inspections.TexifyInspectionTestBase
import nl.hannahsten.texifyidea.util.runCommandWithExitCode
import java.io.File
Expand All @@ -22,36 +24,49 @@ class LatexFileNotFoundInspectionTest : TexifyInspectionTestBase(LatexFileNotFou
super.setUp()
mockkStatic(::runCommandWithExitCode)
every { runCommandWithExitCode(*anyVararg(), workingDirectory = any(), timeout = any(), returnExceptionMessage = any()) } returns Pair(null, 0)

mockkStatic(LatexNavigationGutter::collectNavigationMarkers)
}

override fun getTestDataPath(): String {
return "test/resources/inspections/latex/filenotfound"
}

fun testMissingAbsolutePath() {
myFixture.configureByText(LatexFileType, """\includegraphics{<error>$absoluteWorkingPath/test/resources/completion/path/myPicture.myinvalidextension</error>}""")
myFixture.checkHighlighting()
// Avoid "VfsRootAccess$VfsRootAccessNotAllowedError: File accessed outside allowed roots" on Windows in github actions
if (!SystemInfo.isWindows) {
myFixture.configureByText(LatexFileType, """\includegraphics{<error>$absoluteWorkingPath/test/resources/completion/path/myPicture.myinvalidextension</error>}""")
myFixture.checkHighlighting()
}
}

fun testValidAbsolutePath() {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/completion/path/myPicture.png}""")
if (!SystemInfo.isWindows) {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/completion/path/myPicture.png}""")

myFixture.checkHighlighting()
myFixture.checkHighlighting()
}
}

fun testValidAbsolutePathCaps() {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/inspections/latex/filenotfound/myOtherPicture.PNG}""")
myFixture.checkHighlighting()
if (!SystemInfo.isWindows) {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/inspections/latex/filenotfound/myOtherPicture.PNG}""")
myFixture.checkHighlighting()
}
}

fun testBackActionAbsolute() {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/completion/path/../path/../path/myPicture.png}""")
myFixture.checkHighlighting()
if (!SystemInfo.isWindows) {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/completion/path/../path/../path/myPicture.png}""")
myFixture.checkHighlighting()
}
}

fun testCurrDirActionAbsolute() {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/./resources/./././completion/path/././myPicture.png}""")
myFixture.checkHighlighting()
if (!SystemInfo.isWindows) {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/./resources/./././completion/path/././myPicture.png}""")
myFixture.checkHighlighting()
}
}

fun testAbsoluteGraphicsDirWithInclude() {
Expand Down Expand Up @@ -81,19 +96,25 @@ class LatexFileNotFoundInspectionTest : TexifyInspectionTestBase(LatexFileNotFou
}

fun testDefaultExtensionCompletion() {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/completion/path/myPicture}""")
myFixture.checkHighlighting()
if (!SystemInfo.isWindows) {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/completion/path/myPicture}""")
myFixture.checkHighlighting()
}
}

fun testDefaultUpperCaseExtensionCompletion() {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/inspections/latex/filenotfound/myOtherPicture}""")
myFixture.checkHighlighting()
if (!SystemInfo.isWindows) {
myFixture.configureByText(LatexFileType, """\includegraphics{$absoluteWorkingPath/test/resources/inspections/latex/filenotfound/myOtherPicture}""")
myFixture.checkHighlighting()
}
}

fun testDefaultMixedCaseExtensionCompletion() {
myFixture.configureByText(LatexFileType, """\includegraphics{<error>$absoluteWorkingPath/test/resources/completion/path/myBadPicture</error>}""")
if (!SystemInfo.isWindows) {
myFixture.configureByText(LatexFileType, """\includegraphics{<error>$absoluteWorkingPath/test/resources/completion/path/myBadPicture</error>}""")

myFixture.checkHighlighting()
myFixture.checkHighlighting()
}
}

fun testNoWarningInDefinition() {
Expand Down
12 changes: 9 additions & 3 deletions test/nl/hannahsten/texifyidea/refactoring/InlineFileTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.vfs.CharsetToolkit
import com.intellij.psi.PsiFileFactory
import com.intellij.refactoring.BaseRefactoringProcessor.ConflictsInTestsException
import com.intellij.refactoring.MockInlineMethodOptions
import com.intellij.refactoring.inline.InlineOptions
import com.intellij.testFramework.LightPlatformCodeInsightTestCase
import junit.framework.TestCase
import nl.hannahsten.texifyidea.file.LatexFileType
import nl.hannahsten.texifyidea.refactoring.inlinecommand.LatexInlineCommandHandler.Util.getReference
import nl.hannahsten.texifyidea.refactoring.inlinefile.LatexInlineFileHandler.Util.canInlineLatexElement
Expand Down Expand Up @@ -127,7 +125,7 @@ class InlineFileTest : LightPlatformCodeInsightTestCase() {
private fun configure(testIndex: Int? = null): String {
@NonNls val fileName = getTestName(false) + (testIndex ?: "") + ".tex"
configureByFile(fileName)
TestCase.assertTrue(file.parent != null)
assertTrue(file.parent != null)
if (file.parent?.children?.any { it.containingFile.name == inlineFile } == false) {
val ioFile = File(testDataPath + inlineFile)
checkCaseSensitiveFS(testDataPath + inlineFile, ioFile)
Expand Down Expand Up @@ -182,4 +180,12 @@ class InlineFileTest : LightPlatformCodeInsightTestCase() {
)
processor.run()
}

open class MockInlineMethodOptions : InlineOptions {
override fun isInlineThisOnly() = false

override fun close(p0: Int) {}

override fun isPreviewUsages() = false
}
}

0 comments on commit e536848

Please sign in to comment.