[英]Is it possible to Access the Data of an non opend file and modify it with the vscode API
I'm currently working on an VS Code rename extension for Angular
components and for that I need to change the data in the typescript file as well as in the spec.ts
file.我目前正在为Angular
组件开发 VS Code 重命名扩展,为此我需要更改 typescript 文件以及spec.ts
文件中的数据。 To edit the typescript file I'm able to use the vscode.windiow.activeTextEditor
, but I don't know how I can get access to the spec.ts
file via the API.要编辑 typescript 文件,我可以使用vscode.windiow.activeTextEditor
,但我不知道如何通过 API 访问spec.ts
文件。
I tried to change the activeEditor
by showing the other document but it seems to not change the activeEditor
directly (When I debug the activeEditor
doesn't change).我试图通过显示另一个文档来更改activeEditor
,但它似乎没有直接更改activeEditor
(当我调试activeEditor
时不会更改)。
If I get this right then you just want to open an arbitrary file, change it and save it, in your extension, correct?如果我做对了,那么您只想打开一个任意文件,对其进行更改并将其保存在您的扩展程序中,对吗?
If that's the case then simply use the fs
( file system ) node module to load and save the file.如果是这种情况,那么只需使用fs
(文件系统)节点模块来加载和保存文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.