Skip to content

Commit a2ca88c

Browse files
committed
complete code lens
1 parent 9732485 commit a2ca88c

File tree

13 files changed

+54
-3
lines changed

13 files changed

+54
-3
lines changed

locale/en-us/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ COMMAND_JSON_TO_LUA_FAILED =
447447
'Convert JSON to Lua failed: {}'
448448
COMMAND_ADD_DICT =
449449
'Add Word to dictionary'
450+
COMMAND_REFERENCE_COUNT =
451+
'{} references'
450452

451453
COMPLETION_IMPORT_FROM =
452454
'Import from {}'

locale/en-us/setting.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ config.hint.semicolon.SameLine =
256256
'When two statements are on the same line, display a semicolon between them.'
257257
config.hint.semicolon.Disable =
258258
'Disable virtual semicolons.'
259+
config.codeLens.enable =
260+
'Enable code lens.'
259261
config.format.enable =
260262
'Enable code formatter.'
261263
config.format.defaultConfig =

locale/pt-br/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ COMMAND_JSON_TO_LUA_FAILED =
447447
'Converção de JSON para Lua falhou: {}.'
448448
COMMAND_ADD_DICT =
449449
'Adicione uma palavra ao dicionário'
450+
COMMAND_REFERENCE_COUNT = -- TODO: need translate!
451+
'{} references'
450452

451453
COMPLETION_IMPORT_FROM =
452454
'Importa de {}.'

locale/pt-br/setting.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ config.hint.semicolon.SameLine = -- TODO: need translate!
256256
'When two statements are on the same line, display a semicolon between them.'
257257
config.hint.semicolon.Disable = -- TODO: need translate!
258258
'Disable virtual semicolons.'
259+
config.codeLens.enable = -- TODO: need translate!
260+
'Enable code lens.'
259261
config.format.enable = -- TODO: need translate!
260262
'Enable code formatter.'
261263
config.format.defaultConfig = -- TODO: need translate!

locale/zh-cn/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ COMMAND_JSON_TO_LUA_FAILED =
447447
'JSON 转 Lua 失败:{}'
448448
COMMAND_ADD_DICT = -- TODO: need translate!
449449
'Add Word to dictionary'
450+
COMMAND_REFERENCE_COUNT =
451+
'{} 个引用'
450452

451453
COMPLETION_IMPORT_FROM =
452454
'从 {} 中导入'

locale/zh-cn/setting.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ config.hint.semicolon.SameLine =
255255
'2个语句在同一行时,在它们之间显示分号。'
256256
config.hint.semicolon.Disable =
257257
'禁用虚拟分号。'
258+
config.codeLens.enable = -- TODO: need translate!
259+
'启用代码度量。'
258260
config.format.enable =
259261
'启用代码格式化程序。'
260262
config.format.defaultConfig =

locale/zh-tw/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ COMMAND_JSON_TO_LUA_FAILED =
447447
'JSON 轉 Lua 失敗:{}'
448448
COMMAND_ADD_DICT =
449449
'添加單字到字典裡'
450+
COMMAND_REFERENCE_COUNT = -- TODO: need translate!
451+
'{} references'
450452

451453
COMPLETION_IMPORT_FROM =
452454
'從 {} 中匯入'

locale/zh-tw/setting.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ config.hint.semicolon.SameLine =
255255
'兩個陳述式在同一行時,在它們之間顯示分號。'
256256
config.hint.semicolon.Disable =
257257
'停用虛擬分號。'
258+
config.codeLens.enable = -- TODO: need translate!
259+
'Enable code lens.'
258260
config.format.enable =
259261
'啟用程式碼格式化程式。'
260262
config.format.defaultConfig =

script/config/template.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ local template = {
374374
},
375375
['Lua.window.statusBar'] = Type.Boolean >> true,
376376
['Lua.window.progressBar'] = Type.Boolean >> true,
377+
['Lua.codeLens.enable'] = Type.Boolean >> false,
377378
['Lua.format.enable'] = Type.Boolean >> true,
378379
['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String)
379380
>> {},

script/core/code-lens.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ local guide = require 'parser.guide'
33
local await = require 'await'
44
local conv = require 'proto.converter'
55
local getRef = require 'core.reference'
6+
local lang = require 'language'
67

78
---@class parser.state
89
---@field package _codeLens codeLens
910

1011
---@class codeLens.resolving
11-
---@field mode 'reference'
12-
---@field source parser.object
12+
---@field mode 'reference'
13+
---@field source? parser.object
1314

1415
---@class codeLens.result
1516
---@field position integer
@@ -89,7 +90,7 @@ function mt:resolveReference(source)
8990
local refs = getRef(self.uri, source.finish, false)
9091
local count = refs and #refs or 0
9192
local command = conv.command(
92-
('%d个引用'):format(count),
93+
lang.script('COMMAND_REFERENCE_COUNT', count),
9394
'',
9495
{}
9596
)

0 commit comments

Comments
 (0)