Skip to content

Commit

Permalink
Version 1.24.11
Browse files Browse the repository at this point in the history
Compatibility with IntelliJ 2024.3 and the K2 analysis API. Use IntelliJ Platform Gradle Plugin 2.1.0.
  • Loading branch information
BlueBoxWare committed Nov 8, 2024
1 parent fa20779 commit 4996f57
Show file tree
Hide file tree
Showing 82 changed files with 519 additions and 798 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
/idea-flex.skeleton
/jflex-1.7.0-2.jar
/stuff/
.intellijPlatform
.kotlin
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 1.24.11
* Compatibility with IntelliJ 2024.3 and the K2 analysis API.

### 1.24.10
* Fix another doing slow operation on EDT issue.

Expand Down
2 changes: 0 additions & 2 deletions Inspections.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
| GDXJavaMissingFlush | Missing flush on Preferences | Call Preferences.flush() to make sure changes to preferences are persisted. |
| GDXJavaNonExistingAsset | Resource doesn't exist | Looks in Java and Kotlin code for usages of resources which don't exist. @GDXAssets annotated elements only. |
| GDXJavaProfilingCode | Profiling code | Looks for profiling code, which should be disabled before release. |
| GDXJavaShapeRendererCrash | Using problematic ShapeRenderer | Using ShapeRenderer with libGDX versions prior to 1.9.2 causes a crash on ARM64 Android devices. Upgrade to libGDX to version 1.9.2 or higher (see <a href="https://github.com/libgdx/libgdx/issues/3790">https://github.com/libgdx/libgdx/issues/3790</a>). |
| GDXJavaStaticResource | Static resource | Don't make resources static, unless you take care to properly manage them. Static resources can cause problems on Android, because the life-cycle of a static variable is not necessarily the same as the life-cycle of your application. |
| GDXJavaTestId | Test/dummy IDs | Looks for the use of some known test IDs. |
| GDXJavaUnsafeIterator | Use of non reentrant iterator method | Iterator methods on libGDX collections return the same iterator instance each time the method is called. For nested or multithreaded iteration create a new iterator using the appropriate constructor. |
Expand All @@ -26,7 +25,6 @@
| GDXKotlinMissingFlush | Missing flush on Preferences | Call Preferences.flush() to make sure changes to preferences are persisted. |
| GDXKotlinNonExistingAsset | Resource doesn't exist | Looks in Java and Kotlin code for usages of resources which don't exist. @GDXAssets annotated elements only. |
| GDXKotlinProfilingCode | Profiling code | Looks for profiling code, which should be disabled before release. |
| GDXKotlinShapeRendererCrash | Using problematic ShapeRenderer | Using ShapeRenderer with libGDX versions prior to 1.9.2 causes a crash on ARM64 Android devices. Upgrade to libGDX to version 1.9.2 or higher (see <a href="https://github.com/libgdx/libgdx/issues/3790">https://github.com/libgdx/libgdx/issues/3790</a>). |
| GDXKotlinStaticResource | Static resource | Don't make resources static, unless you take care to properly manage them. Static resources can cause problems on Android, because the life-cycle of a static variable is not necessarily the same as the life-cycle of your application.<br /><br />Note that Kotlin top-level properties and properties of object literals and companion objects are compiled to static properties. |
| GDXKotlinTestId | Test/dummy IDs | Looks for the use of some known test IDs. |
| GDXKotlinUnsafeIterator | Use of non reentrant iterator method | Iterator methods on libGDX collections return the same iterator instance each time the method is called. For nested or multithreaded iteration create a new iterator using the appropriate constructor. |
Expand Down
85 changes: 56 additions & 29 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,58 @@
fun properties(key: String) = project.findProperty(key).toString()
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("java")
id("maven-publish")
id("org.jetbrains.kotlin.jvm") version "1.8.10"
id("org.jetbrains.intellij") version "1.16.1"
id("org.jetbrains.kotlin.jvm") version "2.0.0"
id("com.github.blueboxware.tocme") version "1.8"
id("org.jetbrains.intellij.platform") version "2.1.0"
}

group = properties("pluginGroup")
version = properties("pluginVersion")
group = providers.gradleProperty("pluginGroup").get()
version = providers.gradleProperty("pluginVersion").get()

repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}

dependencies {
intellijPlatform {
intellijIdeaCommunity(providers.gradleProperty("platformVersion"))
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
instrumentationTools()
jetbrainsRuntime()
pluginVerifier()
testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.Plugin.Java)
}
testImplementation("junit:junit:4.13.2")
}

kotlin {
jvmToolchain(17)
jvmToolchain(21)
}

intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
downloadSources.set(properties("platformDownloadSources").toBoolean())
updateSinceUntilBuild.set(true)
intellijPlatform {
pluginConfiguration {
name = providers.gradleProperty("pluginName")
ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = provider { null }
}
}
pluginVerification {
ides {
ide(IntelliJPlatformType.IntellijIdeaCommunity, providers.gradleProperty("platformVersion").get())
recommended()
}
}

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
}

sourceSets {
Expand All @@ -45,19 +70,27 @@ sourceSets {

tasks {
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
sourceCompatibility = "21"
targetCompatibility = "21"
}

named<JavaCompile>("compileAnnotationsJava") {
sourceCompatibility = "11"
targetCompatibility = "11"
}

named<KotlinCompile>("compileTestKotlin") {
compilerOptions {
freeCompilerArgs.add("-opt-in=org.jetbrains.kotlin.analysis.api.permissions.KaAllowProhibitedAnalyzeFromWriteAction")
}
}

runIde {
maxHeapSize = "8g"
systemProperties = mapOf(
"idea.ProcessCanceledException" to "disabled"
"idea.ProcessCanceledException" to "disabled",
"idea.is.internal" to "true",
"idea.kotlin.plugin.use.k2" to "true"
)
}

Expand All @@ -69,29 +102,23 @@ tasks {
enabled = true
}

patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))
}

runPluginVerifier {
ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty))
}

test {
systemProperty("idea.home.path", System.getenv("LIBGDXPLUGIN_IDEA"))
environment("NO_FS_ROOTS_ACCESS_CHECK", "1")
isScanForTestClasses = false
include("**/Test*.class")
include("com/gmail/blueboxware/libgdxplugin/ShowInfo.class")
exclude("**/*$*.class")
jvmArgumentProviders += CommandLineArgumentProvider {
listOf("-Didea.kotlin.plugin.use.k2=true")
}
}

register<Jar>("annotationsJar") {
archiveBaseName.set("libgdxpluginannotations")
from(sourceSets.getByName("annotations").output)
include("com/gmail/blueboxware/libgdxplugin/annotations/**")
archiveVersion.set(properties("pluginVersion"))
archiveVersion.set(providers.gradleProperty("pluginVersion"))
}

register<Jar>("annotationsSourcesJar") {
Expand All @@ -100,7 +127,7 @@ tasks {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
include(project.tasks.getByName<Jar>("annotationsJar").includes)
archiveBaseName.set(project.tasks.getByName<Jar>("annotationsJar").archiveBaseName)
archiveVersion.set(properties("pluginVersion"))
archiveVersion.set(providers.gradleProperty("pluginVersion"))
}

}
Expand Down
16 changes: 7 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
pluginGroup = com.gmail.blueboxware
pluginName = LibGDX Plugin
pluginVersion = 1.24.10
pluginName = LibGDX
pluginVersion = 1.24.11

pluginSinceBuild = 233.11799.300
pluginUntilBuild =
pluginSinceBuild = 243.21565.23

# https://www.jetbrains.com/intellij-repository/snapshots/
# https://www.jetbrains.com/intellij-repository/releases/
# gradle printProductsReleases
pluginVerifierIdeVersions = 241.17890.1

platformType = IC
platformVersion = 241.17890.1
platformDownloadSources = true
platformVersion = 243.21565.23

platformPlugins = java, Kotlin, Groovy, properties
platformBundledPlugins = com.intellij.java, org.jetbrains.kotlin, org.intellij.groovy, com.intellij.properties, com.intellij.modules.json

kotlin.stdlib.default.dependency = false

kotlin.daemon.jvmargs=-Xmx2000m

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ private var ourBundle: Reference<ResourceBundle>? = null

private const val BUNDLE = "libgdxplugin"

fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any, default: String? = null): String {
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any, default: String? = null): String =

getBundle()?.let { bundle ->
return if (default == null) {
if (default == null) {
AbstractBundle.message(bundle, key, *params)
} else {
AbstractBundle.messageOrDefault(bundle, key, default, *params)
AbstractBundle.messageOrDefault(bundle, key, default, *params) ?: ""
}
}
} ?: ""

return ""
}

fun getBundle(): ResourceBundle? {
var bundle = com.intellij.reference.SoftReference.dereference(ourBundle)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.gmail.blueboxware.libgdxplugin

import com.gmail.blueboxware.libgdxplugin.filetypes.skin.refactoring.ChangeKotlinPackageListener
import com.gmail.blueboxware.libgdxplugin.versions.VersionService
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.ProjectActivity
import com.intellij.psi.PsiManager


/*
Expand All @@ -26,11 +24,6 @@ import com.intellij.psi.PsiManager
internal class LibGDXStartupActivity : ProjectActivity {

override suspend fun execute(project: Project) {
PsiManager.getInstance(project).addPsiTreeChangeListener(
ChangeKotlinPackageListener(project),
project.service<DisposableProvider>()
)

project.service<VersionService>().projectOpened()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.gmail.blueboxware.libgdxplugin.completion
import com.gmail.blueboxware.libgdxplugin.utils.*
import com.intellij.codeInsight.completion.CompletionConfidence
import com.intellij.ide.highlighter.JavaFileType
import com.intellij.openapi.editor.Editor
import com.intellij.psi.*
import com.intellij.util.ThreeState
import org.jetbrains.kotlin.asJava.toLightAnnotation
Expand All @@ -29,7 +30,12 @@ import org.jetbrains.kotlin.psi.KtStringTemplateExpression
*/
internal class LibGDXCompletionConfidence : CompletionConfidence() {

override fun shouldSkipAutopopup(contextElement: PsiElement, psiFile: PsiFile, offset: Int): ThreeState {
override fun shouldSkipAutopopup(
editor: Editor,
contextElement: PsiElement,
psiFile: PsiFile,
offset: Int
): ThreeState {

if (!contextElement.project.isLibGDXProject()) {
return ThreeState.UNSURE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import icons.Icons
internal object LibGDXJsonFileType : LanguageFileType(LibGDXJsonLanuage) {

init {
FileTypeEditorHighlighterProviders.INSTANCE.addExplicitExtension(this) { _, _, _, colors ->
FileTypeEditorHighlighterProviders.getInstance().addExplicitExtension(this) { _, _, _, colors ->
LayeredLexerEditorHighlighter(GdxJsonSyntaxHighlighterFactory.GdxJsonHighlighter(), colors)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal class GDXImplicitPropertyUsageProvider : ImplicitPropertyUsageProvider

val psiSearchHelper = PsiSearchHelper.getInstance(property.project)

when (psiSearchHelper.isCheapEnoughToSearch(name, scope, null, null)) {
when (psiSearchHelper.isCheapEnoughToSearch(name, scope, null)) {
PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES -> return false
PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES -> return true
else -> ReferencesSearch.search(property, scope, false).forEach { reference ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import icons.Icons
internal object LibGDXSkinFileType : LanguageFileType(LibGDXSkinLanguage.INSTANCE) {

init {
FileTypeEditorHighlighterProviders.INSTANCE.addExplicitExtension(this) { _, _, _, colors ->
FileTypeEditorHighlighterProviders.getInstance().addExplicitExtension(this) { _, _, _, colors ->
LayeredLexerEditorHighlighter(SkinSyntaxHighlighterFactory.SkinHighlighter(), colors)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ internal class SkinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettings
"PROPERTY_ALIGNMENT",
"Align",
"Objects",
SkinCodeStyleSettings.PropertyAlignment.values().map { it.description }.toTypedArray(),
SkinCodeStyleSettings.PropertyAlignment.values().map { it.id }.toIntArray()
SkinCodeStyleSettings.PropertyAlignment.entries.map { it.description }.toTypedArray(),
SkinCodeStyleSettings.PropertyAlignment.entries.map { it.id }.toIntArray()
)
consumer.showCustomOption(
SkinCodeStyleSettings::class.java,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class CreateAssetQuickFix(

val skinFile = startElement.containingFile as? SkinFileImpl ?: return

FileEditorManager.getInstance(project).openFile(skinFile.virtualFile, true, true)
skinFile.virtualFile?.let { virtualFile ->
FileEditorManager.getInstance(project).openFile(virtualFile, true, true)
}

val (_, position) = when (className.plainName) {
DRAWABLE_CLASS_NAME -> skinFile.addTintedDrawable(assetName, startElement as? SkinElement)
Expand Down
Loading

0 comments on commit 4996f57

Please sign in to comment.