-
Notifications
You must be signed in to change notification settings - Fork 285
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
Source generated by build plugin is ignored #665
Comments
rdar://102242345 |
It looks like this is not completely true. I can get code completion etc to work by restarting the sourcekit-lsp server. I'm guessing this is a similar issue to #620 |
I am running into the same problem. In my project I am using protobuf, grpc, and a custom code generator and LSP isn't able to find any of the generated code (not even after restarting VSCode, LSP, reloading the window, clean and rebuild...) I created a tiny [reproduction project(https://github.com/mpilman/ProtoRepro) (on macOS the This is what the swift-file looks like in VSCode after the project has been successfully built: |
I've moved my generated code from manually running the tool to being a plugin yesterday and I'm affected by this too. The repo is located here, tho it's not a tiny example :) |
This appears to be resolved in the latest swift 5.9 toolchain. But we still have the issue where we cannot use go to definition within generated code. EDIT: This still needs a LSP restart |
The problem for not getting any semantic functionality in the generated files is that we don’t get compiler arguments for them. As I understand, being able to get them requires a couple of non-trivial changes to SwiftPM, which we’re now tracking in swiftlang/swift-package-manager#6700. |
FWIW: Restarting SourceKit doesn't help me at all; I need to manually copy the generated source file into my project folder to get things to work. |
I've encountered this issue since I've started a swift vapor project with vscode. But suddenly the lsp is able to parse the generated files after I switched to xcode today to develop the module that uses the swift openapi plugin and exports the generated source code. A little unwilling to try to replicate by deleting my .build since it's actually working for once 😅 . |
FWIW, a workaround for now is to generate all files into their own module with |
@ahoppen ’s tip seems to work for me too. Quite hacky though 😅 EDIT: In my case, I made it package scoped. |
This should be fixed by the following: Note that it is not enabled when background indexing is disabled - we'd need swiftlang/swift-package-manager#6700 to fix that case. |
The source code generated by a SwiftPM build plugin does not get parsed by SourceKit-LSP. So any code referencing generated code is considered an error and "Go to definition..." etc don't work
I have a sample project here https://github.com/adam-fowler/soto-codegenerator-plugin-test. It has an AWS model file that defines the API for the SNS service from AWS. The build plugin generates source code from this and the generated code is used in the file
SNSTest.swift
. SourceKit-LSP reports 4 problems in this file even though the project builds fineThe text was updated successfully, but these errors were encountered: