File tree Expand file tree Collapse file tree
libs/parsing/index/src/lib/post-process/populate-type/return Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { CancellationToken } from '@idl/cancellation-tokens' ;
2+ import { IParsed } from '@idl/parsing/syntax-tree' ;
3+ import {
4+ GLOBAL_TOKEN_TYPES ,
5+ GlobalFunctionMethodToken ,
6+ GlobalFunctionToken ,
7+ IDLTypeHelper ,
8+ IGlobalIndexedToken ,
9+ } from '@idl/types/core' ;
10+
11+ import { IDLIndex } from '../../../idl-index.class' ;
12+
13+ /**
14+ * What global tokens do we try and get return types for
15+ */
16+ const RETURN_TYPES_FOR : { [ key : string ] : undefined } = { } ;
17+ RETURN_TYPES_FOR [ GLOBAL_TOKEN_TYPES . FUNCTION ] = undefined ;
18+ RETURN_TYPES_FOR [ GLOBAL_TOKEN_TYPES . FUNCTION_METHOD ] = undefined ;
19+
20+ /**
21+ * Populates the return type for functions
22+ */
23+ export function PopulateReturnType (
24+ index : IDLIndex ,
25+ parsed : IParsed ,
26+ cancel : CancellationToken
27+ ) {
28+ /**
29+ * Find functions to process
30+ */
31+ const functions = (
32+ parsed . global . filter (
33+ ( global ) =>
34+ global . type in RETURN_TYPES_FOR && ! global . name . endsWith ( '::init' )
35+ ) as IGlobalIndexedToken < GlobalFunctionToken | GlobalFunctionMethodToken > [ ]
36+ ) . filter ( ( global ) => ! IDLTypeHelper . isAnyType ( global . meta . returns ) ) ;
37+
38+ /**
39+ * Do nothing if we have no matches
40+ */
41+ if ( functions . length === 0 ) {
42+ return ;
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments