@@ -7,6 +7,8 @@ import com.github.continuedev.continueintellijextension.utils.*
7
7
import com.intellij.codeInsight.daemon.impl.HighlightInfo
8
8
import com.intellij.execution.configurations.GeneralCommandLine
9
9
import com.intellij.execution.util.ExecUtil
10
+ import com.intellij.find.FindModel
11
+ import com.intellij.find.impl.FindInProjectUtil
10
12
import com.intellij.ide.plugins.PluginManager
11
13
import com.intellij.ide.plugins.PluginManagerCore
12
14
import com.intellij.lang.annotation.HighlightSeverity
@@ -20,15 +22,19 @@ import com.intellij.openapi.editor.impl.DocumentMarkupModel
20
22
import com.intellij.openapi.extensions.PluginId
21
23
import com.intellij.openapi.fileEditor.FileDocumentManager
22
24
import com.intellij.openapi.fileEditor.FileEditorManager
25
+ import com.intellij.openapi.progress.EmptyProgressIndicator
23
26
import com.intellij.openapi.project.Project
24
27
import com.intellij.openapi.project.guessProjectDir
28
+ import com.intellij.openapi.roots.ProjectFileIndex
25
29
import com.intellij.openapi.util.IconLoader
26
30
import com.intellij.openapi.vfs.LocalFileSystem
27
31
import com.intellij.openapi.vfs.VirtualFileManager
28
32
import com.intellij.psi.PsiDocumentManager
29
33
import com.intellij.psi.search.FilenameIndex
30
34
import com.intellij.psi.search.GlobalSearchScope
31
35
import com.intellij.testFramework.LightVirtualFile
36
+ import com.intellij.usages.FindUsagesProcessPresentation
37
+ import com.intellij.usages.UsageViewPresentation
32
38
import kotlinx.coroutines.*
33
39
import java.awt.Toolkit
34
40
import java.awt.datatransfer.DataFlavor
@@ -327,58 +333,67 @@ class IntelliJIDE(
327
333
return listOf (" " )
328
334
}
329
335
override suspend fun getSearchResults (query : String ): String {
330
- // val findModel = FindModel().apply {
331
- // stringToFind = searchText
332
- // isRegularExpressions = false
333
- // isWholeWordsOnly = false
334
- // isCaseSensitive = false
335
- // searchContext = FindModel.SearchContext.ANY
336
- // isGlobal = true
337
- // }
338
-
339
- // val findManager = FindManager.getInstance(project)
340
- // val scope = GlobalSearchScope.projectScope(project)
341
-
342
- // FindInProjectUtil.findUsages(
343
- // findModel,
344
- // project.basePath,
345
- // project,
346
- // {
347
- // // Process each found usage
348
- // val virtualFile = it.virtualFile
349
- // val lineNumber = it.line
350
- // // Handle result
351
- // },
352
- // scope
353
- // )
354
-
355
- // return withContext(Dispatchers.IO) {
356
- // val findModel = FindModel().apply {
357
- // stringToFind = query
358
- // isRegularExpressions = false
359
- // isWholeWordsOnly = false
360
- // isCaseSensitive = false
361
- // searchContext = UsageSearchContext.ANY
362
- // }
336
+ val ideInfo = this .getIdeInfo()
337
+ if (ideInfo.remoteName != " local" ) {
338
+ val command = GeneralCommandLine (
339
+ ripgrep,
340
+ " -i" ,
341
+ " --ignore-file" ,
342
+ " .continueignore" ,
343
+ " --ignore-file" ,
344
+ " .gitignore" ,
345
+ " -C" ,
346
+ " 2" ,
347
+ " --heading" ,
348
+ " -e" ,
349
+ query,
350
+ " ."
351
+ )
363
352
364
- // val results = StringBuilder()
365
- // runReadAction {
366
- // FindInProjectUtil.findUsages(
367
- // findModel,
368
- // project.baseDir,
369
- // {
370
- // results.append("${it.file.path}:${it.line + 1}: ${it.lineText}\n")
371
- // true
372
- // },
373
- // null
374
- // )
375
- // }
376
- // results.toString()
377
- // }
378
- val command = GeneralCommandLine (ripgrep, " -i" , " -C" , " 2" , " --heading" , " -e" , query, " ." )
379
- command.setWorkDirectory(project.basePath)
380
- return ExecUtil .execAndGetOutput(command).stdout
381
- }
353
+ command.setWorkDirectory(project.basePath)
354
+ return ExecUtil .execAndGetOutput(command).stdout
355
+ } else {
356
+ return " Ripgrep not supported, this workspace is remote"
357
+ // For remote workspaces, use JetBrains search functionality
358
+ // val searchResults = StringBuilder()
359
+ // ApplicationManager.getApplication().invokeAndWait {
360
+ // val options = FindModel().apply {
361
+ // stringToFind = query
362
+ // isCaseSensitive = false
363
+ // isRegularExpressions = false
364
+ // isWholeWordsOnly = false
365
+ // searchContext = FindModel.SearchContext.ANY // or IN_CODE, IN_COMMENTS, IN_STRING_LITERALS, etc.
366
+ // isMultiline = true // Allow matching across multiple lines
367
+ // }
368
+ //
369
+ // val progressIndicator = EmptyProgressIndicator()
370
+ // val presentation = FindUsagesProcessPresentation(
371
+ // UsageViewPresentation()
372
+ // )
373
+ // val filesToSearch = ProjectFileIndex.getInstance(project)
374
+ // .iterateContent(::ArrayList)
375
+ // .filterNot { it.isDirectory }
376
+ // .toSet()
377
+ //
378
+ //
379
+ // FindInProjectUtil.findUsages(
380
+ // options,
381
+ // project,
382
+ // progressIndicator,
383
+ // presentation,
384
+ // filesToSearch
385
+ // ) { result ->
386
+ // val virtualFile = result.virtualFile
387
+ // searchResults.append(virtualFile.path).append("\n")
388
+ // searchResults.append("${result..trim()}\n")
389
+ // true // continue searching
390
+ // }
391
+ // }
392
+ // return searchResults.toString()
393
+ //
394
+ // val scope = GlobalSearchScope.projectScope(project)
395
+ }
396
+ }
382
397
383
398
override suspend fun subprocess (command : String , cwd : String? ): List <Any > {
384
399
val commandList = command.split(" " )
0 commit comments