Feature: Support more languages in source view.

未关闭 适合新手
#6,436 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
领域
frontend

调研方向

语言选择位于 src/components/shared/SourceView-codemirror.ts 中,其中的 switch 硬编码了 JavaScript、Rust 和 C++(链接提交中的第 49-79 行)。先阅读该 switch,然后检查如何在回退到 JavaScript 之前,根据文件名调用 CodeMirror 的 LanguageDescription.matchFilename。完成标准是:扩展名不同的源文件(例如 .py)能够获得语法高亮,并且现有的 JS、Rust 和 C++ 情况仍然正常工作。

由索引模型根据 Issue 内容生成。

描述

Since processed profile json version 64 its possible to include source code of various languages in the profile json. It would be far nicer if this source code was able to be syntax highlighted, at least for all languages supported by CodeMirror.

The current syntax highlighting switch hardcodes js, rust, and cpp:
https://github.com/firefox-devtools/profiler/blob/f3c1c766e85154725ed7c1c4ecdf7d4aa9136892/src/components/shared/SourceView-codemirror.ts#L49-L79

Codemirror supports filename matching across all its built in languages: https://codemirror.net/docs/ref/#language.LanguageDescription^matchFilename

I think, mostly the task would be to actually call this before falling back to javascript.

Image

The profile for screenshot:
ffprofile.json

┆Issue is synchronized with this Jira Task

主要语言
TypeScript
星标
1.5k
派生
498
平均合并
2 天 5 小时
30 天内合并 PR
42

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firefox-devtools/profiler 的其他 Issue

查看 firefox-devtools/profiler 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。