Skip to content
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

Documentation and comments are missing #19

Closed
erizocosmico opened this issue Jan 31, 2019 · 9 comments · Fixed by #31
Closed

Documentation and comments are missing #19

erizocosmico opened this issue Jan 31, 2019 · 9 comments · Fixed by #31
Assignees
Labels
bug Something isn't working

Comments

@erizocosmico
Copy link

Documentation and comments are missing from the returned UAST.

Example:

using System.Net;
using System.Net.Http.Headers;
using System.Net.Sockets;
using Microsoft.AspNetCore.Http;

namespace ProxyKit
{
    public static class XForwardedExtensions
    {
        public const string XForwardedFor = "X-Forwarded-For";
        public const string XForwardedHost = "X-Forwarded-Host";
        public const string XForwardedProto = "X-Forwarded-Proto";
        public const string XForwardedPathBase = "X-Forwarded-PathBase";

        /// <summary>
        ///     Applies X-Forwarded.* headers to the outgoing
        ///     header collection.
        /// </summary>
        /// <param name="outgoingHeaders">The outgoing HTTP request
        /// headers.</param>
        /// <param name="for">The client IP address.</param>
        /// <param name="host">The host of the request.</param>
        /// <param name="proto">The protocol of the incoming request.</param>
        public static void ApplyXForwardedHeaders(
            this HttpRequestHeaders outgoingHeaders,
            IPAddress _for,
            HostString host,
            string proto) 
            => ApplyXForwardedHeaders(outgoingHeaders, _for, host, proto, string.Empty);

        /// <summary>
        ///     Applies X-Forwarded.* headers to the outgoing header collection
        ///     with an additional PathBase parameter.
        /// </summary>
        /// <param name="outgoingHeaders">The outgoing HTTP request
        /// headers.</param>
        /// <param name="for">The client IP address.</param>
        /// <param name="host">The host of the request.</param>
        /// <param name="proto">The protocol of the incoming request.</param>
        /// <param name="pathBase">The base path of the incoming
        /// request.</param>
        public static void ApplyXForwardedHeaders(
            this HttpRequestHeaders outgoingHeaders,
            IPAddress _for,
            HostString host,
            string proto,
            PathString pathBase)
        {
            if (_for != null)
            {
                var forString = _for.AddressFamily == AddressFamily.InterNetworkV6
                    ? $"\"[{_for}]\""
                    : _for.ToString();
                outgoingHeaders.Add(XForwardedFor, forString);
            }

            if (host.HasValue)
            {
                outgoingHeaders.Add(XForwardedHost, host.Value);
            }

            if (!string.IsNullOrWhiteSpace(proto))
            {
                outgoingHeaders.Add(XForwardedProto, proto);
            }

            if (!string.IsNullOrWhiteSpace(pathBase))
            {
                outgoingHeaders.Add(XForwardedPathBase, pathBase);
            }
        }
    }
}

Does not return any of the documentation comments in the code.

@dennwc
Copy link
Member

dennwc commented Jan 31, 2019

@erizocosmico What version are you using? v1.0 should have fixed this issue.

@dennwc dennwc self-assigned this Jan 31, 2019
@erizocosmico
Copy link
Author

The one in the staging bblfsh playground: 1.0.0

@dennwc dennwc added the bug Something isn't working label Jan 31, 2019
@dennwc
Copy link
Member

dennwc commented Jan 31, 2019

Okay, can confirm that it's a bug and the solution is not that simple (see discussion in #3).

For now, you can use Annotated mode to get comments, although they won't be normalized.

@erizocosmico
Copy link
Author

Don't worry, I can move on to other tasks of the PoC and leave this for the end. If it's not fixed by then I will try with annotated mode. What do you mean exactly by "normalized" in this case?

@dennwc
Copy link
Member

dennwc commented Jan 31, 2019

In Semantic, all comments will have a single type: uast:Comment. In Annotated you will have to deal with SingleLineCommentTrivia, SingleLineDocumentationCommentTrivia, MultiLineCommentTrivia and probably handle the differences between them.

@dennwc
Copy link
Member

dennwc commented Jan 31, 2019

Also, note that comments are missing only on specific node types - if they were close to any Identifier.

If the comment is in the code block it should be visible.

@erizocosmico
Copy link
Author

I'm targeting method docs, in particular.

@dennwc
Copy link
Member

dennwc commented Jan 31, 2019

They won't be visible for now :(

@erizocosmico
Copy link
Author

I just tried with annotated mode and turns out it's exactly what I need for the PoC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants