-
Notifications
You must be signed in to change notification settings - Fork 57
FED-4894 Support analyzer >=10 <15 #1012
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6475ca1
Raise analyzer constraint to >=10.0.0 <15.0.0, migrate builder AST fo…
greglittlefield-wf c699fd0
Use more specific typing than dynamic
greglittlefield-wf 7a7bfff
Fix ignore comment
greglittlefield-wf 5f3db8a
Add TODO
greglittlefield-wf 779cc55
Clean up some classish calls
greglittlefield-wf c02a917
Disable analyzer plugin override for now
greglittlefield-wf ef5b671
Fix bad changelog header
greglittlefield-wf 74acac7
Fix nameLexeme in tests
greglittlefield-wf ac64dcc
Fix breakages in newer analyzers
greglittlefield-wf 8021551
Delete dart_dev config so it doesn't error
greglittlefield-wf 15e6397
Fix typo
greglittlefield-wf d2e4ee5
Merge branch 'drop-dart-2-support' into allow-latest-analyzer
greglittlefield-wf 509ef38
Add more descriptive comment around cast
greglittlefield-wf e2c0fa8
Eliminate non-null assertion
greglittlefield-wf ed5cc5b
Bump build_runner to pull in fix for dart-lang/build#4944
greglittlefield-wf 6006680
Fix warnings when compiling errors (not fatal, just noisy)
greglittlefield-wf ee1d14f
Allow latest package_config dep
greglittlefield-wf 207f0f1
Work around test issue
greglittlefield-wf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -68,31 +68,59 @@ extension TypeAnnotationNameHelper on TypeAnnotation { | |
| /// Extension built on [NameHelper] to allow for easy access to the `name` | ||
| /// field of [Identifier]s. | ||
| extension TypeNameHelper on NamedType { | ||
| // Backwards compatibility for various analyzer versions that remove name/name2. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed these since they were only needed for older analyzer versions |
||
| dynamic get name => this.name2; // Use `this.` to point to real impl if it exists, not extension. | ||
| dynamic get name2 => this.name; // Use `this.` to point to real impl if it exists, not extension. | ||
| dynamic get _name => name; | ||
| String get nameLexeme { | ||
| final name = this._name; | ||
| if (name is Identifier) return name.name; | ||
| if (name is Token) return name.lexeme; | ||
| if (name is String) return name; | ||
| throw UnimplementedError('Unexpected type for name: ${name.runtimeType}'); | ||
| } | ||
|
|
||
| /// The type name without any namespace prefixes. | ||
| String get nameWithoutPrefix => nameLexeme; | ||
| String get nameWithoutPrefix => name.lexeme; | ||
|
|
||
| /// The type name including the namespace prefix. | ||
| String get nameWithPrefix { | ||
| final prefix = importPrefix?.name.lexeme; | ||
| return [ | ||
| if (prefix != null) prefix, | ||
| nameLexeme, | ||
| name.lexeme, | ||
| ].join('.'); | ||
| } | ||
| } | ||
|
|
||
| /// Provides `.members` on [ClassBody] for analyzer versions where it is only | ||
| /// declared on [BlockClassBody]. | ||
| /// | ||
| /// On analyzer 12+ the real instance member wins over this extension. | ||
| /// On analyzer 10/11 the cast always succeeds because [EmptyClassBody] does not exist. | ||
| extension ClassBodyMembersCompat on ClassBody { | ||
| NodeList<ClassMember> get members => (this as BlockClassBody).members; | ||
| } | ||
|
|
||
| /// Parts of a named argument, returned by [namedArgumentParts]. | ||
| class NamedArgumentParts { | ||
| const NamedArgumentParts(this.name, this.value); | ||
| final String name; | ||
| final Expression value; | ||
| } | ||
|
|
||
| /// Returns the name label lexeme and value expression of a named argument node | ||
| /// ([NamedArgument] in analyzer 13+, [NamedExpression] in earlier versions), | ||
| /// or `null` if [node] is not a named argument. | ||
| /// | ||
| /// TODO remove once we only support analyzer 13+ | ||
| NamedArgumentParts? namedArgumentParts(AstNode node) { | ||
| // analyzer 13+: NamedArgument (name: Token, argumentExpression: Expression) | ||
| // analyzer 10–12: NamedExpression (name: Label (label: SimpleIdentifier), expression: Expression) | ||
| try { | ||
| final dynamicNode = node as dynamic; | ||
| final nameToken = dynamicNode.name; | ||
| if (nameToken is Token) { | ||
| // analyzer 13+: NamedArgument | ||
| return NamedArgumentParts(nameToken.lexeme, dynamicNode.argumentExpression as Expression); | ||
| } else { | ||
| // analyzer 10–12: NamedExpression — nameToken is a Label whose .label is SimpleIdentifier | ||
| final labelName = (nameToken as dynamic).label.name as String; | ||
| return NamedArgumentParts(labelName, dynamicNode.expression as Expression); | ||
| } | ||
| } catch (_) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| /// Utilities related to simplifying access to node identifier fields. | ||
| extension NameHelper on Identifier { | ||
| /// The identifier without any prefixes (e.g., namespaces, classes, etc). | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note that analyzer_plugin isn't up to date on analyzer yet; that'll be a separate PR