-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework the way AutoValue generates imports.
Previously we attempted to construct the set of all referenced types, before generating anything, and we then used the TypeSimplifier class to generate appropriate imports and respell classes appropriately. Now, we have a two-pass system. Initially we use backquotes to wrap every class name in the text, so java.lang.Number will be `java.lang.Number` and java.util.List<? extends java.lang.Number> might be `java.util.List`<? extends `java.lang.Number`>. The complete source program is generated with class names encoded that way. Then we rescan the source to find which classes are actually referenced in it. We compute the appropriate imports, and we replace the backquoted names with the appropriate spellings given those imports. This makes the code much simpler and less error-prone. In particular, we don't need to have two kinds of TypeVisitor, one for finding referenced classes and another for converting types to strings. The act of converting to a string includes recording the referenced classes. RELNOTES=Reworked the logic for imports in AutoValue. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=178278647
- Loading branch information
1 parent
c9fd48f
commit 39b9987
Showing
23 changed files
with
1,141 additions
and
1,001 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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.