|
@@ -256,7 +256,7 @@ public final class Descriptors {
|
|
|
throws DescriptorValidationException {
|
|
throws DescriptorValidationException {
|
|
|
return buildFrom(proto, dependencies, false);
|
|
return buildFrom(proto, dependencies, false);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Construct a {@code FileDescriptor}.
|
|
* Construct a {@code FileDescriptor}.
|
|
@@ -495,9 +495,9 @@ public final class Descriptors {
|
|
|
proto.getExtension(i), this, null, i, true);
|
|
proto.getExtension(i), this, null, i, true);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * Create a placeholder FileDescriptor for a message Descriptor.
|
|
|
|
|
|
|
+ * Create a placeholder FileDescriptor for a message Descriptor.
|
|
|
*/
|
|
*/
|
|
|
FileDescriptor(String packageName, Descriptor message)
|
|
FileDescriptor(String packageName, Descriptor message)
|
|
|
throws DescriptorValidationException {
|
|
throws DescriptorValidationException {
|
|
@@ -561,7 +561,7 @@ public final class Descriptors {
|
|
|
extensions[i].setProto(proto.getExtension(i));
|
|
extensions[i].setProto(proto.getExtension(i));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
boolean supportsUnknownEnumValue() {
|
|
boolean supportsUnknownEnumValue() {
|
|
|
return getSyntax() == Syntax.PROTO3;
|
|
return getSyntax() == Syntax.PROTO3;
|
|
|
}
|
|
}
|
|
@@ -745,7 +745,7 @@ public final class Descriptors {
|
|
|
this.fields = new FieldDescriptor[0];
|
|
this.fields = new FieldDescriptor[0];
|
|
|
this.extensions = new FieldDescriptor[0];
|
|
this.extensions = new FieldDescriptor[0];
|
|
|
this.oneofs = new OneofDescriptor[0];
|
|
this.oneofs = new OneofDescriptor[0];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Create a placeholder FileDescriptor to hold this message.
|
|
// Create a placeholder FileDescriptor to hold this message.
|
|
|
this.file = new FileDescriptor(packageName, this);
|
|
this.file = new FileDescriptor(packageName, this);
|
|
|
}
|
|
}
|
|
@@ -1333,8 +1333,8 @@ public final class Descriptors {
|
|
|
"Message type had default value.");
|
|
"Message type had default value.");
|
|
|
}
|
|
}
|
|
|
} catch (NumberFormatException e) {
|
|
} catch (NumberFormatException e) {
|
|
|
- throw new DescriptorValidationException(this,
|
|
|
|
|
- "Could not parse default value: \"" +
|
|
|
|
|
|
|
+ throw new DescriptorValidationException(this,
|
|
|
|
|
+ "Could not parse default value: \"" +
|
|
|
proto.getDefaultValue() + '\"', e);
|
|
proto.getDefaultValue() + '\"', e);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
@@ -1456,7 +1456,7 @@ public final class Descriptors {
|
|
|
return file.pool.enumValuesByNumber.get(
|
|
return file.pool.enumValuesByNumber.get(
|
|
|
new DescriptorPool.DescriptorIntPair(this, number));
|
|
new DescriptorPool.DescriptorIntPair(this, number));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Get the enum value for a number. If no enum value has this number,
|
|
* Get the enum value for a number. If no enum value has this number,
|
|
|
* construct an EnumValueDescriptor for it.
|
|
* construct an EnumValueDescriptor for it.
|
|
@@ -1494,7 +1494,7 @@ public final class Descriptors {
|
|
|
// then remove the whole entry. This way unknown descriptors will
|
|
// then remove the whole entry. This way unknown descriptors will
|
|
|
// be freed automatically and we don't need to do anything to
|
|
// be freed automatically and we don't need to do anything to
|
|
|
// clean-up unused map entries.
|
|
// clean-up unused map entries.
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Note: We must use "new Integer(number)" here because we don't want
|
|
// Note: We must use "new Integer(number)" here because we don't want
|
|
|
// these Integer objects to be cached.
|
|
// these Integer objects to be cached.
|
|
|
Integer key = new Integer(number);
|
|
Integer key = new Integer(number);
|
|
@@ -1509,7 +1509,7 @@ public final class Descriptors {
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Used in tests only.
|
|
// Used in tests only.
|
|
|
int getUnknownEnumValueDescriptorCount() {
|
|
int getUnknownEnumValueDescriptorCount() {
|
|
|
return unknownValues.size();
|
|
return unknownValues.size();
|
|
@@ -1585,7 +1585,7 @@ public final class Descriptors {
|
|
|
|
|
|
|
|
/** Get the value's number. */
|
|
/** Get the value's number. */
|
|
|
public int getNumber() { return proto.getNumber(); }
|
|
public int getNumber() { return proto.getNumber(); }
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public String toString() { return proto.getName(); }
|
|
public String toString() { return proto.getName(); }
|
|
|
|
|
|
|
@@ -1627,7 +1627,7 @@ public final class Descriptors {
|
|
|
file.pool.addSymbol(this);
|
|
file.pool.addSymbol(this);
|
|
|
file.pool.addEnumValueByNumber(this);
|
|
file.pool.addEnumValueByNumber(this);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
private Integer number;
|
|
private Integer number;
|
|
|
// Create an unknown enum value.
|
|
// Create an unknown enum value.
|
|
|
private EnumValueDescriptor(
|
|
private EnumValueDescriptor(
|
|
@@ -1643,7 +1643,7 @@ public final class Descriptors {
|
|
|
this.type = parent;
|
|
this.type = parent;
|
|
|
this.fullName = parent.getFullName() + '.' + proto.getName();
|
|
this.fullName = parent.getFullName() + '.' + proto.getName();
|
|
|
this.number = number;
|
|
this.number = number;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Don't add this descriptor into pool.
|
|
// Don't add this descriptor into pool.
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1930,13 +1930,13 @@ public final class Descriptors {
|
|
|
* descriptors defined in a particular file.
|
|
* descriptors defined in a particular file.
|
|
|
*/
|
|
*/
|
|
|
private static final class DescriptorPool {
|
|
private static final class DescriptorPool {
|
|
|
-
|
|
|
|
|
- /** Defines what subclass of descriptors to search in the descriptor pool.
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /** Defines what subclass of descriptors to search in the descriptor pool.
|
|
|
*/
|
|
*/
|
|
|
enum SearchFilter {
|
|
enum SearchFilter {
|
|
|
TYPES_ONLY, AGGREGATES_ONLY, ALL_SYMBOLS
|
|
TYPES_ONLY, AGGREGATES_ONLY, ALL_SYMBOLS
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
DescriptorPool(final FileDescriptor[] dependencies,
|
|
DescriptorPool(final FileDescriptor[] dependencies,
|
|
|
boolean allowUnknownDependencies) {
|
|
boolean allowUnknownDependencies) {
|
|
|
this.dependencies = new HashSet<FileDescriptor>();
|
|
this.dependencies = new HashSet<FileDescriptor>();
|
|
@@ -1982,9 +1982,9 @@ public final class Descriptors {
|
|
|
GenericDescriptor findSymbol(final String fullName) {
|
|
GenericDescriptor findSymbol(final String fullName) {
|
|
|
return findSymbol(fullName, SearchFilter.ALL_SYMBOLS);
|
|
return findSymbol(fullName, SearchFilter.ALL_SYMBOLS);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /** Find a descriptor by fully-qualified name and given option to only
|
|
|
|
|
- * search valid field type descriptors.
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /** Find a descriptor by fully-qualified name and given option to only
|
|
|
|
|
+ * search valid field type descriptors.
|
|
|
*/
|
|
*/
|
|
|
GenericDescriptor findSymbol(final String fullName,
|
|
GenericDescriptor findSymbol(final String fullName,
|
|
|
final SearchFilter filter) {
|
|
final SearchFilter filter) {
|
|
@@ -2013,18 +2013,18 @@ public final class Descriptors {
|
|
|
|
|
|
|
|
/** Checks if the descriptor is a valid type for a message field. */
|
|
/** Checks if the descriptor is a valid type for a message field. */
|
|
|
boolean isType(GenericDescriptor descriptor) {
|
|
boolean isType(GenericDescriptor descriptor) {
|
|
|
- return (descriptor instanceof Descriptor) ||
|
|
|
|
|
|
|
+ return (descriptor instanceof Descriptor) ||
|
|
|
(descriptor instanceof EnumDescriptor);
|
|
(descriptor instanceof EnumDescriptor);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/** Checks if the descriptor is a valid namespace type. */
|
|
/** Checks if the descriptor is a valid namespace type. */
|
|
|
boolean isAggregate(GenericDescriptor descriptor) {
|
|
boolean isAggregate(GenericDescriptor descriptor) {
|
|
|
- return (descriptor instanceof Descriptor) ||
|
|
|
|
|
- (descriptor instanceof EnumDescriptor) ||
|
|
|
|
|
- (descriptor instanceof PackageDescriptor) ||
|
|
|
|
|
|
|
+ return (descriptor instanceof Descriptor) ||
|
|
|
|
|
+ (descriptor instanceof EnumDescriptor) ||
|
|
|
|
|
+ (descriptor instanceof PackageDescriptor) ||
|
|
|
(descriptor instanceof ServiceDescriptor);
|
|
(descriptor instanceof ServiceDescriptor);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Look up a type descriptor by name, relative to some other descriptor.
|
|
* Look up a type descriptor by name, relative to some other descriptor.
|
|
|
* The name may be fully-qualified (with a leading '.'),
|
|
* The name may be fully-qualified (with a leading '.'),
|
|
@@ -2082,7 +2082,7 @@ public final class Descriptors {
|
|
|
|
|
|
|
|
// Append firstPart and try to find
|
|
// Append firstPart and try to find
|
|
|
scopeToTry.append(firstPart);
|
|
scopeToTry.append(firstPart);
|
|
|
- result = findSymbol(scopeToTry.toString(),
|
|
|
|
|
|
|
+ result = findSymbol(scopeToTry.toString(),
|
|
|
DescriptorPool.SearchFilter.AGGREGATES_ONLY);
|
|
DescriptorPool.SearchFilter.AGGREGATES_ONLY);
|
|
|
|
|
|
|
|
if (result != null) {
|
|
if (result != null) {
|