Skip to content
This repository was archived by the owner on Nov 9, 2018. It is now read-only.

Detect and update imports. #29

Closed
lrhn opened this issue May 16, 2018 · 4 comments
Closed

Detect and update imports. #29

lrhn opened this issue May 16, 2018 · 4 comments

Comments

@lrhn
Copy link
Contributor

lrhn commented May 16, 2018

If a file contains an import of dart:convert with a show clause, please convert all the matching imported names as well. Include the encode/decode functions.

That is:

import 'dart:convert' show JSON, UTF8;

should be come

import 'dart:convert' show json, jsonEncode, jsonDecode, utf8;

(or as many of the first three as are actually used, it might just be one of them).

@devoncarew
Copy link
Contributor

This will need a full analysis server refactoring to support. This tool can't do that as it; we use the analysis server to locate deprecated references, but then use simple heuristics to modify the source code. In order to do a better job here, we'll need additional metadata on deprecated annotations (dart-lang/sdk#32726), and then we can create real analysis server refactorings.

@lrhn
Copy link
Contributor Author

lrhn commented May 18, 2018

Or a small RegExp based script.
If you ever insert jsonEncode, jsonDecode or json, remember that. Then if there is a show json in the import for dart:convert (or any import, let's not be stingy, it might be reexported), then replace that by the necessary ones.
Ditto for base64.

Otherwise you can get "jsonEncode not declared" errors and/or unused import warnings.

@devoncarew
Copy link
Contributor

devoncarew commented May 18, 2018

You'd end up chasing a long tail of smaller issues. The analysis server has a semantic understanding of the code, and can do a much better job here in terms of leaving behind correct code.

@devoncarew
Copy link
Contributor

I'd like to close this in favor of dart-lang/sdk#32726.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants