Skip to content
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
cc6614a
Initial plan
Copilot Dec 14, 2025
1f91a40
Implement multi-workspace support with WorkspaceContextManager
Copilot Dec 14, 2025
53fc8ea
Fix didChange URI handling and ensure backward compatibility
Copilot Dec 14, 2025
4494c04
Add URI scheme validation in WorkspaceContext.contains()
Copilot Dec 14, 2025
1242dbb
Add comprehensive tests for WorkspaceContextManager
Copilot Dec 14, 2025
346de9e
Simplify architecture: remove WorkspaceContext, rename to ServerConte…
Copilot Dec 14, 2025
ee5dab8
Translate JavaDoc to Russian and remove @Deprecated from private fields
Copilot Dec 14, 2025
cccfebf
Remove backward compatibility, use Absolute.uri in getContextForDocument
Copilot Dec 14, 2025
0769e4f
Update tests to register workspaces, revert SymbolProviderTest
Copilot Dec 14, 2025
6ffc8fa
Add fallback for old LSP clients using rootUri/rootPath
Copilot Dec 14, 2025
f235d9d
Use Absolute.uri instead of URI constructor in ServerContextProvider
Copilot Dec 14, 2025
9cf5e78
Use Spring ObjectProvider for ServerContext creation, add ServerConte…
Copilot Dec 14, 2025
96cb67c
Remove logging from initialize path, use Absolute.path for URI-to-Pat…
Copilot Dec 14, 2025
f494065
Reuse already created URI variable in Absolute.path call
Copilot Dec 14, 2025
62f7494
Remove unused ConfigurableBeanFactory import, change initialize loggi…
Copilot Dec 14, 2025
7329dd0
Fix multi-workspace support: remove prototype scope, create ServerCon…
Copilot Dec 14, 2025
c95e2c9
Restore @Scope(prototype) for ServerContext and fix tests to use Obje…
Copilot Dec 14, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration;
import com.github._1c_syntax.bsl.languageserver.context.ServerContext;
import com.github._1c_syntax.bsl.languageserver.context.ServerContextProvider;
import com.github._1c_syntax.bsl.languageserver.jsonrpc.DiagnosticParams;
import com.github._1c_syntax.bsl.languageserver.jsonrpc.Diagnostics;
import com.github._1c_syntax.bsl.languageserver.jsonrpc.ProtocolExtension;
Expand Down Expand Up @@ -62,6 +63,8 @@
import org.eclipse.lsp4j.TextDocumentClientCapabilities;
import org.eclipse.lsp4j.TextDocumentSyncKind;
import org.eclipse.lsp4j.TextDocumentSyncOptions;
import org.eclipse.lsp4j.WorkspaceFoldersOptions;
import org.eclipse.lsp4j.WorkspaceServerCapabilities;
import org.eclipse.lsp4j.WorkspaceSymbolOptions;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.eclipse.lsp4j.services.LanguageServer;
Expand Down Expand Up @@ -97,7 +100,7 @@ public class BSLLanguageServer implements LanguageServer, ProtocolExtension {
private final BSLWorkspaceService workspaceService;
private final CommandProvider commandProvider;
private final ClientCapabilitiesHolder clientCapabilitiesHolder;
private final ServerContext context;
private final ServerContextProvider serverContextProvider;
private final ServerInfo serverInfo;
private final SemanticTokensLegend legend;

Expand Down Expand Up @@ -131,6 +134,7 @@ public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
capabilities.setExecuteCommandProvider(getExecuteCommandProvider());
capabilities.setDiagnosticProvider(getDiagnosticProvider());
capabilities.setSemanticTokensProvider(getSemanticTokensProvider());
capabilities.setWorkspace(getWorkspaceCapabilities());

var result = new InitializeResult(capabilities, serverInfo);

Expand All @@ -143,31 +147,29 @@ private void setConfigurationRoot(InitializeParams params) {
return;
}

var rootUri = workspaceFolders.get(0).getUri();
Path rootPath;
try {
rootPath = new File(new URI(rootUri).getPath()).getCanonicalFile().toPath();
} catch (URISyntaxException | IOException e) {
LOGGER.error("Can't read root URI from initialization params.", e);
return;
}

var configurationRoot = LanguageServerConfiguration.getCustomConfigurationRoot(
configuration,
rootPath);
context.setConfigurationRoot(configurationRoot);
// Добавляем все workspace folders
workspaceFolders.forEach(serverContextProvider::addWorkspace);
}

@Override
public void initialized(InitializedParams params) {
var factory = new NamedForkJoinWorkerThreadFactory("populate-context-");
var executorService = new ForkJoinPool(ForkJoinPool.getCommonPoolParallelism(), factory, null, true);
CompletableFuture
.runAsync(context::populateContext, executorService)

// Populate all workspace contexts
var allContexts = serverContextProvider.getAllContexts();
var tasks = allContexts.stream()
.map(serverContext -> CompletableFuture.runAsync(
serverContext::populateContext,
executorService
))
.toArray(CompletableFuture[]::new);

CompletableFuture.allOf(tasks)
.whenComplete((Void unused, @Nullable Throwable throwable) -> {
executorService.shutdown();
if (throwable != null) {
LOGGER.error("Error populating context", throwable);
LOGGER.error("Error populating workspace contexts", throwable);
}
});
}
Expand All @@ -176,7 +178,7 @@ public void initialized(InitializedParams params) {
public CompletableFuture<Object> shutdown() {
shutdownWasCalled = true;
textDocumentService.reset();
context.clear();
serverContextProvider.clear();
return CompletableFuture.completedFuture(Boolean.TRUE);
}

Expand Down Expand Up @@ -384,4 +386,15 @@ private SemanticTokensWithRegistrationOptions getSemanticTokensProvider() {
return semanticTokensProvider;
}

private static WorkspaceServerCapabilities getWorkspaceCapabilities() {
var workspaceCapabilities = new WorkspaceServerCapabilities();

var workspaceFoldersOptions = new WorkspaceFoldersOptions();
workspaceFoldersOptions.setSupported(Boolean.TRUE);
workspaceFoldersOptions.setChangeNotifications(Boolean.TRUE);

workspaceCapabilities.setWorkspaceFolders(workspaceFoldersOptions);
return workspaceCapabilities;
}

}
Loading