[labs/analyzer] Add support for analyzing function declarations#3655
[labs/analyzer] Add support for analyzing function declarations#3655kevinpschaaf merged 5 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 4ef6c0a The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
| }; | ||
| }; | ||
|
|
||
| export const getFunctionDeclaration = ( |
There was a problem hiding this comment.
| export const getFunctionDeclaration = ( | |
| const getFunctionDeclaration = ( |
| declaration: ts.FunctionDeclaration, | ||
| analyzer: AnalyzerInterface | ||
| ): DeclarationInfo => { | ||
| const name = getFunctionDeclarationName(declaration); |
There was a problem hiding this comment.
Is the other stuff in getFunctionLikeInfo() too expensive to call here? This feels like something that should be rolled into it.
There was a problem hiding this comment.
getFunctionLikeInfo() is called here and in ClassMethod
| try { | ||
| const packagePath = fileURLToPath( | ||
| new URL(`../../test-files/${lang}/functions`, import.meta.url).href | ||
| ) as AbsolutePath; | ||
| const analyzer = createPackageAnalyzer(packagePath); | ||
|
|
||
| const result = analyzer.getPackage(); | ||
| const file = getSourceFilename('functions', lang); | ||
| const module = result.modules.find((m) => m.sourcePath === file); | ||
| if (module === undefined) { | ||
| throw new Error(`Analyzer did not analyze file '${file}'`); | ||
| } | ||
|
|
||
| ctx.packagePath = packagePath; | ||
| ctx.analyzer = analyzer; | ||
| ctx.module = module; | ||
| } catch (error) { | ||
| // Uvu has a bug where it silently ignores failures in before and after, | ||
| // see https://github.com/lukeed/uvu/issues/191. | ||
| console.error('uvu before error', error); | ||
| process.exit(1); | ||
| } |
There was a problem hiding this comment.
There's also a chunk like this in ./modules_test.ts. Probably not worth making a function yet if it's just the two, but are there others?
There was a problem hiding this comment.
Will separate into follow-up PR.
There was a problem hiding this comment.
| assert.equal(fn.parameters?.[0].summary, undefined); | ||
| assert.equal(fn.parameters?.[0].type?.text, 'string'); | ||
| assert.equal(fn.parameters?.[0].default, undefined); | ||
| assert.equal(fn.parameters?.[0].rest, false); |
There was a problem hiding this comment.
Uvu's equal() is a deep equal... can you use that for better readability?
There was a problem hiding this comment.
It seems to do pretty bad things with classes, so gonna avoid for now.
No description provided.