Skip to content

Commit 8ab1b4d

Browse files
Push boolean down to be adjacent to deprecated diagnostic logic
1 parent 02a1ddf commit 8ab1b4d

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/FileIndexer.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,7 @@ export class FileIndexer {
243243
symbol: scipSymbol.value,
244244
symbol_roles: role,
245245

246-
// Diagnostics should only be added for references to the symbol, not
247-
// the definition
248-
diagnostics: isDefinitionNode
249-
? undefined
250-
: FileIndexer.diagnosticsForSymbol(sym),
246+
diagnostics: FileIndexer.diagnosticsFor(sym, isDefinitionNode),
251247
})
252248
)
253249
if (isDefinitionNode) {
@@ -725,10 +721,23 @@ export class FileIndexer {
725721
loop(node)
726722
}
727723

728-
// Returns the scip diagnostics for a given typescript symbol
729-
private static diagnosticsForSymbol(
730-
sym: ts.Symbol
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
731732
): 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+
732741
const jsDocTags = sym.getJsDocTags()
733742

734743
const deprecatedTag = jsDocTags.find(tag => tag.name === 'deprecated')

0 commit comments

Comments
 (0)