MyGoland 首次提交:Go 轻量 IDE
- 编辑器:多标签、语法高亮、gopls 全套(补全/诊断/跳转/重命名/代码动作/内联提示/签名大纲) - 调试:Delve DAP(断点/条件断点/变量树/表达式求值/goroutine 列表) - 测试:结果树、覆盖率行着色、失败跳源码、-run 精确运行、行号可跑标记 - Git:状态着色、选择性暂存提交、pull/push、历史并排对比 - 本地历史 + 自动快照 + 崩溃恢复、会话/光标恢复 - 全局搜索替换(预览+确认,GBK 安全)、多终端、gopls 崩溃自愈 - 设计文档与验证记录见 docs/plans/
This commit is contained in:
commit
a80c0f886a
220 files changed
+20784
No files matched your search
@@ -0,0 +1,55 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"mygoland/internal/lsp"
|
||||
)
|
||||
|
||||
func sym(name string, kind int, line int, children ...lsp.DocumentSymbol) lsp.DocumentSymbol {
|
||||
return lsp.DocumentSymbol{
|
||||
Name: name,
|
||||
Kind: kind,
|
||||
Range: lsp.Range{Start: lsp.Position{Line: line}, End: lsp.Position{Line: line}},
|
||||
SelectionRange: lsp.Range{Start: lsp.Position{Line: line}, End: lsp.Position{Line: line}},
|
||||
Children: children,
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlattenSymbols(t *testing.T) {
|
||||
syms := []lsp.DocumentSymbol{
|
||||
sym("helper", 12, 2),
|
||||
sym("point", 23, 4,
|
||||
sym("X", 8, 5),
|
||||
sym("Y", 8, 6),
|
||||
),
|
||||
sym("main", 12, 9),
|
||||
}
|
||||
got := flattenSymbols(syms, 0, nil)
|
||||
if len(got) != 5 {
|
||||
t.Fatalf("应当铺平出 5 项,实际 %d: %+v", len(got), got)
|
||||
}
|
||||
want := []struct {
|
||||
name string
|
||||
line int
|
||||
depth int
|
||||
}{
|
||||
{"helper", 2, 0},
|
||||
{"point", 4, 0},
|
||||
{"X", 5, 1},
|
||||
{"Y", 6, 1},
|
||||
{"main", 9, 0},
|
||||
}
|
||||
for i, w := range want {
|
||||
if got[i].Name != w.name || got[i].Line != w.line || got[i].Depth != w.depth {
|
||||
t.Fatalf("第 %d 项不对: got %+v want %+v", i, got[i], w)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSymbolColorDiffers(t *testing.T) {
|
||||
th := theme(false)
|
||||
if symbolColor(th, 12) == symbolColor(th, 23) {
|
||||
t.Fatal("函数与类型应当用不同颜色")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user