-
Notifications
You must be signed in to change notification settings - Fork 130
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
MIGR-226: Improve the capabilities of the Java AST source analyzer #491
Conversation
Refer to this link for build results (access rights to CI server needed): |
6ba7d37
to
2d2c5f5
Compare
Merged build finished. Test PASSed. |
Refer to this link for build results (access rights to CI server needed): |
@@ -14,6 +14,11 @@ | |||
public interface JavaClassBuilder extends ConditionBuilder | |||
{ | |||
/** | |||
* Specify the exact regex for the line to match (useful to distinguish hard-coded strings etc.) |
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's not a regex, is it? It's a ParameterizedPattern
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.
nor the type in inType is :-)
This looks good. I'm not sure
|
I don't like matches that much because it doesn't say anything about what's going to be matched there and it is already used in XmlFile for xpath match |
|
||
private String extractDefinitionLine(String typeDeclaration) { | ||
String typeLine = ""; | ||
String[] lines = typeDeclaration.split(System.getProperty("line.separator")); |
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.
as jess/lincoln said, this is system specific and will not work in case the scanned library comes from different system
Perhaps "sourceMatches"? |
Or maybe 'matchesSource'? That way, if there are other future matches, they'll all start with matches? |
secondRuleMatchCount++; | ||
} | ||
}).endIteration()) | ||
.where("line").matches("testJavaClassCondition\\(\\) throws IOException, InstantiationException") |
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 regex does not match. In case you know why, I am eager to hear :) because I don't know yet.
The line registered in the graph is exactly
"
@test public void testJavaClassCondition() throws IOException, InstantiationException, IllegalAccessException {"
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.
You have a "\n" character at the beginning and that is throwing off the regex match. Seems a little brittle doesn't it? :)
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 thought {*} will help. Yes, it is brittle, however this one may be easily fixed.
I like the matchesSource approach |
} | ||
} | ||
return typeLine; | ||
} |
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.
Can somebody check this? I am not sure this will work system-wide
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 think that it is ok, although I am not sure how I feel about including the "\n".
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 think there is always only one line, so this may be taken of
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.
Well, it could span quite a few lines in the raw text. But I think accounting for this with a regex would be painful, and the extra lines are not syntactically significant, IMO.
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 think eclipse JDT forgets abouts some lines, so all the times I checked there were lines like "@OverRide public void myMethod(params) {"
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.
That is possible. I haven't really tried it to see.
Refer to this link for build results (access rights to CI server needed): Failed Tests: 3org.jboss.windup.ast:windup-java-ast-tests: 1org.jboss.windup.rules.apps:windup-rules-java-tests: 2
Test FAILed. |
As an FYI, toString() for JavaClass needs to be udpated as well. |
* Gets the snippit referenced by this {@link FileLocationModel}. | ||
*/ | ||
@Property(RESOLVED_SOURCE_SNIPPIT) | ||
void setResolvedSourceSnippit(String source); |
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 think that I would prefer this field be used for the unresolved source snippit. I'm not sure why we need to change the default behavior for referencedSourceSnippit?
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.
What do you mean exactly? I would say it is easier to understand that SOURCE_SNIPPIT is a raw part of the source and it would also correlate with the xml layer we have. BTW thanks for taking time looking at this PR
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.
Maybe it's just "because we've always done it that way". :) It just feels strange to me to change the existing behavior for sourceSnippit (that has existed since Windup 1.x).
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.
@lincolnthree what do you say? :) I will get used to both
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.
@mbriskar After looking over the way we use this value more, I don't think it is a big deal to change it to your approach at all. I'm ok with it. :)
8e886c4
to
33e27b9
Compare
Refer to this link for build results (access rights to CI server needed): Failed Tests: 2org.jboss.windup.ast:windup-java-ast-tests: 1org.jboss.windup.rules.apps:windup-rules-java-tests: 1Test FAILed. |
Refer to this link for build results (access rights to CI server needed): Failed Tests: 2org.jboss.windup.ast:windup-java-ast-tests: 1org.jboss.windup.rules.apps:windup-rules-java-tests: 1Test FAILed. |
Refer to this link for build results (access rights to CI server needed): |
@mbriskar Unless anyone else has objections, I think this is good to go at this point? Maybe it should wait until the metadata merge, though? |
@jsight Both works for me |
This PR adds new attribute to JavaClass, so now we will be able to query the raw line of the file like so:
This condition distinguish the hard-coded string inside the mySimpleMethod call.