-
Notifications
You must be signed in to change notification settings - Fork 1.3k
issue #8495 Java: members entirely missing if generic parameter extends another generic #8534
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
base: master
Are you sure you want to change the base?
Conversation
The information of a class being static was not being processed as it was not stored with a class (contrary to e.g. abstract, but this is done through another mechanism).
Updating the xml xsd file was omitted
…r extends another generic
src/doxygen.cpp
Outdated
| if ((root->lang==SrcLangExt_CSharp || root->lang==SrcLangExt_Java) && (i=fullName.find('<'))!=-1) | ||
| { |
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.
Is this fix also valid for C# or are apply there different rules?
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.
Honestly, I hoped you would know. I guess the findRev was there for a reason and this might require to be guarded as Java-only. What I am rather confident about is that this is the proper way to do it for Java. I can guard it if you think that's required.
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.
Probably safest is to guard it (I'm not a C# expert either)
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.
Unfortunately I am not much familiar with C#. I am aware that it has somewhat similar generics like Java but probably with some differences. I already suspected the issue might apply to C# as well but do not know for sure. The opinion of someone familiar with C# would be helpful. After a quick search it appears to me that it is not totally trivial to comprehend the full set of rules from C# documentation. (Edit: posted before I saw your answer.)
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.
The latest standard,is to the best of my knowledge, ECMA-334, 5th Edition / December 2017. After this there are changes to the standard as Specification Proposals but they have not bee officially standardized (see e.g. https://en.wikipedia.org/wiki/C_Sharp_(programming_language)).
src/defargs.l
Outdated
| } | ||
| <ReadTypeConstraint>">" { | ||
| if (yyextra->argSharpCount > 0) | ||
| { | ||
| yyextra->curTypeConstraint+=yytext; | ||
| --yyextra->argSharpCount; | ||
| } | ||
| else | ||
| { | ||
| unput(*yytext); | ||
| BEGIN(yyextra->lastExtendsContext); | ||
| } | ||
| } | ||
| <ReadTypeConstraint>"<" { | ||
| yyextra->curTypeConstraint+=yytext; | ||
| ++yyextra->argSharpCount; |
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 happens when the user has an error in the number of < > pairs e.g. more > than < (not a valid program but still ...)?
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 behavior would you recommend in this case? Note that the status quo is rather random behavior for examples described in the issue. I guess the behavior of doxygen on invalid programs is in general undefined. However I admit that we may come up with a friendly behavior for this particular type of syntax issue. E.g. raise a warning if a premature [(){}] is encountered (notice that the entrance to <ReadTypeConstraint> is already guarded as Java-only)?
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.
Actually I'm a bit confused as I see that ReadTypeConstraint is entered as soon as the rule <ReadFuncArgType,ReadFuncArgPtr>"extends" is satisfied (for Java) and the count is increased as soon as < is seen and decreased when > is seen, but the count is at that moment still > 0 and when no , or ) is found the user remains in the ReadTypeConstraint and will leave it as soon as it sees a , or ) but what will happen when the user is in a < ..> part and sees a , or ) or is this not possible?
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.
(for reference: discussion on this continued in #8495)
src/defargs.l
Outdated
| @@ -471,6 +471,7 @@ CPPC "/\/" | |||
| { | |||
| yyextra->curTypeConstraint.resize(0); | |||
| yyextra->lastExtendsContext=YY_START; | |||
| assert(yyextra->argSharpCount == 0); | |||
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 sure why an assert is necessary here? or does this have to do with my remark around the lines 503.? Wouldn't it be better to give a real doxygen warning?
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 believe argSharpCount != 0 can never happen here. Just placed the assert to see whether it would go through the ci. The line can be removed.
…ng of nested commas in declarations of Java generics.
src/defargs.l
Outdated
| <ReadStringLiteral>"\\" { | ||
| BEGIN(ReadEscape); | ||
| } |
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 combine this with the rule <ReadEscape>. to <ReadStringLiteral>"\\." (like it is also done for <CopyArgString> )?
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.
Okay. Good idea.
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 found the "\." slightly misleading for escape sequences because they can be longer than one character, e.g. for unicode \uXXXX. So I went with <ReadStringLiteral>"\\\"" which I think is more on spot for the purpose of that rule. Anyway, just a matter of taste I guess.
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.
Probably yes, but I don't really see the problem with the \uXXXX as here the \\. rule would eat the \u and the normal . rule Xs. I think both solutions would be valid in this case.
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.
Yes, sure both would work. That's why I wrote it's a matter of taste. I just found the \\\" rule more explicit for it's purpose.
src/defargs.l
Outdated
| <ReadAnnotation>"\"" { | ||
| BEGIN(ReadStringLiteral); | ||
| } |
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.
Does for annotations also the single quote possibility exist?
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.
No. The string literals in annotations are just usual Java string literals. Java only uses double quotes as string boundaries, much like C and friends do (and unlike Python does).
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.
Oh sorry, I forgot there can also be character literals, which indeed use a single quote. However, there can only be one single character in between (or an escape sequence), so it should be sufficient to handle the rules <ReadAnnotation>"'('" and <ReadAnnotation>"')'", <ReadAnnotation>"'\"'" and probably also <ReadAnnotation>"'\\\"'". It should be possible to combine the first three into <ReadAnnotation>"'"[()\"]"'". I will add them soon.
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 sure but don't forget about the '\'' i.e. "the escaped single quote character literal".
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 about that, but it should be covered by the general <ReadAnnotation>. rule. Since we do not enter a new state on ' (unlike we do for "), no extra care should be required to avoid premature return from such a state. The " must be considered to avoid entering <ReadStringLiteral> falsely, which cannot happen for '.
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.
But couldn't in that case '"' be problematic?
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's covered by <ReadAnnotation>"'\"'". The overall rule I added just now is
<ReadAnnotation>"'"[()\"]"'"|"'\\\"'". It should catch the Java literals '(', ')', '"', '\"' and I confirmed this with some simple tests.
…nd state ReadEscape in defargs.l.
…ate ReadAnnotation to defargs.l.
Feature/issue 8434
Issue 8434
|
@albert-github what ended up happening here? It looks like the PR was completed? |
Proposed fix for #8495. See discussion therein.