public int getIndex() { return _source.getIndex(); } }
public int getIndex() { return _source.getIndex(); } }
public int getIndex() { return _source.getIndex(); } }
@Override public int getIndex() { return mark.getIndex(); }
public int getIndex() { return _source.getIndex(); } }
private boolean validateOffset(Node valueNode) { return valueNode != null && valueNode.getEndMark().getIndex() < offset; }
private boolean validateOffset(Node valueNode) { return valueNode != null && valueNode.getEndMark().getIndex() < offset; }
public static int getEnd(Node node) { return node.getEndMark().getIndex(); }
public static int getStart(Node node) { return node.getStartMark().getIndex(); }
protected DocumentRegion getRegion(Exception e, IDocument doc, Node node) { DocumentRegion region = new DocumentRegion(doc, node.getStartMark().getIndex(), node.getEndMark().getIndex()); if (e instanceof ValueParseException) { ValueParseException parseException = (ValueParseException) e; int start = parseException.getStartIndex() >= 0 ? Math.min(node.getStartMark().getIndex() + parseException.getStartIndex(), node.getEndMark().getIndex()) : node.getStartMark().getIndex(); int end = parseException.getEndIndex() >= 0 ? Math.min(node.getStartMark().getIndex() + parseException.getEndIndex(), node.getEndMark().getIndex()) : node.getEndMark().getIndex(); region = new DocumentRegion(doc, start, end); } return region; }
/** * @return true if two mapping nodes in the same file * have the same start mark index */ private boolean checkLoop(Node node) { if (node.getStartMark() == null) { return false; } String index = contextPath.peek().getIncludeName() + node.getStartMark().getIndex(); if (loopDetector.contains(index)) { return true; } loopDetector.push(index); return false; }
/** * @return true if two mapping nodes in the same file * have the same start mark index */ private boolean checkLoop(Node node) { if (node.getStartMark() == null) { return false; } String index = contextPath.peek().getIncludeName() + node.getStartMark().getIndex(); if (loopDetector.contains(index)) { return true; } loopDetector.push(index); return false; }
private DocumentRegion dashesAtStartOf(YamlFileAST ast, Node node) { try { int start = node.getStartMark().getIndex(); DocumentRegion textBefore = new DocumentRegion(ast.getDocument(), 0, start) .trimEnd(Pattern.compile("\\s*")); DocumentRegion dashes = textBefore.subSequence(textBefore.getLength()-3); if (dashes.toString().equals("---")) { return dashes; } } catch (Exception e) { Log.log(e); } //something unexpected... we couldn't find the '---'. So just mark the entire node. return allOf(ast, node); }
private static Node buildYamlErrorNode(MarkedYAMLException e, String resourcePath) { final ErrorNode errorNode = new ErrorNode("Underlying error while parsing YAML syntax: '" + e.getMessage() + "'"); final Mark problemMark = e.getProblemMark(); errorNode.setStartPosition(new DefaultPosition(problemMark.getIndex(), problemMark.getLine(), 0, resourcePath, new DefaultResourceLoader())); errorNode.setEndPosition(new DefaultPosition(problemMark.getIndex() + 1, problemMark.getLine(), problemMark.getColumn(), resourcePath, new DefaultResourceLoader())); return errorNode; }
private static void raiseParserException(ThreadContext context, IRubyObject yaml, MarkedYAMLException mye, IRubyObject rbPath) { Ruby runtime; Mark mark; RubyClass se; IRubyObject exception; runtime = context.runtime; se = (RubyClass)runtime.getModule("Psych").getConstant("SyntaxError"); mark = mye.getProblemMark(); exception = se.newInstance(context, new IRubyObject[] { rbPath, runtime.newFixnum(mark.getLine() + 1), runtime.newFixnum(mark.getColumn() + 1), runtime.newFixnum(mark.getIndex()), (null == mye.getProblem() ? runtime.getNil() : runtime.newString(mye.getProblem())), (null == mye.getContext() ? runtime.getNil() : runtime.newString(mye.getContext())) }, Block.NULL_BLOCK); RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK); }