@Test public void testInternalReference() throws IOException { File a = writeContentTo( "config.RefMerge {\n" + " ref1 & first = {\n" + " bool_value & boo = false\n" + " msg_value & db {\n" + " driver = \"Driver\"\n" + " }\n" + " }\n" + " ref1_1 = first {\n" + " i16_value = 12345\n" + " msg_value & db2 = db {\n" + " uri = \"someuri\"\n" + " }\n" + " }\n" + " ref2 {\n" + " bool_value = boo" + " msg_value = db2\n" + " }\n" + "}\n", temp.newFile("a.cfg")); try { ProvidenceConfigParser config = new ProvidenceConfigParser(registry, false); RefMerge merged = config.parseConfig(a.toPath(), (RefMerge) null).first; assertThat(debugString(merged), is( "{\n" + " ref1 = {\n" + " bool_value = false\n" + " msg_value = {\n" + " driver = \"Driver\"\n" + " }\n" + " }\n" + " ref1_1 = {\n" + " bool_value = false\n" + " i16_value = 12345\n" + " msg_value = {\n" + " uri = \"someuri\"\n" + " driver = \"Driver\"\n" + " }\n" + " }\n" + " ref2 = {\n" + " bool_value = false\n" + " msg_value = {\n" + " uri = \"someuri\"\n" + " driver = \"Driver\"\n" + " }\n" + " }\n" + "}")); } catch (ProvidenceConfigException e) { System.err.println(e.asString()); throw e; } }
@Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } ProvidenceConfigParser(TypeRegistry registry, boolean strict); }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } ProvidenceConfigParser(TypeRegistry registry, boolean strict);  }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } ProvidenceConfigParser(TypeRegistry registry, boolean strict);   }