IJPL-166086 Convert StructureViewBuilder to Kotlin

Need to add some suspend stuff to it.


(cherry picked from commit 0a12edfddbe7cdc4c2254657155d4ae3cde2ea06)

IJ-CR-149552

GitOrigin-RevId: 33b50b8c12769c9072d02be869f3ca85a6fb6ca6
This commit is contained in:
Sergei Tachenov
2024-11-04 16:57:49 +02:00
committed by intellij-monorepo-bot
parent 0fb0844ba9
commit 66782f337c
2 changed files with 49 additions and 52 deletions

View File

@@ -1,52 +0,0 @@
// 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 com.intellij.ide.structureView;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.KeyedFactoryEPBean;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileTypes.FileTypeExtensionFactory;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Defines the implementation of Structure View and the file structure popup for
* a file type. This class allows to replace the entire Structure View component
* implementation. If it is acceptable to have the standard component implementation
* and to customize only how the Structure View is populated with the file data,
* the standard implementation of this interface - {@link TreeBasedStructureViewBuilder} -
* should be used.
*
* @see com.intellij.lang.LanguageStructureViewBuilder#getStructureViewBuilder(com.intellij.psi.PsiFile)
* @see com.intellij.lang.PsiStructureViewFactory#getStructureViewBuilder(com.intellij.psi.PsiFile)}
*/
public interface StructureViewBuilder {
static @NotNull StructureViewBuilderProvider getProvider() {
return PROVIDER;
}
/**
* Returns the structure view implementation for the specified file
*
* @param fileEditor the editor for which the structure view is requested. Can be null if file is not open (e.g. structure is requested
* from the project view)
* @param project the project containing the file for which the structure view is requested.
* @return the structure view implementation.
* @see TreeBasedStructureViewBuilder
*/
@NotNull
StructureView createStructureView(@Nullable FileEditor fileEditor, @NotNull Project project);
@ApiStatus.Internal
ExtensionPointName<KeyedFactoryEPBean> EP_NAME = ExtensionPointName.create("com.intellij.structureViewBuilder");
/**
* @deprecated use {@link #getProvider()} instead
*/
@Deprecated
StructureViewBuilderProvider PROVIDER =
new FileTypeExtensionFactory<>(StructureViewBuilderProvider.class, EP_NAME).get();
}

View File

@@ -0,0 +1,49 @@
// 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 com.intellij.ide.structureView
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.extensions.ExtensionPointName.Companion.create
import com.intellij.openapi.extensions.KeyedFactoryEPBean
import com.intellij.openapi.fileEditor.FileEditor
import com.intellij.openapi.fileTypes.FileTypeExtensionFactory
import com.intellij.openapi.project.Project
import org.jetbrains.annotations.ApiStatus
/**
* Defines the implementation of Structure View and the file structure popup for
* a file type. This class allows to replace the entire Structure View component
* implementation. If it is acceptable to have the standard component implementation
* and to customize only how the Structure View is populated with the file data,
* the standard implementation of this interface - [TreeBasedStructureViewBuilder] -
* should be used.
*
* @see com.intellij.lang.LanguageStructureViewBuilder.getStructureViewBuilder
* @see com.intellij.lang.PsiStructureViewFactory.getStructureViewBuilder
*/
interface StructureViewBuilder {
/**
* Returns the structure view implementation for the specified file
*
* @param fileEditor the editor for which the structure view is requested. Can be null if file is not open (e.g. structure is requested
* from the project view)
* @param project the project containing the file for which the structure view is requested.
* @return the structure view implementation.
* @see TreeBasedStructureViewBuilder
*/
fun createStructureView(fileEditor: FileEditor?, project: Project): StructureView
@ApiStatus.Internal
companion object {
@ApiStatus.Internal
@JvmField
val EP_NAME: ExtensionPointName<KeyedFactoryEPBean> = create<KeyedFactoryEPBean>("com.intellij.structureViewBuilder")
@JvmStatic
fun getProvider(): StructureViewBuilderProvider = PROVIDER
@Deprecated(replaceWith = ReplaceWith("getProvider()"), message = "Use getProvider()")
@JvmField
val PROVIDER: StructureViewBuilderProvider = FileTypeExtensionFactory<StructureViewBuilderProvider>(
StructureViewBuilderProvider::class.java, EP_NAME).get()
}
}