@@ -155,37 +155,9 @@ func (l *LanguageService) getDocumentationFromDeclaration(c *checker.Checker, sy
155155 if declaration == nil {
156156 return ""
157157 }
158-
159158 isMarkdown := contentFormat == lsproto .MarkupKindMarkdown
160159 var b strings.Builder
161- jsdoc := getJSDocOrTag (c , declaration )
162-
163- // Handle binding elements specially (variables created from destructuring) - we need to get the documentation from the property type
164- // If the binding element doesn't have its own JSDoc, fall back to the property's JSDoc
165- if jsdoc == nil && symbol != nil && symbol .ValueDeclaration != nil && ast .IsBindingElement (symbol .ValueDeclaration ) && ast .IsIdentifier (location ) {
166- bindingElement := symbol .ValueDeclaration
167- parent := bindingElement .Parent
168- name := bindingElement .PropertyName ()
169- if name == nil {
170- name = bindingElement .Name ()
171- }
172- if ast .IsIdentifier (name ) && ast .IsObjectBindingPattern (parent ) {
173- propertyName := name .Text ()
174- objectType := c .GetTypeAtLocation (parent )
175- if objectType != nil {
176- propertySymbol := findPropertyInType (c , objectType , propertyName )
177- if propertySymbol != nil && propertySymbol .ValueDeclaration != nil {
178- jsdoc = getJSDocOrTag (c , propertySymbol .ValueDeclaration )
179- if jsdoc != nil {
180- // Use property declaration for typedef check
181- declaration = propertySymbol .ValueDeclaration
182- }
183- }
184- }
185- }
186- }
187-
188- if jsdoc != nil && ! (declaration .Flags & ast .NodeFlagsReparsed == 0 && containsTypedefTag (jsdoc )) {
160+ if jsdoc := getJSDocOrTag (c , declaration ); jsdoc != nil && ! (declaration .Flags & ast .NodeFlagsReparsed == 0 && containsTypedefTag (jsdoc )) {
189161 l .writeComments (& b , c , jsdoc .Comments (), isMarkdown )
190162 if jsdoc .Kind == ast .KindJSDoc && ! commentOnly {
191163 if tags := jsdoc .AsJSDoc ().Tags ; tags != nil {
@@ -909,6 +881,18 @@ func getJSDocOrTag(c *checker.Checker, node *ast.Node) *ast.Node {
909881 case (ast .IsFunctionExpressionOrArrowFunction (node ) || ast .IsClassExpression (node )) &&
910882 (ast .IsVariableDeclaration (node .Parent ) || ast .IsPropertyDeclaration (node .Parent ) || ast .IsPropertyAssignment (node .Parent )) && node .Parent .Initializer () == node :
911883 return getJSDocOrTag (c , node .Parent )
884+ case ast .IsBindingElement (node ) && ast .IsObjectBindingPattern (node .Parent ):
885+ if name := node .PropertyNameOrName (); ast .IsIdentifier (name ) {
886+ if objectType := c .GetTypeAtLocation (node .Parent ); objectType != nil {
887+ if prop := c .GetPropertyOfType (objectType , name .Text ()); prop != nil {
888+ for _ , d := range prop .Declarations {
889+ if jsdoc := getJSDoc (d ); jsdoc != nil {
890+ return jsdoc
891+ }
892+ }
893+ }
894+ }
895+ }
912896 }
913897 if symbol := node .Symbol (); symbol != nil && node .Parent != nil {
914898 if ast .IsFunctionDeclaration (node ) || ast .IsMethodDeclaration (node ) || ast .IsMethodSignatureDeclaration (node ) || ast .IsConstructorDeclaration (node ) || ast .IsConstructSignatureDeclaration (node ) {
@@ -1135,20 +1119,6 @@ func writeQuotedString(b *strings.Builder, str string, quote bool) {
11351119 }
11361120}
11371121
1138- // findPropertyInType finds a property in a type, handling union types by searching constituent types
1139- func findPropertyInType (c * checker.Checker , objectType * checker.Type , propertyName string ) * ast.Symbol {
1140- // For union types, try to find the property in any of the constituent types
1141- if objectType .IsUnion () {
1142- for _ , t := range objectType .Types () {
1143- if prop := c .GetPropertyOfType (t , propertyName ); prop != nil {
1144- return prop
1145- }
1146- }
1147- return nil
1148- }
1149- return c .GetPropertyOfType (objectType , propertyName )
1150- }
1151-
11521122func getEntityNameString (name * ast.Node ) string {
11531123 var b strings.Builder
11541124 writeEntityNameParts (& b , name )
0 commit comments