generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Fix error when parse any field which not imported by context element
- Loading branch information
Showing
3 changed files
with
53 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/kotlin/io/kanro/idea/plugin/protobuf/grpc/request/ProtoFileReflection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.kanro.idea.plugin.protobuf.grpc.request | ||
|
||
import com.bybutter.sisyphus.protobuf.LocalProtoReflection | ||
import com.bybutter.sisyphus.protobuf.ProtoSupport | ||
import com.bybutter.sisyphus.protobuf.booster.Booster_4CCD27CC8C541E27D15600026AA8457F | ||
import com.bybutter.sisyphus.protobuf.dynamic.DynamicFileSupport | ||
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.psi.search.GlobalSearchScope | ||
import com.intellij.psi.stubs.StubIndex | ||
import io.kanro.idea.plugin.protobuf.compile.Protoc | ||
import io.kanro.idea.plugin.protobuf.lang.psi.primitive.ProtobufElement | ||
import io.kanro.idea.plugin.protobuf.lang.psi.stub.index.QualifiedNameIndex | ||
|
||
class ProtoFileReflection(private val context: ProtobufElement) : LocalProtoReflection() { | ||
init { | ||
Booster_4CCD27CC8C541E27D15600026AA8457F(this) | ||
} | ||
|
||
override fun findSupport(name: String): ProtoSupport<*>? { | ||
super.findSupport(name)?.let { return it } | ||
|
||
synchronized(this) { | ||
ApplicationManager.getApplication().runReadAction { | ||
doResolve(name.trim('.').substringAfterLast('/')) | ||
} | ||
} | ||
|
||
return super.findSupport(name) | ||
} | ||
|
||
private fun doResolve(name: String) { | ||
val elements = StubIndex.getElements( | ||
QualifiedNameIndex.key, | ||
name, | ||
context.project, | ||
GlobalSearchScope.allScope(context.project), | ||
ProtobufElement::class.java | ||
).toList() | ||
val descriptorSet = Protoc.compileFiles(elements) | ||
descriptorSet.file.forEach { | ||
register(DynamicFileSupport(it)) | ||
} | ||
} | ||
} |