static ImmutableList<Extend> fromElements(String packageName, ImmutableList<ExtendElement> extendElements) { ImmutableList.Builder<Extend> extendBuilder = new ImmutableList.Builder<>(); for (ExtendElement extendElement : extendElements) { extendBuilder.add(new Extend(extendElement.location(), extendElement.documentation(), extendElement.name(), Field.fromElements(packageName, extendElement.fields(), true))); } return extendBuilder.build(); }
static ProtoFile get(ProtoFileElement protoFileElement) { String packageName = protoFileElement.packageName(); ImmutableList<Type> types = Type.fromElements(packageName, protoFileElement.types()); ImmutableList<Service> services = Service.fromElements(packageName, protoFileElement.services()); ImmutableList<Extend> wireExtends = Extend.fromElements(packageName, protoFileElement.extendDeclarations()); Options options = new Options(Options.FILE_OPTIONS, protoFileElement.options()); return new ProtoFile(protoFileElement.location(), protoFileElement.imports(), protoFileElement.publicImports(), packageName, types, services, wireExtends, options, protoFileElement.syntax()); }
@Test public void extendTypeImported() throws Exception { Schema schema = new RepoBuilder() .add("a.proto", "" + "package pa;\n" + "import \"b.proto\";\n" + "extend pb.B {\n" + " optional string a = 1;\n" + "}\n") .add("b.proto", "" + "package pb;\n" + "message B {\n" + " extensions 1;\n" + "}\n") .schema(); Extend extendB = schema.protoFiles().get(0).extendList().get(0); MessageType b = (MessageType) schema.getType("pb.B"); assertThat(extendB.type()).isEqualTo(b.type()); }
ProtoFileElement toElement() { return ProtoFileElement.builder(location) .imports(imports) .publicImports(publicImports) .packageName(packageName) .types(Type.toElements(types)) .services(Service.toElements(services)) .extendDeclarations(Extend.toElements(extendList)) .options(options.toElements()) .syntax(syntax) .build(); }
ProtoFileElement toElement() { return ProtoFileElement.builder(location) .imports(imports) .publicImports(publicImports) .packageName(packageName) .types(Type.toElements(types)) .services(Service.toElements(services)) .extendDeclarations(Extend.toElements(extendList)) .options(options.toElements()) .syntax(syntax) .build(); }
ProtoFileElement toElement() { return ProtoFileElement.builder(location) .imports(imports) .publicImports(publicImports) .packageName(packageName) .types(Type.toElements(types)) .services(Service.toElements(services)) .extendDeclarations(Extend.toElements(extendList)) .options(options.toElements()) .syntax(syntax) .build(); }
static ProtoFile get(ProtoFileElement protoFileElement) { String packageName = protoFileElement.packageName(); ImmutableList<Type> types = Type.fromElements(packageName, protoFileElement.types()); ImmutableList<Service> services = Service.fromElements(packageName, protoFileElement.services()); ImmutableList<Extend> wireExtends = Extend.fromElements(packageName, protoFileElement.extendDeclarations()); Options options = new Options(Options.FILE_OPTIONS, protoFileElement.options()); return new ProtoFile(protoFileElement.location(), protoFileElement.imports(), protoFileElement.publicImports(), packageName, types, services, wireExtends, options, protoFileElement.syntax()); }
static ImmutableList<Extend> fromElements(String packageName, ImmutableList<ExtendElement> extendElements) { ImmutableList.Builder<Extend> extendBuilder = new ImmutableList.Builder<>(); for (ExtendElement extendElement : extendElements) { extendBuilder.add(new Extend(extendElement.location(), extendElement.documentation(), extendElement.name(), Field.fromElements(packageName, extendElement.fields(), true))); } return extendBuilder.build(); }
static ProtoFile get(ProtoFileElement protoFileElement) { String packageName = protoFileElement.packageName(); ImmutableList<Type> types = Type.fromElements(packageName, protoFileElement.types()); ImmutableList<Service> services = Service.fromElements(packageName, protoFileElement.services()); ImmutableList<Extend> wireExtends = Extend.fromElements(packageName, protoFileElement.extendDeclarations()); Options options = new Options(Options.FILE_OPTIONS, protoFileElement.options()); return new ProtoFile(protoFileElement.location(), protoFileElement.imports(), protoFileElement.publicImports(), packageName, types, services, wireExtends, options, protoFileElement.syntax()); }
static ImmutableList<Extend> fromElements(String packageName, ImmutableList<ExtendElement> extendElements) { ImmutableList.Builder<Extend> extendBuilder = new ImmutableList.Builder<>(); for (ExtendElement extendElement : extendElements) { extendBuilder.add(new Extend(extendElement.location(), extendElement.documentation(), extendElement.name(), Field.fromElements(packageName, extendElement.fields(), true))); } return extendBuilder.build(); }