@Test public void testRegression() throws IOException { File regressed = copyResourceTo("/idl/backend-libraries/common_fileserver.thrift", tmp.getRoot()); ThriftProgramParser parser = new ThriftProgramParser(); ProgramType program = parser.parse(new FileInputStream(regressed), regressed, new TreeSet<>()); assertEquals("{\n" + " program_name = \"common_fileserver\"\n" + " decl = [\n" + " {\n" + " decl_message = {\n" + " name = \"FileServerConfig\"\n" + " fields = [\n" + " {\n" + " documentation = \"Configuration for the /download… URL.\\nSee https: " id = 3\n" + " requirement = OPTIONAL\n" + " type = \"i32\"\n" + " name = \"download_url\"\n" + " start_pos = {\n" + " line_no = 6\n" + " line_pos = 5\n" + " }\n" + " end_pos = {\n" + " line_no = 6\n" + " line_pos = 33\n" + " }\n" + " }\n" + " ]\n" + " start_pos = {\n" + " line_no = 1\n" + " line_pos = 1\n" + " }\n" + " end_pos = {\n" + " line_no = 7\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; }