Skip to content

Commit

Permalink
Merge pull request #337 from cherylking/filterBetaPlatforms
Browse files Browse the repository at this point in the history
Use private features to collect available platforms
  • Loading branch information
cherylking authored Jan 27, 2025
2 parents d18b5e6 + 01e75d0 commit 793a4d7
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private List<CompletionItem> buildCompletionItems(DOMElement featureElement, DOM
List<Feature> completionFeatures = FeatureService.getInstance().getFeatureReplacements(featureNameToCompare, featureMgrNode, libertyVersion, libertyRuntime, requestDelay, domDocument.getDocumentURI());
return getFeatureCompletionItems(featureElement, domDocument, completionFeatures);
} else {
List<Feature> features = FeatureService.getInstance().getFeatures(libertyVersion, libertyRuntime, requestDelay, domDocument.getDocumentURI());
List<Feature> features = FeatureService.getInstance().getFeaturesAndPlatforms(libertyVersion, libertyRuntime, requestDelay, domDocument.getDocumentURI()).getPublicFeatures();
return getUniqueFeatureCompletionItems(featureElement, domDocument, features, existingFeatures);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2023 IBM Corporation and others.
* Copyright (c) 2020, 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -26,11 +26,22 @@ public class FeatureInfo {
@XmlElement(name = "feature")
private List<Feature> features = null;

@XmlElement(name = "privateFeature")
private List<PrivateFeature> privateFeatures = null;

public List<Feature> getFeatures() {
return features;
}

public void setFeatures(List<Feature> features) {
this.features = features;
}

public List<PrivateFeature> getPrivateFeatures() {
return this.privateFeatures;
}

public void setPrivateFeatures(List<PrivateFeature> privateFeatures) {
this.privateFeatures = privateFeatures;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package io.openliberty.tools.langserver.lemminx.models.feature;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

import io.openliberty.tools.langserver.lemminx.util.LibertyConstants;

public class FeaturesAndPlatforms {
private List<Feature> publicFeatures;
private List<Feature> privateFeatures;
private Set<String> platforms;

public FeaturesAndPlatforms(List<Feature> publicFeatures, List<Feature> privateFeatures) {
this.publicFeatures = publicFeatures;
this.privateFeatures = privateFeatures;

this.platforms = privateFeatures.stream()
.map(Feature::getWlpInformation)
.filter(Objects::nonNull)
.filter(w -> Objects.nonNull(w.getVisibility()))
.filter(w -> w.getVisibility().equals(LibertyConstants.PRIVATE_VISIBILITY))
.map(WlpInformation::getPlatforms)
.filter(Objects::nonNull)
.flatMap(List::stream).collect(Collectors.toSet());
}

public FeaturesAndPlatforms() {
this.publicFeatures = new ArrayList<>();
this.privateFeatures = new ArrayList<>();
this.platforms = new HashSet<>();
}

public void addFeaturesAndPlatforms(FeaturesAndPlatforms fp) {
this.publicFeatures.addAll(fp.getPublicFeatures());
this.privateFeatures.addAll(fp.getPrivateFeatures());
this.platforms.addAll(fp.getPlatforms());
}

public List<Feature> getPublicFeatures() {
return this.publicFeatures;
}

public List<Feature> getPrivateFeatures() {
return this.privateFeatures;
}

public Set<String> getPlatforms() {
return this.platforms;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package io.openliberty.tools.langserver.lemminx.models.feature;

import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.List;

@XmlRootElement(name = "privateFeature")
@XmlAccessorType(XmlAccessType.FIELD)
public class PrivateFeature {

private String symbolicName;
private List<String> platform;

// Getter Methods

public String getSymbolicName() {
return symbolicName;
}

public List<String> getPlatforms() {
return platform;
}

// Setter Methods

public void setSymbolicName(String symbolicName) {
this.symbolicName = symbolicName;
}

public void setPlatforms(List<String> platforms) {
this.platform = platforms;
}
}
Loading

0 comments on commit 793a4d7

Please sign in to comment.