本文整理了Java中org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment
类的一些代码示例,展示了YamlPathSegment
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlPathSegment
类的具体详情如下:
包路径:org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment
类名称:YamlPathSegment
[英]A YamlPathSegment is a 'primitive' NodeNavigator operation. More complex operations (i.e YamlPath) are composed as seqences of 0 or more YamlPathSegments.
[中]YamlPathSegment是一种“原始”节点激活器操作。更复杂的操作(即YamlPath)由0个或更多YamlPath段组成。
代码示例来源:origin: spring-projects/sts4
public static YamlPathSegment decode(String code) {
switch (code.charAt(0)) {
case '*':
return anyChild();
case '.':
return valueAt(code.substring(1));
case '&':
return keyAt(code.substring(1));
case '[':
return valueAt(Integer.parseInt(code.substring(1)));
default:
throw new IllegalArgumentException("Can't decode YamlPathSegment from '"+code+"'");
}
}
代码示例来源:origin: spring-projects/sts4
@Override
public Stream<SNode> traverseAmbiguously(YamlPathSegment s) {
switch (s.getType()) {
case VAL_AT_KEY:
return this.getChildrenWithKey(s.toPropString());
case VAL_AT_INDEX:
return Streams.fromNullable(this.getSeqChildWithIndex(s.toIndex()));
default:
return Stream.empty();
}
}
代码示例来源:origin: spring-projects/sts4
public String encode() {
return getTypeCode() + getValueCode();
}
代码示例来源:origin: spring-projects/sts4
public String toPropString() {
StringBuilder buf = new StringBuilder();
boolean first = true;
for (YamlPathSegment s : segments) {
if (first) {
buf.append(s.toPropString());
} else {
buf.append(s.toNavString());
}
first = false;
}
return buf.toString();
}
代码示例来源:origin: spring-projects/sts4
private void verify_heatth_check_http_end_point_constraint(DynamicSchemaContext dc, Node parent, Node node, YType type, IProblemCollector problems) {
YamlFileAST ast = dc.getAST();
if (ast!=null) {
Node markerNode = YamlPathSegment.keyAt(HEALTH_CHECK_HTTP_ENDPOINT_PROP).traverseNode(node);
if (markerNode != null) {
String healthCheckType = getEffectiveHealthCheckType(ast, dc.getPath(), node);
if (!"http".equals(healthCheckType)) {
problems.accept(YamlSchemaProblems.problem(ManifestYamlSchemaProblemsTypes.IGNORED_PROPERTY,
"This has no effect unless `"+HEALTH_CHECK_TYPE_PROP+"` is `http` (but it is currently set to `"+healthCheckType+"`)", markerNode));
}
}
}
}
代码示例来源:origin: spring-projects/sts4
/**
* Attempt to interpret last segment of path as a bean property name.
* @return The name of the property or null if not applicable.
*/
public String getBeanPropertyName() {
if (!isEmpty()) {
YamlPathSegment lastSegment = getLastSegment();
YamlPathSegmentType kind = lastSegment.getType();
if (kind==YamlPathSegmentType.KEY_AT_KEY || kind==YamlPathSegmentType.VAL_AT_KEY) {
return lastSegment.toPropString();
}
}
return null;
}
代码示例来源:origin: spring-projects/sts4
private YamlPath keyAt(YamlPath path, String key) {
if (path!=null && key!=null) {
return path.append(YamlPathSegment.keyAt(key));
}
return null;
}
代码示例来源:origin: spring-projects/sts4
case ROOT:
RootRef rref = (RootRef) nodeRef;
segments.add(YamlPathSegment.valueAt(rref.getIndex()));
break;
case KEY: {
return null;
} else {
segments.add(YamlPathSegment.keyAt(key));
} }
break;
return null;
} else {
segments.add(YamlPathSegment.valueAt(key));
} }
break;
case SEQ:
SeqRef sref = ((SeqRef)nodeRef);
segments.add(YamlPathSegment.valueAt(sref.getIndex()));
break;
default:
代码示例来源:origin: spring-projects/sts4
private YamlPath valueAt(YamlPath path, int index) {
if (path!=null) {
return path.append(YamlPathSegment.valueAt(index));
}
return null;
}
代码示例来源:origin: spring-projects/sts4
@Override
public Stream<ASTCursor> traverseAmbiguously(YamlPathSegment s) {
switch (s.getType()) {
case KEY_AT_KEY: {
return Stream.empty();
}
case ANY_CHILD: {
return getNode().getNodes().stream().map(NodeCursor::new);
}
case VAL_AT_INDEX: {
List<Node> nodes = getNode().getNodes();
int index = s.toIndex();
int size = nodes.size();
if (index<size && index >= 0) {
return Stream.of(new NodeCursor(nodes.get(index)));
}
return Stream.empty();
}
case VAL_AT_KEY: {
return Stream.empty();
}
default:
Assert.isLegal(false, "Bug? Missing switch case?");
return Stream.empty();
}
}
代码示例来源:origin: spring-projects/sts4
String key = path.getLastSegment().toPropString();
assistPath = path.dropLast().append(YamlPathSegment.valueAt(key));
代码示例来源:origin: spring-projects/sts4
@Override
public YamlAssistContext traverse(YamlPathSegment s) throws Exception {
Integer documentSelector = s.toIndex();
if (documentSelector!=null) {
return getDocumentContext(documentSelector);
}
return null;
}
代码示例来源:origin: spring-projects/sts4
public boolean pointsAtValue() {
YamlPathSegment s = getLastSegment();
if (s!=null) {
YamlPathSegmentType type = s.getType();
return type==YamlPathSegmentType.VAL_AT_KEY || type==YamlPathSegmentType.VAL_AT_INDEX;
}
return false;
}
代码示例来源:origin: spring-projects/sts4
@Override
public String toString() {
return toNavString();
}
代码示例来源:origin: spring-projects/sts4
default YamlTraversal thenAnyChild() {
return then(YamlPathSegment.anyChild());
}
default YamlTraversal or(YamlTraversal other) {
代码示例来源:origin: spring-projects/sts4
protected String createPathInsertionText(YamlPath path, int indent, boolean startOnNewLine, String appendText) {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < path.size(); i++) {
if (startOnNewLine||i>0) {
indentUtil.addNewlineWithIndent(indent, buf);
}
String key = path.getSegment(i).toPropString();
buf.append(YamlUtil.stringEscape(key));
buf.append(":");
if (i<path.size()-1) {
indent += YamlIndentUtil.INDENT_BY;
} else {
buf.append(indentUtil.applyIndentation(appendText, indent));
}
}
return buf.toString();
}
代码示例来源:origin: spring-projects/sts4
public static Constraint mutuallyExclusive(String target, String... propertyIds) {
return (dc, parent, node, type, problems) -> {
Node targetNode = YamlPathSegment.keyAt(target).traverseNode(node);
if (targetNode != null) {
YamlTraversal conflictingTraversal = getConflictingNodesTraversal(dc.getPath(), propertyIds);
List<Node> conflictingNodes = conflictingTraversal.traverseAmbiguously(dc.getAST()).collect(Collectors.toList());
if (!conflictingNodes.isEmpty()) {
Set<String> conflicts = conflictingNodes.stream().map(NodeUtil::asScalar).collect(Collectors.toCollection(TreeSet::new));
problems.accept(YamlSchemaProblems.problem(
ManifestYamlSchemaProblemsTypes.MUTUALLY_EXCLUSIVE_PROPERTY_PROBLEM,
"Property cannot co-exist with properties " + conflicts, targetNode));
for (Node cn : conflictingNodes) {
problems.accept(YamlSchemaProblems.problem(
ManifestYamlSchemaProblemsTypes.MUTUALLY_EXCLUSIVE_PROPERTY_PROBLEM,
"Property cannot co-exist with property '" + target + "'", cn));
}
}
}
};
}
代码示例来源:origin: spring-projects/sts4
@Override
public Renderable getHoverInfo(YamlPathSegment lastSegment) {
//Hoverinfo is only attached to YTypedProperties so...
switch (lastSegment.getType()) {
case VAL_AT_KEY:
case KEY_AT_KEY:
YTypedProperty prop = getProperty(lastSegment.toPropString());
if (prop!=null) {
return YPropertyInfoTemplates.createHover(contextPath.toPropString(), getType(), prop);
}
break;
default:
}
return null;
}
代码示例来源:origin: spring-projects/sts4
default YamlTraversal thenKeyAt(String key) {
return then(YamlPathSegment.keyAt(key));
}
default YamlTraversal thenAnyChild() {
代码示例来源:origin: spring-projects/sts4
/**
* Create a YamlPath with a single segment (i.e. like 'fromProperty', but does
* not parse '.' as segment separators.
*/
public static YamlPath fromSimpleProperty(String name) {
return new YamlPath(YamlPathSegment.valueAt(name));
}
内容来源于网络,如有侵权,请联系作者删除!