Skip to content

Commit ec6816c

Browse files
committed
Implement UiDataProvider along side DataProvider.
1 parent fed3d58 commit ec6816c

6 files changed

Lines changed: 56 additions & 48 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (C) 2025 Reece H. Dunn. SPDX-License-Identifier: Apache-2.0
2+
package com.intellij.compat.actionSystem
3+
4+
import com.intellij.openapi.actionSystem.DataKey
5+
6+
interface DataSink {
7+
operator fun <T : Any> set(key: DataKey<T>, data: T?)
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (C) 2025 Reece H. Dunn. SPDX-License-Identifier: Apache-2.0
2+
package com.intellij.compat.actionSystem
3+
4+
interface UiDataProvider {
5+
fun uiDataSnapshot(sink: DataSink)
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (C) 2025 Reece H. Dunn. SPDX-License-Identifier: Apache-2.0
2+
package com.intellij.compat.actionSystem
3+
4+
typealias DataSink = com.intellij.openapi.actionSystem.DataSink
5+
6+
typealias UiDataProvider = com.intellij.openapi.actionSystem.UiDataProvider

src/kotlin-intellij/main/uk/co/reecedunn/intellij/plugin/core/execution/ui/ConsoleViewImpl.kt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
/*
2-
* Copyright (C) 2019 Reece H. Dunn
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
1+
// Copyright (C) 2019, 2025 Reece H. Dunn. SPDX-License-Identifier: Apache-2.0
162
package uk.co.reecedunn.intellij.plugin.core.execution.ui
173

4+
import com.intellij.compat.actionSystem.DataSink
5+
import com.intellij.compat.actionSystem.UiDataProvider
186
import com.intellij.execution.filters.Filter
197
import com.intellij.execution.filters.HyperlinkInfo
208
import com.intellij.execution.process.ProcessHandler
@@ -28,7 +16,7 @@ import java.awt.BorderLayout
2816
import javax.swing.JComponent
2917
import javax.swing.JPanel
3018

31-
open class ConsoleViewImpl : JPanel(BorderLayout()), ConsoleView, DataProvider {
19+
open class ConsoleViewImpl : JPanel(BorderLayout()), ConsoleView, UiDataProvider, DataProvider {
3220
private var helpId: String? = null
3321

3422
// region ConsoleView
@@ -83,6 +71,14 @@ open class ConsoleViewImpl : JPanel(BorderLayout()), ConsoleView, DataProvider {
8371
override fun scrollTo(offset: Int) {
8472
}
8573

74+
// endregion
75+
// region UiDataProvider
76+
77+
override fun uiDataSnapshot(sink: DataSink) {
78+
sink[PlatformDataKeys.HELP_ID] = helpId
79+
sink[LangDataKeys.CONSOLE_VIEW] = this
80+
}
81+
8682
// endregion
8783
// region DataProvider
8884

src/plugin-exquery/main/uk/co/reecedunn/intellij/plugin/exquery/restxq/endpoints/RestXqEndpoint.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
/*
2-
* Copyright (C) 2020-2023 Reece H. Dunn
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
1+
// Copyright (C) 2020-2023, 2025 Reece H. Dunn. SPDX-License-Identifier: Apache-2.0
162
package uk.co.reecedunn.intellij.plugin.exquery.restxq.endpoints
173

4+
import com.intellij.compat.actionSystem.DataSink
5+
import com.intellij.compat.actionSystem.UiDataProvider
186
import com.intellij.navigation.ItemPresentation
197
import com.intellij.openapi.actionSystem.CommonDataKeys
208
import com.intellij.openapi.actionSystem.DataProvider
@@ -29,6 +17,7 @@ import javax.swing.Icon
2917
class RestXqEndpoint(private val endpoint: XpmFunctionDeclaration) :
3018
EndpointMethodPresentation,
3119
ItemPresentation,
20+
UiDataProvider,
3221
DataProvider {
3322
// region ItemPresentation
3423

@@ -52,6 +41,13 @@ class RestXqEndpoint(private val endpoint: XpmFunctionDeclaration) :
5241
override val endpointMethods: List<String>
5342
get() = rest?.methods ?: listOf()
5443

44+
// endregion
45+
// region UiDataProvider
46+
47+
override fun uiDataSnapshot(sink: DataSink) {
48+
sink[CommonDataKeys.PSI_ELEMENT] = endpoint as PsiElement
49+
}
50+
5551
// endregion
5652
// region DataProvider
5753

src/plugin-marklogic/main/uk/co/reecedunn/intellij/plugin/marklogic/rewriter/endpoints/RewriterEndpoint.kt

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
1-
/*
2-
* Copyright (C) 2020-2023 Reece H. Dunn
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
1+
// Copyright (C) 2020-2023, 2025 Reece H. Dunn. SPDX-License-Identifier: Apache-2.0
162
package uk.co.reecedunn.intellij.plugin.marklogic.rewriter.endpoints
173

4+
import com.intellij.compat.actionSystem.DataSink
5+
import com.intellij.compat.actionSystem.UiDataProvider
6+
import com.intellij.compat.microservices.endpoints.presentation.EndpointMethodPresentation
7+
import com.intellij.compat.microservices.endpoints.presentation.HttpMethodPresentation
188
import com.intellij.navigation.ItemPresentation
199
import com.intellij.openapi.actionSystem.CommonDataKeys
2010
import com.intellij.openapi.actionSystem.DataProvider
2111
import com.intellij.psi.xml.XmlTag
22-
import com.intellij.compat.microservices.endpoints.presentation.EndpointMethodPresentation
23-
import com.intellij.compat.microservices.endpoints.presentation.HttpMethodPresentation
2412
import uk.co.reecedunn.intellij.plugin.core.xml.psi.ancestor
2513
import uk.co.reecedunn.intellij.plugin.marklogic.resources.MarkLogicBundle
2614
import uk.co.reecedunn.intellij.plugin.marklogic.resources.MarkLogicIcons
@@ -31,6 +19,7 @@ import javax.swing.Icon
3119
class RewriterEndpoint(val endpoint: XmlTag) :
3220
EndpointMethodPresentation,
3321
ItemPresentation,
22+
UiDataProvider,
3423
DataProvider {
3524
// region ItemPresentation
3625

@@ -59,6 +48,13 @@ class RewriterEndpoint(val endpoint: XmlTag) :
5948
methods?.split("\\s+") ?: listOf()
6049
}
6150

51+
// endregion
52+
// region UiDataProvider
53+
54+
override fun uiDataSnapshot(sink: DataSink) {
55+
sink[CommonDataKeys.PSI_ELEMENT] = endpointTarget?.resolve()
56+
}
57+
6258
// endregion
6359
// region DataProvider
6460

0 commit comments

Comments
 (0)