diff --git a/CHANGELOG.md b/CHANGELOG.md index a48fff65..8cb57c97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,25 @@ ## [Unreleased] +### Fixed + +- Fix group extension field decompile error +- Fix group field annotation always fail +- Fix group extension field range check + +### Changed + +- Make auto-decompile default as disable + ## [1.6.21] -### Fixed -- Fix gRPC request require a proxy -- Fix gRPC request with schema -### Added +### Fixed + +- Fix gRPC request require a proxy +- Fix gRPC request with schema + +### Added + - Support the grpc-status-bin header ## [1.6.20] diff --git a/gradle.properties b/gradle.properties index 2e270c45..535718d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ pluginGroup=io.kanro.idea.plugin.protobuf pluginName=IntelliJ Protobuf Language Plugin # SemVer format -> https://semver.org -pluginVersion=1.6.21 +pluginVersion=1.6.22 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. pluginSinceBuild=222 diff --git a/src/main/kotlin/io/kanro/idea/plugin/protobuf/decompile/ProtobufDecompiler.kt b/src/main/kotlin/io/kanro/idea/plugin/protobuf/decompile/ProtobufDecompiler.kt index 1f6e9e6a..8be01dcb 100644 --- a/src/main/kotlin/io/kanro/idea/plugin/protobuf/decompile/ProtobufDecompiler.kt +++ b/src/main/kotlin/io/kanro/idea/plugin/protobuf/decompile/ProtobufDecompiler.kt @@ -41,21 +41,31 @@ object ProtobufDecompiler { val stack = Stack() stack.add(fileDescriptor) + val groups = mutableSetOf() + + fileDescriptor.extensionList.forEach { + if (it.type == DescriptorProtos.FieldDescriptorProto.Type.TYPE_GROUP) { + groups += it.typeName.substringAfterLast('.') + } + } + + fileDescriptor.extensionList.groupBy { it.extendee }.forEach { + generate(this, stack, it.value) + } + fileDescriptor.serviceList.forEach { generate(this, stack, it) } fileDescriptor.messageTypeList.forEach { + if (it.options.mapEntry) return@forEach + if (it.name in groups) return@forEach generate(this, stack, it) } fileDescriptor.enumTypeList.forEach { generate(this, stack, it) } - - fileDescriptor.extensionList.groupBy { it.extendee }.forEach { - generate(this, stack, it.value) - } } } @@ -138,7 +148,7 @@ object ProtobufDecompiler { } findGroup(stack, field)?.let { - block("${stack.label(field)}group ${field.name} = ${field.number}") { + block("${stack.label(field)}group ${it.name} = ${field.number}") { normalizeStatementLn() generateBlockOption(this, it.options) normalizeStatementLn() @@ -275,16 +285,12 @@ object ProtobufDecompiler { stack: Stack, field: DescriptorProtos.FieldDescriptorProto ): DescriptorProtos.DescriptorProto? { if (field.type != DescriptorProtos.FieldDescriptorProto.Type.TYPE_GROUP) return null - val groupLevel = stack.asReversed().indexOfFirst { it is DescriptorProtos.DescriptorProto } val qName = field.typeName.toQualifiedName() - val subName = qName.subQualifiedName(qName.componentCount - groupLevel, qName.componentCount) - var message = stack.parent() ?: return null - for (component in subName.components) { - message = message.nestedTypeList.firstOrNull { - it.name == component - } ?: return null + return stack.parent()?.nestedTypeList?.firstOrNull { + it.name == qName.lastComponent + } ?: stack.parent()?.messageTypeList?.firstOrNull { + it.name == qName.lastComponent } - return message } private fun stackWrapper(stack: Stack, item: Message, block: () -> Unit) { diff --git a/src/main/kotlin/io/kanro/idea/plugin/protobuf/golang/GoDecompileLineMarker.kt b/src/main/kotlin/io/kanro/idea/plugin/protobuf/golang/GoDecompileLineMarker.kt index 4d351479..104cd0e5 100644 --- a/src/main/kotlin/io/kanro/idea/plugin/protobuf/golang/GoDecompileLineMarker.kt +++ b/src/main/kotlin/io/kanro/idea/plugin/protobuf/golang/GoDecompileLineMarker.kt @@ -15,7 +15,7 @@ import java.awt.event.MouseEvent class GoDecompileLineMarker : LineMarkerProviderDescriptor() { override fun getName(): String? { - return null + return "Go Decompile" } override fun getLineMarkerInfo(element: PsiElement): LineMarkerInfo<*>? { @@ -26,21 +26,19 @@ class GoDecompileLineMarker : LineMarkerProviderDescriptor() { val type = compositeLit.type as? GoArrayOrSliceType ?: return null if (!type.type.textMatches("byte")) return null - return ProtobufDecompileLineMarkerInfo(element) + return LineMarkerInfo( + element, element.textRange, ProtobufIcons.PROTO_DECOMPILE, + { + "Decompile protobuf descriptor" + }, + ProtobufDecompileNavigationHandler, GutterIconRenderer.Alignment.CENTER, + { + "Decompile descriptor" + } + ) } } -class ProtobufDecompileLineMarkerInfo(element: GoVarDefinition) : LineMarkerInfo( - element, element.textRange, ProtobufIcons.PROTO_DECOMPILE, - { - "Decompile protobuf descriptor" - }, - ProtobufDecompileNavigationHandler, GutterIconRenderer.Alignment.CENTER, - { - "Decompile descriptor" - } -) - object ProtobufDecompileNavigationHandler : GutterIconNavigationHandler { override fun navigate(e: MouseEvent, element: GoVarDefinition) { val varSpec = element.parent as? GoVarSpec ?: return diff --git a/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/annotator/ProtobufAnnotator.kt b/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/annotator/ProtobufAnnotator.kt index ade7d60d..1873ef0b 100644 --- a/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/annotator/ProtobufAnnotator.kt +++ b/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/annotator/ProtobufAnnotator.kt @@ -300,6 +300,7 @@ class ProtobufAnnotator : Annotator { } private fun visitExtendItem(o: ProtobufElement) { + if (o.parentOfType() != null) return val extendMessage = o.parentOfType()?.typeName?.reference?.resolve() as? ProtobufMessageDefinition ?: return diff --git a/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/psi/primitive/element/ProtobufGroupDefinition.kt b/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/psi/primitive/element/ProtobufGroupDefinition.kt index 9b2d3db9..507ba496 100644 --- a/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/psi/primitive/element/ProtobufGroupDefinition.kt +++ b/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/psi/primitive/element/ProtobufGroupDefinition.kt @@ -28,7 +28,7 @@ interface ProtobufGroupDefinition : ProtobufFieldLike, ProtobufNumberScope, Prot } override fun name(): String? { - return identifier()?.text?.let { StringUtil.wordsToBeginFromLowerCase(it) } + return identifier()?.text } override fun names(): Set { diff --git a/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/settings/ProtobufSettings.kt b/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/settings/ProtobufSettings.kt index 959b18ec..acabfb57 100644 --- a/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/settings/ProtobufSettings.kt +++ b/src/main/kotlin/io/kanro/idea/plugin/protobuf/lang/settings/ProtobufSettings.kt @@ -36,6 +36,6 @@ class ProtobufSettings : SimplePersistentStateComponent( @get:XCollection(propertyElementName = "roots", style = XCollection.Style.v2) var importRoots by list() - var autoDecompile by property(true) + var autoDecompile by property(false) } } diff --git a/src/main/resources/io/kanro/idea/plugin/protobuf/icon/proto_decompile.svg b/src/main/resources/io/kanro/idea/plugin/protobuf/icon/proto_decompile.svg index 9de4f623..f1d699fb 100644 --- a/src/main/resources/io/kanro/idea/plugin/protobuf/icon/proto_decompile.svg +++ b/src/main/resources/io/kanro/idea/plugin/protobuf/icon/proto_decompile.svg @@ -1,14 +1,12 @@ - - - - - - - + + + + + diff --git a/src/main/resources/io/kanro/idea/plugin/protobuf/icon/proto_decompile_dark.svg b/src/main/resources/io/kanro/idea/plugin/protobuf/icon/proto_decompile_dark.svg index 7464bb90..77fa4051 100644 --- a/src/main/resources/io/kanro/idea/plugin/protobuf/icon/proto_decompile_dark.svg +++ b/src/main/resources/io/kanro/idea/plugin/protobuf/icon/proto_decompile_dark.svg @@ -1,14 +1,12 @@ - - - - - - - + + + + +