@Test public void test_tab_makes_problems() { String text = "test:\txx"; YamlScriptModel result = builderToTest.build(text); List<YamlNode> nodes = result.getRootNode().getChildren(); assertTrue(nodes.isEmpty()); assertTrue(result.hasErrors()); }
public YamlScriptModel build(String unsafeSourceCode) { YamlScriptModel model = new YamlScriptModel(); try { YamlSanitizerContext context = new YamlSanitizerContext(); String escapedSource = unsafeSourceCode; for (YamlSanitizer yamlSanitizer : this.sanitizers) { escapedSource = yamlSanitizer.sanitize(escapedSource,context); } model.getMessages().addAll(context.getSanitizerMessages()); StringReader reader = new StringReader(escapedSource); YamlNode root = model.getRootNode(); Iterable<Node> nodes = yamlParser.composeAll(reader); for (Node node : nodes) { buildNode(model, root, node); } if (calculateFoldings) { IndentionBlockBuilder builder = new IndentionBlockBuilder(); List<IndentionBlock> blocks = builder.build(escapedSource); transformIndentionsToFoldings(model, blocks); } } catch (MarkedYAMLException e) { String message = e.getMessage(); Mark problem = e.getProblemMark(); int start = problem.getIndex(); int end = start + 1; YamlError error = new YamlError(start, end, message); model.errors.add(error); } return model; }
YamlScriptModelBuilder { public YamlScriptModel build(String unsafeSourceCode) { YamlScriptModel model = new YamlScriptModel(); try { YamlSanitizerContext context = new YamlSanitizerContext(); String escapedSource = unsafeSourceCode; for (YamlSanitizer yamlSanitizer : this.sanitizers) { escapedSource = yamlSanitizer.sanitize(escapedSource,context); } model.getMessages().addAll(context.getSanitizerMessages()); StringReader reader = new StringReader(escapedSource); YamlNode root = model.getRootNode(); Iterable<Node> nodes = yamlParser.composeAll(reader); for (Node node : nodes) { buildNode(model, root, node); } if (calculateFoldings) { IndentionBlockBuilder builder = new IndentionBlockBuilder(); List<IndentionBlock> blocks = builder.build(escapedSource); transformIndentionsToFoldings(model, blocks); } } catch (MarkedYAMLException e) { String message = e.getMessage(); Mark problem = e.getProblemMark(); int start = problem.getIndex(); int end = start + 1; YamlError error = new YamlError(start, end, message); model.errors.add(error); } return model; } }
YamlScriptModelBuilder { public YamlScriptModel build(String unsafeSourceCode) { YamlScriptModel model = new YamlScriptModel(); try { YamlSanitizerContext context = new YamlSanitizerContext(); String escapedSource = unsafeSourceCode; for (YamlSanitizer yamlSanitizer : this.sanitizers) { escapedSource = yamlSanitizer.sanitize(escapedSource,context); } model.getMessages().addAll(context.getSanitizerMessages()); StringReader reader = new StringReader(escapedSource); YamlNode root = model.getRootNode(); Iterable<Node> nodes = yamlParser.composeAll(reader); for (Node node : nodes) { buildNode(model, root, node); } if (calculateFoldings) { IndentionBlockBuilder builder = new IndentionBlockBuilder(); List<IndentionBlock> blocks = builder.build(escapedSource); transformIndentionsToFoldings(model, blocks); } } catch (MarkedYAMLException e) { String message = e.getMessage(); Mark problem = e.getProblemMark(); int start = problem.getIndex(); int end = start + 1; YamlError error = new YamlError(start, end, message); model.errors.add(error); } return model; } YamlScriptModelBuilder(); }
YamlScriptModelBuilder { public YamlScriptModel build(String unsafeSourceCode) { YamlScriptModel model = new YamlScriptModel(); try { YamlSanitizerContext context = new YamlSanitizerContext(); String escapedSource = unsafeSourceCode; for (YamlSanitizer yamlSanitizer : this.sanitizers) { escapedSource = yamlSanitizer.sanitize(escapedSource,context); } model.getMessages().addAll(context.getSanitizerMessages()); StringReader reader = new StringReader(escapedSource); YamlNode root = model.getRootNode(); Iterable<Node> nodes = yamlParser.composeAll(reader); for (Node node : nodes) { buildNode(model, root, node); } if (calculateFoldings) { IndentionBlockBuilder builder = new IndentionBlockBuilder(); List<IndentionBlock> blocks = builder.build(escapedSource); transformIndentionsToFoldings(model, blocks); } } catch (MarkedYAMLException e) { String message = e.getMessage(); Mark problem = e.getProblemMark(); int start = problem.getIndex(); int end = start + 1; YamlError error = new YamlError(start, end, message); model.errors.add(error); } return model; } YamlScriptModelBuilder(); YamlScriptModelBuilder setSanitizers(YamlSanitizer... sanitizers); YamlScriptModelBuilder setCalculateFoldings(boolean calculateFoldings); YamlScriptModel build(String unsafeSourceCode); }
YamlScriptModelBuilder { public YamlScriptModel build(String unsafeSourceCode) { YamlScriptModel model = new YamlScriptModel(); try { YamlSanitizerContext context = new YamlSanitizerContext(); String escapedSource = unsafeSourceCode; for (YamlSanitizer yamlSanitizer : this.sanitizers) { escapedSource = yamlSanitizer.sanitize(escapedSource,context); } model.getMessages().addAll(context.getSanitizerMessages()); StringReader reader = new StringReader(escapedSource); YamlNode root = model.getRootNode(); Iterable<Node> nodes = yamlParser.composeAll(reader); for (Node node : nodes) { buildNode(model, root, node); } if (calculateFoldings) { IndentionBlockBuilder builder = new IndentionBlockBuilder(); List<IndentionBlock> blocks = builder.build(escapedSource); transformIndentionsToFoldings(model, blocks); } } catch (MarkedYAMLException e) { String message = e.getMessage(); Mark problem = e.getProblemMark(); int start = problem.getIndex(); int end = start + 1; YamlError error = new YamlError(start, end, message); model.errors.add(error); } return model; } YamlScriptModelBuilder(); YamlScriptModelBuilder setSanitizers(YamlSanitizer... sanitizers); YamlScriptModelBuilder setCalculateFoldings(boolean calculateFoldings); YamlScriptModel build(String unsafeSourceCode);  }