@@ -12,7 +12,7 @@ import { SchemaRetriever } from '../schema/SchemaRetriever';
1212import { LoggerFactory } from '../telemetry/LoggerFactory' ;
1313import { getFuzzySearchFunction } from '../utils/FuzzySearchUtil' ;
1414import { CompletionProvider } from './CompletionProvider' ;
15- import { createCompletionItem , createReplacementRange } from './CompletionUtils' ;
15+ import { createCompletionItem , createMarkupContent , createReplacementRange } from './CompletionUtils' ;
1616
1717interface IntrinsicFunctionInfo {
1818 type : IntrinsicFunction ;
@@ -344,10 +344,25 @@ export class IntrinsicFunctionArgumentCompletionProvider implements CompletionPr
344344
345345 const attributes = this . getResourceAttributes ( resource . Type ) ;
346346 for ( const attributeName of attributes ) {
347+ const schema = this . schemaRetriever . getDefault ( ) . schemas . get ( resource . Type ) ;
348+ let attributeDescription = `${ attributeName } attribute of ${ resource . Type } ` ;
349+
350+ if ( schema ) {
351+ const jsonPointerPath = `/properties/${ attributeName . replaceAll ( '.' , '/' ) } ` ;
352+
353+ try {
354+ const resolvedSchemas = schema . resolveJsonPointerPath ( jsonPointerPath ) ;
355+ if ( resolvedSchemas . length > 0 && resolvedSchemas [ 0 ] . description ) {
356+ attributeDescription = resolvedSchemas [ 0 ] . description ;
357+ }
358+ } catch ( error ) {
359+ log . error ( { error } , 'Error resolving JSON Pointer path' ) ;
360+ }
361+ }
347362 completionItems . push (
348363 createCompletionItem ( `${ resourceName } .${ attributeName } ` , CompletionItemKind . Property , {
349364 detail : `GetAtt (${ resource . Type } )` ,
350- documentation : `Get attribute ${ attributeName } from resource ${ resourceName } ` ,
365+ documentation : createMarkupContent ( attributeDescription ) ,
351366 data : {
352367 isIntrinsicFunction : true ,
353368 } ,
@@ -648,7 +663,8 @@ export class IntrinsicFunctionArgumentCompletionProvider implements CompletionPr
648663 }
649664
650665 const resource = resourceContext . entity as Resource ;
651- if ( ! resource . Type || typeof resource . Type !== 'string' ) {
666+ const resourceType = resource . Type ;
667+ if ( ! resourceType || typeof resourceType !== 'string' ) {
652668 return undefined ;
653669 }
654670
@@ -658,8 +674,36 @@ export class IntrinsicFunctionArgumentCompletionProvider implements CompletionPr
658674 }
659675
660676 const completionItems = attributes . map ( ( attributeName ) => {
677+ const schema = this . schemaRetriever . getDefault ( ) . schemas . get ( resourceType ) ;
678+ let documentation ;
679+
680+ if ( schema ) {
681+ const jsonPointerPath = `/properties/${ attributeName . replaceAll ( '.' , '/properties/' ) } ` ;
682+ documentation = createMarkupContent (
683+ `**${ attributeName } ** attribute of **${ resource . Type } **\n\nReturns the value of this attribute when used with the GetAtt intrinsic function.` ,
684+ ) ;
685+
686+ try {
687+ const resolvedSchemas = schema . resolveJsonPointerPath ( jsonPointerPath ) ;
688+
689+ if ( resolvedSchemas . length > 0 ) {
690+ const firstSchema = resolvedSchemas [ 0 ] ;
691+
692+ if ( firstSchema . description ) {
693+ documentation = createMarkupContent ( firstSchema . description ) ;
694+ }
695+ }
696+ } catch ( error ) {
697+ log . debug ( error ) ;
698+ }
699+ }
700+
661701 const item = createCompletionItem ( attributeName , CompletionItemKind . Property , {
662- data : { isIntrinsicFunction : true } ,
702+ documentation : documentation ,
703+ detail : `GetAtt attribute for ${ resource . Type } ` ,
704+ data : {
705+ isIntrinsicFunction : true ,
706+ } ,
663707 } ) ;
664708
665709 if ( context . text . length > 0 ) {
0 commit comments