Skip to content

PrintAST and contextual queries use incorrect getEncodedFile for windows paths #4621

@aeisenberg

Description

@aeisenberg

In all of the external string selectedSourceFile(); for contextual queries, references for windows paths are not created properly. All paths must begin with a /. The reason is that this path represents a piece of a uri (even though special characters like spaces are not encoded) and must always have a slash at the front.

Currently, paths inside of a database's src.zip file for dbs created on windows look like this:

/C_/databases/my-database/my-file.cpp

and the original path looks like this:

C:\databases\my-database\my-file.cpp

The problem is that inside of the extension, there is no way to determine if C_ is an encoded drive name on windows, or a directory name from a linux-like system.

The extension, therefore passes the path with the leading / to the contextual query and the contextual query does not recognize it as a path to any file in the database.

One example is here:

File getEncodedFile(string name) { result.getAbsolutePath().replaceAll(":", "_") = name }

One proposed solution is to move getEncodedFile to a shared location and fix it once. All language libraries would use the same implementation. Though, this would not work for go or ruby.

Originally reported by @nickrolfe

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions