Skip to content

Commit

Permalink
Merge pull request #50 from timaliberdov/idea242-compat
Browse files Browse the repository at this point in the history
Test fixes after update to IDEA 2024.2
  • Loading branch information
ghik authored Aug 7, 2024
2 parents 5379f77 + 6c1882c commit 1e4ea51
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 19 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
scala: [2.13.14]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
scala: [2.13.14]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -100,12 +100,12 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.13.10)
- name: Download target directories (2.13.14)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.13.10-${{ matrix.java }}
name: target-${{ matrix.os }}-2.13.14-${{ matrix.java }}

- name: Inflate target directories (2.13.10)
- name: Inflate target directories (2.13.14)
run: |
tar xf targets.tar
rm targets.tar
Expand Down
8 changes: 6 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import org.jetbrains.sbtidea.Keys._

ThisBuild / scalaVersion := "2.13.10"
ThisBuild / scalaVersion := "2.13.14"
ThisBuild / intellijPluginName := "intellij-hocon"
ThisBuild / intellijBuild := "241.8102.112"
ThisBuild / intellijBuild := "242.18071.24"
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"))

val junitInterfaceVersion = "0.11"
val commonsTextVersion = "1.12.0"
val opentest4jVersion = "1.3.0"

lazy val hocon = project.in(file(".")).enablePlugins(SbtIdeaPlugin).settings(
version := "2024.1.99-SNAPSHOT",
Expand All @@ -22,7 +24,9 @@ lazy val hocon = project.in(file(".")).enablePlugins(SbtIdeaPlugin).settings(
ideBasePackages := Seq("org.jetbrains.plugins.hocon"),
intellijPlugins := Seq("com.intellij.properties", "com.intellij.java", "com.intellij.java-i18n").map(_.toPlugin),
libraryDependencies ++= Seq(
"org.apache.commons" % "commons-text" % commonsTextVersion,
"com.novocode" % "junit-interface" % junitInterfaceVersion % Test,
"org.opentest4j" % "opentest4j" % opentest4jVersion % Test,
),
packageLibraryMappings := Seq.empty, // allow scala-library
patchPluginXml := pluginXmlOptions { xml =>
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.8.2
sbt.version=1.10.0
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "3.18.3")
addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "3.26.2")
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.1")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
2 changes: 1 addition & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description>Standalone HOCON plugin for IntelliJ IDEA</description>
<version>2024.1.99-SNAPSHOT</version>
<vendor>Roman Janusz, AVSystem, JetBrains</vendor>
<idea-version since-build="241.0" until-build="250.0"/>
<idea-version since-build="242.0" until-build="250.0"/>
<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.lang</depends>
<depends optional="true" config-file="hocon-java.xml">com.intellij.modules.java</depends>
Expand Down
2 changes: 1 addition & 1 deletion src/org/jetbrains/plugins/hocon/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package object hocon extends AsJavaExtensions with AsScalaExtensions {
type JMap[K, V] = java.util.Map[K, V]

final val HoconIcon = AllIcons.FileTypes.Config
final val PropertyIcon = IconManager.getInstance.getIcon("/icons/property.svg", getClass)
final val PropertyIcon = IconManager.getInstance.getIcon("/icons/property.svg", getClass.getClassLoader)

def notWhiteSpaceSibling(element: PsiElement)
(sibling: PsiElement => PsiElement): PsiElement = {
Expand Down
10 changes: 6 additions & 4 deletions test/org/jetbrains/plugins/hocon/HoconActionTest.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jetbrains.plugins.hocon

import com.intellij.ide.DataManager
import com.intellij.openapi.actionSystem._
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.fileEditor.{FileEditorManager, OpenFileDescriptor}
Expand Down Expand Up @@ -29,7 +30,7 @@ abstract class HoconActionTest protected(protected val actionId: String, subPath
editor.getCaretModel.moveToOffset(offset)

try {
executeAction(new MockDataContext(psiFile, editor), editor)
executeAction(mockDataContext(psiFile, editor), editor)
extractResult(psiFile, editor)
} finally {
editorManager.closeFile(psiFile.getVirtualFile)
Expand All @@ -53,12 +54,13 @@ abstract class HoconActionTest protected(protected val actionId: String, subPath

object HoconActionTest {

private class MockDataContext(file: PsiFile, editor: Editor) extends DataContext with DataProvider {
def getData(dataId: String): AnyRef = {
private def mockDataContext(file: PsiFile, editor: Editor) = {
val parentContext = DataManager.getInstance().getDataContext(editor.getComponent)
CustomizedDataContext.withProvider(parentContext, (dataId: String) => {
if (CommonDataKeys.PROJECT is dataId) file.getProject
else if (CommonDataKeys.EDITOR is dataId) editor
else null
}
})
}

}
8 changes: 5 additions & 3 deletions test/org/jetbrains/plugins/hocon/HoconMultiModuleTest.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package org.jetbrains.plugins.hocon

import java.io.File

import com.intellij.openapi.module.Module
import com.intellij.openapi.roots._
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.testFramework.UsefulTestCase
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder
import com.intellij.testFramework.fixtures._
import com.intellij.testFramework.fixtures.impl.{JavaModuleFixtureBuilderImpl, ModuleFixtureImpl}
import com.intellij.testFramework.{IndexingTestUtil, UsefulTestCase}
import org.jetbrains.jps.model.java.JavaSourceRootType

import java.io.File

abstract class HoconMultiModuleTest extends UsefulTestCase with HoconTestUtils {

import HoconMultiModuleTest._
Expand Down Expand Up @@ -71,6 +71,8 @@ abstract class HoconMultiModuleTest extends UsefulTestCase with HoconTestUtils {

models.values.foreach(_.commit())
}

IndexingTestUtil.waitUntilIndexesAreReady(_fixture.getProject)
}

override def tearDown(): Unit = {
Expand Down
4 changes: 3 additions & 1 deletion test/org/jetbrains/plugins/hocon/HoconSingleModuleTest.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jetbrains.plugins.hocon

import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.testFramework.LightPlatformCodeInsightTestCase
import com.intellij.testFramework.PsiTestUtil.removeContentEntry
import com.intellij.testFramework.{IndexingTestUtil, LightPlatformCodeInsightTestCase}

abstract class HoconSingleModuleTest extends LightPlatformCodeInsightTestCase with HoconTestUtils {
final def project = getProject
Expand All @@ -18,6 +18,8 @@ abstract class HoconSingleModuleTest extends LightPlatformCodeInsightTestCase wi
inWriteAction {
rootModel.commit()
}

IndexingTestUtil.waitUntilIndexesAreReady(project)
}

override def tearDown(): Unit = {
Expand Down

0 comments on commit 1e4ea51

Please sign in to comment.