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

Shows errors that classes are not defined, when they are, and I can navigate to definition.

Open safield opened this issue 3 years ago • 5 comments

I have a A.proto file that imports another B.proto file.

Classes defined in B.proto are showing errors in vscode when referenced in A.proto...


"Foo" is not defined.
"Bar" is not defined.
  1. These classes are correctly defined and referenced.
  2. The protobuf definitions compile without error.
  3. I can even "goto definition" for the references of these classes, and the extension properly navigates to their definition. So even the vscode-proto3 definition knows that these classes are correctly defined.

Yet it still shows the errors that they are not defined.

I have tried reloading the workspace, but that did not rectify the problem.

safield avatar Sep 09 '21 15:09 safield

Affects me to. I mean everything is working as expected but it still underlines every imported line with red as if there is an issue. I spent quite some time trying to resolve import error due to this. In the end tried running protoc and their was no issue at all.

Please fix this. I don't want anyone else to waste their time because of this issue.

Thanks for creating this extension. It has proved very helpful.

quaintdev avatar Apr 18 '22 07:04 quaintdev

Sorry for this bug. Could you upload a zip folder containing minimum proto files to let me reproduce this bug? Thank you.

zxh0 avatar Apr 20 '22 07:04 zxh0

I was facing this issue at work and unfortunately I can't share those proto files. Anyways I was trying to reproduce this on my personal laptop and was surprised that it was working without any issue. It took me some time but I figured out when this happens

Create 2 proto files: main.proto and common.proto with below contents

main.proto:

syntax = "proto3";
package Entity.main;
import "common.proto";
option go_package="./";

message School{
    string value=1;
    Entity.common.Person person=2;
}

common.proto:

syntax = "proto3";

package Entity.common;
option go_package="./";

message Person {
    string Name=1;
}

Keep both these files in empty directory and open this folder in vscode. You will not see any issue. Now create another folder from vscode sidebar and move both files into this new folder. You will start seeing errors in main.proto even though we can navigate to Person object defined in common.proto.

The errors shown go away if we move both files back to parent directory.

image

quaintdev avatar Apr 23 '22 18:04 quaintdev

When putting .proto files under subforlder I got this error information from vs code OUTPUT, I guest this is a protoc command --proto_path option issue.

[2022-10-31 08:40:45.404] [renderer1] [error] [Extension Host]   @<filename>                 Read options and filenames from file. If a
                              relative file path is specified, the file
                              will be searched in the working directory.
                              The --proto_path option will not affect how
                              this argument file is searched. Content of
                              the file will be expanded in the position of
                              @<filename> as in the argument list. Note
                              that shell expansion is not applied to the
                              content of the file (i.e., you cannot use
                              quotes, wildcards, escapes, commands, etc.).
                              Each line corresponds to a single argument,
                              even if it contains spaces.
##
ubuntu 20.04

##
vs code Version: 1.72.2

Commit: d045a5eda657f4d7b676dedbfa7aab8207f8a075
Date: 2022-10-12T22:16:26.920Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 5.15.0-52-generic
Sandboxed: No

##
vscode-proto3 0.5.5

huahouye avatar Oct 31 '22 00:10 huahouye

Facing same issue. Whenever anything is defined with a package (e.g. foxglove.Vector3 translation = 4;), they are wrongly shown as undefined.

Here is the proto files I am working with: https://github.com/foxglove/schemas/tree/main/schemas/proto/foxglove

aeon0 avatar Feb 22 '23 15:02 aeon0