Skip to content

Commit

Permalink
Fixed deprecation warnings in the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
odisseus authored and exigow committed Jul 23, 2023
1 parent 375f3c4 commit 059436c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/main/kotlin/common/Icons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import javax.swing.Icon

object Icons {

val GDSCRIPT_FILE = IconLoader.getIcon("/fileIcon.png")
@JvmField
val GDSCRIPT_FILE = IconLoader.getIcon("/fileIcon.png", javaClass)
val TSCN_FILE: Icon = FileTypes.Config
val JSON_FILE: Icon = FileTypes.Json
val ANY_FILE: Icon = FileTypes.Any_type
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/gdscript/annotation/ResourceAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gdscript.annotation

import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator
import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiElement
Expand All @@ -19,7 +20,8 @@ class ResourceAnnotator : Annotator {
val project: VirtualFile = ResourceUtil.findProject(element) ?: return
val path: String = ResourceUtil.cleanResource(element.text)
if (VfsUtilCore.findRelativeFile(path, project) == null)
holder.createWeakWarningAnnotation(element, "Cannot resolve resource '$path'")
holder.newAnnotation(HighlightSeverity.WEAK_WARNING, "Cannot resolve resource '$path'")
.range(element).create()
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/main/kotlin/gdscript/annotation/utils.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package gdscript.annotation

import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.psi.PsiElement

fun AnnotationHolder.createTextAttributesAnnotation(element: PsiElement, textAttributes: TextAttributesKey) {
val annotation = createInfoAnnotation(element, null)
annotation.textAttributes = textAttributes
newAnnotation(HighlightSeverity.INFORMATION, "")
.range(element)
.textAttributes(textAttributes)
.create()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiManager
import com.intellij.psi.PsiReferenceBase
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.parentOfType
import com.intellij.psi.util.parentOfTypes
import common.ResourceUtil
import tscn.psi.TscnAttribute
import tscn.psi.TscnExtEntry
Expand All @@ -23,7 +23,7 @@ class TscnResourceExtReference(element: TscnExtExpression) :
.flatMap { entry -> PsiTreeUtil.getChildrenOfType(entry, TscnAttribute::class.java).orEmpty().asIterable() }
.filter { attribute -> attribute.key.text == "id" }
.find { attribute -> attribute.value.text.toIntOrNull() == id }
?.parentOfType(TscnExtEntry::class)
?.parentOfTypes(TscnExtEntry::class)
?: return null
val resourcePath = entry.attributeList.find { it.key.text.equals("path") }?.value?.text
?: return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiReferenceBase
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.parentOfType
import com.intellij.psi.util.parentOfTypes
import tscn.psi.TscnAttribute
import tscn.psi.TscnSubEntry
import tscn.psi.TscnSubExpression
Expand All @@ -20,7 +20,7 @@ class TscnResourceSubReference(element: TscnSubExpression) :
.flatMap { entry -> PsiTreeUtil.getChildrenOfType(entry, TscnAttribute::class.java).orEmpty().asIterable() }
.filter { attribute -> attribute.key.text == "id" }
.find { attribute -> attribute.value.text.toIntOrNull() == id }
?.parentOfType(TscnSubEntry::class)
?.parentOfTypes(TscnSubEntry::class)
}

}

0 comments on commit 059436c

Please sign in to comment.