Skip to content
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

CPLAT-11722 Add uiForwardRef #612

Merged
merged 30 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a29da58
Merge branch 'function-components-wip' of github.com:Workiva/over_rea…
joebingham-wk Jul 29, 2020
53fd919
Initial implementation
joebingham-wk Jul 29, 2020
968de33
Add first go at examples
joebingham-wk Jul 29, 2020
c542033
Add extension method
joebingham-wk Jul 30, 2020
841d102
Add tests
joebingham-wk Aug 3, 2020
117cadb
Format tests
joebingham-wk Aug 3, 2020
68f4700
Merge in base
joebingham-wk Aug 3, 2020
96ba4ff
Clean up
joebingham-wk Aug 3, 2020
de94787
Rename FunctionComponentConfig to UiFactoryConfig
joebingham-wk Aug 3, 2020
ea10a41
Check for generated config
joebingham-wk Aug 3, 2020
d435a1f
Fix parsing
joebingham-wk Aug 4, 2020
d865b24
Fix up example
joebingham-wk Aug 5, 2020
378a58d
Fix CI
joebingham-wk Aug 5, 2020
7d288eb
Fix breakages from analyzer 0.39.16
joebingham-wk Aug 5, 2020
861fda7
Format
joebingham-wk Aug 5, 2020
fa6eb84
Address feedback
joebingham-wk Aug 6, 2020
1de88bb
Revert unintentional change
joebingham-wk Aug 6, 2020
d66db3f
Fix empty name issue
joebingham-wk Aug 6, 2020
0e3f5ef
Revert change to getFunctionName
joebingham-wk Aug 6, 2020
236f344
Fix doc comment
joebingham-wk Aug 6, 2020
ac8a42c
Improve example logging readability
joebingham-wk Aug 6, 2020
9e3f6d3
Improve deprecation doc comment
joebingham-wk Aug 6, 2020
e5001d2
Address parser feedback
joebingham-wk Aug 6, 2020
8189f1c
Fix up example
joebingham-wk Aug 7, 2020
49df84c
Add integration tests
joebingham-wk Aug 7, 2020
acf2582
Format
joebingham-wk Aug 7, 2020
af9e2e4
Update doc comment
joebingham-wk Aug 7, 2020
31b3414
Address more feedback :tada:
joebingham-wk Aug 7, 2020
b0f9877
Add displayName to doc comment
joebingham-wk Aug 7, 2020
d12bca5
Fix example title
joebingham-wk Aug 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:over_react_analyzer_plugin/src/diagnostic_contributor.dart';
import 'package:over_react_analyzer_plugin/src/fluent_interface_util.dart';
import 'package:over_react_analyzer_plugin/src/util/ast_util.dart';

const _desc = "Props can't be cascaded after unparenthesized arrow functions.";
// <editor-fold desc="Documentation Details">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,6 @@ extension on SourceSpan {
SourceRange asRangeOrEmpty() => this == null ? SourceRange.EMPTY : asRange();
}

extension<E> on Iterable<E> {
void forEachIndexed(void Function(E, int) callback) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new analyzer version made improvements to the analysis of extensions and caught this was unused

var i = 0;
forEach((e) {
callback(e, i);
i++;
});
}
}

// TODO use the version from over_react instead after initial release
Iterable<PartDirective> getNonGeneratedParts(CompilationUnit libraryUnit) {
return libraryUnit.directives
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ignore: deprecated_member_use
import 'package:analyzer/analyzer.dart'
show CompileTimeErrorCode, NodeLocator, StaticTypeWarningCode, StaticWarningCode;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codes below were moved to CompileTimeErrorCode: dart-lang/sdk@8de8a1c#diff-ff9cb85838db7a802ac5aa9c55f26d86

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't exist in the lowest allowed version of the analyzer package; that dependency needs to be raised in order to use these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh yep, thanks for catching that!

show CompileTimeErrorCode, NodeLocator;
import 'package:analyzer/dart/ast/ast.dart';
import 'package:over_react_analyzer_plugin/src/util/react_types.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
Expand Down Expand Up @@ -63,16 +63,16 @@ class MissingCascadeParensDiagnostic extends DiagnosticContributor {
computeErrors(result, collector) async {
for (final error in result.errors) {
final isBadFunction = const {
StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION,
StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION,
CompileTimeErrorCode.INVOCATION_OF_NON_FUNCTION,
CompileTimeErrorCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION,
}.contains(error.errorCode);
final isBadArity = const {
CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS,
CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED,
CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS,
}.contains(error.errorCode);
final isVoidUsage = const {
StaticWarningCode.USE_OF_VOID_RESULT,
CompileTimeErrorCode.USE_OF_VOID_RESULT,
}.contains(error.errorCode);

if (isBadFunction || isBadArity || isVoidUsage) {
Expand Down
2 changes: 1 addition & 1 deletion web/component2/src/demos/ref.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ mixin RefDemoProps on UiProps {}

final RefDemoContainer = uiFunction<RefDemoProps>(
(props) {
// `uiForwardRef` Refs
// `uiForwardRef` Refs
final buttonNodeRefForSimpleFunctionComponent = createRef<Element>();
final buttonNodeRefForComplexFunctionComponent = createRef<Element>();
final buttonNodeRefForSimpleComponent = createRef<Element>();
Expand Down