Skip to content

Commit

Permalink
Add an extendedClientCapability to skip project configuration.
Browse files Browse the repository at this point in the history
In some contexts (eg running inside Eclipse IDE), the project
configuration is already present and maintained, so JDT-LS shouldn't try
to override it.
  • Loading branch information
mickaelistria authored and rgrunber committed Mar 28, 2023
1 parent 00391c1 commit 9514370
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,10 @@ public CompletableFuture<BuildWorkspaceStatus> buildProjects(ProjectBuildParams
@Override
public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) {
logInfo(">> java/didChangeWorkspaceFolders");
WorkspaceFolderChangeHandler handler = new WorkspaceFolderChangeHandler(pm, preferenceManager);
handler.update(params);
if (!preferenceManager.getClientPreferences().skipProjectConfiguration()) {
WorkspaceFolderChangeHandler handler = new WorkspaceFolderChangeHandler(pm, preferenceManager);
handler.update(params);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,22 @@ public ProjectsManager(PreferenceManager preferenceManager) {

@Override
public void initializeProjects(final Collection<IPath> rootPaths, IProgressMonitor monitor) throws CoreException, OperationCanceledException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
cleanInvalidProjects(rootPaths, subMonitor.split(20));
createJavaProject(getDefaultProject(), subMonitor.split(10));
cleanupResources(getDefaultProject());
Collection<IPath> projectConfigurations = preferenceManager.getPreferences().getProjectConfigurations();
if (projectConfigurations == null) {
// old way to import project
importProjects(rootPaths, subMonitor.split(70));
} else {
importProjectsFromConfigurationFiles(rootPaths, projectConfigurations, monitor);
if (!preferenceManager.getClientPreferences().skipProjectConfiguration()) {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
cleanInvalidProjects(rootPaths, subMonitor.split(20));
createJavaProject(getDefaultProject(), subMonitor.split(10));
cleanupResources(getDefaultProject());
Collection<IPath> projectConfigurations = preferenceManager.getPreferences().getProjectConfigurations();
if (projectConfigurations == null) {
// old way to import project
importProjects(rootPaths, subMonitor.split(70));
} else {
importProjectsFromConfigurationFiles(rootPaths, projectConfigurations, monitor);
}
updateEncoding(monitor);
reportProjectsStatus();
subMonitor.done();
}
updateEncoding(monitor);
reportProjectsStatus();
subMonitor.done();
}

private void updateEncoding(IProgressMonitor monitor) throws CoreException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ public boolean isChangeAnnotationSupport() {
&& capabilities.getWorkspace() != null
&& capabilities.getWorkspace().getWorkspaceEdit() != null
&& capabilities.getWorkspace().getWorkspaceEdit().getChangeAnnotationSupport() != null;
}

public boolean skipProjectConfiguration() {
return Boolean.parseBoolean(extendedClientCapabilities.getOrDefault("skipProjectConfiguration", "false").toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal;

import java.util.Map;

import org.eclipse.lsp4j.ClientCapabilities;
import org.junit.AfterClass;
import org.junit.BeforeClass;

Expand All @@ -23,6 +26,7 @@ public abstract class AbstractWorkspaceTest {

@BeforeClass
public static void initWorkspace() throws Exception {
JavaLanguageServerPlugin.getPreferencesManager().updateClientPrefences(new ClientCapabilities(), Map.of());
WorkspaceHelper.initWorkspace();
}

Expand Down

0 comments on commit 9514370

Please sign in to comment.