mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
IJPL-157219 SE - use IdeNavigationService, fire fileOpened for remote dev
GitOrigin-RevId: e42bd583212c25881596e6fb3ecb975ba4c97e5b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f3e7336716
commit
91aa759fc9
@@ -13915,6 +13915,7 @@ a:com.intellij.ide.actions.searcheverywhere.AbstractGotoSEContributor
|
||||
- getElementsRenderer():javax.swing.ListCellRenderer
|
||||
- getItemDescription(java.lang.Object):java.lang.String
|
||||
- psf:getLineAndColumn(java.lang.String):com.intellij.util.IntPair
|
||||
- pf:getProject():com.intellij.openapi.project.Project
|
||||
- getScope():com.intellij.ide.util.scopeChooser.ScopeDescriptor
|
||||
- getSearchProviderId():java.lang.String
|
||||
- getSupportedScopes():java.util.List
|
||||
@@ -13922,11 +13923,11 @@ a:com.intellij.ide.actions.searcheverywhere.AbstractGotoSEContributor
|
||||
- pf:isEverywhere():Z
|
||||
- isMultiSelectionSupported():Z
|
||||
- isShownInSeparateTab():Z
|
||||
- pf:preparePsi(com.intellij.psi.PsiElement,java.lang.String):com.intellij.psi.PsiElement
|
||||
- p:processElement(com.intellij.openapi.progress.ProgressIndicator,com.intellij.util.Processor,com.intellij.ide.util.gotoByName.FilteringGotoByModel,java.lang.Object,I):Z
|
||||
- processSelectedItem(java.lang.Object,I,java.lang.String):Z
|
||||
- setScope(com.intellij.ide.util.scopeChooser.ScopeDescriptor):V
|
||||
- showInFindResults():Z
|
||||
- p:triggerLineOrColumnFeatureUsed(com.intellij.pom.Navigatable,kotlin.coroutines.Continuation):java.lang.Object
|
||||
f:com.intellij.ide.actions.searcheverywhere.AbstractGotoSEContributor$Companion
|
||||
- f:createContext(com.intellij.openapi.project.Project,com.intellij.psi.SmartPsiElementPointer):com.intellij.openapi.actionSystem.DataContext
|
||||
- f:getElement(com.intellij.psi.PsiElement,java.lang.String):com.intellij.psi.PsiElement
|
||||
@@ -14035,13 +14036,13 @@ c:com.intellij.ide.actions.searcheverywhere.FileSearchEverywhereContributor
|
||||
- getActions(java.lang.Runnable):java.util.List
|
||||
- getDataForItem(java.lang.Object,java.lang.String):java.lang.Object
|
||||
- getElementPriority(java.lang.Object,java.lang.String):I
|
||||
- getElementsRenderer():javax.swing.ListCellRenderer
|
||||
- f:getElementsRenderer():javax.swing.ListCellRenderer
|
||||
- getGroupName():java.lang.String
|
||||
- getItemDescription(java.lang.Object):java.lang.String
|
||||
- getSortWeight():I
|
||||
- isEmptyPatternSupported():Z
|
||||
- p:processElement(com.intellij.openapi.progress.ProgressIndicator,com.intellij.util.Processor,com.intellij.ide.util.gotoByName.FilteringGotoByModel,java.lang.Object,I):Z
|
||||
- processSelectedItem(java.lang.Object,I,java.lang.String):Z
|
||||
- pf:processElement(com.intellij.openapi.progress.ProgressIndicator,com.intellij.util.Processor,com.intellij.ide.util.gotoByName.FilteringGotoByModel,java.lang.Object,I):Z
|
||||
- pf:triggerLineOrColumnFeatureUsed(com.intellij.pom.Navigatable,kotlin.coroutines.Continuation):java.lang.Object
|
||||
f:com.intellij.ide.actions.searcheverywhere.FileSearchEverywhereContributor$Companion
|
||||
- f:createFileTypeFilter(com.intellij.openapi.project.Project):com.intellij.ide.actions.searcheverywhere.PersistentSearchEverywhereContributorFilter
|
||||
a:com.intellij.ide.actions.searcheverywhere.FixedTabsListCustomizationStrategy
|
||||
|
||||
@@ -106,6 +106,9 @@ abstract class AbstractGotoSEContributor protected constructor(event: AnActionEv
|
||||
})
|
||||
}
|
||||
|
||||
protected val project: Project
|
||||
get() = myProject
|
||||
|
||||
companion object {
|
||||
fun createContext(project: Project?, psiContext: SmartPsiElementPointer<PsiElement?>?): DataContext {
|
||||
val parentContext = if (project == null) null else SimpleDataContext.getProjectContext(project)
|
||||
@@ -368,51 +371,58 @@ abstract class AbstractGotoSEContributor protected constructor(event: AnActionEv
|
||||
override fun showInFindResults(): Boolean = true
|
||||
|
||||
override fun processSelectedItem(selected: Any, modifiers: Int, searchText: String): Boolean {
|
||||
if (selected is PsiElement) {
|
||||
if (!selected.isValid) {
|
||||
LOG.warn("Cannot navigate to invalid PsiElement")
|
||||
return true
|
||||
}
|
||||
if (selected !is PsiElement) {
|
||||
EditSourceUtil.navigate((selected as NavigationItem), true, false)
|
||||
return true
|
||||
}
|
||||
|
||||
myProject.service<SearchEverywhereContributorCoroutineScopeHolder>().coroutineScope.launch(ClientId.coroutineContext()) {
|
||||
val command = readAction {
|
||||
val psiElement = preparePsi(selected, searchText)
|
||||
val extNavigatable = createExtendedNavigatable(psi = psiElement, searchText = searchText, modifiers = modifiers)
|
||||
val file = PsiUtilCore.getVirtualFile(psiElement)
|
||||
if (!selected.isValid) {
|
||||
LOG.warn("Cannot navigate to invalid PsiElement")
|
||||
return true
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
if ((modifiers and InputEvent.SHIFT_MASK) != 0 && file != null) {
|
||||
suspend {
|
||||
withContext(Dispatchers.EDT + ModalityState.nonModal().asContextElement()) {
|
||||
openInRightSplit(project = myProject, file = file, element = extNavigatable, requestFocus = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
suspend {
|
||||
if (extNavigatable == null) {
|
||||
val navigationRequests = serviceAsync<NavigationRequests>()
|
||||
readAction { navigationRequests.sourceNavigationRequest(myProject, file!!, -1, null) }?.let {
|
||||
myProject.serviceAsync<NavigationService>().navigate(it)
|
||||
}
|
||||
}
|
||||
else {
|
||||
myProject.serviceAsync<NavigationService>().navigate(extNavigatable)
|
||||
project.service<SearchEverywhereContributorCoroutineScopeHolder>().coroutineScope.launch(ClientId.coroutineContext()) {
|
||||
val command = readAction {
|
||||
val psiElement = preparePsi(selected, searchText)
|
||||
val extendedNavigatable = createExtendedNavigatable(psi = psiElement, searchText = searchText, modifiers = modifiers)
|
||||
val file = PsiUtilCore.getVirtualFile(psiElement)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
if ((modifiers and InputEvent.SHIFT_MASK) != 0 && file != null) {
|
||||
suspend {
|
||||
withContext(Dispatchers.EDT + ModalityState.nonModal().asContextElement()) {
|
||||
openInRightSplit(project = project, file = file, element = extendedNavigatable, requestFocus = true)
|
||||
if (extendedNavigatable != null) {
|
||||
triggerLineOrColumnFeatureUsed(extendedNavigatable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
command()
|
||||
else {
|
||||
suspend {
|
||||
if (extendedNavigatable == null) {
|
||||
val navigationRequests = serviceAsync<NavigationRequests>()
|
||||
readAction { navigationRequests.sourceNavigationRequest(project, file!!, -1, null) }?.let {
|
||||
project.serviceAsync<NavigationService>().navigate(it)
|
||||
}
|
||||
}
|
||||
else {
|
||||
project.serviceAsync<NavigationService>().navigate(extendedNavigatable)
|
||||
triggerLineOrColumnFeatureUsed(extendedNavigatable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
EditSourceUtil.navigate((selected as NavigationItem), true, false)
|
||||
|
||||
command()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
protected open suspend fun triggerLineOrColumnFeatureUsed(extendedNavigatable: Navigatable) {
|
||||
}
|
||||
|
||||
override fun getDataForItem(element: Any, dataId: String): Any? {
|
||||
if (CommonDataKeys.PSI_ELEMENT.`is`(dataId)) {
|
||||
when (element) {
|
||||
@@ -447,12 +457,10 @@ abstract class AbstractGotoSEContributor protected constructor(event: AnActionEv
|
||||
return null
|
||||
}
|
||||
|
||||
protected fun preparePsi(psiElement: PsiElement, searchText: String): PsiElement {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
var psiElement = psiElement
|
||||
val path = pathToAnonymousClass(searchText)
|
||||
if (path != null) {
|
||||
psiElement = getElement(psiElement, path)
|
||||
private fun preparePsi(originalPsiElement: PsiElement, searchText: String): PsiElement {
|
||||
var psiElement = originalPsiElement
|
||||
pathToAnonymousClass(searchText)?.let {
|
||||
psiElement = getElement(psiElement, it)
|
||||
}
|
||||
return psiElement.navigationElement
|
||||
}
|
||||
|
||||
@@ -113,10 +113,10 @@ public class ClassSearchEverywhereContributor extends AbstractGotoSEContributor
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Navigatable createExtendedNavigatable(PsiElement psi, String searchText, int modifiers) {
|
||||
Navigatable res = super.createExtendedNavigatable(psi, searchText, modifiers);
|
||||
if (res != null) {
|
||||
return res;
|
||||
protected @Nullable Navigatable createExtendedNavigatable(@NotNull PsiElement psi, @NotNull String searchText, int modifiers) {
|
||||
Navigatable result = super.createExtendedNavigatable(psi, searchText, modifiers);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
VirtualFile file = PsiUtilCore.getVirtualFile(psi);
|
||||
@@ -129,7 +129,6 @@ public class ClassSearchEverywhereContributor extends AbstractGotoSEContributor
|
||||
public void navigate(boolean requestFocus) {
|
||||
NavigationUtil.activateFileWithPsiElement(psi, false);
|
||||
delegate.navigate(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
// 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.actions.searcheverywhere
|
||||
|
||||
import com.intellij.codeWithMe.ClientId
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker
|
||||
import com.intellij.ide.IdeBundle
|
||||
import com.intellij.ide.actions.OpenInRightSplitAction.Companion.openInRightSplit
|
||||
import com.intellij.ide.actions.SearchEverywherePsiRenderer
|
||||
import com.intellij.ide.actions.searcheverywhere.SearchEverywhereFiltersStatisticsCollector.FileTypeFilterCollector
|
||||
import com.intellij.ide.actions.searcheverywhere.footer.createPsiExtendedInfo
|
||||
@@ -16,28 +14,19 @@ import com.intellij.ide.util.gotoByName.GotoFileModel
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.readAction
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.components.serviceAsync
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.platform.backend.navigation.NavigationRequests
|
||||
import com.intellij.platform.ide.navigation.NavigationService
|
||||
import com.intellij.pom.Navigatable
|
||||
import com.intellij.psi.PsiDirectory
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiFileSystemItem
|
||||
import com.intellij.ui.DirtyUI
|
||||
import com.intellij.util.Processor
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
import org.jetbrains.annotations.Nls
|
||||
import java.awt.event.InputEvent
|
||||
import javax.swing.JList
|
||||
import javax.swing.ListCellRenderer
|
||||
|
||||
@@ -79,7 +68,7 @@ open class FileSearchEverywhereContributor(event: AnActionEvent) : AbstractGotoS
|
||||
|
||||
override fun getActions(onChanged: Runnable): List<AnAction> = doGetActions(filter, FileTypeFilterCollector(), onChanged)
|
||||
|
||||
override fun getElementsRenderer(): ListCellRenderer<in Any?> {
|
||||
final override fun getElementsRenderer(): ListCellRenderer<in Any?> {
|
||||
return object : SearchEverywherePsiRenderer(this) {
|
||||
@DirtyUI
|
||||
override fun getItemMatchers(list: JList<*>, value: Any): ItemMatchers {
|
||||
@@ -92,7 +81,7 @@ open class FileSearchEverywhereContributor(event: AnActionEvent) : AbstractGotoS
|
||||
}
|
||||
}
|
||||
|
||||
override fun processElement(
|
||||
final override fun processElement(
|
||||
progressIndicator: ProgressIndicator,
|
||||
consumer: Processor<in FoundItemDescriptor<Any>>,
|
||||
model: FilteringGotoByModel<*>,
|
||||
@@ -111,45 +100,8 @@ open class FileSearchEverywhereContributor(event: AnActionEvent) : AbstractGotoS
|
||||
return consumer.process(FoundItemDescriptor(element, degree))
|
||||
}
|
||||
|
||||
override fun processSelectedItem(selected: Any, modifiers: Int, searchText: String): Boolean {
|
||||
if (selected is PsiFile) {
|
||||
val file = selected.virtualFile
|
||||
if (file == null) {
|
||||
return super.processSelectedItem(selected, modifiers, searchText)
|
||||
}
|
||||
|
||||
val lineAndColumn = getLineAndColumn(searchText)
|
||||
if (file.isValid) {
|
||||
if (lineAndColumn.first == -1 && lineAndColumn.second == -1) {
|
||||
myProject.service<SearchEverywhereContributorCoroutineScopeHolder>().coroutineScope.launch(ClientId.coroutineContext()) {
|
||||
val navigationRequests = serviceAsync<NavigationRequests>()
|
||||
readAction { navigationRequests.sourceNavigationRequest(myProject, file, -1, null) }?.let {
|
||||
myProject.serviceAsync<NavigationService>().navigate(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
val descriptor = OpenFileDescriptor(myProject, file, lineAndColumn.first, lineAndColumn.second)
|
||||
myProject.service<SearchEverywhereContributorCoroutineScopeHolder>().coroutineScope.launch(ClientId.coroutineContext()) {
|
||||
@Suppress("DEPRECATION")
|
||||
if ((modifiers and InputEvent.SHIFT_MASK) != 0) {
|
||||
withContext(Dispatchers.EDT) {
|
||||
openInRightSplit(project = myProject, file = file, element = descriptor, requestFocus = true)
|
||||
}
|
||||
}
|
||||
else {
|
||||
myProject.serviceAsync<NavigationService>().navigate(descriptor)
|
||||
}
|
||||
if (lineAndColumn.first > 0) {
|
||||
serviceAsync<FeatureUsageTracker>().triggerFeatureUsed("navigation.goto.file.line")
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return super.processSelectedItem(selected, modifiers, searchText)
|
||||
final override suspend fun triggerLineOrColumnFeatureUsed(extendedNavigatable: Navigatable) {
|
||||
serviceAsync<FeatureUsageTracker>().triggerFeatureUsed("navigation.goto.file.line")
|
||||
}
|
||||
|
||||
override fun getDataForItem(element: Any, dataId: String): Any? {
|
||||
|
||||
@@ -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.projectView.impl
|
||||
|
||||
import com.intellij.codeWithMe.ClientId
|
||||
@@ -10,7 +10,9 @@ import com.intellij.openapi.application.ReadConstraint
|
||||
import com.intellij.openapi.application.constrainedReadAction
|
||||
import com.intellij.openapi.application.readAction
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.components.serviceAsync
|
||||
import com.intellij.openapi.components.serviceOrNull
|
||||
import com.intellij.openapi.diagnostic.debug
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.fileEditor.FileEditor
|
||||
@@ -125,7 +127,7 @@ internal class SelectInProjectViewImpl(
|
||||
}
|
||||
|
||||
private suspend fun allEditors(): List<FileEditor> = withContext(Dispatchers.EDT) {
|
||||
val fileEditorManager = FileEditorManager.getInstance(project)
|
||||
val fileEditorManager = project.serviceAsync<FileEditorManager>()
|
||||
val result = mutableListOf<FileEditor?>()
|
||||
result.add(fileEditorManager.selectedEditor)
|
||||
result.addAll(fileEditorManager.selectedEditors)
|
||||
@@ -288,19 +290,13 @@ internal class SelectInProjectViewImpl(
|
||||
}
|
||||
|
||||
private suspend fun doSelectInAnyTarget(context: SelectInContext, targets: Collection<SelectInTarget>, requestFocus: Boolean) {
|
||||
if (LOG.isDebugEnabled) {
|
||||
LOG.debug("doSelectInAnyTarget: context=$context, targets=$targets, requestFocus=$requestFocus")
|
||||
}
|
||||
LOG.debug { "doSelectInAnyTarget: context=$context, targets=$targets, requestFocus=$requestFocus" }
|
||||
for (target in targets) {
|
||||
val canSelect = readAction { target.canSelect(context) }
|
||||
if (LOG.isDebugEnabled) {
|
||||
LOG.debug("${if (canSelect) "Can" else "Can NOT"} select $context in $target")
|
||||
}
|
||||
LOG.debug { "${if (canSelect) "Can" else "Can NOT"} select $context in $target" }
|
||||
if (canSelect) {
|
||||
withContext(Dispatchers.EDT) {
|
||||
if (LOG.isDebugEnabled) {
|
||||
LOG.debug("Selecting $context in $target")
|
||||
}
|
||||
LOG.debug { "Selecting $context in $target" }
|
||||
target.selectIn(context, requestFocus)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// 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.platform.ide.navigation.impl
|
||||
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.ide.ui.UISettings
|
||||
import com.intellij.ide.util.PsiNavigationSupport
|
||||
import com.intellij.injected.editor.VirtualFileWindow
|
||||
@@ -211,19 +210,11 @@ private suspend fun navigateToSource(
|
||||
descriptor.isUsePreviewTab = true
|
||||
}
|
||||
|
||||
val fileNavigator = serviceAsync<FileNavigator>()
|
||||
if (fileNavigator is FileNavigatorImpl &&
|
||||
withContext(Dispatchers.EDT) {
|
||||
blockingContext {
|
||||
fileNavigator.navigateInRequestedEditor(
|
||||
descriptor = descriptor,
|
||||
dataContextSupplier = {
|
||||
dataContext ?: @Suppress("DEPRECATION") DataManager.getInstance().dataContext
|
||||
},
|
||||
)
|
||||
}
|
||||
}) {
|
||||
return
|
||||
if (dataContext != null) {
|
||||
val fileNavigator = serviceAsync<FileNavigator>()
|
||||
if (fileNavigator is FileNavigatorImpl && fileNavigator.navigateInRequestedEditorAsync(descriptor, dataContext)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (openFile(request = request, descriptor = descriptor, options = options, openMode = openMode)) {
|
||||
@@ -243,7 +234,7 @@ private suspend fun openFile(
|
||||
): Boolean {
|
||||
val originalFile = descriptor.file
|
||||
val fileEditorManager = descriptor.project.serviceAsync<FileEditorManager>() as FileEditorManagerEx
|
||||
val effectiveDescriptor: FileEditorNavigatable
|
||||
val effectiveDescriptor: OpenFileDescriptor
|
||||
if (originalFile is VirtualFileWindow) {
|
||||
effectiveDescriptor = readAction {
|
||||
val hostOffset = originalFile.documentWindow.injectedToHost(descriptor.offset)
|
||||
@@ -270,8 +261,8 @@ private suspend fun openFile(
|
||||
return false
|
||||
}
|
||||
|
||||
val currentCompositeForFile = fileEditorManager.getComposite(file) as? EditorComposite
|
||||
val elementRange = if (options.preserveCaret) request.elementRangeMarker?.takeIf { it.isValid }?.textRange else null
|
||||
val currentCompositeForFile = fileEditorManager.getComposite(file) as? EditorComposite
|
||||
if (elementRange != null) {
|
||||
for (editor in fileEditors) {
|
||||
if (editor is TextEditor) {
|
||||
@@ -284,6 +275,11 @@ private suspend fun openFile(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (effectiveDescriptor.line == -1 && effectiveDescriptor.column == -1 && effectiveDescriptor.offset == -1) {
|
||||
return true
|
||||
}
|
||||
|
||||
suspend fun tryNavigate(filter: (NavigatableFileEditor) -> Boolean): Boolean {
|
||||
for (editor in fileEditors) {
|
||||
// try to navigate opened editor
|
||||
|
||||
@@ -3,12 +3,17 @@ package com.intellij.openapi.fileEditor
|
||||
|
||||
import com.intellij.ide.DataManager
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.components.serviceAsync
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager
|
||||
import com.intellij.openapi.fileTypes.INativeFileType
|
||||
import com.intellij.openapi.progress.blockingContext
|
||||
import com.intellij.pom.Navigatable
|
||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
|
||||
@@ -51,18 +56,16 @@ class FileNavigatorImpl : FileNavigator {
|
||||
}
|
||||
|
||||
override fun navigateInEditor(descriptor: OpenFileDescriptor, requestFocus: Boolean): Boolean {
|
||||
return navigateInRequestedEditor(descriptor, dataContextSupplier = {
|
||||
@Suppress("DEPRECATION")
|
||||
DataManager.getInstance().dataContext
|
||||
}) || navigateInAnyFileEditor(descriptor, requestFocus)
|
||||
return navigateInRequestedEditor(descriptor) || navigateInAnyFileEditor(descriptor, requestFocus)
|
||||
}
|
||||
|
||||
fun navigateInRequestedEditor(descriptor: OpenFileDescriptor, dataContextSupplier: () -> DataContext): Boolean {
|
||||
fun navigateInRequestedEditor(descriptor: OpenFileDescriptor): Boolean {
|
||||
if (ignoreContextEditor.get() == true) {
|
||||
return false
|
||||
}
|
||||
|
||||
val dataContext = dataContextSupplier()
|
||||
@Suppress("DEPRECATION")
|
||||
val dataContext = DataManager.getInstance().dataContext
|
||||
val e = OpenFileDescriptor.NAVIGATE_IN_EDITOR.getData(dataContext) ?: return false
|
||||
if (e.isDisposed) {
|
||||
logger<FileNavigatorImpl>().error("Disposed editor returned for NAVIGATE_IN_EDITOR from $dataContext")
|
||||
@@ -75,6 +78,25 @@ class FileNavigatorImpl : FileNavigator {
|
||||
return true
|
||||
}
|
||||
|
||||
suspend fun navigateInRequestedEditorAsync(descriptor: OpenFileDescriptor, dataContext: DataContext): Boolean {
|
||||
val e = OpenFileDescriptor.NAVIGATE_IN_EDITOR.getData(dataContext) ?: return false
|
||||
if (e.isDisposed) {
|
||||
logger<FileNavigatorImpl>().error("Disposed editor returned for NAVIGATE_IN_EDITOR from $dataContext")
|
||||
return false
|
||||
}
|
||||
|
||||
if (serviceAsync<FileDocumentManager>().getFile(e.document) != descriptor.file) {
|
||||
return false
|
||||
}
|
||||
|
||||
withContext(Dispatchers.EDT) {
|
||||
blockingContext {
|
||||
OpenFileDescriptor.navigateInEditor(descriptor, e)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
fun navigateIgnoringContextEditor(navigatable: Navigatable): Boolean {
|
||||
if (!navigatable.canNavigate()) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.intellij.ide.actions.searcheverywhere.PsiItemWithSimilarity
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.searchEverywhereMl.SemanticSearchEverywhereContributor
|
||||
import com.intellij.searchEverywhereMl.semantics.providers.SemanticClassesProvider
|
||||
@@ -23,8 +22,6 @@ import java.util.function.Consumer
|
||||
class SemanticClassSearchEverywhereContributor(initEvent: AnActionEvent)
|
||||
: ClassSearchEverywhereContributor(initEvent), SemanticSearchEverywhereContributor,
|
||||
SearchEverywhereConcurrentPsiElementsFetcher, PossibleSlowContributor {
|
||||
private val project = initEvent.project ?: ProjectManager.getInstance().openProjects[0]
|
||||
|
||||
override val itemsProvider = SemanticClassesProvider(project)
|
||||
|
||||
override var notifyCallback: Consumer<String>? = null
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.intellij.ide.actions.searcheverywhere.PsiItemWithSimilarity
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.searchEverywhereMl.SemanticSearchEverywhereContributor
|
||||
import com.intellij.searchEverywhereMl.semantics.providers.SemanticFilesProvider
|
||||
@@ -27,8 +26,6 @@ import java.util.function.Consumer
|
||||
open class SemanticFileSearchEverywhereContributor(initEvent: AnActionEvent)
|
||||
: FileSearchEverywhereContributor(initEvent), SemanticSearchEverywhereContributor,
|
||||
SearchEverywhereConcurrentPsiElementsFetcher, PossibleSlowContributor {
|
||||
private val project = initEvent.project ?: ProjectManager.getInstance().openProjects[0]
|
||||
|
||||
override val itemsProvider = SemanticFilesProvider(project)
|
||||
|
||||
override var notifyCallback: Consumer<String>? = null
|
||||
|
||||
@@ -2,14 +2,13 @@ package com.intellij.searchEverywhereMl.semantics.contributors
|
||||
|
||||
import com.intellij.concurrency.SensitiveProgressWrapper
|
||||
import com.intellij.ide.actions.SearchEverywherePsiRenderer
|
||||
import com.intellij.ide.actions.searcheverywhere.SymbolSearchEverywhereContributor
|
||||
import com.intellij.ide.actions.searcheverywhere.FoundItemDescriptor
|
||||
import com.intellij.ide.actions.searcheverywhere.PossibleSlowContributor
|
||||
import com.intellij.ide.actions.searcheverywhere.PsiItemWithSimilarity
|
||||
import com.intellij.ide.actions.searcheverywhere.SymbolSearchEverywhereContributor
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.searchEverywhereMl.SemanticSearchEverywhereContributor
|
||||
import com.intellij.searchEverywhereMl.semantics.providers.SemanticSymbolsProvider
|
||||
@@ -28,8 +27,6 @@ import java.util.function.Consumer
|
||||
class SemanticSymbolSearchEverywhereContributor(initEvent: AnActionEvent)
|
||||
: SymbolSearchEverywhereContributor(initEvent), SemanticSearchEverywhereContributor,
|
||||
SearchEverywhereConcurrentPsiElementsFetcher, PossibleSlowContributor {
|
||||
private val project = initEvent.project ?: ProjectManager.getInstance().openProjects[0]
|
||||
|
||||
override val itemsProvider = SemanticSymbolsProvider(project)
|
||||
|
||||
override var notifyCallback: Consumer<String>? = null
|
||||
|
||||
Reference in New Issue
Block a user