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
UIP-1638: Make transformer output strong mode compliant #81
Conversation
…on-abstract components
…ry to the Component class UIP-1638
RavenNumber of Findings: 0 |
Codecov Report
@@ Coverage Diff @@
## master #81 +/- ##
==========================================
+ Coverage 97.57% 97.58% +0.02%
==========================================
Files 29 29
Lines 1394 1402 +8
==========================================
+ Hits 1360 1368 +8
Misses 34 34 |
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.
Couple things, but looking really good!
@@ -273,6 +277,22 @@ class ImplGenerator { | |||
' extends Object with $componentClassImplMixinName' | |||
); | |||
} | |||
|
|||
if (new RegExp(r'typed(Props|State)Factory\(.+\)(\s+)?({|=>)').hasMatch(sourceFile.getText(0))) { |
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.
I think it'd be much more robust to use the AST to detect this.
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.
Could do something like this:
typedMap.node.members.any((member) => member is MethodDeclaration && !member.isStatic && (
member.name.name == 'typedPropsFactory' ||
member.name.name == 'typedStateFactory'
));
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.
Yeah I like that a lot better! Thanks
var args = ['--strong'] | ||
..addAll(files); | ||
|
||
return await Process.run('dartanalyzer', args); |
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.
You can just give dartanalyzer
a path:
return await Process.run('dartanalyzer', ['--strong', projectPath]);
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 keeps timing out when I do that
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.
Hm, interesting.
I'd try using the project path as the working directory for the command. If that doesn't work, that's fine, but we should have a comment here as to why we're listing out all of the files.
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.
Addressed!
test('generates strong mode compliant code', () async { | ||
var testProject = copyProject(strongModeProject); | ||
|
||
// Run `pub get` and the bootstrap up-front so that back-to-back runs on the same directory complete faster. |
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.
I think this comment was relevant to this code being run in setUpAll
, and is no longer applicable here.
class GenericStatelessProps extends UiProps {} | ||
|
||
@Component() | ||
class GenericStatelessComponent<T extends GenericStatelessProps> extends UiComponent<T> { |
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.
We should add a test fixture for a component with generic state as well, to fully test the generation of typedStateFactory
in that scenario.
UIP-1638
@greglittlefield-wf Feedback has been addressed/replied to |
+10 |
QA +1
Merging. |
Ultimate problem:
Code outputted by generated code was not strong-mode compliant under certain circumstances (concrete classes with generic parameter for props/state type).
How it was fixed:
typedPropsFactory
andtypedStateFactory
to get around that.typedPropsFactory
ortypedStateFactory
Testing suggestions:
Potential areas of regression: