Remove dependency of serialization on frontend

Move ApplicationExtensionDescriptor and ProjectExtensionDescriptor to
:compiler:util.
This commit is contained in:
Alexander Udalov
2021-04-22 20:04:15 +02:00
parent 8b3769b88e
commit e790fa8ac9
3 changed files with 4 additions and 15 deletions
@@ -1,34 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.extensions
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.extensions.ExtensionPoint
import com.intellij.openapi.extensions.ExtensionPointName
open class ApplicationExtensionDescriptor<T : Any>(name: String, private val extensionClass: Class<T>) {
val extensionPointName: ExtensionPointName<T> = ExtensionPointName.create(name)
fun registerExtensionPoint() {
ApplicationManager.getApplication().extensionArea.registerExtensionPoint(
extensionPointName.name,
extensionClass.name,
ExtensionPoint.Kind.INTERFACE
)
}
fun registerExtension(extension: T, disposable: Disposable) {
ApplicationManager.getApplication().extensionArea.getExtensionPoint(extensionPointName).registerExtension(extension, disposable)
}
fun getInstances(): List<T> {
val projectArea = ApplicationManager.getApplication().extensionArea
if (!projectArea.hasExtensionPoint(extensionPointName.name)) return listOf()
return projectArea.getExtensionPoint(extensionPointName).extensions.toList()
}
}
@@ -1,44 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.extensions
import com.intellij.openapi.extensions.ExtensionPoint
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.project.Project
open class ProjectExtensionDescriptor<T : Any>(name: String, private val extensionClass: Class<T>) {
val extensionPointName: ExtensionPointName<T> = ExtensionPointName.create(name)
fun registerExtensionPoint(project: Project) {
project.extensionArea.registerExtensionPoint(
extensionPointName.name,
extensionClass.name,
ExtensionPoint.Kind.INTERFACE
)
}
fun registerExtension(project: Project, extension: T) {
project.extensionArea.getExtensionPoint(extensionPointName).registerExtension(extension, project)
}
fun getInstances(project: Project): List<T> {
val projectArea = project.extensionArea
if (!projectArea.hasExtensionPoint(extensionPointName.name)) return listOf()
return projectArea.getExtensionPoint(extensionPointName).extensions.toList()
}
}