New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[labs/analyzer] Add support for analyzing function declarations #3655
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getFunctionDeclaration = ( | |
const getFunctionDeclaration = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
declaration: ts.FunctionDeclaration, | ||
analyzer: AnalyzerInterface | ||
): DeclarationInfo => { | ||
const name = getFunctionDeclarationName(declaration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will separate into follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uvu's equal()
is a deep equal... can you use that for better readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to do pretty bad things with classes, so gonna avoid for now.
No description provided.