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

Allow configuration providers to provide the compileCommands file path #12252

Open
g-arjones opened this issue Apr 24, 2024 · 11 comments
Open

Allow configuration providers to provide the compileCommands file path #12252

g-arjones opened this issue Apr 24, 2024 · 11 comments
Labels
Feature: Compile Commands Feature: Configuration Provider Related to the configurationProvider property, e.g. ms-vscode.cmake-tools, ms-vscode.makefile-tools. Feature: Configuration An issue related to configuring the extension or IntelliSense Feature Request Language Service

Comments

@g-arjones
Copy link
Contributor

Feature Request

I've also looked for documentation (a developer guide?) about how extension authors should use the configuration provider interface and could not find any...

@sean-mcmanus
Copy link
Collaborator

@g-arjones See https://github.com/microsoft/vscode-cpptools-api . We could move this feature request there.

@sean-mcmanus sean-mcmanus added Language Service Feature Request Feature: Configuration An issue related to configuring the extension or IntelliSense Feature: Compile Commands Feature: Configuration Provider Related to the configurationProvider property, e.g. ms-vscode.cmake-tools, ms-vscode.makefile-tools. labels Apr 24, 2024
@g-arjones
Copy link
Contributor Author

Thanks!

We could move this feature request there

Sounds good to me!

@bobbrow
Copy link
Member

bobbrow commented Apr 24, 2024

I believe the feature has been requested already: microsoft/vscode-cpptools-api#50

@g-arjones
Copy link
Contributor Author

g-arjones commented Apr 24, 2024

As far as I understood, the other one proposes the construction of a SourceFileConfigurationItem from a compilation database (a.k.a. parse it and fill the existing fields). My suggestion was to extend SourceFileConfigurationItem to include a compileCommands member and then leverage what's already implemented in vscode-cpptools/IntelliSense.

Would fit my use case as well but not the same. I think my suggestion is simpler to implement.

@bobbrow
Copy link
Member

bobbrow commented Apr 25, 2024

(a.k.a. parse it and fill the existing fields)

I believe they said they had started doing that, but wanted to just give us the compile_commands.json so they wouldn't have to do it.

Currently I am trying to parse out the command portion of the compile_commands.json to get the compiler args/fragments, and building up the compilerFragments list, but it would be so much better to point at compile_commands.json directly, similar to how it is being done in the c_cpp_properties.json config.

@g-arjones
Copy link
Contributor Author

Yeah... I understood they wanted something like:

let config = SourceFileConfigurationItem("path/to/compile_commands.json");
// ... the file is parsed by **vscode-cpptools-api** (no changes to the interface)
// and the existing members are set

What I am suggesting is:

let config = SourceFileConfigurationItem();
config.compileCommands = "path/to/compile_commands.json";
// requires adding `compileCommands` to `SourceFileConfigurationItem`
// parsing is done by vscode-cpptools/IntelliSense (I'm not sure which one consumes the compilation db)
// `config` may have nothing set aside from `SourceFileConfigurationItem.compileCommands`

That's how I typically use c_cpp_properties.json (the only option I set is compileCommands)

@g-arjones
Copy link
Contributor Author

To be clear: I would be fine with either. Is anything like this currently a planned feature?

@bobbrow
Copy link
Member

bobbrow commented Apr 25, 2024

The difference between the two examples you provided looks like an implementation detail and I believe either would achieve the same purpose. However, since the SourceFileConfiguration[Item] interfaces are at a level more granular than a compile commands database, we probably wouldn't want to expose it there. I think a new ProjectConfiguration or similar interface needs to be designed so that information about all known files can be provided up front.

@Colengms and I have discussed the project configuration concept before but we haven't scheduled this work yet due to competing priorities. It's possible that much of this work could be done in the Open Source portions of our codebase and we would accept help from someone in the community if they had the time to look into it.

@g-arjones
Copy link
Contributor Author

I think a new ProjectConfiguration or similar interface needs to be designed so that information about all known files can be provided up front.

Doesn't a compileCommands fit in WorkspaceBrowseConfiguration ?

I may find some time to help with the implementation if you guys can help with design and planning. I'm not familiar with this codebase and unfortunately cannot look deep into it.

@bobbrow
Copy link
Member

bobbrow commented Apr 25, 2024

Doesn't a compileCommands fit in WorkspaceBrowseConfiguration ?

It could, but the browse configuration is only looking for file paths to scan. It doesn't help with the IntelliSense configuration. The ProjectConfiguration (or similar) would conceptually be a merger of the browse configuration and an array of all SourceFileConfigurations known to the project. I haven't spent a ton of time thinking about the design yet, but if an extension supported the ProjectConfiguration, we would only request that object and not request separate WorkspaceBrowseConfigurations or individual SourceFileConfigurations - I would expect that all of that information is provided up front. A compile commands database would satisfy those requirements.

@g-arjones
Copy link
Contributor Author

That makes sense.

I haven't spent a ton of time thinking about the design yet

Please, let me know if/when you do. I'll be happy to take care of the implementation since that would save me a lot of work on a feature I'm working on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Compile Commands Feature: Configuration Provider Related to the configurationProvider property, e.g. ms-vscode.cmake-tools, ms-vscode.makefile-tools. Feature: Configuration An issue related to configuring the extension or IntelliSense Feature Request Language Service
Projects
None yet
Development

No branches or pull requests

3 participants