-
Notifications
You must be signed in to change notification settings - Fork 63
Description
Hi all -
I'm creating an analyzer based utility package, to more-easily allow developers to create lint rules, quick assists, etc, and one of the individual proof-of-concepts I'm designing is a more intuitive API for interacting with AST utilities like type-checkers. For more context, you can check out sidecar (the aforementioned analyzer utility) and reflectable_flutter_analyzer (attempted PoC of a Flutter-based analyzer that uses reflectable package).
As the title explains, I'm unable to reflect flutter/material.dart type URIs using package:reflectable, which are needed to perform runtime-checking of a URI match between an analyzer Element's source URI and the expected URI of the Type (e.g. Container). I have this working for dart.ui.Color but it does not work for Container from package:flutter:
import 'package:flutter/material.dart';
import 'package:reflectable_analyzer/reflectable_analyzer.dart';
@GlobalQuantifyCapability(r'\.Color$', analyzerReflector)
@GlobalQuantifyCapability(r'\.Container$', analyzerReflector)
import 'package:reflectable/reflectable.dart' hide SourceLocation;
import 'reflector.reflectable.dart';
void main() {
initializeReflectable();
}The above code incorrectly generates the following:
...
<m.LibraryMirror>[
r.LibraryMirrorImpl(
r'dart.ui', // Correct library mirror for ```dart.ui.Color```
Uri.parse(r'reflectable://0/dart.ui'),
...
),
r.LibraryMirrorImpl(
r'', // Blank library mirror for ```flutter.material.Container```
Uri.parse(r'reflectable://1/'),
...
),
],
... <m.TypeMirror>[
r.NonGenericClassMirrorImpl(
r'Color',
r'dart.ui.Color', // Correct qualified name
...
),
r.NonGenericClassMirrorImpl(
r'Container',
r'.Container', // Expected ```flutter.material.Container``` or something similar
...
),