Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scip_indexer/SCIPIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ class SCIPSemanticExtension : public SemanticExtension {
// NOTE: We are not respecting the path prefix option here. Should we do that?
// FIXME(varun): filesystem::current_path() returns the path in 'native' format,
// so this won't work on Windows.
metadata.set_project_root("file:/" + filesystem::current_path().string());
metadata.set_project_root("file://" + filesystem::current_path().string());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@varungandhi-src is the note above still actual?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's still accurate. Sorbet has an extra flag remove-path-prefix which is not accounted for here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So scip-ruby is broken on Windows? Not a big deal, just curious how C++ folks get around with that. Why ProjectRoot is URI at all and not a path?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So scip-ruby is broken on Windows?

It's not supported on Windows. We haven't tried to build it on Windows, and there is no release binary for Windows.

Not a big deal, just curious how C++ folks get around with that.

Could you be a bit more specific here? It isn't clear to me what you're asking...

Why ProjectRoot is URI at all and not a path?

Windows paths can be in many different formats. Using a URI avoids downstream tooling having to deal with that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you be a bit more specific here? It isn't clear to me what you're asking...

How C++ folks are normalizing paths to be cross-platform.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How C++ folks are normalizing paths to be cross-platform.

Generally it isn't an operation that makes sense, because the set of allowed characters in path components is different. E.g. you can have a backslash inside a component on Linux but not on Windows IIUC. There's also the question of case-sensitivity which varies across filesystems (not OSes).

If one really wants, one can use string replacement or similar based on what the exact requirements are...

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact requirement is to have machine independent format in SCIP files. Storing absolute paths is probably not compatible with this use case.

@varungandhi-src varungandhi-src Jul 20, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That applies to most other fields of SCIP but not this one. For this particular field, it's not meant for the Sourcegraph backend, it's meant for any other tools in case the index is moved around/generated somewhere other than the project root. E.g. the scip snapshot subcommand from the scip CLI can generate sources annotated with occurrence information -- it needs an absolute path to locate the source code.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaking absolute project paths may be a security issue. Maybe I am just paranoid.

metadata.set_text_document_encoding(scip::TextEncoding::UTF8);

vector<SCIPState> allStates;
Expand Down