Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ export class Core {
if (data?.shouldClearIndexes) {
await this.codeBaseIndexer.clearIndexes();
}

const dirs = data?.dirs ?? (await this.ide.getWorkspaceDirs());
await this.codeBaseIndexer.refreshCodebaseIndex(dirs);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import java.nio.charset.StandardCharsets
import java.nio.file.Paths
import javax.swing.*
import com.intellij.openapi.components.service
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.project.ModuleListener
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.vfs.newvfs.BulkFileListener
Expand All @@ -39,6 +41,7 @@ import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent
import com.intellij.ide.ui.LafManagerListener
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.Function

fun showTutorial(project: Project) {
val tutorialFileName = getTutorialFileName()
Expand Down Expand Up @@ -193,6 +196,41 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
}
})

// Handle workspace directories changes
connection.subscribe(
ModuleListener.TOPIC,
object : ModuleListener {
override fun modulesAdded(project: Project, modules: MutableList<out Module>) {

val allModulePaths = ModuleManager.getInstance(project).modules
.flatMap { module -> ModuleRootManager.getInstance(module).contentRoots.mapNotNull { it.toUriOrNull() } }

val topLevelModulePaths = allModulePaths
.filter { modulePath -> allModulePaths.none { it != modulePath && modulePath.startsWith(it) } }

continuePluginService.workspacePaths = topLevelModulePaths.toTypedArray();
}

override fun moduleRemoved(project: Project, module: Module) {
val removedPaths = ModuleRootManager.getInstance(module).contentRoots.mapNotNull { it.toUriOrNull() } ;
continuePluginService.workspacePaths = continuePluginService.workspacePaths?.toList()?.filter { path -> removedPaths.none {removedPath -> path == removedPath }}?.toTypedArray();
}

override fun modulesRenamed(
project: Project,
modules: MutableList<out Module>,
oldNameProvider: Function<in Module, String>
) {
val allModulePaths = ModuleManager.getInstance(project).modules
.flatMap { module -> ModuleRootManager.getInstance(module).contentRoots.mapNotNull { it.toUriOrNull() } }

val topLevelModulePaths = allModulePaths
.filter { modulePath -> allModulePaths.none { it != modulePath && modulePath.startsWith(it) } }

continuePluginService.workspacePaths = topLevelModulePaths.toTypedArray()
}
}
)

connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, object : FileEditorManagerListener {
override fun fileClosed(source: FileEditorManager, file: VirtualFile) {
Expand Down
15 changes: 15 additions & 0 deletions extensions/vscode/src/extension/VsCodeExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,21 @@ export class VsCodeExtension {
});
});

vscode.workspace.onDidChangeWorkspaceFolders(async (event) => {
const dirs = vscode.workspace.workspaceFolders?.map(
(folder) => folder.uri,
);

this.ideUtils.setWokspaceDirectories(dirs);

this.core.invoke("index/forceReIndex", {
dirs: [
...event.added.map((folder) => folder.uri.toString()),
...event.removed.map((folder) => folder.uri.toString()),
],
});
});

vscode.workspace.onDidOpenTextDocument(async (event) => {
console.log("onDidOpenTextDocument");
const ast = await getAst(event.fileName, event.getText());
Expand Down
4 changes: 4 additions & 0 deletions extensions/vscode/src/util/ideUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export class VsCodeIdeUtils {
return this._workspaceDirectories;
}

setWokspaceDirectories(dirs: vscode.Uri[] | undefined): void {
this._workspaceDirectories = dirs;
}

getUniqueId() {
return getUniqueId();
}
Expand Down
Loading