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(); } }
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(); } }