Skip to content

Conversation

@kevmoo
Copy link
Member

@kevmoo kevmoo commented Jun 23, 2017

No description provided.

@kevmoo kevmoo force-pushed the reviver_hacks branch 2 times, most recently from d070fad to 14e2274 Compare June 23, 2017 05:30
kevmoo added 3 commits June 22, 2017 22:30
aligns with URL behavior of _MirrorTypeChecker - which also returns
the library URI (not the part)
@kevmoo kevmoo changed the title WIP: just checking bots... Add types to ConstantReader, fix issue with parts, migrate annotation helpers Jun 23, 2017
@kevmoo kevmoo requested a review from matanlurey June 23, 2017 05:31
/// Returns a [DartType] representing this as a `Type` value.
///
/// Throws [FormatException] if [isType] is `false`.
DartType get typeValue;
Copy link
Member Author

Choose a reason for hiding this comment

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

@matanlurey – can't get the actual Type because runtime vs static.

_object.toIntValue() ??
_object.toStringValue() ??
_object.toDoubleValue() ??
(isSymbol ? this.symbolValue : null) ??
Copy link
Member Author

Choose a reason for hiding this comment

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

Special case here to return an actual Symbol and not a String

var annotationObject = annotation.constantValue;
try {
return _getValue(annotationObject, annotation.element.context.typeProvider);
return _getValue(annotation.constantValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK you always want to use computeConstantValue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just ran a little test – in all cases constantValue and computeConstantValue return the same result. 🤷‍♂️

dynamic _getValue(DartObject object) {
var reader = new ConstantReader(object);

if (reader.isNull) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: You can use anyValue for this purpose if you'd like.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sadly no, we need to talk about that.

Type, List, and Map are weird – you get DartType.

I think we should update anyValue to exclude those and explain why.

bool get isType => _object.toTypeValue() != null;

@override
DartType get typeValue =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Consistent use of ' please.

Copy link
Member Author

Choose a reason for hiding this comment

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

done – enable a lint 😁

@override
bool get isDouble => false;

@override
Copy link
Contributor

Choose a reason for hiding this comment

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

'

Copy link
Member Author

Choose a reason for hiding this comment

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

Huh?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh...geez...

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@override
bool get isSymbol => false;

@override
Copy link
Contributor

Choose a reason for hiding this comment

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

'

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@override
get isType => false;

@override
Copy link
Contributor

Choose a reason for hiding this comment

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

'

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@matanlurey matanlurey merged commit bf929d6 into master Jun 23, 2017
@matanlurey matanlurey deleted the reviver_hacks branch June 23, 2017 05:46
mosuem pushed a commit to dart-lang/build that referenced this pull request Dec 10, 2024
… helpers (dart-lang/source_gen#184)

* ConstantReader: Add Symbol, Type, double

* urlOfElement: use librarySource.uri

aligns with URL behavior of _MirrorTypeChecker - which also returns
the library URI (not the part)

* Migrate annotation helpers to TypeChecker and ConstantReader
mosuem pushed a commit to dart-lang/build that referenced this pull request Dec 10, 2024
… helpers (dart-lang/source_gen#184)

* ConstantReader: Add Symbol, Type, double

* urlOfElement: use librarySource.uri

aligns with URL behavior of _MirrorTypeChecker - which also returns
the library URI (not the part)

* Migrate annotation helpers to TypeChecker and ConstantReader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants