-
Notifications
You must be signed in to change notification settings - Fork 423
Allow to update multiple projects at the same time #2131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
org.eclipse.jdt.ls.core/src/org/eclipse/lsp4j/extended/ProjectConfigurationsUpdateParam.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Microsoft Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.lsp4j.extended; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.lsp4j.TextDocumentIdentifier; | ||
import org.eclipse.lsp4j.jsonrpc.validation.NonNull; | ||
import org.eclipse.lsp4j.util.Preconditions; | ||
import org.eclipse.xtext.xbase.lib.Pure; | ||
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder; | ||
|
||
@SuppressWarnings("all") | ||
public class ProjectConfigurationsUpdateParam { | ||
/** | ||
* The text document's identifiers. | ||
*/ | ||
@NonNull | ||
private List<TextDocumentIdentifier> identifiers; | ||
|
||
public ProjectConfigurationsUpdateParam() { | ||
} | ||
|
||
public ProjectConfigurationsUpdateParam(@NonNull final List<TextDocumentIdentifier> identifiers) { | ||
this.identifiers = Preconditions.<List<TextDocumentIdentifier>>checkNotNull(identifiers, "identifiers"); | ||
} | ||
|
||
@Pure | ||
@NonNull | ||
public List<TextDocumentIdentifier> getIdentifiers() { | ||
return identifiers; | ||
} | ||
|
||
public void setIdentifiers(@NonNull final List<TextDocumentIdentifier> identifiers) { | ||
this.identifiers = Preconditions.<List<TextDocumentIdentifier>>checkNotNull(identifiers, "identifiers"); | ||
} | ||
|
||
@Override | ||
@Pure | ||
public String toString() { | ||
ToStringBuilder b = new ToStringBuilder(this); | ||
b.add("identifiers", this.identifiers); | ||
return b.toString(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((identifiers == null) ? 0 : identifiers.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
ProjectConfigurationsUpdateParam other = (ProjectConfigurationsUpdateParam) obj; | ||
if (identifiers == null) { | ||
if (other.identifiers != null) | ||
return false; | ||
} else if (!identifiers.equals(other.identifiers)) | ||
return false; | ||
return true; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
.../src/org/eclipse/jdt/ls/core/internal/handlers/ProjectConfigurationUpdateHandlerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Microsoft Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.jdt.ls.core.internal.handlers; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyBoolean; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.jdt.ls.core.internal.WorkspaceHelper; | ||
import org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest; | ||
import org.eclipse.jdt.ls.core.internal.managers.ProjectsManager; | ||
import org.eclipse.lsp4j.TextDocumentIdentifier; | ||
import org.eclipse.lsp4j.extended.ProjectConfigurationsUpdateParam; | ||
import org.junit.Test; | ||
|
||
public class ProjectConfigurationUpdateHandlerTest extends AbstractProjectsManagerBasedTest { | ||
|
||
@Test | ||
public void testUpdateConfiguration() throws Exception { | ||
importProjects("maven/multimodule"); | ||
ProjectsManager pm = mock(ProjectsManager.class); | ||
when(pm.updateProject(any(IProject.class), anyBoolean())).thenReturn(null); | ||
ProjectConfigurationUpdateHandler handler = new ProjectConfigurationUpdateHandler(pm); | ||
IProject project = WorkspaceHelper.getProject("multimodule"); | ||
handler.updateConfiguration(new TextDocumentIdentifier(project.getLocationURI().toString())); | ||
verify(pm, times(1)).updateProject(any(IProject.class), eq(true)); | ||
} | ||
|
||
@Test | ||
public void testUpdateConfigurations() throws Exception { | ||
importProjects("maven/multimodule"); | ||
ProjectsManager pm = mock(ProjectsManager.class); | ||
when(pm.updateProject(any(IProject.class), anyBoolean())).thenReturn(null); | ||
ProjectConfigurationUpdateHandler handler = new ProjectConfigurationUpdateHandler(pm); | ||
List<TextDocumentIdentifier> list = new ArrayList<>(); | ||
IProject project = WorkspaceHelper.getProject("module1"); | ||
list.add(new TextDocumentIdentifier(project.getLocationURI().toString())); | ||
project = WorkspaceHelper.getProject("module2"); | ||
list.add(new TextDocumentIdentifier(project.getLocationURI().toString())); | ||
|
||
ProjectConfigurationsUpdateParam param = new ProjectConfigurationsUpdateParam(list); | ||
|
||
handler.updateConfigurations(param.getIdentifiers()); | ||
verify(pm, times(2)).updateProject(any(IProject.class), eq(true)); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.