Skip to content
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

Merged
merged 3 commits into from
Jun 1, 2016
Merged

Conversation

mareknovotny
Copy link
Contributor

https://issues.jboss.org/browse/WINDUP-1002

I added ENUM_CONSTANT type. It resolves/creates a ClassReference with qualifiedName as Enum.CONSTANT

@mareknovotny
Copy link
Contributor Author

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);
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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.

@jsight
Copy link
Member

jsight commented May 16, 2016

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.

@mareknovotny
Copy link
Contributor Author

I think that is handled already in return Enum.valueOf(TypeReferenceLocation.class, location.trim()); at https://github.com/windup/windup/blob/master/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/xml/TypeReferenceLocationHandler.java#L41

@mareknovotny mareknovotny force-pushed the WINDUP-1002 branch 4 times, most recently from c55003a to 76baaa6 Compare May 25, 2016 22:43
@mareknovotny
Copy link
Contributor Author

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> -->
Copy link
Member

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?

Copy link
Contributor Author

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.

@jsight
Copy link
Member

jsight commented May 26, 2016

I've sent a PR to this branch: mareknovotny#1

@mareknovotny
Copy link
Contributor Author

ok, i will look what needs to be changed, thanks @jsight !

@mareknovotny
Copy link
Contributor Author

mareknovotny commented May 27, 2016

it seems that for some tests it can't parse the java source from decompiled bytecode. I will look into root cause failures.

WINDUP-1002 fixing parsing issue for variant number arguments in method
calls

return sb.toString();
}

public static PackageAndClassName parseFromQualifiedName(String qualifiedName)
{
final String packageName;
Copy link
Contributor

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.

Copy link
Member

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.

@mareknovotny mareknovotny deleted the WINDUP-1002 branch June 13, 2016 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants