mirror of https://github.com/grpc/grpc-node.git
reflection: Fix references to symbols with no package
This commit is contained in:
parent
c10d973d38
commit
0207979a4d
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@grpc/reflection",
|
"name": "@grpc/reflection",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Google Inc."
|
"name": "Google Inc."
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,6 +8,7 @@ import 'unscoped.proto';
|
||||||
service SampleService {
|
service SampleService {
|
||||||
rpc Hello (HelloRequest) returns (HelloResponse) {}
|
rpc Hello (HelloRequest) returns (HelloResponse) {}
|
||||||
rpc Hello2 (HelloRequest) returns (CommonMessage) {}
|
rpc Hello2 (HelloRequest) returns (CommonMessage) {}
|
||||||
|
rpc Hello3 (ProcessRequest) returns (TopLevelMessage) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
service IgnoreService {
|
service IgnoreService {
|
||||||
|
|
|
@ -113,8 +113,12 @@ export class ReflectionV1Implementation {
|
||||||
|
|
||||||
let referencedFile: IFileDescriptorProto | null = null;
|
let referencedFile: IFileDescriptorProto | null = null;
|
||||||
if (ref.startsWith('.')) {
|
if (ref.startsWith('.')) {
|
||||||
// absolute reference -- just remove the leading '.' and use the ref directly
|
/* absolute reference -- In files with no package, symbols are
|
||||||
referencedFile = this.symbols[ref.slice(1)];
|
* populated in the symbols table with a leading period in the key.
|
||||||
|
* If there is a package, the symbol does not have a leading period in
|
||||||
|
* the key. For simplicity, we check without the period, then with it.
|
||||||
|
*/
|
||||||
|
referencedFile = this.symbols[ref.slice(1)] ?? this.symbols[ref];
|
||||||
} else {
|
} else {
|
||||||
// relative reference -- need to seek upwards up the current package scope until we find it
|
// relative reference -- need to seek upwards up the current package scope until we find it
|
||||||
let pkg = pkgScope;
|
let pkg = pkgScope;
|
||||||
|
|
|
@ -51,7 +51,7 @@ describe('GrpcReflectionService', () => {
|
||||||
const names = descriptors.map((desc) => desc.name);
|
const names = descriptors.map((desc) => desc.name);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
new Set(names),
|
new Set(names),
|
||||||
new Set(['sample.proto', 'vendor.proto', 'vendor_dependency.proto'])
|
new Set(['root.proto', 'sample.proto', 'vendor.proto', 'vendor_dependency.proto'])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ describe('GrpcReflectionService', () => {
|
||||||
const names = descriptors.map((desc) => desc.name);
|
const names = descriptors.map((desc) => desc.name);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
new Set(names),
|
new Set(names),
|
||||||
new Set(['sample.proto', 'vendor.proto', 'vendor_dependency.proto']),
|
new Set(['root.proto', 'sample.proto', 'vendor.proto', 'vendor_dependency.proto']),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ describe('GrpcReflectionService', () => {
|
||||||
const names = descriptors.map((desc) => desc.name);
|
const names = descriptors.map((desc) => desc.name);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
new Set(names),
|
new Set(names),
|
||||||
new Set(['sample.proto', 'vendor.proto', 'vendor_dependency.proto']),
|
new Set(['root.proto', 'sample.proto', 'vendor.proto', 'vendor_dependency.proto']),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ describe('GrpcReflectionService', () => {
|
||||||
const names = descriptors.map((desc) => desc.name);
|
const names = descriptors.map((desc) => desc.name);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
new Set(names),
|
new Set(names),
|
||||||
new Set(['sample.proto', 'vendor.proto', 'vendor_dependency.proto']),
|
new Set(['root.proto', 'sample.proto', 'vendor.proto', 'vendor_dependency.proto']),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue