-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed up Refaster
bug checker
#261
base: master
Are you sure you want to change the base?
Changes from 1 commit
69386f0
84061fc
827880b
0f44844
0e46f9c
914d30a
458fb99
db8cf3c
abb6cea
cf772c4
d26bc18
01b7e5b
3482641
12d09ad
74d6c9a
c4b6a5f
d899a8a
20d194b
ad1c98d
50443d1
7e49b08
594f51c
e6caceb
b2ef631
8bd88bb
302e20b
32300ff
d21ac59
0484762
1624ebf
ee74279
344f4e4
6739cb4
72ff8ae
39dc9aa
2a93011
1c5077f
2c137c0
c3a5106
9151287
a27d635
2003bd2
7889148
afdcf52
ab03739
457a8e2
63ad14e
0cf891c
2cb4bd0
c34fa4d
d59b626
5ba7075
0157692
72f8881
77bc107
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -153,7 +153,8 @@ private static void collectRuleIdentifiers( | |||||
} | ||||||
} | ||||||
|
||||||
// XXX: Decompose `RefasterRule`s such that each rule has exactly one `@BeforeTemplate`. | ||||||
// XXX: Consider decomposing `RefasterRule`s such that each rule has exactly one | ||||||
// `@BeforeTemplate`. | ||||||
private static ImmutableSet<ImmutableSet<String>> extractRuleIdentifiers( | ||||||
RefasterRule<?, ?> refasterRule) { | ||||||
ImmutableSet.Builder<ImmutableSet<String>> results = ImmutableSet.builder(); | ||||||
|
@@ -285,13 +286,7 @@ private static String treeKindToString(Tree.Kind kind) { | |||||
|
||||||
private static final class RefasterIntrospection { | ||||||
private static final String UCLASS_IDENT_FQCN = "com.google.errorprone.refaster.UClassIdent"; | ||||||
// XXX: Probably there is a better way to fix this... For a few BeforeTemplates like | ||||||
// `ImmutableMapBuilder` the algorithm wouldn't match so created this fix for now. About 10 | ||||||
// templates would always match. | ||||||
private static final String AUTO_VALUE_UCLASS_IDENT_FQCN = | ||||||
"com.google.errorprone.refaster.AutoValue_UClassIdent"; | ||||||
private static final Class<?> UCLASS_IDENT = getClass(UCLASS_IDENT_FQCN); | ||||||
private static final Class<?> UCLASS_AUTOVALUE_IDENT = getClass(AUTO_VALUE_UCLASS_IDENT_FQCN); | ||||||
private static final Method METHOD_REFASTER_RULE_BEFORE_TEMPLATES = | ||||||
getMethod(RefasterRule.class, "beforeTemplates"); | ||||||
private static final Method METHOD_EXPRESSION_TEMPLATE_EXPRESSION = | ||||||
|
@@ -305,7 +300,7 @@ private static final class RefasterIntrospection { | |||||
private static final Method METHOD_UANY_OF_EXPRESSIONS = getMethod(UAnyOf.class, "expressions"); | ||||||
|
||||||
static boolean isUClassIdent(IdentifierTree tree) { | ||||||
return UCLASS_IDENT.equals(tree.getClass()) || UCLASS_AUTOVALUE_IDENT.equals(tree.getClass()); | ||||||
return UCLASS_IDENT.isAssignableFrom(tree.getClass()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice one @Stephan202, this is way better haha. |
||||||
} | ||||||
|
||||||
static ImmutableList<?> getBeforeTemplates(RefasterRule<?, ?> refasterRule) { | ||||||
|
@@ -320,12 +315,11 @@ static ImmutableList<UStatement> getTemplateStatements(BlockTemplate template) { | |||||
return invokeMethod(METHOD_BLOCK_TEMPLATE_TEMPLATE_STATEMENTS, template); | ||||||
} | ||||||
|
||||||
// Actually UClassIdent. | ||||||
static IdentifierTree getClassIdent(UStaticIdent tree) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return invokeMethod(METHOD_USTATIC_IDENT_CLASS_IDENT, tree); | ||||||
} | ||||||
|
||||||
// XXX: Make nicer. Or rename the other params. | ||||||
// Arguments to this method must actually be of the package-private type `UClassIdent`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One passes arguments to a method. (Corresponding to the parameters of said method. But here we are talking about the provided argument; the comment is here precisely because the parameter type isn't specific enough.) |
||||||
static String getTopLevelClass(IdentifierTree uClassIdent) { | ||||||
return invokeMethod(METHOD_UCLASS_IDENT_GET_TOP_LEVEL_CLASS, uClassIdent); | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the full word.