diff --git a/headless-services/manifest-yaml-language-server/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestConstraints.java b/headless-services/manifest-yaml-language-server/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestConstraints.java index b70f797d4..325057ad0 100644 --- a/headless-services/manifest-yaml-language-server/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestConstraints.java +++ b/headless-services/manifest-yaml-language-server/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestConstraints.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2017 Pivotal, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ package org.springframework.ide.vscode.manifest.yaml; import java.util.Arrays; @@ -11,9 +21,15 @@ import org.yaml.snakeyaml.nodes.MappingNode; import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.nodes.SequenceNode; +/** + * Constraints for Manifest YAML structure + * + * @author Alex Boyko + * + */ public class ManifestConstraints { - public static Constraint mutuallyExclusive(String... propertyIds) { + public static Constraint exclusiveWith(String... propertyIds) { return (dc, parent, node, type, problems) -> { Set keys = new HashSet<>(); Node root = dc.getAST().getNodes().get(0); diff --git a/headless-services/manifest-yaml-language-server/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java b/headless-services/manifest-yaml-language-server/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java index 90353793c..4f70d51cb 100644 --- a/headless-services/manifest-yaml-language-server/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java +++ b/headless-services/manifest-yaml-language-server/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java @@ -127,7 +127,7 @@ public class ManifestYmlSchema implements YamlSchema { } YAtomicType t_domain = f.yatomic("Domain"); - t_domain.require(ManifestConstraints.mutuallyExclusive("routes")); + t_domain.require(ManifestConstraints.exclusiveWith("routes")); if (domainsProvider != null) { t_domain.addHintProvider(domainsProvider); t_domain.parseWith(ManifestYmlValueParsers.fromValueHints(domainsProvider, t_domain, ManifestYamlSchemaProblemsTypes.UNKNOWN_DOMAIN_PROBLEM)); @@ -173,19 +173,19 @@ public class ManifestYmlSchema implements YamlSchema { TOPLEVEL_TYPE.addProperty("inherit", t_string, descriptionFor("inherit")); YSeqType routesType = f.yseq(route); - routesType.require(ManifestConstraints.mutuallyExclusive("domain", "domains", "host", "hosts", "no-hostname")); + routesType.require(ManifestConstraints.exclusiveWith("domain", "domains", "host", "hosts", "no-hostname")); YSeqType domainsType = f.yseq(t_domain); - domainsType.require(ManifestConstraints.mutuallyExclusive("routes")); + domainsType.require(ManifestConstraints.exclusiveWith("routes")); YSeqType hostsType = f.yseq(t_string); - hostsType.require(ManifestConstraints.mutuallyExclusive("routes")); + hostsType.require(ManifestConstraints.exclusiveWith("routes")); YAtomicType hostType = f.yatomic("String"); - hostType.require(ManifestConstraints.mutuallyExclusive("routes")); + hostType.require(ManifestConstraints.exclusiveWith("routes")); YAtomicType noHostType = f.yenum("boolean", "true", "false"); - noHostType.require(ManifestConstraints.mutuallyExclusive("routes")); + noHostType.require(ManifestConstraints.exclusiveWith("routes")); YTypedPropertyImpl[] props = { f.yprop("buildpack", t_buildpack),