-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
WIP feat: javadoc {@link} can be made fully-qualified #2172
Conversation
first version with parsing code from JavaParser. |
@monperrus, It is great that you are working on model of javadoc comment content! |
Work:
|
rebased. CI OK. |
I see the problem with line separators. The new javadoc parsing code often uses Note that Spoon CtComment is always using /**
* This line separator is used in comments returned by {@link #getContent()}.
* It is OS independent.
* It has no influence to pretty printed comments, which uses by default OS dependent line separator
*/
String LINE_SEPARATOR = "\n"; It is much simpler to analyze comments when you can be sure that EOL is always So the idea is: When Spoon parses comments it detects all possible kinds of EOL and replaces them by So I guess that code of this PR will work well on Linux and will always fail on other OSes. |
src/main/java/spoon/reflect/visitor/DefaultJavaPrettyPrinter.java
Outdated
Show resolved
Hide resolved
Normally no. I took care of not writing anything OS-dependent.
This PR implements a third option, in normal model (no sniper), it uses the original line breaks from the original source file. I now look at your detailed comments. |
Addressed all your comments. |
src/main/java/spoon/support/compiler/jdt/JDTCommentBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/spoon/support/compiler/jdt/JDTCommentBuilder.java
Outdated
Show resolved
Hide resolved
No mistery ... I am fighting with github comment approval process. I made this comment weeks ago. But I just found that I have to approve them before anybody else can see them... |
Working on this, based on @pvojtechovsky comments in order to make progress towards merge
|
Spoon model is "semantic java model" not source code java model. Therefore I am not happy with storing rawComment in model which may cause performance problems. |
which may cause performance problems.
I disagree here, we have no measurement yet to claim anything or take a decision.
Are you talking about memory performance or runtime performance?
|
I talk about runtime performance. But I do not have any numbers, so I agree to continue like you suggest. We can always change it. It is a minor internal thing. |
cool :)
yes, software is soft! |
Printing of raw comment has these bad side effects:
Looking at all necessary changes I would say that storing of raw content is not good.
@monperrus Is it the only reason why we store raw content and print wrong aligned comments with inconsistent EOLs now? It is quite high price for that :-( |
See alternative implementation of |
* the indentation of the comments will not fit with indentation of context
Yes, I agree with you, we want to keep this behavior.
* the EOL in comment body may be different to other EOLs in the file
Correct, this is not good.
* the setComment("first line\nsecond line"), will be printed wrong now
What do you mean?
Looking at all necessary changes I would say that storing of raw content is not good.
I disagree. The problem is not about storing it, it's about using it in the way I've explored
yesterday , which is not satisfactory, I agree.
It does not comply with requirement R2 in #2172 (comment).
But the more I think about it, the more I prefer this alternative implementation you propose. It
would still enable client code to do what the they want in most cases.
WDYT?
|
I did not noticed that requirement. What is the use case behind that: "the Java files don't exist anymore on disk"? By the way Sniper printer will not work in such case too.
if printing would use original tabs and EOLs then it would print /* first line
second line */
someElementWithIndent; instead of current /*
* first line
* second line
*/
someElementWithIndent;
I liked the origin cleaned/semantic comments. They are more fitting to concept of semantic Java AST, then rawComments. So I would prefer that simple alternative solution too. |
I liked the origin cleaned/semantic comments
Now that we're introducing an object tree for comment comments, we have to basically give away the
String field, and only maintain an object field. (note that we already had a proto-tree with the
tags before ... and actually some hidden synchronization problems already)
The pretty-printed string version of the comment has to be computed on the fly (and possibly cached
... to the price of maintaining a cache infrastructure).
WDYT?
|
I do not know all side effects yet, but I agree that we should get rid of String representation of comment and switch to the |
Please maximize compatibility - most of old tests should pass without all these changes. |
OK, we're along the same line. I agree, we can add support for position and change listeners later. |
And you know me, I take backward compatibility super seriously. |
91849c2
to
61dbbe3
Compare
the diff is clean and CI is OK ... but the performance cost is huge: (11 minutes versus 7 minutes per job) https://travis-ci.org/INRIA/spoon/builds/462260778 What are the solutions? |
If I understood it well, then There is also another reason why we should do it different - new concept of handling of imports, which I discussed with Simon (#2683). One of the ideas of this concept is that model is normally not modified to show/hide fully qualified names. Only just before printing, there are started some model procesors/validators, which changes model to apply imports or FQN mode. So may be So I suggest to wait with this PR after #2683 is merged. |
Yes the super slow call is OK for me, let's wait. I WIP this one again. |
#3160 is a better alternative, way faster (no call to |
Requirements implemented:
R1: add support for getting the original commentsdone in feature: CtComment#getRawContent() #2746R2: the original comment can be analyzed from the model and from the serialized model, even if the Java files don't exist anymore on disk)abandonedR3: the @link fragments can be analyzed donein feat: add support for javadoc inline tags #2802fix #2170