@Test public void testAutoId() throws IOException { copyResourceTo("/parser/tests/autoid.thrift", tmp.getRoot()); File autoid = new File(tmp.getRoot(), "autoid.thrift"); ThriftProgramParser parser = new ThriftProgramParser(); ProgramType program = parser.parse(new FileInputStream(autoid), autoid, new TreeSet<>()); assertEquals("{\n" + " program_name = \"autoid\"\n" + " namespaces = {\n" + " \"java\": \"net.morimekta.test.autoid\"\n" + " }\n" + " decl = [\n" + " {\n" + " decl_message = {\n" + " variant = EXCEPTION\n" + " name = \"AutoId\"\n" + " fields = [\n" + " {\n" + " id = -1\n" + " type = \"string\"\n" + " name = \"message\"\n" + " start_pos = {\n" + " line_no = 4\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 4\n" + " line_pos = 19\n" + " }\n" + " },\n" + " {\n" + " id = -2\n" + " type = \"i32\"\n" + " name = \"second\"\n" + " start_pos = {\n" + " line_no = 5\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 5\n" + " line_pos = 15\n" + " }\n" + " }\n" + " ]\n" + " start_pos = {\n" + " line_no = 3\n" + " line_pos = 1\n" + " }\n" + " end_pos = {\n" + " line_no = 6\n" + " line_pos = 2\n" + " }\n" + " }\n" + " },\n" + " {\n" + " decl_service = {\n" + " name = \"AutoParam\"\n" + " methods = [\n" + " {\n" + " return_type = \"i32\"\n" + " name = \"method\"\n" + " params = [\n" + " {\n" + " id = -1\n" + " type = \"i32\"\n" + " name = \"a\"\n" + " start_pos = {\n" + " line_no = 9\n" + " line_pos = 16\n" + " }\n" + " end_pos = {\n" + " line_no = 9\n" + " line_pos = 21\n" + " }\n" + " },\n" + " {\n" + " id = -2\n" + " type = \"i32\"\n" + " name = \"b\"\n" + " start_pos = {\n" + " line_no = 9\n" + " line_pos = 23\n" + " }\n" + " end_pos = {\n" + " line_no = 9\n" + " line_pos = 28\n" + " }\n" + " }\n" + " ]\n" + " exceptions = [\n" + " {\n" + " id = -1\n" + " type = \"AutoId\"\n" + " name = \"auto1\"\n" + " start_pos = {\n" + " line_no = 9\n" + " line_pos = 38\n" + " }\n" + " end_pos = {\n" + " line_no = 9\n" + " line_pos = 50\n" + " }\n" + " }\n" + " ]\n" + " start_pos = {\n" + " line_no = 9\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 9\n" + " line_pos = 51\n" + " }\n" + " }\n" + " ]\n" + " start_pos = {\n" + " line_no = 8\n" + " line_pos = 1\n" + " }\n" + " end_pos = {\n" + " line_no = 10\n" + " line_pos = 1\n" + " }\n" + " }\n" + " }\n" + " ]\n" + "}", debugString(program)); }
@Override public ProgramType parse(InputStream in, File file, Collection<File> includeDirs) throws IOException { try { return parseInternal(in, file, includeDirs); } catch (TokenizerException e) { if (e.getFile() == null) { e.setFile(file.getName()); } throw e; } }
ThriftProgramParser implements ProgramParser { @Override public ProgramType parse(InputStream in, File file, Collection<File> includeDirs) throws IOException { try { return parseInternal(in, file, includeDirs); } catch (TokenizerException e) { if (e.getFile() == null) { e.setFile(file.getName()); } throw e; } } }
ThriftProgramParser implements ProgramParser { @Override public ProgramType parse(InputStream in, File file, Collection<File> includeDirs) throws IOException { try { return parseInternal(in, file, includeDirs); } catch (TokenizerException e) { if (e.getFile() == null) { e.setFile(file.getName()); } throw e; } } ThriftProgramParser();  ThriftProgramParser(boolean requireFieldId,
                               boolean requireEnumValue);  ThriftProgramParser(boolean requireFieldId,
                               boolean requireEnumValue,
                               boolean allowLanguageReservedNames); }
ThriftProgramParser implements ProgramParser { @Override public ProgramType parse(InputStream in, File file, Collection<File> includeDirs) throws IOException { try { return parseInternal(in, file, includeDirs); } catch (TokenizerException e) { if (e.getFile() == null) { e.setFile(file.getName()); } throw e; } } ThriftProgramParser();  ThriftProgramParser(boolean requireFieldId,
                               boolean requireEnumValue);  ThriftProgramParser(boolean requireFieldId,
                               boolean requireEnumValue,
                               boolean allowLanguageReservedNames); @Override ProgramType parse(InputStream in, File file, Collection<File> includeDirs); }
ThriftProgramParser implements ProgramParser { @Override public ProgramType parse(InputStream in, File file, Collection<File> includeDirs) throws IOException { try { return parseInternal(in, file, includeDirs); } catch (TokenizerException e) { if (e.getFile() == null) { e.setFile(file.getName()); } throw e; } } ThriftProgramParser();  ThriftProgramParser(boolean requireFieldId,
                               boolean requireEnumValue);  ThriftProgramParser(boolean requireFieldId,
                               boolean requireEnumValue,
                               boolean allowLanguageReservedNames); @Override ProgramType parse(InputStream in, File file, Collection<File> includeDirs); static final Pattern VALID_NAMESPACE; static final Pattern VALID_SDI_NAMESPACE; }