@@ -242,6 +242,8 @@ export class FileIndexer {
242242 range,
243243 symbol : scipSymbol . value ,
244244 symbol_roles : role ,
245+
246+ diagnostics : FileIndexer . diagnosticsFor ( sym , isDefinitionNode ) ,
245247 } )
246248 )
247249 if ( isDefinitionNode ) {
@@ -718,6 +720,42 @@ export class FileIndexer {
718720 }
719721 loop ( node )
720722 }
723+
724+ /**
725+ * Returns the scip diagnostics for a given typescript symbol.
726+ * @param sym - The TypeScript symbol to get diagnostics for
727+ * @param isDefinition - Whether this occurrence is a definition of the symbol
728+ */
729+ private static diagnosticsFor (
730+ sym : ts . Symbol ,
731+ isDefinition : boolean
732+ ) : scip . scip . Diagnostic [ ] | undefined {
733+ // Currently, the logic below only supports deprecation
734+ // diagnostics. Since linters typically only emit such
735+ // diagnostics at reference sites, skip the check if we're
736+ // not at a definition.
737+ if ( isDefinition ) {
738+ return undefined
739+ }
740+
741+ const jsDocTags = sym . getJsDocTags ( )
742+
743+ const deprecatedTag = jsDocTags . find ( tag => tag . name === 'deprecated' )
744+ if ( deprecatedTag ) {
745+ return [
746+ new scip . scip . Diagnostic ( {
747+ severity : scip . scip . Severity . Information ,
748+ code : 'DEPRECATED' ,
749+ // jsDocInfo.text is a tokenized representation of the tag text.
750+ // Concatenate the elements to get the full message
751+ message : deprecatedTag . text ?. map ( part => part . text ) . join ( '' ) ,
752+ tags : [ scip . scip . DiagnosticTag . Deprecated ] ,
753+ } ) ,
754+ ]
755+ }
756+
757+ return undefined
758+ }
721759}
722760
723761function isAnonymousContainerOfSymbols ( node : ts . Node ) : boolean {
0 commit comments