8000 fix: Normalize name and version correctly by varungandhi-src · Pull Request #99 · sourcegraph/scip-python · GitHub
[go: up one dir, main page]

Skip to content

fix: Normalize name and version correctly #99

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

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
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
8000
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/pyright-scip/snapshots/output/odd_pkg_name_1/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# < definition scip-python python package with space 0.1 main/__init__:
# < definition scip-python python package with space 0.1 main/__init__:
#documentation (module) main

def main():
# ^^^^ definition package with space 0.1 main/main().
# ^^^^ definition package with space 0.1 main/main().
# documentation ```python
# > def main(): # -> None:
# > ```
pass

main()
#^^^ reference package with space 0.1 main/main().
#^^^ reference package with space 0.1 main/main().

15 changes: 13 additions & 2 deletions packages/pyright-scip/src/ScipSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ export class ScipSymbol extends TypescriptScipSymbol {
}

public static override package(name: string, version: string): TypescriptScipSymbol {
name = name.replace(/\./, '/');
name = name.trim();
name = normalizeNameOrVersion(name);
version = normalizeNameOrVersion(version);

// @ts-ignore
return new TypescriptScipSymbol(`scip-python python ${name} ${version} `);
}
}

// See https://github.com/sourcegraph/scip/blob/main/scip.proto#L118-L121
function normalizeNameOrVersion(s: string): string {
if (s === '') {
return '.';
}
if (s.indexOf(' ') === -1) {
return s;
}
return s.replace(/ /g, ' ');
}
0