MCPcopy Create free account
hub / github.com/facebook/pyrefly / moduleNameFromPath

Function moduleNameFromPath

lsp/src/codeLens.ts:155–173  ·  view source on GitHub ↗
(uri: vscode.Uri)

Source from the content-addressed store, hash-verified

153}
154
155function moduleNameFromPath(uri: vscode.Uri): string | undefined {
156 const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
157 if (!workspaceFolder) {
158 return undefined;
159 }
160 let relativePath = path.relative(workspaceFolder.uri.fsPath, uri.fsPath);
161 if (relativePath.startsWith('..')) {
162 return undefined;
163 }
164 if (relativePath.endsWith('.py')) {
165 relativePath = relativePath.slice(0, -3);
166 } else {
167 return undefined;
168 }
169 return relativePath
170 .split(path.sep)
171 .filter(part => part.length > 0)
172 .join('.');
173}
174
175async function runAtCursor(
176 uri: vscode.Uri,

Callers 1

runTestAtLocationFunction · 0.85

Calls 2

splitMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected