@@ -83,33 +83,21 @@ local function asString(source)
83
83
or asStringView (source , literal )
84
84
end
85
85
86
- local function getBindComment (source )
87
- local lines = {}
88
- for _ , docComment in ipairs (source .bindComments ) do
89
- if docComment .comment .text :sub (1 , 1 ) == ' -' then
90
- lines [# lines + 1 ] = docComment .comment .text :sub (2 )
91
- else
92
- lines [# lines + 1 ] = docComment .comment .text
93
- end
94
- end
95
- if not lines or # lines == 0 then
96
- return nil
97
- end
98
- return table.concat (lines , ' \n ' )
99
- end
100
-
101
86
--- @param comment string
102
87
--- @param suri uri
103
88
--- @return string ?
104
89
local function normalizeComment (comment , suri )
90
+ if not comment then
91
+ return nil
92
+ end
105
93
if comment :sub (1 , 1 ) == ' -' then
106
94
comment = comment :sub (2 )
107
95
end
108
96
if comment :sub (1 , 1 ) == ' @' then
109
97
return nil
110
98
end
111
99
comment = comment :gsub (' (%[.-%]%()(.-)(%))' , function (left , path , right )
112
- if path : match ' ^file:/ ' then
100
+ if furi . split ( path ) then
113
101
return
114
102
end
115
103
local absPath = ws .getAbsolutePath (suri :gsub (' /[^/]+$' , ' ' ), path )
@@ -122,6 +110,18 @@ local function normalizeComment(comment, suri)
122
110
return comment
123
111
end
124
112
113
+ local function getBindComment (source )
114
+ local uri = guide .getUri (source )
115
+ local lines = {}
116
+ for _ , docComment in ipairs (source .bindComments ) do
117
+ lines [# lines + 1 ] = normalizeComment (docComment .comment .text , uri )
118
+ end
119
+ if not lines or # lines == 0 then
120
+ return nil
121
+ end
122
+ return table.concat (lines , ' \n ' )
123
+ end
124
+
125
125
local function lookUpDocComments (source , docGroup )
126
126
if source .type == ' setlocal'
127
127
or source .type == ' getlocal' then
@@ -134,25 +134,19 @@ local function lookUpDocComments(source, docGroup)
134
134
local lines = {}
135
135
for _ , doc in ipairs (docGroup ) do
136
136
if doc .type == ' doc.comment' then
137
- local comment = normalizeComment (doc .comment .text , uri )
138
- lines [# lines + 1 ] = comment
137
+ lines [# lines + 1 ] = normalizeComment (doc .comment .text , uri )
139
138
elseif doc .type == ' doc.type' then
140
139
if doc .comment then
141
- lines [# lines + 1 ] = doc .comment .text
140
+ lines [# lines + 1 ] = normalizeComment ( doc .comment .text , uri )
142
141
end
143
142
elseif doc .type == ' doc.class' then
144
143
for _ , docComment in ipairs (doc .bindComments ) do
145
- if docComment .comment .text :sub (1 , 1 ) == ' -' then
146
- lines [# lines + 1 ] = docComment .comment .text :sub (2 )
147
- else
148
- lines [# lines + 1 ] = docComment .comment .text
149
- end
144
+ lines [# lines + 1 ] = normalizeComment (docComment .comment .text , uri )
150
145
end
151
146
end
152
- :: CONTINUE::
153
147
end
154
148
if source .comment then
155
- lines [# lines + 1 ] = source .comment .text
149
+ lines [# lines + 1 ] = normalizeComment ( source .comment .text , uri )
156
150
end
157
151
if not lines or # lines == 0 then
158
152
return nil
0 commit comments