# Copyright (c) Meta Platforms, Inc. and affiliates. schema codemarkup.erlang.2 { import src import code.erlang import codemarkup.types import erlang # # Resolving locations to entities # predicate ErlangResolveLocation: { location: codemarkup.types.Location, entity: code.erlang.Entity, } { { Name, File, { span = Span }, nothing }, { decl = Declaration } } where # Location.name is weird but we aren't using it for anything yet. # Weirdness is that distinct fucntions foo/1 and foo/2 have same Location.name ("foo"). # Use `Name = Fqn.name + str(Fqn.arity)` when primops available so names are "foo/1" and "foo/2" Declaration = erlang.Declaration { func = { fqn = {name = Name}, file = File, span = Span } }; # # Finding entities' locations # predicate ErlangEntityLocation: { entity: code.erlang.Entity, location: codemarkup.types.Location, } { { decl = D }, { Name, File, { span = Span }, nothing } } where erlang.DeclarationLocation { declaration = D, file = File, span = Span }; # Location.name here is weird, see ErlangResolveLocation comment { func = erlang.FunctionDeclaration { fqn = {name = Name } , file = _, span = _} } = D; # # Finding references in a file # predicate ErlangFileEntityXRefLocations: { file: src.File, xref: codemarkup.types.XRefLocation, entity: code.erlang.Entity, } { File, { target = TargetLocation, source = { span = Span } }, { decl = Decl } } where erlang.XRefsViaFqnByFile { file = File, xrefs = XRefs }; { target = Fqn, source = Span } = XRefs[..]; erlang.DeclarationWithFqn { fqn = Fqn, declaration = Decl }; # Location.name here is weird, see ErlangResolveLocation comment { func = { fqn = { name = Name }, file = TargetFile, span = TargetSpan } } = Decl; { Name, TargetFile, { span = TargetSpan }, nothing } = TargetLocation; # # Language entity uses # predicate ErlangEntityUses: { target: code.erlang.Entity, file: src.File, span: src.ByteSpan, } { { decl = D }, File, Span } where erlang.DeclarationUses { declaration = D, file = File, span = Span} # # Language-specific symbol info # predicate ErlangEntityKind: { entity: code.erlang.Entity, kind: codemarkup.types.SymbolKind, } { { decl = { func = D } }, Function } where erlang.FunctionDeclaration {} = D # For backward compatibility: predicate ErlangEntityInfo: { entity: code.erlang.Entity, info: codemarkup.types.SymbolInfo, } { E, { kind = K, isAbstract = false } } where ErlangEntityKind { E, K } predicate ErlangEntityDocumentation : { entity : code.erlang.Entity, file : src.File, span : src.ByteSpan, text : maybe string, } { Entity, File, Span, Text } where { decl = Decl } = Entity; erlang.DeclarationComment { Decl1, File, Span, Text }; erlang.Declaration { func = Decl1 } = Decl }