@@ -18,6 +18,7 @@ import {getDocumentSettings, TactSettings} from "@server/utils/settings"
18
18
import { File } from "@server/psi/File"
19
19
import { Position } from "vscode-languageclient"
20
20
import { asLspPosition } from "@server/utils/position"
21
+ import { FieldsOwnerTy , sizeOfPresentation } from "@server/types/BaseTy"
21
22
22
23
const CODE_FENCE = "```"
23
24
const DOC_TMPL = `${ CODE_FENCE } tact\n{signature}\n${ CODE_FENCE } \n{documentation}\n`
@@ -148,14 +149,16 @@ export async function generateDocFor(node: NamedNode, place: SyntaxNode): Promis
148
149
const doc = extractCommentsDoc ( node )
149
150
const struct = new Struct ( node . node , node . file )
150
151
const body = struct . body ( ) ?. text ?? ""
151
- return defaultResult ( `struct ${ node . name ( ) } ${ body } ` , doc )
152
+ const sizeDoc = documentationSizeOf ( struct )
153
+ return defaultResult ( `struct ${ node . name ( ) } ${ body } ` , doc + sizeDoc )
152
154
}
153
155
case "message" : {
154
156
const doc = extractCommentsDoc ( node )
155
157
const message = new Message ( node . node , node . file )
156
158
const body = message . body ( ) ?. text ?? ""
157
159
const value = message . value ( )
158
- return defaultResult ( `message${ value } ${ node . name ( ) } ${ body } ` , doc )
160
+ const sizeDoc = documentationSizeOf ( message )
161
+ return defaultResult ( `message${ value } ${ node . name ( ) } ${ body } ` , doc + sizeDoc )
159
162
}
160
163
case "primitive" : {
161
164
const doc = extractCommentsDoc ( node )
@@ -399,7 +402,14 @@ function requireFunctionDoc(place: SyntaxNode, file: File, settings: TactSetting
399
402
400
403
const exitCode = compiler . requireFunctionExitCode ( callNode , file , settings . hints . exitCodeFormat )
401
404
if ( ! exitCode ) return ""
402
- return `Edit code: **${ exitCode . value } **\n\n`
405
+ return `Exit code: **${ exitCode . value } **\n\n`
406
+ }
407
+
408
+ function documentationSizeOf ( struct : Struct ) : string {
409
+ const ty = new FieldsOwnerTy ( struct . name ( ) , struct )
410
+ const sizeOf = ty . sizeOf ( )
411
+ const sizeOfPres = sizeOfPresentation ( sizeOf )
412
+ return `\n\n**Size**: ${ sizeOfPres } `
403
413
}
404
414
405
415
function defaultResult ( signature : string , documentation : string = "" ) : string {
0 commit comments