@Test public void testGetDeclaredType() { assertThat(registry.getDeclaredType("number.I").getQualifiedName(), is(Imaginary.kDescriptor.getQualifiedName())); try { registry.getDeclaredType("FakeNews"); fail(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Requesting global type name without program name: \"FakeNews\"")); } try { registry.getDeclaredType("real.fake.News"); fail(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Invalid identifier: \"real.fake.News\"")); } try { registry.getDeclaredType("fake.News"); fail(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("No such program \"fake\" known for type \"News\"")); } try { registry.getDeclaredType("number.Fake"); fail(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("No such type \"Fake\" in program \"number\"")); } try { registry.getDeclaredType("gurba.Imaginary"); fail("no exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("No such program \"gurba\" known for type \"Imaginary\"")); } try { registry.getDeclaredType("Imaginary", "gurba"); fail("no exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("No such program \"gurba\" known for type \"Imaginary\"")); } try { registry.getDeclaredType("number.Gurba"); fail("no exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("No such type \"Gurba\" in program \"number\"")); } try { registry.getDeclaredType("Gurba", "number"); fail("no exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("No such type \"Gurba\" in program \"number\"")); } }
@Nonnull @Override public <T extends PDeclaredDescriptor<T>> T getDeclaredType(@Nonnull String typeName, @Nonnull String programContext) { return handle(typeName, programContext, false, p -> p.getDeclaredType(typeName, programContext)); }
ProgramRegistry implements TypeRegistry { @Nonnull @Override public <T extends PDeclaredDescriptor<T>> T getDeclaredType(@Nonnull String typeName, @Nonnull String programContext) { return handle(typeName, programContext, false, p -> p.getDeclaredType(typeName, programContext)); } }
ProgramRegistry implements TypeRegistry { @Nonnull @Override public <T extends PDeclaredDescriptor<T>> T getDeclaredType(@Nonnull String typeName, @Nonnull String programContext) { return handle(typeName, programContext, false, p -> p.getDeclaredType(typeName, programContext)); } ProgramRegistry(); }
ProgramRegistry implements TypeRegistry { @Nonnull @Override public <T extends PDeclaredDescriptor<T>> T getDeclaredType(@Nonnull String typeName, @Nonnull String programContext) { return handle(typeName, programContext, false, p -> p.getDeclaredType(typeName, programContext)); } ProgramRegistry(); @Nonnull ProgramTypeRegistry registryForPath(String path); @Nonnull Collection<ProgramTypeRegistry> getLoadedRegistries(); boolean containsProgramPath(String path); void putProgram(String path, CProgram program); void putProgramType(String path, ProgramType program); @Nonnull @Override T getDeclaredType(@Nonnull String typeName,
                                                                @Nonnull String programContext); @Nullable @Override T getConstantValue(@Nonnull String constReference, @Nonnull String programContext); @Nonnull @Override PService getService(String serviceName, String programContext); @Nonnull @Override PDescriptorProvider getProvider(String typeName, String programContext, Map<String, String> annotations); @Nonnull @Override PServiceProvider getServiceProvider(String serviceName, String programContext); }
ProgramRegistry implements TypeRegistry { @Nonnull @Override public <T extends PDeclaredDescriptor<T>> T getDeclaredType(@Nonnull String typeName, @Nonnull String programContext) { return handle(typeName, programContext, false, p -> p.getDeclaredType(typeName, programContext)); } ProgramRegistry(); @Nonnull ProgramTypeRegistry registryForPath(String path); @Nonnull Collection<ProgramTypeRegistry> getLoadedRegistries(); boolean containsProgramPath(String path); void putProgram(String path, CProgram program); void putProgramType(String path, ProgramType program); @Nonnull @Override T getDeclaredType(@Nonnull String typeName,
                                                                @Nonnull String programContext); @Nullable @Override T getConstantValue(@Nonnull String constReference, @Nonnull String programContext); @Nonnull @Override PService getService(String serviceName, String programContext); @Nonnull @Override PDescriptorProvider getProvider(String typeName, String programContext, Map<String, String> annotations); @Nonnull @Override PServiceProvider getServiceProvider(String serviceName, String programContext);  }