IJPL-796 cleanup

GitOrigin-RevId: 9c31f9aa03450af29ff5650d249c62e3198d0fc9
This commit is contained in:
Vladimir Krivosheev
2024-06-03 18:19:31 +02:00
committed by intellij-monorepo-bot
parent 00e68080c1
commit 7f93e0ee0a
6 changed files with 50 additions and 65 deletions

View File

@@ -746,21 +746,6 @@ c:com.intellij.diff.tools.binary.TwosideBinaryDiffViewer
- a:cleanBlocks():V
- a:getBlocks():java.util.List
- a:setBlocks(java.util.List):V
*f:com.intellij.diff.tools.combined.CombinedDiffEditorState
- com.intellij.openapi.fileEditor.impl.FileEditorStateWithPreferredOpenMode
- <init>(java.util.Set,com.intellij.diff.tools.combined.CombinedBlockId,java.util.List):V
- canBeMergedWith(com.intellij.openapi.fileEditor.FileEditorState,com.intellij.openapi.fileEditor.FileEditorStateLevel):Z
- f:component1():java.util.Set
- f:component2():com.intellij.diff.tools.combined.CombinedBlockId
- f:component3():java.util.List
- f:copy(java.util.Set,com.intellij.diff.tools.combined.CombinedBlockId,java.util.List):com.intellij.diff.tools.combined.CombinedDiffEditorState
- bs:copy$default(com.intellij.diff.tools.combined.CombinedDiffEditorState,java.util.Set,com.intellij.diff.tools.combined.CombinedBlockId,java.util.List,I,java.lang.Object):com.intellij.diff.tools.combined.CombinedDiffEditorState
- equals(java.lang.Object):Z
- f:getActiveBlockId():com.intellij.diff.tools.combined.CombinedBlockId
- f:getActiveEditorStates():java.util.List
- f:getCurrentBlockIds():java.util.Set
- getOpenMode():com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$OpenMode
- hashCode():I
f:com.intellij.diff.tools.combined.CombinedDiffKeysKt
- *sf:getCOMBINED_DIFF_MAIN_UI():com.intellij.openapi.util.Key
- *sf:getCOMBINED_DIFF_SCROLL_TO_BLOCK():com.intellij.openapi.util.Key

View File

@@ -791,11 +791,8 @@ f:com.intellij.openapi.fileEditor.impl.NonProjectFileWritingAccessProvider
- s:setCustomUnlocker(com.intellij.util.NullableFunction):V
c:com.intellij.openapi.fileEditor.impl.UniqueNameEditorTabTitleProvider
- com.intellij.openapi.fileEditor.impl.EditorTabTitleProvider
- sf:Companion:com.intellij.openapi.fileEditor.impl.UniqueNameEditorTabTitleProvider$Companion
- <init>():V
- getEditorTabTitle(com.intellij.openapi.project.Project,com.intellij.openapi.vfs.VirtualFile):java.lang.String
f:com.intellij.openapi.fileEditor.impl.UniqueNameEditorTabTitleProvider$Companion
- f:getEditorTabText(java.lang.String,java.lang.String,Z):java.lang.String
a:com.intellij.openapi.fileTypes.ex.FileTypeManagerEx
- com.intellij.openapi.fileTypes.FileTypeManager
- <init>():V

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.impl
import com.intellij.ide.ActivityTracker
@@ -17,6 +17,7 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.actionSystem.impl.Utils
import com.intellij.openapi.application.*
import com.intellij.openapi.components.serviceAsync
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.fileEditor.FileEditor
import com.intellij.openapi.fileEditor.FileEditorManager
@@ -69,18 +70,15 @@ import javax.swing.JComponent
import javax.swing.JPanel
import javax.swing.SwingUtilities
/**
* @author Eugene Belyaev
*/
@OptIn(FlowPreview::class)
class StructureViewWrapperImpl(private val myProject: Project,
class StructureViewWrapperImpl(private val project: Project,
private val myToolWindow: ToolWindow,
private val coroutineScope: CoroutineScope) : StructureViewWrapper, Disposable {
private var myFile: VirtualFile? = null
private var myStructureView: StructureView? = null
private var myFileEditor: FileEditor? = null
private var myModuleStructureComponent: ModuleStructureComponent? = null
private var myPanels: List<JPanel> = emptyList()
private var panels: List<JPanel> = emptyList()
private var pendingSelectionFunc: AtomicReference<(suspend () -> Unit)?> = AtomicReference()
private var myFirstRun = true
private var myActivityCount = 0
@@ -92,7 +90,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
val component = myToolWindow.component
@Suppress("TestOnlyProblems")
if (isLight(myProject)) {
if (isLight(project)) {
LOG.error("StructureViewWrapperImpl must be not created for light project.")
}
@@ -123,7 +121,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
loggedRun("update file") { checkUpdate() }
scheduleRebuild()
}
else if (!myProject.isDisposed) {
else if (!project.isDisposed) {
myFile = null
rebuildNow("clear a structure on hide")
}
@@ -172,7 +170,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
}
private fun clearCaches() {
StructureViewComponent.clearStructureViewState(myProject)
StructureViewComponent.clearStructureViewState(project)
if (myStructureView != null) {
myStructureView!!.disableStoreState()
}
@@ -180,7 +178,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
}
private fun checkUpdate() {
if (myProject.isDisposed) return
if (project.isDisposed) return
val owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().focusOwner
val insideToolwindow = SwingUtilities.isDescendingFrom(myToolWindow.component, owner)
if (insideToolwindow) LOG.debug("inside structure view")
@@ -189,7 +187,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
}
val dataContext = DataManager.getInstance().getDataContext(owner)
if (WRAPPER_DATA_KEY.getData(dataContext) === this) return
if (CommonDataKeys.PROJECT.getData(dataContext) !== myProject) return
if (CommonDataKeys.PROJECT.getData(dataContext) !== project) return
if (insideToolwindow) {
if (myFirstRun) {
setFileFromSelectionHistory()
@@ -221,8 +219,8 @@ class StructureViewWrapperImpl(private val myProject: Project,
}
private fun setFileFromSelectionHistory() {
val editorManager = FileEditorManager.getInstance(myProject) as FileEditorManagerImpl
val firstInHistory = editorManager.getSelectionHistory().firstOrNull()
val editorManager = FileEditorManager.getInstance(project) as FileEditorManagerImpl
val firstInHistory = editorManager.getSelectionHistoryList().firstOrNull()
if (firstInHistory != null) {
coroutineScope.launch {
setFile(firstInHistory.first)
@@ -273,7 +271,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
// editor is different
if (file != null) {
val editorIsDifferent = withContext(Dispatchers.EDT) {
FileEditorManager.getInstance(myProject).getSelectedEditor(file) !== myFileEditor
project.serviceAsync<FileEditorManager>().getSelectedEditor(file) !== myFileEditor
}
if (editorIsDifferent) {
setFileAndRebuild()
@@ -362,7 +360,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
}
val file = myFile ?: run {
val selectedFiles = FileEditorManager.getInstance(myProject).selectedFiles
val selectedFiles = project.serviceAsync<FileEditorManager>().selectedFiles
if (selectedFiles.isNotEmpty()) selectedFiles[0] else null
}
@@ -370,11 +368,11 @@ class StructureViewWrapperImpl(private val myProject: Project,
if (file != null && file.isValid) {
if (file.isDirectory) {
val module = readAction {
if (!ProjectRootsUtil.isModuleContentRoot(file, myProject)) {
if (!ProjectRootsUtil.isModuleContentRoot(file, project)) {
null
}
else {
ModuleUtilCore.findModuleForFile(file, myProject)
ModuleUtilCore.findModuleForFile(file, project)
}
}
@@ -385,11 +383,11 @@ class StructureViewWrapperImpl(private val myProject: Project,
}
}
else {
val editor = FileEditorManager.getInstance(myProject).getSelectedEditor(file)
val editor = project.serviceAsync<FileEditorManager>().getSelectedEditor(file)
val structureViewBuilder = if (editor != null && editor.isValid)
readAction { editor.structureViewBuilder } else createStructureViewBuilder(file)
if (structureViewBuilder != null) {
val structureView = structureViewBuilder.createStructureView(editor, myProject)
val structureView = structureViewBuilder.createStructureView(editor, project)
myStructureView = structureView
myFileEditor = editor
@@ -397,7 +395,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
if (structureView is StructureViewComposite) {
val views: Array<StructureViewDescriptor> = structureView.structureViews
names = views.map { it.title }.toTypedArray()
myPanels = views.map { createContentPanel(it.structureView.component) }
panels = views.map { createContentPanel(it.structureView.component) }
}
else {
createSinglePanel(structureView.component)
@@ -417,8 +415,8 @@ class StructureViewWrapperImpl(private val myProject: Project,
panel.emptyText.setText(LangBundle.message("panel.empty.text.no.structure"))
createSinglePanel(panel)
}
for (i in myPanels.indices) {
val content = ContentFactory.getInstance().createContent(myPanels[i], names[i], false)
for (i in panels.indices) {
val content = ContentFactory.getInstance().createContent(panels[i], names[i], false)
contentManager.addContent(content)
if (i == 0 && myStructureView != null) {
Disposer.register(content, myStructureView!!)
@@ -434,7 +432,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
if (wasFocused) {
val policy = container.focusTraversalPolicy
val component = policy?.getDefaultComponent(container)
if (component != null) IdeFocusManager.getInstance(myProject).requestFocusInProject(component, myProject)
if (component != null) IdeFocusManager.getInstance(project).requestFocusInProject(component, project)
}
}
@@ -457,7 +455,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
}
private fun createSinglePanel(component: JComponent) {
myPanels = listOf(createContentPanel(component))
panels = listOf(createContentPanel(component))
}
private fun createContentPanel(component: JComponent): ContentPanel {
@@ -469,12 +467,12 @@ class StructureViewWrapperImpl(private val myProject: Project,
private suspend fun createStructureViewBuilder(file: VirtualFile): StructureViewBuilder? {
if (file.length > PersistentFSConstants.getMaxIntellisenseFileSize()) return null
val providers = getInstance().getProvidersAsync(myProject, file)
val providers = getInstance().getProvidersAsync(project, file)
val provider = (if (providers.isEmpty()) null else providers[0]) ?: return null
if (provider is StructureViewFileEditorProvider) {
return readAction { (provider as StructureViewFileEditorProvider).getStructureViewBuilder(myProject, file) }
return readAction { (provider as StructureViewFileEditorProvider).getStructureViewBuilder(project, file) }
}
val editor = withContext(Dispatchers.EDT) { provider.createEditor (myProject, file) }
val editor = withContext(Dispatchers.EDT) { provider.createEditor (project, file) }
return try {
readAction { editor.structureViewBuilder }
}
@@ -485,7 +483,7 @@ class StructureViewWrapperImpl(private val myProject: Project,
private val isStructureViewShowing: Boolean
get() {
val windowManager = getInstance(myProject)
val windowManager = getInstance(project)
val toolWindow = windowManager.getToolWindow(ToolWindowId.STRUCTURE_VIEW)
// it means that window is registered
return toolWindow != null && toolWindow.isVisible

View File

@@ -62,7 +62,6 @@ import com.intellij.ui.render.RenderingUtil
import com.intellij.ui.speedSearch.FilteringListModel
import com.intellij.ui.speedSearch.NameFilteringListModel
import com.intellij.util.concurrency.AppExecutorUtil
import com.intellij.util.containers.ContainerUtil
import com.intellij.util.ui.JBDimension
import com.intellij.util.ui.JBUI
import com.intellij.util.ui.StartupUiUtil
@@ -129,8 +128,7 @@ object Switcher : BaseSwitcherAction(null) {
when {
CommonDataKeys.PROJECT.`is`(dataId) -> return project
PlatformCoreDataKeys.SELECTED_ITEM.`is`(dataId) -> {
if (files.isSelectionEmpty) return null
return ContainerUtil.getOnlyItem<SwitcherVirtualFile>(files.selectedValuesList)?.file
return if (files.isSelectionEmpty) null else files.selectedValuesList.singleOrNull()?.file
}
PlatformDataKeys.SPEED_SEARCH_TEXT.`is`(dataId) -> {
return if (speedSearch?.isPopupActive == true) speedSearch.enteredPrefix else null
@@ -209,7 +207,7 @@ object Switcher : BaseSwitcherAction(null) {
header.add(HorizontalLayout.RIGHT, cbShowOnlyEditedFiles)
WindowMoveListener(header).installTo(header)
val shortcuts = KeymapUtil.getActiveKeymapShortcuts("SwitcherRecentEditedChangedToggleCheckBox")
if (shortcuts.shortcuts.size > 0) {
if (shortcuts.shortcuts.isNotEmpty()) {
val label = JLabel(KeymapUtil.getShortcutsText(shortcuts.shortcuts))
label.foreground = JBUI.CurrentTheme.ContextHelp.FOREGROUND
header.add(HorizontalLayout.RIGHT, label)
@@ -508,7 +506,7 @@ object Switcher : BaseSwitcherAction(null) {
go(false)
}
internal val selectedList: JBList<out SwitcherListItem>?
private val selectedList: JBList<out SwitcherListItem>?
get() = getSelectedList(files)
private fun getSelectedList(preferable: JBList<out SwitcherListItem>?): JBList<out SwitcherListItem>? {
@@ -715,7 +713,7 @@ object Switcher : BaseSwitcherAction(null) {
val editors = ArrayList<SwitcherVirtualFile>()
val addedFiles: MutableSet<VirtualFile> = LinkedHashSet()
if (!pinned) {
for (pair in (FileEditorManager.getInstance(project) as FileEditorManagerImpl).getSelectionHistory()) {
for (pair in (FileEditorManager.getInstance(project) as FileEditorManagerImpl).getSelectionHistoryList()) {
editors.add(SwitcherVirtualFile(project, pair.first, pair.second))
}
}
@@ -790,7 +788,7 @@ object Switcher : BaseSwitcherAction(null) {
val recentFiles = getInstance(project).fileList
val openFiles = FileEditorManager.getInstance(project).openFiles
val recentFilesSet: Set<VirtualFile> = HashSet(recentFiles)
val openFilesSet: Set<VirtualFile> = ContainerUtil.newHashSet(*openFiles)
val openFilesSet = openFiles.toHashSet()
// Add missing FileEditor tabs right after the last one, that is available via "Recent Files"
var index = 0

View File

@@ -2103,6 +2103,8 @@ open class FileEditorManagerImpl(
return selectionHistory.getHistory().map { Pair(it.first, it.second) }
}
fun getSelectionHistoryList(): Collection<kotlin.Pair<VirtualFile, EditorWindow>> = selectionHistory.getHistory()
final override fun addSelectionRecord(file: VirtualFile, window: EditorWindow) {
selectionHistory.addRecord(file, window)
}
@@ -2290,19 +2292,24 @@ private class SelectionHistory {
@Synchronized
fun getHistory(): Collection<kotlin.Pair<VirtualFile, EditorWindow>> {
val copy = LinkedHashSet<kotlin.Pair<VirtualFile, EditorWindow>>()
var modified = false
for (pair in history) {
if (pair.second.files().none()) {
val windows = pair.second.owner.windows().toList()
val editorWindow = pair.second
if (editorWindow.files().none()) {
val windows = editorWindow.owner.windows().toList()
if (windows.isNotEmpty() && windows[0].files().any()) {
copy.add(pair.first to windows[0])
}
modified = true
}
else {
copy.add(pair)
}
}
history.clear()
history.addAll(copy)
if (modified) {
history.clear()
history.addAll(copy)
}
return copy
}
}
@@ -2310,8 +2317,8 @@ private class SelectionHistory {
private class SelectionState(@JvmField val composite: EditorComposite, @JvmField val fileEditorProvider: FileEditorWithProvider)
@Internal
suspend fun waitForFullyCompleted(fileEditorComposite: FileEditorComposite) {
for (editor in fileEditorComposite.allEditors) {
suspend fun waitForFullyCompleted(composite: FileEditorComposite) {
for (editor in composite.allEditors) {
if (editor is TextEditor) {
AsyncEditorLoader.waitForCompleted(editor.editor)
}

View File

@@ -54,10 +54,10 @@ class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdap
override suspend fun doExecute(context: PlaybackContext) {
val arguments = extractCommandArgument(PREFIX)
val myOptions = getOptions(arguments)
val filePath = (myOptions?.file ?: text.split(' ', limit = 4)[1]).replace("SPACE_SYMBOL", " ")
val timeout = myOptions?.timeout ?: 0
val suppressErrors = myOptions?.suppressErrors ?: false
val options = getOptions(arguments)
val filePath = (options?.file ?: text.split(' ', limit = 4)[1]).replace("SPACE_SYMBOL", " ")
val timeout = options?.timeout ?: 0
val suppressErrors = options?.suppressErrors ?: false
val project = context.project
val file = findFile(filePath, project) ?: error(PerformanceTestingBundle.message("command.file.not.found", filePath))
@@ -78,7 +78,7 @@ class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdap
val fileEditor = (project.serviceAsync<FileEditorManager>() as FileEditorManagerEx)
.openFile(file = file, options = FileEditorOpenOptions(requestFocus = true))
if (myOptions != null && !myOptions.disableCodeAnalysis) {
if (options != null && !options.disableCodeAnalysis) {
waitForFullyCompleted(fileEditor)
}
@@ -87,7 +87,7 @@ class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdap
}
job.withErrorMessage("Timeout on open file ${file.path} more than $timeout seconds")
if (myOptions != null && !myOptions.disableCodeAnalysis) {
if (options != null && !options.disableCodeAnalysis) {
job.waitForComplete()
}
}