Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove Non-extendable interface usage #1146

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ plugin_version=2.7.1.212.0
kotlin.code.style=official
kotlin_version=1.8.0
junit_version=5.9.2
itangcent_intellij_version=1.6.4
itangcent_intellij_version=1.6.6

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import com.itangcent.common.spi.SpiUtils
import com.itangcent.idea.config.CachedResourceResolver
import com.itangcent.idea.plugin.Initializer
import com.itangcent.idea.plugin.log.CustomLogConfig
import com.itangcent.idea.psi.DisableDocSupport
import com.itangcent.idea.utils.ConfigurableLogger
import com.itangcent.intellij.actions.ActionEventDataContextAdaptor
import com.itangcent.intellij.actions.KotlinAnAction
import com.itangcent.intellij.config.resource.ResourceResolver
import com.itangcent.intellij.context.ActionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.itangcent.idea.plugin.actions

import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.project.Project
import com.itangcent.idea.plugin.DataEventCollector
import com.itangcent.idea.plugin.api.export.ExportDoc
import com.itangcent.idea.plugin.api.export.condition.markAsSimple
import com.itangcent.idea.plugin.api.export.core.ClassExporter
Expand All @@ -19,28 +17,14 @@ import com.itangcent.intellij.extend.guice.singleton
import com.itangcent.intellij.extend.guice.with
import com.itangcent.intellij.file.DefaultLocalFileRepository
import com.itangcent.intellij.file.LocalFileRepository
import com.itangcent.intellij.psi.DataContextProvider

class SuvExportAction : ApiExportAction("Export Api") {

private var dataEventCollector: DataEventCollector? = null

override fun actionPerformed(anActionEvent: AnActionEvent) {
dataEventCollector = DataEventCollector(anActionEvent)

load(dataEventCollector!!)

dataEventCollector!!.disableDataReach()

super.actionPerformed(anActionEvent)
}

override fun afterBuildActionContext(event: AnActionEvent, builder: ActionContext.ActionContextBuilder) {

super.afterBuildActionContext(event, builder)

val copyDataEventCollector = dataEventCollector
builder.bind(DataContext::class) { it.toInstance(copyDataEventCollector) }

builder.bind(ClassExporter::class) { it.with(CompositeClassExporter::class).singleton() }

builder.bindInstance(ExportDoc::class, ExportDoc.of("request", "methodDoc"))
Expand All @@ -52,25 +36,21 @@ class SuvExportAction : ApiExportAction("Export Api") {

builder.bind(MethodFilter::class) { it.with(ConfigurableMethodFilter::class).singleton() }

builder.cache("DATA_EVENT_COLLECTOR", dataEventCollector)

dataEventCollector = null

builder.bind(PostmanApiHelper::class) { it.with(PostmanCachedApiHelper::class).singleton() }

}

private fun load(dataContext: DataContext) {
dataContext.getData(CommonDataKeys.PROJECT)
dataContext.getData(CommonDataKeys.PSI_FILE)
dataContext.getData(CommonDataKeys.NAVIGATABLE_ARRAY)
dataContext.getData(CommonDataKeys.NAVIGATABLE)
dataContext.getData(CommonDataKeys.EDITOR)
dataContext.getData(CommonDataKeys.PSI_ELEMENT)
private fun DataContextProvider.preLoadData() {
getData(CommonDataKeys.PROJECT)
getData(CommonDataKeys.PSI_FILE)
getData(CommonDataKeys.NAVIGATABLE_ARRAY)
getData(CommonDataKeys.NAVIGATABLE)
getData(CommonDataKeys.EDITOR)
getData(CommonDataKeys.PSI_ELEMENT)
}

override fun actionPerformed(actionContext: ActionContext, project: Project?, anActionEvent: AnActionEvent) {
super.actionPerformed(actionContext, project, anActionEvent)
actionContext.instance(DataContextProvider::class).preLoadData()
val multipleApiExporter = actionContext.instance(SuvApiExporter::class)
multipleApiExporter.showExportWindow()
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ internal class PsiActionContextKitTest : PluginContextLightCodeInsightFixtureTes
val psiElement = mock<PsiMethod> {
on(it.context).thenReturn(it)
}
actionContext.cache(CommonDataKeys.PSI_ELEMENT.name, psiElement)
actionContext.cache("dataContext:${CommonDataKeys.PSI_ELEMENT.name}", psiElement)
kotlin.test.assertEquals(psiElement, actionContext.findCurrentMethod())
}
}
Loading