/** * Remove the saved possible key position at the current flow level. */ private void removePossibleSimpleKey() { SimpleKey key = possibleSimpleKeys.remove(flowLevel); if (key != null && key.isRequired()) { throw new ScannerException("while scanning a simple key", key.getMark(), "could not find expected ':'", reader.getMark()); } }
public YAMLParserException interpret(ScannerException e) { String scalarScanning = "while scanning a plain scalar"; if (e.getContext() != null && e.getContext().matches(scalarScanning)) { String unexpected = "found unexpected ':'"; if (e.getProblem().matches(unexpected)) { String msg = "Using \":\" in values in flow context is invalid \n" + "Put all names (especially URIs) in parentheses. \n\n" + "(Example INVALID: { get_operation_output: [ SELF, http://www.example.com/interface/lifecycle, " + "operationName, outputName ] })\n" + "(Example VALID: { get_operation_output: [ SELF, \"http://www.example.com/interface/lifecycle\", " + "operationName, outputName ] })\n\n" + e.getMessage(); return new InvalidYamlSyntax(msg); } } return new InvalidYamlSyntax(e.toString()); } }
public YAMLException(ScannerException e, VirtualFile yaml) { super(e.getMessage() + " (in file " + yaml.relativePath() + " line " + (e.getProblemMark().getLine() + 1) + ", column " + (e.getProblemMark().getColumn() + 1) + ")", e); this.e = e; this.yaml = yaml; }
private void softScan() { if (scanner != null) { try { // Reset continuous flag bContinuousMode = false; if (scanner.isReadPending()) { // Cancel the pending read. scanner.cancelRead(); } scanner.triggerType = TriggerType.SOFT_ONCE; scanner.read(); new AsyncUiControlUpdate().execute(true); } catch (ScannerException e) { textViewStatus.setText("Status: " + e.getMessage()); } } }
@Override public boolean isSourceAvailable() { return yaml != null && e.getProblemMark() != null; } }
@Override public void reconcile(IDocument doc, IProblemCollector problemCollector) { problemCollector.beginCollecting(); try { YamlFileAST ast = parser.getAST(doc); YamlASTReconciler reconciler = getASTReconciler(doc, problemCollector); if (reconciler!=null) { reconciler.reconcile(ast); } } catch (ParserException e) { String msg = e.getProblem(); Mark mark = e.getProblemMark(); problemCollector.accept(syntaxError(msg, mark.getIndex(), 1)); } catch (ScannerException e) { String msg = e.getProblem(); Mark mark = e.getProblemMark(); problemCollector.accept(syntaxError(msg, mark.getIndex(), 1)); } catch (Exception e) { logger.error("unexpected error during reconcile", e); } finally { problemCollector.endCollecting(); } }
@Override public String getErrorDescription() { if (yaml == null) { return "Cannot parse the yaml file: " + e.getProblem(); } return "Cannot parse the <strong>" + yaml.relativePath() + "</strong> file: " + e.getProblem(); }
@Override public String getMessage() { return super.getMessage() + '\n' + scannerException.getMessage(); } }
@Override public Integer getLineNumber() { return e.getProblemMark().getLine() + 1; }
/** * Scan a %TAG directive's handle. This is YAML's c-tag-handle. * * @see <a href="http://www.yaml.org/spec/1.1/#id896876"></a> * @param startMark * @return */ private String scanTagDirectiveHandle(Mark startMark) { // See the specification for details. String value = scanTagHandle("directive", startMark); int c = reader.peek(); if (c != ' ') { final String s = String.valueOf(Character.toChars(c)); throw new ScannerException("while scanning a directive", startMark, "expected ' ', but found " + s + "(" + c + ")", reader.getMark()); } return value; }
public ParseConfigException(ScannerException e) { Problem problem = new ConfigProblemBuilder(Problem.Severity.FATAL, "Could not parse your halconfig: " + e.getMessage()).build(); getProblems().add(problem); }
parser = null; StringBuilder message = new StringBuilder("syntax error"); if (se.getProblemMark() != null) { message.append(se.getProblemMark().toString());
/** * Read a %YAML directive number: this is either the major or the minor * part. Stop reading at a non-digit character (usually either '.' or '\n'). * * @see <a href="http://www.yaml.org/spec/1.1/#id895631"></a> * @see <a href="http://www.yaml.org/spec/1.1/#ns-dec-digit"></a> */ private Integer scanYamlDirectiveNumber(Mark startMark) { // See the specification for details. int c = reader.peek(); if (!Character.isDigit(c)) { final String s = String.valueOf(Character.toChars(c)); throw new ScannerException("while scanning a directive", startMark, "expected a digit, but found " + s + "(" + (c) + ")", reader.getMark()); } int length = 0; while (Character.isDigit(reader.peek(length))) { length++; } Integer value = Integer.parseInt(reader.prefixForward(length)); return value; }
public ParseConfigException(ScannerException e) { Problem problem = new ConfigProblemBuilder(Problem.Severity.FATAL, "Could not parse your halconfig: " + e.getMessage()).build(); getProblems().add(problem); }
parser = null; StringBuilder message = new StringBuilder("syntax error"); if (se.getProblemMark() != null) { message.append(se.getProblemMark().toString());
/** * Scan a %TAG directive's prefix. This is YAML's ns-tag-prefix. * * @see <a href="http://www.yaml.org/spec/1.1/#ns-tag-prefix"></a> */ private String scanTagDirectivePrefix(Mark startMark) { // See the specification for details. String value = scanTagUri("directive", startMark); int c = reader.peek(); if (Constant.NULL_BL_LINEBR.hasNo(c)) { final String s = String.valueOf(Character.toChars(c)); throw new ScannerException("while scanning a directive", startMark, "expected ' ', but found " + s + "(" + c + ")", reader.getMark()); } return value; }
if (c == '\0') { throw new ScannerException("while scanning a quoted scalar", startMark, "found unexpected end of stream", reader.getMark());
private String scanFlowScalarBreaks(Mark startMark) { // See the specification for details. StringBuilder chunks = new StringBuilder(); while (true) { // Instead of checking indentation, we check for document // separators. String prefix = reader.prefix(3); if (("---".equals(prefix) || "...".equals(prefix)) && Constant.NULL_BL_T_LINEBR.has(reader.peek(3))) { throw new ScannerException("while scanning a quoted scalar", startMark, "found unexpected document separator", reader.getMark()); } // Scan past any number of spaces and tabs, ignoring them while (" \t".indexOf(reader.peek()) != -1) { reader.forward(); } // If we stopped at a line break, add that; otherwise, return the // assembled set of scalar breaks. String lineBreak = scanLineBreak(); if (lineBreak.length() != 0) { chunks.append(lineBreak); } else { return chunks.toString(); } } }
private List<Integer> scanYamlDirectiveValue(Mark startMark) { // See the specification for details. while (reader.peek() == ' ') { reader.forward(); } Integer major = scanYamlDirectiveNumber(startMark); int c = reader.peek(); if (c != '.') { final String s = String.valueOf(Character.toChars(c)); throw new ScannerException("while scanning a directive", startMark, "expected a digit or '.', but found " + s + "(" + c + ")", reader.getMark()); } reader.forward(); Integer minor = scanYamlDirectiveNumber(startMark); c = reader.peek(); if (Constant.NULL_BL_LINEBR.hasNo(c)) { final String s = String.valueOf(Character.toChars(c)); throw new ScannerException("while scanning a directive", startMark, "expected a digit or ' ', but found " + s + "(" + c + ")", reader.getMark()); } List<Integer> result = new ArrayList<Integer>(2); result.add(major); result.add(minor); return result; }
throw new ScannerException("while scanning a " + name, startMark, "expected URI, but found " + s + "(" + (c) + ")", reader.getMark());