Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/jsii-reflect/lib/jsii-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,29 +232,34 @@ function matches(el: ApiElement, kind: string, pred: Predicate): boolean {
if (!['type', 'class'].includes(kind)) return false;

context.kind = 'class';
context.fqn = el.fqn;
}
if (el instanceof InterfaceType) {
const moreSpecificInterfaceType = el.datatype ? 'struct' : 'interface';
if (!['type', moreSpecificInterfaceType].includes(kind)) return false;

context.kind = moreSpecificInterfaceType;
context.fqn = el.fqn;
}
if (el instanceof EnumType) {
if (!['type', 'enum'].includes(kind)) return false;

context.kind = 'enum';
context.fqn = el.fqn;
}
if (el instanceof Property) {
if (!['member', 'property'].includes(kind)) return false;

context.kind = 'property';
context.fqn = `${el.parentType.fqn}#${el.name}`;
}
if (el instanceof Callable) {
const moreSpecificCallable =
el instanceof Initializer ? 'initializer' : 'method';
if (!['member', moreSpecificCallable].includes(kind)) return false;

context.kind = moreSpecificCallable;
context.fqn = `${el.parentType.fqn}#${el.name}`;
}

Object.assign(
Expand Down Expand Up @@ -430,6 +435,7 @@ type ApiElementAttribute =

const API_ELEMENT_ATTRIBUTES: ApiElementAttribute[] = [
'kind',
'fqn',
// Types
'ancestors',
'abstract',
Expand Down
10 changes: 10 additions & 0 deletions packages/jsii-reflect/test/jsii-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ describe('filtering', () => {
'static @scope/jsii-calc-base-of-base.StaticConsumer#consume(..._args: any[]): void',
);
});

test('fqn is available to filter on', async () => {
const result = await query([
parseExpression('class:fqn.includes("base.StaticConsumer")'),
]);

expect(result).toContainEqual(
'static @scope/jsii-calc-base-of-base.StaticConsumer#consume(..._args: any[]): void',
);
});
});

async function query(
Expand Down
Loading