-
Notifications
You must be signed in to change notification settings - Fork 129
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
WINDUP-1002 new Type location Enum #927
Conversation
What is required to have Enum.CONSTANT searchable? I am a little lost where to add this in a RuleProvider. |
Class clazz = null; | ||
try | ||
{ | ||
clazz = Class.forName(clazzName); |
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.
I would expect this to fail most of the time. Most of the time the code from the client's application will not be on the classpath.
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.
yep, that's true unfortunately. The other way of guessing constant would be probably more hard or not effective.
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.
In the case of assignment, it is possible to get it from JDT (expression.getName(), I think). I'm not sure about the other cases.
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.
It looks like MethodInvocation has a List accessible via "arguments()" with this information as well.
It would just need to be added to the schema, I think. org.jboss.windup.rules.apps.java.xml.TypeReferenceLocationHandler should be able to load it based upon the enum. |
I think that is handled already in |
c55003a
to
76baaa6
Compare
The Enum const location type reference is added and both cases when Enum class is on classpath or is not it is recognized by Windup AST. The cases are method parameters, variable initialization, field declaration and constructor call. Adding more tests to test the whole thing |
@@ -19,7 +19,7 @@ | |||
<groupId>org.eclipse.tycho</groupId> | |||
<artifactId>org.eclipse.jdt.core</artifactId> | |||
<version>3.10.0.v20140604-1726</version> | |||
<scope>provided</scope> | |||
<!-- <scope>provided</scope> --> |
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.
This will have the side effect of pulling this into the windup distribution again, creating a conflict between our modified version and the upstream version.
I don't think we can leave it this way for the merge, although maybe it is your intention to remove it before merging?
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.
+1, I had hard time to have it in provided scope for Eclipse development and Junit test running. So I have commented that line temporary.
I've sent a PR to this branch: mareknovotny#1 |
ok, i will look what needs to be changed, thanks @jsight ! |
it seems that for some tests it can't parse the java source from decompiled bytecode. I will look into root cause failures. |
38f89ca
to
e091da0
Compare
WINDUP-1002 fixing parsing issue for variant number arguments in method calls
|
||
return sb.toString(); | ||
} | ||
|
||
public static PackageAndClassName parseFromQualifiedName(String qualifiedName) | ||
{ | ||
final String packageName; |
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.
(Not related to the PR) This class seriously needs to be refactored to smaller parts.
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.
Yeah, probably. More importantly, I would like for it output a graph of type reference information rather than the current flat list.
https://issues.jboss.org/browse/WINDUP-1002
I added ENUM_CONSTANT type. It resolves/creates a ClassReference with qualifiedName as Enum.CONSTANT