glean-0.1.0.0: glean/schema/source/codemarkup.search.angle
# Copyright (c) Meta Platforms, Inc. and affiliates.
schema codemarkup.search.1 {
import code.24
import codemarkup
import codemarkup.types
import search.code
#
# Public API
#
# Note the Insensitive case implies you did toLower on the argument
type SearchCase = enum { Sensitive | Insensitive }
#
# search for entities by identifier name, either case insensitive or not
# with optional symbol kind and language filter constraints
#
predicate SearchByName:
{
searchcase: SearchCase,
name: string,
entity: code.Entity,
location: codemarkup.types.Location,
kind: maybe codemarkup.types.SymbolKind,
language: code.Language # optional language filter, could be wild
}
{ SearchCase, Name, Entity, Location, Kind, Language } where
if (Insensitive = SearchCase)
then (
( search.code.SearchByLowerCaseNameKindAndLanguage { Name, Language, Kind, Entity };
codemarkup.EntityLocation { Entity, Location }
) | ( # old form
search.code.SearchByLowerCaseNameAndLanguage { Name, Language, Entity };
EntityLocationAndKind { Entity, Location, Kind }
)
) else ( # case sensitive, either kinded or not
( search.code.SearchByNameKindAndLanguage { Name, Language, Kind, Entity };
codemarkup.EntityLocation { Entity, Location }
) | ( # old form
search.code.SearchByNameAndLanguage { Name, Language, Entity };
EntityLocationAndKind { Entity, Location, Kind } )
);
#
# search by name and scope, with language and kind filters.
#
predicate SearchByScope:
{
searchcase: SearchCase,
name: string,
scope: [string],
entity: code.Entity,
location: codemarkup.types.Location,
kind: maybe codemarkup.types.SymbolKind,
language: code.Language
}
{ SearchCase, Name, Scope, Entity, Location, Kind, Language } where
if (Insensitive = SearchCase)
then (
( search.code.SearchByLowerCaseScopeAndKind { Name, Scope, Language, Kind, Entity };
codemarkup.EntityLocation { Entity, Location }
) | ( # old form
search.code.SearchByLowerCaseScope { Name, Scope, Language, Entity };
EntityLocationAndKind { Entity, Location, Kind }
)
) else (
( search.code.SearchByScopeAndKind { Name, Scope, Language, Kind, Entity };
codemarkup.EntityLocation { Entity, Location }
) | ( # old form
search.code.SearchByScope { Name, Scope, Language, Entity };
EntityLocationAndKind { Entity, Location, Kind };
)
);
# Symbol kind of entity, where kind is optional.
# We can avoid this post-query filter with kind-optimized lookups
predicate EntityLocationAndKind:
{
entity: code.Entity,
location: codemarkup.types.Location,
kind: maybe codemarkup.types.SymbolKind
}
{ Entity, Location, MKind } where
codemarkup.EntityLocation { Entity, Location };
(if codemarkup.EntityKind { Entity, Kind }
then { just = Kind } else nothing) = MKind;
}