CodeBuilder { public CodeBuilder inject(String variable, String path) throws CodeSyntaxException { machine.accept(maker.inject(variable, path)); return this; } CodeBuilder(); RootInst build(); CodeBuilder accept(Instruction instruction); CodeBuilder alternatesWith(); CodeBuilder bindvar(String name, String path); CodeBuilder comment(StringView view); CodeBuilder comment(String str); CodeBuilder comment(String str, int start, int end); CodeBuilder ctxvar(String name, List<Binding> bindings); CodeBuilder ctxvar(String name, String... bindings); CodeBuilder macro(String name); CodeBuilder mcomment(StringView view); CodeBuilder mcomment(String str); CodeBuilder mcomment(String str, int start, int end); CodeBuilder end(); CodeBuilder eof(); CodeBuilder ifexpn(List<String> variables, List<Operator> operators); CodeBuilder ifpred(Predicate predicate); CodeBuilder ifpred(Predicate predicate, Arguments args); CodeBuilder inject(String variable, String path); CodeBuilder inject(String variable, String path, Arguments args); CodeBuilder metaLeft(); CodeBuilder metaRight(); CodeBuilder newline(); CodeBuilder or(); CodeBuilder or(Predicate impl); CodeBuilder predicate(Predicate impl); CodeBuilder repeated(String name); CodeBuilder section(String name); CodeBuilder space(); CodeBuilder tab(); CodeBuilder text(StringView view); CodeBuilder text(String str); CodeBuilder text(String str, int start, int end); CodeBuilder var(String name); CodeBuilder var(String name, Formatter... formatters); CodeBuilder var(String name, FormatterCall formatter); CodeBuilder var(String name, List<FormatterCall> formatters);  }
@Test public void testInject() throws CodeException { CodeMaker mk = new CodeMaker(); Instruction expected = parse("{.inject @foo ./bar.json}"); assertEquals(builder().inject("@foo", "./bar.json").eof().build(), expected); expected = parse("{.inject @foo ./bar.json arg1}"); assertEquals(builder().inject("@foo", "./bar.json", mk.args(" arg1")).eof().build(), expected); }