@Test public void testAutoValue() throws IOException { copyResourceTo("/parser/tests/autovalue.thrift", tmp.getRoot()); File autovalue = new File(tmp.getRoot(), "autovalue.thrift"); ThriftProgramParser parser = new ThriftProgramParser(); ProgramType program = parser.parse(new FileInputStream(autovalue), autovalue, new TreeSet<>()); assertEquals("{\n" + " program_name = \"autovalue\"\n" + " namespaces = {\n" + " \"java\": \"net.morimekta.test.autoid\"\n" + " }\n" + " decl = [\n" + " {\n" + " decl_enum = {\n" + " name = \"AutoValue\"\n" + " values = [\n" + " {\n" + " name = \"FIRST\"\n" + " id = 0\n" + " start_pos = {\n" + " line_no = 4\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 4\n" + " line_pos = 10\n" + " }\n" + " },\n" + " {\n" + " name = \"SECOND\"\n" + " id = 1\n" + " start_pos = {\n" + " line_no = 5\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 5\n" + " line_pos = 11\n" + " }\n" + " },\n" + " {\n" + " name = \"THIRD\"\n" + " id = 2\n" + " start_pos = {\n" + " line_no = 6\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 6\n" + " line_pos = 10\n" + " }\n" + " }\n" + " ]\n" + " start_pos = {\n" + " line_no = 3\n" + " line_pos = 1\n" + " }\n" + " end_pos = {\n" + " line_no = 7\n" + " line_pos = 2\n" + " }\n" + " }\n" + " },\n" + " {\n" + " decl_enum = {\n" + " name = \"PartialAutoValue\"\n" + " values = [\n" + " {\n" + " name = \"FIRST\"\n" + " id = 5\n" + " start_pos = {\n" + " line_no = 10\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 10\n" + " line_pos = 14\n" + " }\n" + " },\n" + " {\n" + " name = \"SECOND\"\n" + " id = 6\n" + " start_pos = {\n" + " line_no = 11\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 11\n" + " line_pos = 11\n" + " }\n" + " },\n" + " {\n" + " name = \"THIRD\"\n" + " id = 7\n" + " start_pos = {\n" + " line_no = 12\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 12\n" + " line_pos = 10\n" + " }\n" + " }\n" + " ]\n" + " start_pos = {\n" + " line_no = 9\n" + " line_pos = 1\n" + " }\n" + " end_pos = {\n" + " line_no = 13\n" + " line_pos = 2\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; }