mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
Extract REST API endpoints /file, /setting and /openProjectSet to a non-bundled plugin
GitOrigin-RevId: 43773f5f0008bd592dd4f81c6c6c61ad064d9a56
This commit is contained in:
committed by
intellij-monorepo-bot
parent
35928f1f38
commit
fc4c5f36ce
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@@ -965,6 +965,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/python/rest/intellij.reStructuredText.iml" filepath="$PROJECT_DIR$/python/rest/intellij.reStructuredText.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/RegExpSupport/intellij.regexp.iml" filepath="$PROJECT_DIR$/RegExpSupport/intellij.regexp.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/xml/relaxng/intellij.relaxng.iml" filepath="$PROJECT_DIR$/xml/relaxng/intellij.relaxng.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/remote-control/intellij.remoteControl.iml" filepath="$PROJECT_DIR$/plugins/remote-control/intellij.remoteControl.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/remoteDev-util/intellij.remoteDev.util.iml" filepath="$PROJECT_DIR$/platform/remoteDev-util/intellij.remoteDev.util.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/repository-search/intellij.repository.search.iml" filepath="$PROJECT_DIR$/plugins/repository-search/intellij.repository.search.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/search-everywhere-ml/intellij.searchEverywhereMl.iml" filepath="$PROJECT_DIR$/plugins/search-everywhere-ml/intellij.searchEverywhereMl.iml" />
|
||||
|
||||
@@ -190,5 +190,6 @@
|
||||
<orderEntry type="module" module-name="intellij.vcs.gitlab" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.platform.warmup" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework.junit5" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.remoteControl" scope="RUNTIME" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -27,11 +27,8 @@
|
||||
<applicationService serviceInterface="com.intellij.ide.XmlRpcServer" serviceImplementation="org.jetbrains.ide.XmlRpcServerImpl"/>
|
||||
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.XmlRpcServerImpl$XmlRpcRequestHandler"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.ProjectSetRequestHandler"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.OpenFileHttpService"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.AboutHttpService"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.StartUpMeasurementService"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.OpenSettingsService"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.InstallPluginService"/>
|
||||
|
||||
<applicationService serviceImplementation="org.jetbrains.ide.ToolboxRestServiceConfig" preload="true"/>
|
||||
|
||||
@@ -92,7 +92,7 @@ private class StaticFileHandler : WebServerFileHandler() {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun checkAccess(file: Path, root: Path = file.root): Boolean {
|
||||
fun checkAccess(file: Path, root: Path = file.root): Boolean {
|
||||
var parent = file
|
||||
do {
|
||||
if (!hasAccess(parent)) {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
###
|
||||
@apiDefine DiffRequestExample
|
||||
|
||||
@apiExample {json} Request-Example:
|
||||
{
|
||||
"fileType": "JSON",
|
||||
"contents": [
|
||||
{
|
||||
"title": "Actual",
|
||||
"content": "foo"
|
||||
},
|
||||
{
|
||||
"title": "Expected",
|
||||
"content": "bar"
|
||||
}
|
||||
]
|
||||
}
|
||||
###
|
||||
@@ -7,29 +7,12 @@ import com.intellij.openapi.application.JBProtocolCommand
|
||||
import com.intellij.openapi.options.newEditor.SettingsDialog
|
||||
import com.intellij.openapi.options.newEditor.SettingsDialogFactory
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import io.netty.channel.ChannelHandlerContext
|
||||
import io.netty.handler.codec.http.FullHttpRequest
|
||||
import io.netty.handler.codec.http.QueryStringDecoder
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.concurrent.Future
|
||||
|
||||
private const val SERVICE_NAME = "settings"
|
||||
|
||||
internal class OpenSettingsService : RestService() {
|
||||
override fun getServiceName() = SERVICE_NAME
|
||||
|
||||
override fun execute(urlDecoder: QueryStringDecoder, request: FullHttpRequest, context: ChannelHandlerContext): String? {
|
||||
val name = urlDecoder.parameters()["name"]?.firstOrNull()?.trim() ?: return parameterMissedErrorMessage("name")
|
||||
if (!doOpenSettings(name)) {
|
||||
return "no configurables found"
|
||||
}
|
||||
|
||||
sendOk(request, context)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private fun doOpenSettings(name: String): Boolean {
|
||||
fun doOpenSettings(name: String): Boolean {
|
||||
val project = RestService.getLastFocusedOrOpenedProject() ?: ProjectManager.getInstance().defaultProject
|
||||
val configurable = SearchConfigurableByNameHelper(name, project).searchByName() ?: return false
|
||||
ApplicationManager.getApplication().invokeLater(
|
||||
|
||||
@@ -314,6 +314,6 @@ abstract class RestService : HttpRequestHandler() {
|
||||
abstract fun execute(urlDecoder: QueryStringDecoder, request: FullHttpRequest, context: ChannelHandlerContext): String?
|
||||
}
|
||||
|
||||
internal fun HttpResponseStatus.orInSafeMode(safeStatus: HttpResponseStatus): HttpResponseStatus {
|
||||
fun HttpResponseStatus.orInSafeMode(safeStatus: HttpResponseStatus): HttpResponseStatus {
|
||||
return if (Registry.`is`("ide.http.server.response.actual.status", true) || ApplicationManager.getApplication()?.isUnitTestMode == true) this else safeStatus
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.net.http.HttpRequest
|
||||
import java.net.http.HttpResponse
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
internal abstract class BuiltInServerTestCase {
|
||||
abstract class BuiltInServerTestCase {
|
||||
companion object {
|
||||
@JvmField
|
||||
@ClassRule
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.junit.runner.Description
|
||||
|
||||
private const val EXCLUDED_DIR_NAME = "excludedDir"
|
||||
|
||||
internal class TestManager(private val projectRule: ProjectRule, private val tempDirManager: TemporaryDirectory) : TestWatcher() {
|
||||
class TestManager(private val projectRule: ProjectRule, private val tempDirManager: TemporaryDirectory) : TestWatcher() {
|
||||
var annotation: TestDescriptor? = null
|
||||
|
||||
var filePath: String? = null
|
||||
|
||||
26
plugins/remote-control/intellij.remoteControl.iml
Normal file
26
plugins/remote-control/intellij.remoteControl.iml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="kotlin-stdlib-jdk8" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.builtInServer" />
|
||||
<orderEntry type="module" module-name="intellij.platform.builtInServer.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.util.netty" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
|
||||
<orderEntry type="library" name="netty-buffer" level="project" />
|
||||
<orderEntry type="library" name="netty-codec-http" level="project" />
|
||||
<orderEntry type="library" name="gson" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.vcs" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.vcs.impl" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.builtInServer.tests" scope="TEST" />
|
||||
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
16
plugins/remote-control/resources/META-INF/plugin.xml
Normal file
16
plugins/remote-control/resources/META-INF/plugin.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<idea-plugin>
|
||||
<id>com.intellij.remoteControl</id>
|
||||
<name>IDE Remote Control</name>
|
||||
<description>
|
||||
Allows opening projects, files and settings through the REST API of the built-in Web server.
|
||||
</description>
|
||||
<vendor>JetBrains</vendor>
|
||||
|
||||
<depends>com.intellij.modules.lang</depends>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.OpenFileHttpService"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.OpenSettingsService"/>
|
||||
<httpRequestHandler implementation="org.jetbrains.ide.ProjectSetRequestHandler"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.jetbrains.ide
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext
|
||||
import io.netty.handler.codec.http.FullHttpRequest
|
||||
import io.netty.handler.codec.http.QueryStringDecoder
|
||||
|
||||
internal class OpenSettingsService : RestService() {
|
||||
override fun getServiceName() = "settings"
|
||||
|
||||
override fun execute(urlDecoder: QueryStringDecoder, request: FullHttpRequest, context: ChannelHandlerContext): String? {
|
||||
val name = urlDecoder.parameters()["name"]?.firstOrNull()?.trim() ?: return parameterMissedErrorMessage("name")
|
||||
if (!doOpenSettings(name)) {
|
||||
return "no configurables found"
|
||||
}
|
||||
|
||||
sendOk(request, context)
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.ide
|
||||
|
||||
import com.google.gson.stream.JsonWriter
|
||||
Reference in New Issue
Block a user