✨ feat(vscode): 代码阅读契约加命令规则(按命令名注册、读一条命令)、按位置的参数 / 输出 / 返回、解释器和选项块、分情况 / 命令 / 管道种类、常量色;模板引擎加节点读法;没有定义、高亮提供者的语言用语言插件认的同一文件里的名字跳转、高亮
This commit is contained in:
1 parent
cf09c24730
commit
ff2a44f080
17 files changed
+555
-60
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import type { LocalSymbol, SourceRange } from './contract'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { definitionFor, symbolAt, symbolOccurrences } from './localSymbols'
|
||||
|
||||
function range(startIndex: number, endIndex: number): SourceRange {
|
||||
return { startIndex, endIndex }
|
||||
}
|
||||
|
||||
// out=1(0-3);echo $out(10-13);out=2(15-18);echo $out(25-28)
|
||||
const OUT: LocalSymbol = { definitions: [range(0, 3), range(15, 18)], occurrences: [range(0, 3), range(10, 13), range(15, 18), range(25, 28)] }
|
||||
const URL: LocalSymbol = { definitions: [range(40, 43)], occurrences: [range(30, 33), range(40, 43)] }
|
||||
|
||||
describe('语言插件认出的同一文件里的名字', () => {
|
||||
it('找盖住位置的名字;名字外面没有', () => {
|
||||
expect(symbolAt([URL, OUT], 11)).toBe(OUT)
|
||||
expect(symbolAt([URL, OUT], 13)).toBeUndefined()
|
||||
})
|
||||
|
||||
it('跳到之前最近的一处定义;前面没有定义就跳到第一处', () => {
|
||||
expect(definitionFor(OUT, 11)).toEqual(range(0, 3))
|
||||
expect(definitionFor(OUT, 26)).toEqual(range(15, 18))
|
||||
expect(definitionFor(URL, 31)).toEqual(range(40, 43))
|
||||
})
|
||||
|
||||
it('各处出现:定义处算写,别处算读', () => {
|
||||
expect(symbolOccurrences(OUT)).toEqual([
|
||||
{ start: 0, end: 3, kind: 'write' },
|
||||
{ start: 10, end: 13, kind: 'read' },
|
||||
{ start: 15, end: 18, kind: 'write' },
|
||||
{ start: 25, end: 28, kind: 'read' },
|
||||
])
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user