diff --git a/.vscode/launch.json b/.vscode/launch.json index 44b0ac35..40650720 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -41,7 +41,8 @@ // / "Cannot register 'viper.xxx' ... already registered" 激活失败。 "--extensionDevelopmentPath=${workspaceFolder}/packages/vscode-vipeye", // 禁用已安装的发布版,避免与调试版同时加载冲突。 - "--disable-extension=TermiNexus.vscode-vipeye" + "--disable-extension=TermiNexus.vscode-vipeye", + "--disable-extension=TermiNexus.vipeye", ], "smartStep": true, "sourceMaps": true, @@ -59,7 +60,8 @@ "--extensionDevelopmentPath=${workspaceFolder}/packages/vscode-vipeye", "--disable-extension=TermiNexus.vscode-vipeye", "--disable-extension=be5invis.vscode-custom-css", - "--disable-extension=msgcenterext.msgcenter" + "--disable-extension=msgcenterext.msgcenter", + "--disable-extension=TermiNexus.vipeye", ], "smartStep": true, "sourceMaps": true, diff --git a/packages/vipeye-internal/src/analyzer/pyTypedUtils.ts b/packages/vipeye-internal/src/analyzer/pyTypedUtils.ts index cfbcfc05..cc1e80c4 100644 --- a/packages/vipeye-internal/src/analyzer/pyTypedUtils.ts +++ b/packages/vipeye-internal/src/analyzer/pyTypedUtils.ts @@ -8,7 +8,7 @@ */ import { FileSystem } from '../common/fileSystem'; -import { IsViperDialect, LanguageDialect } from '../common/dialect'; +import { LanguageDialect } from '../common/dialect'; import { Uri } from '../common/uri/uri'; import { isDirectory, isFile } from '../common/uri/uriUtils'; @@ -20,16 +20,16 @@ export interface PyTypedInfo { // // Retrieves information about a py.typed file, if it exists, under the given path. // +// 注:本模块只做纯文件系统探测,不做方言分支。Viper 工程同样需要该探测: +// `foo-stubs/` 存根包(PEP 561 式布局)的虚拟映射(PartialStubService)依据 +// py.typed 的 `partial` 标记决定是否把存根合并进已安装目录;此前按方言短路 +// 会让映射永不生效(viperFileSystem 用例全部失败)。 +// dialect 参数保留是为了兼容既有调用点,当前实现不依赖它。 export function getPyTypedInfo( fileSystem: FileSystem, dirPath: Uri, - dialect?: LanguageDialect + _dialect?: LanguageDialect ): PyTypedInfo | undefined { - // Viper 模式短路:Viper 无 PEP 561 py.typed 标记机制,跳过探测。 - if (IsViperDialect(dialect)) { - return undefined; - } - if (!fileSystem.existsSync(dirPath) || !isDirectory(fileSystem, dirPath)) { return undefined; } @@ -39,7 +39,7 @@ export function getPyTypedInfo( return undefined; } - return getPyTypedInfoForPyTypedFile(fileSystem, pyTypedPath, dialect); + return getPyTypedInfoForPyTypedFile(fileSystem, pyTypedPath, _dialect); } // @@ -48,13 +48,8 @@ export function getPyTypedInfo( export function getPyTypedInfoForPyTypedFile( fileSystem: FileSystem, pyTypedPath: Uri, - dialect?: LanguageDialect + _dialect?: LanguageDialect ) { - // Viper 模式短路:Viper 无 PEP 561 py.typed 标记机制,跳过解析。 - if (IsViperDialect(dialect)) { - return undefined; - } - // This function intentionally doesn't check whether the given py.typed path exists or not, // as filesystem access is expensive if done repeatedly. // The caller should verify the file's validity before calling this method and use a cache if possible diff --git a/packages/vipeye-internal/src/partialStubService.ts b/packages/vipeye-internal/src/partialStubService.ts index e2c3ab08..df4c0b72 100644 --- a/packages/vipeye-internal/src/partialStubService.ts +++ b/packages/vipeye-internal/src/partialStubService.ts @@ -118,6 +118,9 @@ export class PartialStubService implements SupportPartialStubs { continue; } // Merge partial stub packages to the library. + // 只映射存根文件(.vpi/.vpnci 为 Viper 存根,.pyi 为 Python 兼容回退, + // 见 importResolver.supportedSourceFileExtensions)与目录; + // 其它文件(如 py.typed 标记)不进入映射视图。 this._movedDirectories.push( this._realFs.mapDirectory( packagePath, @@ -125,6 +128,7 @@ export class PartialStubService implements SupportPartialStubs { (u, fs) => u.hasExtension('.vpi') || u.hasExtension('.vpnci') || + u.hasExtension('.pyi') || (fs.existsSync(u) && fs.statSync(u).isDirectory()) ) ); diff --git a/packages/vipeye-internal/src/tests/__unary_ptr__/unary_ptr.vp b/packages/vipeye-internal/src/tests/__unary_ptr__/unary_ptr.vp index 25496f95..bc3d0438 100644 --- a/packages/vipeye-internal/src/tests/__unary_ptr__/unary_ptr.vp +++ b/packages/vipeye-internal/src/tests/__unary_ptr__/unary_ptr.vp @@ -1,6 +1,10 @@ import t, c -import ast -class Holder: - ch_r: list[ast.AST*]* - direct: rawptr[ast.AST] +def main() -> int: + x: int = 42 + px: int | t.CPtr = &x + *px = 100 + y: int = *px + pz: int* = &x + *pz = 7 + return 0