Hi Feng,

2016-03-31 22:28 GMT+02:00 Feng Xiao <[email protected]>:
>
>
> On Wed, Mar 30, 2016 at 9:40 AM, Elvis Stansvik <[email protected]> wrote:
>>
>> On Wednesday, March 30, 2016 at 2:12:46 AM UTC+2, Horst Noreick wrote:
>>>
>>> the compiler uses GOPATH from environment
>>
>>
>> Hm, I think you may have misunderstood me. GOPATH seems to be some
>> variable to control the paths searched by the Go language compiler.
>>
>> What I'm looking for is a way to determine (from the
>> google::protobuf::FileDescriptor, or some other API accessible to protobuf
>> compiler plugins) the full on-disk path to the directory that is considered
>> the "source tree" of the currently processed file, so that I can construct
>> the full on-disk path to it. The reason I need this is that my plugin needs
>> to open the file to do some ad-hoc parsing of the file.
>
> Can you describe a bit more about what info do you need from the original
> file? If it's useful for documentation, we could consider adding that to
> FileDescriptorProto (like the SourceCodeInfo field) and send it along to the
> plugins.

I'm afraid my requirement might be too specific to be considered.

My use case is this:

<Foo.proto>
/// This file contains Foo and stuff.
///
/// Blah blah.
package some.package;

message Foo {...}

message Blah {...}
<Foo.proto>

or

<Foo.proto>
/**
 * This file contains Foo and stuff.
 *
 * Blah blah.
 */
package some.package;

message Foo {...}

message Blah {...}
<Foo.proto>

where I need access to the documentation comment at the very top of
the input .proto file. User's are using this to document the file as a
whole.

At the moment I've implemented this like this:

   https://github.com/estan/protoc-gen-doc/blob/master/src/main.cpp#L157-L225

That is, by opening the file and parsing it out myself, but this will
fail sometimes as I'm simply opening using FileDescriptor::name() as
file name, not the full path. So I need a way to get the full resolved
on-disk path to an input file.

For many other comments, I'm making good use of
SourceLocation::leading_comments and SourceLocation::trailing_comments
to get the comments for messages, enums, fields et.c.

Cheers,
Elvis

>
>>
>>
>> I don't think GOPATH will give me any of this.
>>
>> Cheers,
>> Elvis
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to