public AnchorNode(Node realNode) { super(realNode.getTag(), realNode.getStartMark(), realNode.getEndMark()); this.realNode = realNode; }
@Nonnull @Override public Position getEndPosition() { return new SYPosition(yamlNode.getEndMark(), resourceLoader, resourcePath); }
private boolean validateOffset(Node valueNode) { return valueNode != null && valueNode.getEndMark().getIndex() < offset; }
private int indexEnd(Node node, boolean defaultIsYamlEnd) { if (!found() || node==null) return defaultIsYamlEnd ? yaml.length() : 0; return index(node.getEndMark()); } private int index(Mark mark) {
/** * Add an invalid type {@link ParsingError} to the given parsing errors list. * * @param node The node that is causing the type error. * @param parsingErrors The parsing errors in which to add the error. * @param expectedType The type that was actually expected. */ public static void addTypeError(Node node, List<ParsingError> parsingErrors, String expectedType) { parsingErrors.add(new ParsingError(ErrorCode.SYNTAX_ERROR, "Invalid type syntax", node.getStartMark(), "Expected the type to match tosca type", node .getEndMark(), expectedType)); } }
public static ValidationResult createErrorResult(String message, Node node) { return createErrorResult(message, node.getStartMark(), node.getEndMark()); }
public static ValidationResult createErrorResult(String message, Node node) { return createErrorResult(message, node.getStartMark(), node.getEndMark()); }
private Map.Entry<String, INodeParser<?>> processTypeMapping(Node node, ParsingContextExecution context) { try { return doProcessTypeMapping(node, context); } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { log.error("Failed to load class while parsing mapping", e); context.getParsingErrors() .add(new ParsingError(ErrorCode.SYNTAX_ERROR, "Unable to load class", node.getStartMark(), e.getMessage(), node.getEndMark(), "")); return null; } }
@Override public void onCustomTagError(Tag tag, Node node, String message) { addMessages(Arrays.asList(createErrorResult(message, node.getStartMark(), node.getEndMark()))); }
@Override public void onCustomTagError(Tag tag, Node node, String message) { addMessages(Arrays.asList(createErrorResult(message, node.getStartMark(), node.getEndMark()))); }
@Override protected void postProcessArtifactRef(Node node, String artifactReference) { if (artifactReference == null) { Node referenceNode = ParsingContextExecution.getObjectToNodeMap().get(artifactReference); if (referenceNode == null) { referenceNode = node; } ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.SYNTAX_ERROR, "Implementation artifact", referenceNode.getStartMark(), "No artifact reference is defined, 'file' is mandatory in a long notation artifact definition", referenceNode.getEndMark(), null)); } } }
@Override protected void postProcessArtifactRef(Node node, String artifactReference) { if (artifactReference == null) { Node referenceNode = ParsingContextExecution.getObjectToNodeMap().get(artifactReference); if (referenceNode == null) { referenceNode = node; } ParsingContextExecution.getParsingErrors().add(new ParsingError(ParsingErrorLevel.WARNING, ErrorCode.UNRESOLVED_ARTIFACT, "Deployment artifact", node.getStartMark(), "No artifact reference is defined, user will have to define / override in order to make ", node.getEndMark(), null)); } } }
@Override public T parse(Node node, ParsingContextExecution context) { INodeParser<?> delegate = context.getRegistry().get(typeName); if (delegate == null) { log.error("No parser found for yaml type {}", typeName); context.getParsingErrors().add( new ParsingError(ErrorCode.ALIEN_MAPPING_ERROR, "No parser found for yaml type", node.getStartMark(), "", node.getEndMark(), typeName)); return null; } return (T) delegate.parse(node, context); } }
private MappingTarget mapMappingNode(MappingNode mappingNode, ParsingContextExecution context) { String key = ParserUtils.getScalar(mappingNode.getValue().get(0).getKeyNode(), context); IMappingBuilder mappingBuilder = mappingBuilders.get(key); if (mappingBuilder != null) { log.debug("Mapping yaml key <" + key + "> using mapping builder " + mappingBuilder.getClass().getName()); return mappingBuilder.buildMapping(mappingNode, context); } context.getParsingErrors().add(new ParsingError(ErrorCode.SYNTAX_ERROR, "No mapping target found for key", mappingNode.getValue().get(0).getKeyNode().getStartMark(), key, mappingNode.getValue().get(0).getKeyNode().getEndMark(), "")); return null; }
private void addError(ErrorCode errorCode, String context, String problem, String note, Node node) { if (node != null) { ParsingContextExecution.getParsingErrors().add(new ParsingError(errorCode, context, node.getStartMark(), problem, node.getEndMark(), note)); } else { ParsingContextExecution.getParsingErrors().add(new ParsingError(errorCode, context, null, problem, null, note)); } }
public static ReconcileProblem problem(ProblemType problemType, String msg, Node node) { int start = node.getStartMark().getIndex(); int end = node.getEndMark().getIndex(); return new ReconcileProblemImpl(problemType, msg, start, end-start); }
public static ReconcileProblem schemaProblem(String msg, Node node) { int start = node.getStartMark().getIndex(); int end = node.getEndMark().getIndex(); return new ReconcileProblemImpl(SCHEMA_PROBLEM, msg, start, end-start); }
public static ValidationResult createWarnResult(String message, Node node) { return new ValidationResult(Level.WARN, message, node.getStartMark().getLine(), node.getStartMark().getColumn(), node.getEndMark().getColumn()); }
public static ValidationResult createWarnResult(String message, Node node) { return new ValidationResult(Level.WARN, message, node.getStartMark().getLine(), node.getStartMark().getColumn(), node.getEndMark().getColumn()); }
private IRegion getHoverRegion(YamlFileAST ast, int offset) { if (ast != null) { Node n = ast.findNode(offset); if (n != null && n.getNodeId() == NodeId.scalar) { int start = n.getStartMark().getIndex(); int end = n.getEndMark().getIndex(); return new Region(start, end - start); } } return null; }