/** Returns the proto file in which this element lives. */ public ProtoFile getFile() { // Don't need to care about root case as that overrides. return parent.getFile(); }
/** Returns the proto file in which this element lives. */ public ProtoFile getFile() { // Don't need to care about root case as that overrides. return parent.getFile(); }
/** Deliver the location of this protocol element. */ @Override public Location getLocation() { return getFile().getLocation(this); }
/** Deliver the location of this protocol element. */ @Override public Location getLocation() { return getFile().getLocation(this); }
public String getLinkedElementName(ProtoElement element) { String simpleName = element.getSimpleName(); String packageName = element.getFile().getFullName(); return String.format("[%s]{@link %s.%s}", simpleName, packageName, simpleName); } }
private static String getShortName(ProtoElement elem) { return elem.getFullName().substring(elem.getFile().getFullName().length() + 1); }
private static String getProtoElementPackage(ProtoElement elem) { String name = getJavaPackage(elem.getFile()); if (!elem.getFile().getProto().getOptions().getJavaMultipleFiles()) { String outerClassName = elem.getFile().getProto().getOptions().getJavaOuterClassname(); if (outerClassName.isEmpty()) { outerClassName = getFileClassName(elem.getFile()); } name = name + "." + outerClassName; } return name; }
@Override public String getContainerName() { return element.getFile().getLocation().getDisplayString(); }
@Override public String getContainerName() { return element.getFile().getLocation().getDisplayString(); }
@Override public TypeName getTypeName(ProtoElement elem) { List<String> path = getClassNamePath(elem); if (elem instanceof EnumType) { path.add(0, "enums"); String shortName = Joiner.on(".").join(path); return getTypeNameInImplicitPackage(shortName); } boolean useGrpcName = elem instanceof Interface || elem instanceof Method; if (elem.getFile().getSimpleName().equals("google/iam/v1/iam_policy.proto")) { // IAM policy gRPC service isn't actually used; API producers implement this themselves. useGrpcName = false; } if (useGrpcName) { path.add(0, getGrpcPbFileName(elem.getFile().getSimpleName())); } else { path.add(0, getPbFileName(elem.getFile().getSimpleName())); } path.add(0, protoPackageToPythonPackage(elem.getFile().getProto().getPackage())); String fullName = Joiner.on(".").join(path); return typeNameConverter.getTypeName(fullName); }
public static TypeName getGrpcTypeName(ProtoElement elem) { String packageName = getJavaPackage(elem.getFile()); String shortName = getShortName(elem); String longName = packageName + "." + shortName; return new TypeName(longName, shortName); }
public ProtoLocation( DescriptorProtos.SourceCodeInfo.Location location, final ProtoElement element) { // Spit out "?:?" for line:column if there's no "span" set in the location. This can happen // when (for example) a proto transform tool synthesizes a field that doesn't appear in the // source *.proto files. if (location.getSpanCount() > 0) { this.displayString = String.format( "%s:%d:%d", element.getFile().getLocation().getDisplayString(), location.getSpan(0) + 1, location.getSpan(1) + 1); } else { this.displayString = String.format("%s:?:?", element.getFile().getLocation().getDisplayString()); } this.element = element; }
private String getIdlDocumentation(ProtoElement element) { return element.getFile().getDocumentation(element); }
public ProtoLocation( DescriptorProtos.SourceCodeInfo.Location location, final ProtoElement element) { // Spit out "?:?" for line:column if there's no "span" set in the location. This can happen // when (for example) a proto transform tool synthesizes a field that doesn't appear in the // source *.proto files. if (location.getSpanCount() > 0) { this.displayString = String.format( "%s:%d:%d", element.getFile().getLocation().getDisplayString(), location.getSpan(0) + 1, location.getSpan(1) + 1); } else { this.displayString = String.format("%s:?:?", element.getFile().getLocation().getDisplayString()); } this.element = element; }
TypeName getTypeName(ProtoElement elem, boolean isPointer) { String importPath = elem.getFile().getProto().getOptions().getGoPackage(); String elemName = getElemName(elem); return getTypeName(importPath, elemName, isPointer); }
@Override @Nullable protected DocumentationRule fromIdlLayer(ProtoElement element) { // For the case there is no documentation rule, synthesize one from the comment // in the proto. String description = element.getFile().getDocumentation(element); if (inlineAllMessages && (element instanceof MessageType || element instanceof EnumType)) { description = description + "\n(== inline_message ==)"; } if (Strings.isNullOrEmpty(description)) { return null; } return DocumentationRule.newBuilder() .setSelector(element.getFullName()) .setDescription(trimCommentIndentation(description)) .build(); }
@Override @Nullable protected DocumentationRule fromIdlLayer(ProtoElement element) { // For the case there is no documentation rule, synthesize one from the comment // in the proto. String description = element.getFile().getDocumentation(element); if (inlineAllMessages && (element instanceof MessageType || element instanceof EnumType)) { description = description + "\n(== inline_message ==)"; } if (Strings.isNullOrEmpty(description)) { return null; } return DocumentationRule.newBuilder() .setSelector(element.getFullName()) .setDescription(trimCommentIndentation(description)) .build(); }