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
[ROASTER-64] Improve the handling of generics - RFC #33
Conversation
Build 48 outcome was FAILURE using a merge of 4ee164e Build problems:Failed tests detected Failed tests
|
Build 48 outcome was FAILURE using a merge of 4ee164e Build problems:Failed tests detected Failed tests
|
|
||
private static final Pattern SIMPLE_ARRAY_PATTERN = Pattern | ||
.compile("^((.)+)(\\[\\])+$"); | ||
private static final Pattern IDENTIFIER_PATTERN = Pattern |
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.
These regexps are the critical issue to be discussed
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.
Generics, due to the balanced angular brackets, require a context-free grammar, e.g.
T -> ID Gen
Gen -> '<' T '>'
And context-free grammars are not regular, which means that they can't be recognized by a regular expression
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 is excellent. I actually had no idea you could call Character methods through the POSIX \p. Looks like I need to add something to my regular expression tutorials!
I still need to complete the work and fix a few failing tests, but I'd like some feedback on the regexp issue |
String stub = "public class Stub { public void method( " + Types.toSimpleName(Types.fixArray(type, false)) + " " | ||
+ name + " ) {} }"; | ||
String resolvedType = TypeImpl.ensureImports(getOrigin(), new TypeImpl<O>(getOrigin(),null,type)); | ||
String stub = "public class Stub { public void method( " + resolvedType + name + " ) {} }"; |
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.
Tests fail just because a + " " + was lost between resolvedType and name :)
If we agree on the rest, I'll amend the PR
@@ -722,6 +723,11 @@ public boolean isAnnotation() | |||
} | |||
|
|||
@Override | |||
public String ensureImports(Type<?> type) { | |||
throw new UnsupportedOperationException("Imports cannot be added at the package-info level"); |
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.
Why not?
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.
right, you can import package level annotations among other things.. I'll fix it
Conflicts: impl/src/main/java/org/jboss/forge/roaster/model/impl/MethodImpl.java
* @return The name (simple or fully qualified) that should be used to reference the imported type in the code | ||
* @seeAlso org.jboss.forge.roaster.model.Type | ||
*/ | ||
public Import addImport(Type<?> type); |
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.
Very good
Merged in http://github.com/forge/roaster/commit/541472e80. Thanks! |
Some further formatting fixes may be needed, but need the approach validated first