Skip to content

Commit 475fe88

Browse files
committed
use custom notifcation param type for index update events
1 parent 74024b5 commit 475fe88

File tree

6 files changed

+74
-34
lines changed

6 files changed

+74
-34
lines changed

eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
import org.springframework.ide.vscode.commons.protocol.java.ProjectGavParams;
8686
import org.springframework.ide.vscode.commons.protocol.java.TypeData;
8787
import org.springframework.ide.vscode.commons.protocol.java.TypeDescriptorData;
88+
import org.springframework.ide.vscode.commons.protocol.spring.IndexUpdatedParams;
8889
import org.springframework.tooling.jdt.ls.commons.Logger;
8990
import org.springframework.tooling.jdt.ls.commons.classpath.ReusableClasspathListenerHandler;
9091
import org.springframework.tooling.jdt.ls.commons.java.BuildInfo;
@@ -633,7 +634,7 @@ public void liveProcessMemoryMetricsDataUpdated(LiveProcessSummary arg0) {
633634
}
634635

635636
@Override
636-
public void indexUpdated(List<String> affectedProjects) {
637+
public void indexUpdated(IndexUpdatedParams indexUpdateDetails) {
637638
}
638639

639640
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Broadcom
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Broadcom - initial API and implementation
10+
*******************************************************************************/
11+
package org.springframework.ide.vscode.commons.protocol.spring;
12+
13+
import java.util.List;
14+
15+
public class IndexUpdatedParams {
16+
17+
private List<String> affectedProjects;
18+
19+
public List<String> getAffectedProjects() {
20+
return affectedProjects;
21+
}
22+
23+
public void setAffectedProjects(List<String> affectedProjects) {
24+
this.affectedProjects = affectedProjects;
25+
}
26+
27+
public static IndexUpdatedParams of(List<String> affectedProjects) {
28+
IndexUpdatedParams params = new IndexUpdatedParams();
29+
params.setAffectedProjects(affectedProjects);
30+
return params;
31+
}
32+
33+
public static IndexUpdatedParams of(String affectedProject) {
34+
IndexUpdatedParams params = new IndexUpdatedParams();
35+
params.setAffectedProjects(List.of(affectedProject));
36+
return params;
37+
}
38+
39+
}

headless-services/commons/commons-lsp-extensions/src/main/java/org/springframework/ide/vscode/commons/protocol/spring/SpringIndexLanguageClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
*******************************************************************************/
1111
package org.springframework.ide.vscode.commons.protocol.spring;
1212

13-
import java.util.List;
14-
1513
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification;
1614
import org.eclipse.lsp4j.services.LanguageClient;
1715

1816
public interface SpringIndexLanguageClient extends LanguageClient {
1917

2018
@JsonNotification("spring/index/updated")
21-
void indexUpdated(List<String> affectedProjects);
19+
void indexUpdated(IndexUpdatedParams indexUpdateDetails);
2220

2321
}

headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
import org.springframework.ide.vscode.commons.protocol.java.ProjectGavParams;
138138
import org.springframework.ide.vscode.commons.protocol.java.TypeData;
139139
import org.springframework.ide.vscode.commons.protocol.java.TypeDescriptorData;
140+
import org.springframework.ide.vscode.commons.protocol.spring.IndexUpdatedParams;
140141
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
141142
import org.springframework.ide.vscode.commons.util.IOUtil;
142143
import org.springframework.ide.vscode.commons.util.UriUtil;
@@ -176,7 +177,7 @@ public class LanguageServerHarness {
176177

177178
private boolean enableHierarchicalDocumentSymbols = false;
178179

179-
private List<List<String>> indexUpdated = new ArrayList<>();
180+
private List<IndexUpdatedParams> indexUpdated = new ArrayList<>();
180181

181182

182183
public LanguageServerHarness(SimpleLanguageServer server, LanguageId defaultLanguageId) {
@@ -262,15 +263,15 @@ private void receiveHighlights(HighlightParams highlights) {
262263
}
263264
}
264265

265-
private void receiveIndexUpdated(List<String> affectedProjects) {
266-
this.indexUpdated.add(affectedProjects);
266+
private void receiveIndexUpdated(IndexUpdatedParams indexUpdatedParams) {
267+
this.indexUpdated.add(indexUpdatedParams);
267268
}
268269

269270
public int getIndexUpdatedCount() {
270271
return this.indexUpdated.size();
271272
}
272273

273-
public List<String> getIndexUpdatedDetails(int updateNo) {
274+
public IndexUpdatedParams getIndexUpdatedDetails(int updateNo) {
274275
return this.indexUpdated.get(updateNo);
275276
}
276277

@@ -457,8 +458,8 @@ public void liveProcessGcPausesMetricsDataUpdated(LiveProcessSummary processKey)
457458
}
458459

459460
@Override
460-
public void indexUpdated(List<String> affectedProjects) {
461-
receiveIndexUpdated(affectedProjects);
461+
public void indexUpdated(IndexUpdatedParams indexUpdatedParams) {
462+
receiveIndexUpdated(indexUpdatedParams);
462463
}
463464

464465
@Override

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/SpringSymbolIndex.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
8686
import org.springframework.ide.vscode.commons.protocol.spring.BeansParams;
8787
import org.springframework.ide.vscode.commons.protocol.spring.DocumentElement;
88+
import org.springframework.ide.vscode.commons.protocol.spring.IndexUpdatedParams;
8889
import org.springframework.ide.vscode.commons.protocol.spring.MatchingBeansParams;
8990
import org.springframework.ide.vscode.commons.protocol.spring.ProjectElement;
9091
import org.springframework.ide.vscode.commons.protocol.spring.SpringIndex;
@@ -410,7 +411,7 @@ private CompletableFuture<Void> _initializeProject(IJavaProject project, boolean
410411

411412
CompletableFuture<Void> future = CompletableFuture.allOf(futures);
412413

413-
future = future.thenAccept(v -> server.getClient().indexUpdated(List.of(project.getElementName()))).thenAccept(v -> listeners.fire(v));
414+
future = future.thenAccept(v -> server.getClient().indexUpdated(IndexUpdatedParams.of(List.of(project.getElementName())))).thenAccept(v -> listeners.fire(v));
414415

415416
this.latestScheduledTaskByProject.put(project.getElementName(), future);
416417
return future;
@@ -482,7 +483,7 @@ public CompletableFuture<Void> createDocuments(String[] docURIs) {
482483
}
483484

484485
CompletableFuture<Void> future = CompletableFuture.allOf((CompletableFuture[]) futures.toArray(new CompletableFuture[futures.size()]));
485-
future = future.thenAccept(v -> server.getClient().indexUpdated(affectedProjects)).thenAccept(v -> listeners.fire(v));
486+
future = future.thenAccept(v -> server.getClient().indexUpdated(IndexUpdatedParams.of(affectedProjects))).thenAccept(v -> listeners.fire(v));
486487
return future;
487488
}
488489
}
@@ -540,7 +541,7 @@ public CompletableFuture<Void> updateDocument(String docURI, String content, Str
540541
}
541542
}
542543
CompletableFuture<Void> future = CompletableFuture.allOf((CompletableFuture[]) futures.toArray(new CompletableFuture[futures.size()]));
543-
future = future.thenAccept(v -> server.getClient().indexUpdated(affectedProjects)).thenAccept(v -> listeners.fire(v));
544+
future = future.thenAccept(v -> server.getClient().indexUpdated(IndexUpdatedParams.of(affectedProjects))).thenAccept(v -> listeners.fire(v));
544545
return future;
545546
}
546547
}
@@ -574,7 +575,7 @@ public CompletableFuture<Void> updateDocuments(String[] docURIs, String reason)
574575
}
575576
}
576577
CompletableFuture<Void> future = CompletableFuture.allOf((CompletableFuture[]) futures.toArray(new CompletableFuture[futures.size()]));
577-
future = future.thenAccept(v -> server.getClient().indexUpdated(affectedProjects)).thenAccept(v -> listeners.fire(v));
578+
future = future.thenAccept(v -> server.getClient().indexUpdated(IndexUpdatedParams.of(affectedProjects))).thenAccept(v -> listeners.fire(v));
578579
return future;
579580
}
580581
}
@@ -670,7 +671,7 @@ public CompletableFuture<Void> deleteDocuments(String[] deletedPathURIs) {
670671

671672
if (futures.size() > 0) {
672673
CompletableFuture<Void> future = CompletableFuture.allOf((CompletableFuture[]) futures.toArray(new CompletableFuture[futures.size()]));
673-
future = future.thenAccept(v -> server.getClient().indexUpdated(affectedProjects)).thenAccept(v -> listeners.fire(v));
674+
future = future.thenAccept(v -> server.getClient().indexUpdated(IndexUpdatedParams.of(affectedProjects))).thenAccept(v -> listeners.fire(v));
674675
return future;
675676
}
676677
else {
@@ -1109,7 +1110,7 @@ public void run() {
11091110
index.removeProject(project);
11101111
}
11111112
springIndex.removeProject(project.getElementName());
1112-
server.getClient().indexUpdated(List.of(project.getElementName()));
1113+
server.getClient().indexUpdated(IndexUpdatedParams.of(project.getElementName()));
11131114

11141115
log.debug("{} completed", this);
11151116
} catch (Throwable e) {

headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/index/test/SpringMetamodelIndexingTest.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public void setup() throws Exception {
7171
@Test
7272
void testUpdateNotificationAfterProjectCreation() {
7373
assertEquals(1, harness.getIndexUpdatedCount());
74-
assertEquals(1, harness.getIndexUpdatedDetails(0).size());
75-
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).get(0));
74+
assertEquals(1, harness.getIndexUpdatedDetails(0).getAffectedProjects().size());
75+
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).getAffectedProjects().get(0));
7676
}
7777

7878
@Test
@@ -87,10 +87,10 @@ void testDeleteProject() throws Exception {
8787
assertEquals(0, noBeansAnymore.length);
8888

8989
assertEquals(2, harness.getIndexUpdatedCount()); // 1x project created, 1x project deleted
90-
assertEquals(1, harness.getIndexUpdatedDetails(0).size());
91-
assertEquals(1, harness.getIndexUpdatedDetails(1).size());
92-
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).get(0));
93-
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(1).get(0));
90+
assertEquals(1, harness.getIndexUpdatedDetails(0).getAffectedProjects().size());
91+
assertEquals(1, harness.getIndexUpdatedDetails(1).getAffectedProjects().size());
92+
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).getAffectedProjects().get(0));
93+
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(1).getAffectedProjects().get(0));
9494
}
9595

9696
@Test
@@ -116,10 +116,10 @@ void testRemoveSymbolsFromDeletedDocument() throws Exception {
116116
assertEquals(allBeansOfProject.length - 1, lessBeansOfProject.length);
117117

118118
assertEquals(2, harness.getIndexUpdatedCount()); // 1x project created, 1x document deleted
119-
assertEquals(1, harness.getIndexUpdatedDetails(0).size());
120-
assertEquals(1, harness.getIndexUpdatedDetails(1).size());
121-
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).get(0));
122-
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(1).get(0));
119+
assertEquals(1, harness.getIndexUpdatedDetails(0).getAffectedProjects().size());
120+
assertEquals(1, harness.getIndexUpdatedDetails(1).getAffectedProjects().size());
121+
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).getAffectedProjects().get(0));
122+
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(1).getAffectedProjects().get(0));
123123
}
124124

125125
@Test
@@ -149,10 +149,10 @@ void testUpdateChangedDocument() throws Exception {
149149
assertEquals("bean1", updatedInjectionPoints[0].getName());
150150

151151
assertEquals(2, harness.getIndexUpdatedCount()); // 1x project created, 1x document updated
152-
assertEquals(1, harness.getIndexUpdatedDetails(0).size());
153-
assertEquals(1, harness.getIndexUpdatedDetails(1).size());
154-
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).get(0));
155-
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(1).get(0));
152+
assertEquals(1, harness.getIndexUpdatedDetails(0).getAffectedProjects().size());
153+
assertEquals(1, harness.getIndexUpdatedDetails(1).getAffectedProjects().size());
154+
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).getAffectedProjects().get(0));
155+
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(1).getAffectedProjects().get(0));
156156
}
157157

158158
@Test
@@ -212,10 +212,10 @@ void testNewDocumentCreated() throws Exception {
212212
assertEquals("org.test.BeanClass1", newBeans[1].getType());
213213

214214
assertEquals(2, harness.getIndexUpdatedCount()); // 1x project created, 1x new document created
215-
assertEquals(1, harness.getIndexUpdatedDetails(0).size());
216-
assertEquals(1, harness.getIndexUpdatedDetails(1).size());
217-
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).get(0));
218-
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(1).get(0));
215+
assertEquals(1, harness.getIndexUpdatedDetails(0).getAffectedProjects().size());
216+
assertEquals(1, harness.getIndexUpdatedDetails(1).getAffectedProjects().size());
217+
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(0).getAffectedProjects().get(0));
218+
assertEquals("test-spring-indexing", harness.getIndexUpdatedDetails(1).getAffectedProjects().get(0));
219219
}
220220
finally {
221221
FileUtils.deleteQuietly(new File(new URI(createdDocURI)));

0 commit comments

Comments
 (0)