-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
390 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
|
||
// Checks if a string is a valid name for a constructor in JavaScript | ||
export const CONSTRUCTOR_EXPRESSION = /^[A-Z]/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export interface ProgramExports { | ||
ctors: Array<string>; | ||
identifiers: Array<string>; | ||
indirects: Record<string, string>; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/generators/api-links/utils/checkIndirectReferences.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { visit } from 'estree-util-visit'; | ||
|
||
/** | ||
* | ||
* @param program | ||
* @param {import('../types.d.ts').ProgramExports} exports | ||
* @param {Record<string, number>} nameToLineNumberMap | ||
*/ | ||
export function checkIndirectReferences(program, exports, nameToLineNumberMap) { | ||
if (Object.keys(exports.indirects).length === 0) { | ||
return; | ||
} | ||
|
||
visit(program, node => { | ||
if (!node.loc || node.type !== 'FunctionDeclaration') { | ||
return; | ||
} | ||
|
||
const name = node.id.name; | ||
|
||
if (name in exports.indirects) { | ||
nameToLineNumberMap[exports.indirects[name]] = node.loc.start.line; | ||
} | ||
}); | ||
} |
Oops, something went wrong.