Skip to content

Commit

Permalink
✨ Fix grpc request
Browse files Browse the repository at this point in the history
  • Loading branch information
devkanro committed Aug 25, 2023
1 parent 2956837 commit 456b3cf
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 14 deletions.
6 changes: 2 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,18 @@ dependencies {
implementation("org.commonmark:commonmark:0.21.0")
implementation("org.commonmark:commonmark-ext-gfm-tables:0.21.0")
implementation("org.commonmark:commonmark-ext-autolink:0.21.0")
implementation("com.bybutter.sisyphus:sisyphus-grpc:1.7.13") {
implementation("com.bybutter.sisyphus:sisyphus-grpc:2.0.11") {
exclude("io.grpc")
exclude("org.jetbrains.kotlin")
exclude("org.jetbrains.kotlinx")
}
implementation("com.bybutter.sisyphus:sisyphus-jackson-protobuf:1.7.13") {
implementation("com.bybutter.sisyphus:sisyphus-jackson-protobuf:2.0.11") {
exclude("com.fasterxml.jackson.core")
exclude("com.fasterxml.jackson.dataformat")
exclude("com.fasterxml.jackson.module")
exclude("org.jetbrains.kotlin")
exclude("org.jetbrains.kotlinx")
}
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.14.2")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.2")
}

// Configure gradle-intellij-plugin plugin.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pluginGroup=io.kanro.idea.plugin.protobuf
pluginName=IntelliJ Protobuf Language Plugin
# SemVer format -> https://semver.org
pluginVersion=1.7.14
pluginVersion=1.7.15
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild=232
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.components.BaseState
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.project.DumbAware
Expand Down Expand Up @@ -57,6 +58,7 @@ import io.kanro.idea.plugin.protobuf.ui.SmartTreeModel
import java.util.Stack

@State(name = "BufFileManager", storages = [Storage("protobuf.xml")])
@Service(Service.Level.PROJECT)
class BufFileManager(val project: Project) : PersistentStateComponent<BufFileManager.State>, DumbAware {
private val state = State()
private val yamlMapper = YAMLMapper()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package io.kanro.idea.plugin.protobuf.buf.project

import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.ProjectActivity
import com.intellij.openapi.startup.StartupActivity
import com.intellij.openapi.vfs.VirtualFileManager

class BufProjectInitializer : StartupActivity.DumbAware {
override fun runActivity(project: Project) {
class BufProjectInitializer : ProjectActivity {
override suspend fun execute(project: Project) {
val fileManager = project.service<BufFileManager>()
VirtualFileManager.getInstance().addAsyncFileListener(BufFileListener(project, fileManager), project)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.kanro.idea.plugin.protobuf.buf.settings

import com.intellij.openapi.components.BaseState
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.SimplePersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
Expand All @@ -10,6 +11,7 @@ import java.nio.file.Path
name = "BufSettings",
storages = [Storage("protobuf.xml")]
)
@Service(Service.Level.PROJECT)
class BufSettings : SimplePersistentStateComponent<BufSettings.State>(State()) {
fun bufPath(): Path? {
return if (state.path.isNullOrEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,10 @@ class MessageMapFieldCompiler : BaseProtobufCompilerPlugin<MessageMapFieldCompil
state.target().apply {
this.name = name
this.type = FieldDescriptorProto.Type.MESSAGE
this.label = FieldDescriptorProto.Label.REPEATED
this.typeName = typename
this.number = number.toInt()
this.jsonName = field.jsonName() ?: name
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ class GrpcRunRequestGutterProvider : RelatedItemLineMarkerProvider() {
HttpRequestUrlPathInfo.create(
element.project, "$serviceName/$methodName", listOf("GRPC")
).unwrap(false)
), RequestUrlContextInfo.createNonHttp(element.project, listOf("localhost:9090")).unwrap(false) ?: return
),
RequestUrlContextInfo.createNonHttp(
element.project,
listOf("http://", "https://"),
listOf("localhost:9090")
).unwrap(false) ?: return
)

result += OpenInHttpClientLineMarkerBuilder.fromGenerationRequest(element.project, request)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.kanro.idea.plugin.protobuf.lang.settings

import com.intellij.openapi.components.BaseState
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.SimplePersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
Expand All @@ -13,6 +14,7 @@ import com.intellij.util.xmlb.annotations.XCollection
name = "ProtobufSettings",
storages = [Storage("protobuf.xml")]
)
@Service(Service.Level.PROJECT)
class ProtobufSettings : SimplePersistentStateComponent<ProtobufSettings.State>(State()), ModificationTracker {
override fun getModificationCount(): Long {
return stateModificationCount
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/io/kanro/idea/plugin/protobuf/ui/SmartTree.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ModalityState
import com.intellij.pom.Navigatable
import com.intellij.ui.DoubleClickListener
import com.intellij.ui.TreeSpeedSearch
import com.intellij.ui.TreeUIHelper
import com.intellij.ui.treeStructure.Tree
import com.intellij.util.OpenSourceUtil
import java.awt.event.InputEvent
Expand All @@ -30,10 +30,11 @@ class SmartTree(treeModel: SmartTreeModel) : Tree(treeModel) {
}
}
})
TreeSpeedSearch(this, false) {

TreeUIHelper.getInstance().installTreeSpeedSearch(this, {
val wrapper = (it.lastPathComponent as TreeElementWrapper)
(wrapper.element as? ItemPresentation)?.presentableText
}
}, false)
}

private fun hasSingleSelection(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
<fileTypeDetector implementation="io.kanro.idea.plugin.protobuf.buf.BufLockFileTypeDetector"/>
<projectConfigurable groupId="language"
instance="io.kanro.idea.plugin.protobuf.buf.settings.BufSettingsConfigurable"/>
<projectService serviceImplementation="io.kanro.idea.plugin.protobuf.buf.settings.BufSettings"/>
<editorNotificationProvider
implementation="io.kanro.idea.plugin.protobuf.buf.ui.BufNotConfiguredNotificationProvider"/>
<additionalLibraryRootsProvider
implementation="io.kanro.idea.plugin.protobuf.buf.project.BufLibraryRootsProvider"/>

<projectService serviceImplementation="io.kanro.idea.plugin.protobuf.buf.project.BufFileManager"/>
<postStartupActivity implementation="io.kanro.idea.plugin.protobuf.buf.project.BufProjectInitializer"/>
<externalAnnotator language="protobuf"
implementationClass="io.kanro.idea.plugin.protobuf.buf.annotator.BufLintAnnotator"/>
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@

<projectConfigurable groupId="language"
instance="io.kanro.idea.plugin.protobuf.lang.settings.ProtobufSettingsConfigurable"/>
<projectService serviceImplementation="io.kanro.idea.plugin.protobuf.lang.settings.ProtobufSettings"/>
<gotoSymbolContributor
implementation="io.kanro.idea.plugin.protobuf.lang.reference.ProtobufGotoSymbolContributor"/>
<psi.referenceContributor
Expand Down

0 comments on commit 456b3cf

Please sign in to comment.