Skip to content

Commit

Permalink
fix: adapt delete of cast safely method
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhangli committed Apr 13, 2023
1 parent 3809752 commit 2803030
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.7.22"
id("org.jetbrains.kotlin.jvm") version "1.8.20"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.10.0"
id("org.jetbrains.intellij") version "1.13.3"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "1.3.1"
id("org.jetbrains.changelog") version "2.0.0"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "0.1.13"
}
Expand Down
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ platformPlugins = org.jetbrains.plugins.go,org.jetbrains.plugins.terminal,idea.p
# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 7.5.1
runIde.autoReloadPlugins=true
# Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency = false
#org.gradle.jvmargs=-XX\:MaxHeapSize\=4096m -Xmx8192m
## Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
## suppress inspection "UnusedProperty"
#kotlin.stdlib.default.dependency = false
#systemProp.http.proxyHost=127.0.0.1
#systemProp.http.proxyPort=7890
#systemProp.https.proxyHost=127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.intellij.navigation.GotoRelatedItem
import com.intellij.navigation.GotoRelatedProvider
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import com.intellij.util.castSafelyTo


class PbGoToDeclarationProvider : GotoDeclarationHandler {
Expand All @@ -16,8 +15,9 @@ class PbGoToDeclarationProvider : GotoDeclarationHandler {
offset: Int,
editor: Editor?
): Array<PsiElement>? {
if (element?.parent is GoReferenceExpression) {
val declaration = findImplementMethodFromCli(element.parent.castSafelyTo<GoReferenceExpression>() ?: return null)
val expr = element?.parent ?: return null;
if (expr is GoReferenceExpression) {
val declaration = findImplementMethodFromCli(expr)
if(declaration != null){
return arrayOf(declaration)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package com.github.suhli.ideagokratosplugin.extends

import com.intellij.protobuf.lang.psi.PbMessageBody
import com.intellij.protobuf.lang.psi.PbTypeName
import javax.annotation.Nullable

class KratosRpcField(val name: String, val isRepeat: Boolean, @Nullable val children: List<KratosRpcField>?) {
class KratosRpcField(val name: String, val isRepeat: Boolean, val children: List<KratosRpcField>?) {
companion object{
public fun getFieldsInMessageTypeName(name: PbTypeName): List<KratosRpcField> {
val fields = arrayListOf<KratosRpcField>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.searches.DefinitionsScopedSearch
import com.intellij.psi.util.childrenOfType
import com.intellij.psi.util.findParentOfType
import com.intellij.util.castSafelyTo
import java.io.File

private var LOG: Logger? = null
Expand Down Expand Up @@ -158,7 +157,10 @@ fun findImplementMethodFromCli(element: GoReferenceExpression): GoMethodDeclarat
if (!file.name.endsWith(".pb.go")) {
return null
}
val cli = declareMethod.parent.parent.parent.castSafelyTo<GoTypeSpec>() ?: return null
val serverName = cli.name?.replace("Client", "") ?: return null
return findPbImplementByName(file, serverName, element.reference.canonicalText)
val cliElem = declareMethod.parent.parent.parent ?: return null;
if (cliElem is GoTypeSpec) {
val serverName = cliElem.name?.replace("Client", "") ?: return null
return findPbImplementByName(file, serverName, element.reference.canonicalText)
}
return null;
}

0 comments on commit 2803030

Please sign in to comment.