11local files = require (" files" )
22local guide = require (" parser.guide" )
3+ local converter = require (" proto.converter" )
4+ local subString = require ' core.substring'
5+
36
47
58--- @class psi.view.node
@@ -15,6 +18,7 @@ local guide = require("parser.guide")
1518--- @field end integer
1619
1720--- @param astNode parser.object
21+ --- @param state parser.state
1822--- @return psi.view.node | nil
1923local function toPsiNode (astNode , state )
2024 if not astNode then
@@ -26,8 +30,13 @@ local function toPsiNode(astNode, state)
2630
2731 local startOffset = guide .positionToOffset (state , astNode .start )
2832 local finishOffset = guide .positionToOffset (state , astNode .finish )
33+ local startPosition = converter .packPosition (state .uri , astNode .start )
34+ local finishPosition = converter .packPosition (state .uri , astNode .finish )
2935 return {
30- name = string.format (" %s@%d..%d" , astNode .type , startOffset , finishOffset ),
36+ name = string.format (" %s@[%d:%d .. %d:%d]" ,
37+ astNode .type ,
38+ startPosition .line + 1 , startPosition .character + 1 ,
39+ finishPosition .line + 1 , finishPosition .character + 1 ),
3140 attr = {
3241 range = {
3342 start = startOffset ,
@@ -67,9 +76,15 @@ local function collectPsi(astNode, state)
6776 end
6877 end
6978
70- -- if not psiNode.children then
71- -- psiNode.name = psiNode.name
72- -- end
79+ if not psiNode .children then
80+ local subber = subString (state )
81+ local showText = subber (astNode .start + 1 , astNode .finish )
82+ if string.len (showText ) > 30 then
83+ showText = showText :sub (0 , 30 ).. " ... "
84+ end
85+
86+ psiNode .name = psiNode .name .. " " .. showText
87+ end
7388
7489 return psiNode
7590end
0 commit comments