XML Definition Navigator
这是一个VS Code扩展,用于解析工程中的XML文件并提供"转到定义"功能。
功能特性
- 自动解析XML文件: 扫描工作区中所有XML文件,提取
<XXXDef Name="[NAME]"> 格式的定义
- F12跳转: 在XML文件中,将光标放在任何名称上按F12可跳转到对应的定义
- 实时更新: 监听XML文件的变化,自动更新定义索引
- 多文件支持: 支持跨文件的定义引用和跳转
- 统计信息: 显示已解析的定义数量和统计信息
使用方法
- 打开包含XML文件的工作区
- 插件会自动扫描所有.xml文件
- 在任何XML文件中,将光标放在想要查找的名称上
- 按
F12 键或右键选择"转到定义"
- 如果找到对应的定义,会跳转到定义位置
支持的XML结构
插件会识别以下格式的XML定义:
<List>
<PlayerDef Name="Warrior">
<!-- 定义内容 -->
</PlayerDef>
<WeaponDef Name="IronSword">
<!-- 定义内容 -->
</WeaponDef>
<SkillDef Name="Fireball">
<!-- 定义内容 -->
</SkillDef>
</List>
命令
插件提供以下命令(通过命令面板 Ctrl+Shift+P 访问):
- XML Navigator: Rescan XML Definitions - 重新扫描所有XML文件
- XML Navigator: Show XML Definition Stats - 显示当前解析的定义统计信息
测试示例
项目包含了一些测试XML文件在 test-data 目录下:
players.xml - 包含玩家和武器定义
skills.xml - 包含技能定义
quests.xml - 包含任务定义,引用其他文件中的名称
你可以在这些文件中测试跳转功能。例如:
- 打开
quests.xml
- 将光标放在
Warrior 、IronSword 或 Fireball 上
- 按
F12 查看跳转效果
开发和调试
运行扩展
- 打开项目目录
- 按
F5 或使用 "Run Extension" 调试配置
- 在新的VS Code窗口中测试功能
编译
npm run compile
监听模式
npm run watch
运行测试
npm test
myExtension.enable : Enable/disable this extension.
myExtension.thing : Set to blah to do something.
Known Issues
Calling out known issues can help limit users opening duplicate issues against your extension.
Release Notes
Users appreciate release notes as you update your extension.
1.0.0
Initial release of ...
1.0.1
Fixed issue #.
1.1.0
Added features X, Y, and Z.
Following extension guidelines
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.
Working with Markdown
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
- Split the editor (
Cmd+\ on macOS or Ctrl+\ on Windows and Linux).
- Toggle preview (
Shift+Cmd+V on macOS or Shift+Ctrl+V on Windows and Linux).
- Press
Ctrl+Space (Windows, Linux, macOS) to see a list of Markdown snippets.
Enjoy!
| |