private void add(List<FieldDescriptorProto> extensions) { for (int i = 0; i < extensions.size(); i++) { pathSegments.push(i); FieldDescriptorProto extensionProto = extensions.get(i); String extendee = resolve(extensionProto.getExtendee()); Multimap<String, Extension> messageExtensions = builder.get(extendee); if (messageExtensions == null) { messageExtensions = ArrayListMultimap.create(); builder.put(extendee, messageExtensions); } String path = DOT_JOINER.join(pathSegments.descendingIterator()); DescriptorProtos.SourceCodeInfo.Location location = locationMap.get(path).get(0); // Since paths are only unique within a file, we need a synthetic path to make them unique, // given that paths are used to uniquely identify elements in a ProtoFile, and we're // stuffing elements from another file into it. path = currentFile.getName() + ":" + path; Location fileLocation = new SimpleLocation(String.format( "%s:%d:%d", currentFile.getName(), location.getSpan(0) + 1, location.getSpan(1) + 1)); Extension extension = new Extension(extensionProto, location, path, fileLocation); messageExtensions.put(getExtensionFieldName(extensionProto.getName()), extension); pathSegments.pop(); } }
builder.put(entry.getKey().getPath(), entry.getKey().getLocation()); protoToLocation.put(entry.getValue(), entry.getKey().getFileLocation());
extensionPool.getSortedExtensionsByTypeName(getFullName())) { fieldsBuilder.add(Field.createAsExtension( this, entry.getValue(), entry.getValue().getPath(), entry.getKey()));
extensionPool.getSortedExtensionsByTypeName(getFullName())) { fieldsBuilder.add(Field.createAsExtension( this, entry.getValue(), entry.getValue().getPath(), entry.getKey()));
builder.put(entry.getKey().getPath(), entry.getKey().getLocation()); protoToLocation.put(entry.getValue(), entry.getKey().getFileLocation());
private void add(List<FieldDescriptorProto> extensions) { for (int i = 0; i < extensions.size(); i++) { pathSegments.push(i); FieldDescriptorProto extensionProto = extensions.get(i); String extendee = resolve(extensionProto.getExtendee()); Multimap<String, Extension> messageExtensions = builder.get(extendee); if (messageExtensions == null) { messageExtensions = ArrayListMultimap.create(); builder.put(extendee, messageExtensions); } String path = DOT_JOINER.join(pathSegments.descendingIterator()); DescriptorProtos.SourceCodeInfo.Location location = locationMap.get(path).get(0); // Since paths are only unique within a file, we need a synthetic path to make them unique, // given that paths are used to uniquely identify elements in a ProtoFile, and we're // stuffing elements from another file into it. path = currentFile.getName() + ":" + path; Location fileLocation = new SimpleLocation(String.format( "%s:%d:%d", currentFile.getName(), location.getSpan(0) + 1, location.getSpan(1) + 1)); Extension extension = new Extension(extensionProto, location, path, fileLocation); messageExtensions.put(getExtensionFieldName(extensionProto.getName()), extension); pathSegments.pop(); } }
/** * Creates a field that represents an extension. */ public static Field createAsExtension(MessageType parent, Extension extension, String path, String name) { Field field = new Field(parent, extension.getProto(), path, null, name); field.getFile().addExtension(extension, field); return field; }
/** * Creates a field that represents an extension. */ public static Field createAsExtension(MessageType parent, Extension extension, String path, String name) { Field field = new Field(parent, extension.getProto(), path, null, name); field.getFile().addExtension(extension, field); return field; }