mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 21:21:32 +00:00
Add ability for the angular plugin to set ErrorVerifier.enclosingClass.
There is a similar setter on Resolver, and without it, users are seeing an issue: https://github.com/dart-lang/angular_analyzer_plugin/issues/567. Alternative options to modifying pkg:analyzer APIs are few. One option is to block UNQUALIFIED_STATIC_REFERNCE errors, however, that will be too general. We would need to implement a lookup to double-check when those errors are reported, if they should be. Alternatively the plugin could block all of them, and then do a second pass to provide them where the plugins deems they should exist. This seems the easiest approach and mirrors the api that [Resolver.set enclosingClass] provides, but the chain of assertions makes we want a second look on it. Change-Id: I12df71719c7a0e968a0b3a43cc27c69160ec5210 Reviewed-on: https://dart-review.googlesource.com/54703 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
This commit is contained in:
parent
4b647fcfe1
commit
ddd1c3548f
|
@ -209,6 +209,24 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
|||
*/
|
||||
ClassElementImpl _enclosingClass;
|
||||
|
||||
ClassElement get enclosingClass => _enclosingClass;
|
||||
|
||||
/**
|
||||
* For consumers of error verification as a library, (currently just the
|
||||
* angular plugin), expose a setter that can make the errors reported more
|
||||
* accurate when dangling code snippets are being resolved from a class
|
||||
* context. Note that this setter is very defensive for potential misuse; it
|
||||
* should not be modified in the middle of visiting a tree and requires an
|
||||
* analyzer-provided Impl instance to work.
|
||||
*/
|
||||
set enclosingClass(ClassElement classElement) {
|
||||
assert(classElement is ClassElementImpl);
|
||||
assert(_enclosingClass == null);
|
||||
assert(_enclosingEnum == null);
|
||||
assert(_enclosingFunction == null);
|
||||
_enclosingClass = classElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* The enum containing the AST nodes being visited, or `null` if we are not
|
||||
* in the scope of an enum.
|
||||
|
|
Loading…
Reference in a new issue