Skip to content

[Java.Interop.Tools.JavaSource] Parse {@param} tags #1045

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

Merged
merged 1 commit into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ internal void CreateRules (SourceJavadocToXmldocGrammar grammar)
| SeeDeclaration
| ValueDeclaration
| IgnorableDeclaration
| InlineParamDeclaration
;

CodeDeclaration.Rule = grammar.ToTerm ("{@code") + InlineValue + "}";
Expand Down Expand Up @@ -116,6 +117,12 @@ internal void CreateRules (SourceJavadocToXmldocGrammar grammar)
IgnorableDeclaration.AstConfig.NodeCreator = (context, parseNode) => {
parseNode.AstNode = new XText (parseNode.ChildNodes [0].Term.Name.Trim ());
};

InlineParamDeclaration.Rule = grammar.ToTerm ("{@param") + InlineValue + "}";
InlineParamDeclaration.AstConfig.NodeCreator = (context, parseNode) => {
var target = parseNode.ChildNodes [1].AstNode;
parseNode.AstNode = new XElement ("paramref", target);
};
}

public readonly NonTerminal AllInlineTerms = new NonTerminal (nameof (AllInlineTerms), ConcatChildNodes);
Expand Down Expand Up @@ -151,6 +158,7 @@ internal void CreateRules (SourceJavadocToXmldocGrammar grammar)

public readonly NonTerminal IgnorableDeclaration = new NonTerminal (nameof (IgnorableDeclaration));

public readonly NonTerminal InlineParamDeclaration = new NonTerminal (nameof (InlineParamDeclaration));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,15 @@ public void ValueDeclaration ()
Assert.IsFalse (r.HasErrors (), DumpMessages (r, p));
Assert.AreEqual ("<c>#field</c>", r.Root.AstNode.ToString ());
}

[Test]
public void InlineParamDeclaration ()
{
var p = CreateParser (g => g.InlineTagsTerms.InlineParamDeclaration);

var r = p.Parse ("{@param phoneNumberString}");
Assert.IsFalse (r.HasErrors (), DumpMessages (r, p));
Assert.AreEqual ("<paramref>phoneNumberString</paramref>", r.Root.AstNode.ToString ());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ more description {e.g. something} here. Include @ character.
How about another link <a href=""http://man7.org/linux/man-pages/man2/accept.2.html"">accept(2)</a>
@param manifest The value of the <a
HREF = ""{@docRoot}guide/topics/manifest/manifest-element.html#vcode"">{@code
android:versionCode}</a> manifest attribute.
android:versionCode}</a> manifest attribute. See {@param empty}.
@param empty
@param options Additional options.
See {@link foo()}
bar()} for more details.
@return the return value
",
FullXml = $@"<member>
<param name=""manifest"">The value of the <see href=""{DocRootPrefixExpected}guide/topics/manifest/manifest-element.html#vcode""><c>android:versionCode</c></see> manifest attribute.</param>
<param name=""manifest"">The value of the <see href=""{DocRootPrefixExpected}guide/topics/manifest/manifest-element.html#vcode""><c>android:versionCode</c></see> manifest attribute. See <paramref>empty</paramref>.</param>
<param name=""empty"">empty</param>
<param name=""options"">Additional options.
See <c>foo()</c>
Expand All @@ -210,7 +210,7 @@ more description {{e.g. something}} here. Include @ character.
<returns>the return value</returns>
</member>",
IntelliSenseXml = $@"<member>
<param name=""manifest"">The value of the <see href=""{DocRootPrefixExpected}guide/topics/manifest/manifest-element.html#vcode""><c>android:versionCode</c></see> manifest attribute.</param>
<param name=""manifest"">The value of the <see href=""{DocRootPrefixExpected}guide/topics/manifest/manifest-element.html#vcode""><c>android:versionCode</c></see> manifest attribute. See <paramref>empty</paramref>.</param>
<param name=""empty"">empty</param>
<param name=""options"">Additional options.
See <c>foo()</c>
Expand Down