vscode-proto3 icon indicating copy to clipboard operation
vscode-proto3 copied to clipboard

Follow imports

Open baconalot opened this issue 8 years ago • 31 comments

Now I get errors from imported fields:

image

From: import "currency.proto";

It would be awesome if those import types are also imported.

baconalot avatar Jan 10 '17 15:01 baconalot

Hi, could you provide some more information? What is the error message?

zxh0 avatar Jan 12 '17 02:01 zxh0

The message reads "currency.Currency" is not defined. Reproduction is easy:

"foo.proto"

syntax = "proto3";

package foo;

message Foo {
    string a = 1;
}

and in the same folder "bar.proto"

syntax = "proto3";

package bar;

import "foo.proto";

message Bar {
    foo.Foo a = 1;
}

yields the error message "foo.Foo" is not defined with the error marker on foo.Foo a = 1;

baconalot avatar Jan 12 '17 08:01 baconalot

Hi, maybe the problem is comes from import statement. How about change it to import "foo.proto";?

zxh0 avatar Jan 12 '17 09:01 zxh0

Ow, my bad, that syntax is what I already use in real files. This still does not fix the issue, I still get the undefined error.

baconalot avatar Jan 12 '17 09:01 baconalot

This extension just calls protoc when it need to check proto syntax. So I guess the import path is not correct. How about import "path/to/foo.proto";?

zxh0 avatar Jan 12 '17 09:01 zxh0

I have the same problem. Both files are in the same folder. They compile fine using protoc on the command line.

Iulian7 avatar Mar 11 '17 19:03 Iulian7

Hi,

I have the same issue described here.

Multiple proto files in the same directory ( same package so I dont prefix with xx.yyy but I import them ) and I also have "xxxx" is not defined

Protoc is able to compile those files too.

Tommy-42 avatar Apr 16 '18 09:04 Tommy-42

hi @Tommy-42 could you provide a minimal folder with some proto files to let me reproduce this issue ? thank you

zxh0 avatar Apr 16 '18 14:04 zxh0

Hey @zxh0 sure :)

This should trigger the error on vscode but compile fine with : protoc --go_out=. *.proto

test.zip

Tommy-42 avatar Apr 16 '18 16:04 Tommy-42

I have the same problem. "msg.base.ReqReconnect" is not defined.

The message is not normally identified

hanyu363 avatar Apr 18 '18 02:04 hanyu363

@Tommy-42 it's weird that I am not able to reproduce the error (on both Windows and macOS) using test.zip you uploaded

zxh0 avatar Apr 18 '18 04:04 zxh0

hi @hanyu363 could you give me a zip like Tommy-42 to let me reproduce the error?

zxh0 avatar Apr 18 '18 04:04 zxh0

proto.zip Is it related to setting up

hanyu363 avatar Apr 19 '18 01:04 hanyu363

@hanyu363 我没办法重现你的问题,我给你邮箱发了一封邮件,请查收一下。

zxh0 avatar Apr 19 '18 06:04 zxh0

英文差,这么快就被识别出来了。 问题解决了。。应该需要设置一下Proto文件路径才可以。。 "protoc": { "path": "/usr/local/bin/protoc", "options": [ "--proto_path=/Users/weihua/workspace/CityGuardians/common/proto", ] } 谢谢啦。

hanyu363 avatar Apr 20 '18 02:04 hanyu363

If you open the proto directory alone, no problem. If proto is not the root directory, it needs to be explicitly specified in the vs configuration. Then restart the editor just fine. Please refer to "protoc": { "path": "/usr/local/bin/protoc", "options": [ "--proto_path=${workspaceRoot}/common/proto", ] }

hanyu363 avatar Apr 20 '18 02:04 hanyu363

thank you @hanyu363

zxh0 avatar Apr 20 '18 03:04 zxh0

I have the same issue: the defined type that from imported proto file is marked as not defined by vscode-proto3. Both of the proto files are from the same folder named proto, I've tried to set proto_path=${workspaceRoot}/proto in setting.json, while it seems not work.

mingweiLIU avatar Aug 10 '18 16:08 mingweiLIU

@mingweiLIU please remove ${workspaceRoot} and use relative path in your settings.json

zxh0 avatar Aug 11 '18 09:08 zxh0

Thanks, it works now!

mingweiLIU avatar Aug 15 '18 03:08 mingweiLIU

@mingweiLIU I have the same issue,how to fix ?

luanxuechao avatar Sep 14 '18 06:09 luanxuechao

@luanxuechao Just set proto_path=proto in setting.json will be ok (proto is the folder name of your proto files).

mingweiLIU avatar Sep 14 '18 12:09 mingweiLIU

Encoutered the same issue, just restarted vscode then problem solved.

awper361 avatar Nov 05 '18 10:11 awper361

Encoutered the same issue, just restarted vscode then problem solved.

So do I.

zoe0316 avatar Mar 22 '19 04:03 zoe0316

+1 same issue -- had to restart

jpreese avatar Apr 08 '19 15:04 jpreese

I had the same problem (I use Windows 10) and I solved it by adding the following to my workspace settings.json:

{
    "protoc": {
        "path": "C:/Path/To/Protoc binary",
        "options": [
        "--proto_path=C:/path/to/my/protofiles/directory",
        ]
        }
}

AliAlhajji avatar Jan 04 '20 15:01 AliAlhajji

I just found out:

the syntax

import "uphierarchy/message.proto";

works in VS code if uphierarchy is the folder from where vs code was started.

That means: No need to override settings.json locally

Sieboldianus avatar Feb 04 '20 10:02 Sieboldianus

If I have a multi-root workspace, how should this setting be written. Different roots will have different include paths?

CMCDragonkai avatar Dec 20 '21 02:12 CMCDragonkai

This isn't working for me. If I set the proto_path option VSCode is still unable to jump to definitions. If I open the Proto path in VSCode directly as the root, then it works.

clayne11 avatar Dec 18 '23 15:12 clayne11

For me it really doesn't work. After modifying settings.json errors aren't shown, and autocomplete will not suggest imported symbols (but sometime i can jump to definitions).

geovex avatar Apr 01 '24 00:04 geovex