Skip to content

Commit 035c174

Browse files
committed
GH-1703: work with streams instead of adding collections, they might be immutable
1 parent d160536 commit 035c174

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import org.springframework.ide.vscode.commons.util.BadLocationException;
3535
import org.springframework.ide.vscode.commons.util.text.TextDocument;
3636

37+
import com.google.common.collect.Streams;
38+
3739
public class WebConfigCodeLensProvider implements CodeLensProvider {
3840

3941
// private static final Logger log = LoggerFactory.getLogger(WebConfigCodeLensProvider.class);
@@ -80,15 +82,11 @@ private void provideCodeLens(CancelChecker cancelToken, TypeDeclaration node, Te
8082

8183
List<WebConfigIndexElement> webConfigs = springIndex.getNodesOfType(project.getElementName(), WebConfigIndexElement.class);
8284
List<WebConfigIndexElement> webConfigFromProperties = new WebConfigPropertiesIndexer().findWebConfigFromProperties(project);
83-
webConfigs.addAll(webConfigFromProperties);
84-
85-
for (WebConfigIndexElement webConfig : webConfigs) {
86-
CodeLens codeLens = createCodeLens(webConfig, node, doc);
87-
if (codeLens != null) {
88-
codeLenses.add(codeLens);
89-
}
90-
}
9185

86+
Streams.concat(webConfigs.stream(), webConfigFromProperties.stream())
87+
.map(webConfig -> createCodeLens(webConfig, node, doc))
88+
.filter(codeLens -> codeLens != null)
89+
.forEach(codeLens -> codeLenses.add(codeLens));
9290
}
9391

9492
private CodeLens createCodeLens(WebConfigIndexElement webConfig, TypeDeclaration node, TextDocument doc) {

0 commit comments

Comments
 (0)