Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Stewori
Copy link

@Stewori Stewori commented May 4, 2021

Proposed fix for #8495. See discussion therein.

albert-github and others added 4 commits March 17, 2021 13:12
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).
src/doxygen.cpp Outdated
Comment on lines 1052 to 1053
if ((root->lang==SrcLangExt_CSharp || root->lang==SrcLangExt_Java) && (i=fullName.find('<'))!=-1)
{
Copy link
Collaborator

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?

Copy link
Author

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.

Copy link
Collaborator

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)

Copy link
Author

@Stewori Stewori May 4, 2021

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.)

Copy link
Collaborator

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
Comment on lines 507 to 522
}
<ReadTypeConstraint>">" {
if (yyextra->argSharpCount > 0)
{
yyextra->curTypeConstraint+=yytext;
--yyextra->argSharpCount;
}
else
{
unput(*yytext);
BEGIN(yyextra->lastExtendsContext);
}
}
<ReadTypeConstraint>"<" {
yyextra->curTypeConstraint+=yytext;
++yyextra->argSharpCount;
Copy link
Collaborator

@albert-github albert-github May 4, 2021

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 ...)?

Copy link
Author

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)?

Copy link
Collaborator

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?

Copy link
Author

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

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?

Copy link
Author

@Stewori Stewori May 4, 2021

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.

@Stewori Stewori marked this pull request as draft May 4, 2021 13:34
…ng of nested commas in declarations of Java generics.
@Stewori Stewori marked this pull request as ready for review May 5, 2021 19:16
src/defargs.l Outdated
Comment on lines 541 to 543
<ReadStringLiteral>"\\" {
BEGIN(ReadEscape);
}
Copy link
Collaborator

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> )?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Good idea.

Copy link
Author

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.

Copy link
Collaborator

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.

Copy link
Author

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
Comment on lines 535 to 537
<ReadAnnotation>"\"" {
BEGIN(ReadStringLiteral);
}
Copy link
Collaborator

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?

Copy link
Author

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).

Copy link
Author

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.

Copy link
Collaborator

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".

Copy link
Author

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 '.

Copy link
Collaborator

@albert-github albert-github May 8, 2021

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?

Copy link
Author

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.

@Stewori Stewori marked this pull request as draft May 8, 2021 10:27
@Stewori Stewori marked this pull request as ready for review May 8, 2021 12:54
@asteele0
Copy link

@albert-github what ended up happening here? It looks like the PR was completed?
I'm also running into this issue, so it would be nice to have fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants