diff --git a/lib/adapters/autocomplete-adapter.ts b/lib/adapters/autocomplete-adapter.ts index aec86db9..769579f1 100644 --- a/lib/adapters/autocomplete-adapter.ts +++ b/lib/adapters/autocomplete-adapter.ts @@ -59,12 +59,12 @@ class PossiblyResolvedCompletionItem { /** Public: Adapts the language server protocol "textDocument/completion" to the Atom AutoComplete+ package. */ export default class AutocompleteAdapter { public static canAdapt(serverCapabilities: ServerCapabilities): boolean { - return serverCapabilities.completionProvider != null + return serverCapabilities.completionProvider !== undefined } public static canResolve(serverCapabilities: ServerCapabilities): boolean { return ( - serverCapabilities.completionProvider != null && serverCapabilities.completionProvider.resolveProvider === true + serverCapabilities.completionProvider !== undefined && serverCapabilities.completionProvider.resolveProvider === true ) } @@ -89,7 +89,7 @@ export default class AutocompleteAdapter { shouldReplace: ShouldReplace = false ): Promise { const triggerChars = - server.capabilities.completionProvider != null + server.capabilities.completionProvider !== undefined ? server.capabilities.completionProvider.triggerCharacters || [] : [] @@ -233,11 +233,11 @@ export default class AutocompleteAdapter { const cache = this._suggestionCache.get(server) if (cache) { const possiblyResolvedCompletionItem = cache.suggestionMap.get(suggestion) - if (possiblyResolvedCompletionItem != null && possiblyResolvedCompletionItem.isResolved === false) { + if (possiblyResolvedCompletionItem !== undefined && possiblyResolvedCompletionItem.isResolved === false) { const resolvedCompletionItem = await server.connection.completionItemResolve( possiblyResolvedCompletionItem.completionItem ) - if (resolvedCompletionItem != null) { + if (resolvedCompletionItem !== null) { AutocompleteAdapter.resolveSuggestion(resolvedCompletionItem, suggestion, request, onDidConvertCompletionItem) possiblyResolvedCompletionItem.isResolved = true } @@ -254,7 +254,7 @@ export default class AutocompleteAdapter { ): void { // only the `documentation` and `detail` properties may change when resolving AutocompleteAdapter.applyDetailsToSuggestion(resolvedCompletionItem, suggestion) - if (onDidConvertCompletionItem != null) { + if (onDidConvertCompletionItem !== undefined) { onDidConvertCompletionItem(resolvedCompletionItem, suggestion as ac.AnySuggestion, request) } } @@ -417,7 +417,7 @@ export default class AutocompleteAdapter { shouldReplace ) AutocompleteAdapter.applySnippetToSuggestion(item, suggestion as SnippetSuggestion) - if (onDidConvertCompletionItem != null) { + if (onDidConvertCompletionItem !== undefined) { onDidConvertCompletionItem(item, suggestion as ac.AnySuggestion, request) } @@ -448,7 +448,7 @@ export default class AutocompleteAdapter { suggestion.description = item.documentation } - if (item.documentation != null && typeof item.documentation === "object") { + if (item.documentation !== undefined && typeof item.documentation === "object") { // Newer format specifies the kind of documentation, assign appropriately if (item.documentation.kind === "markdown") { suggestion.descriptionMarkdown = item.documentation.value diff --git a/lib/adapters/code-action-adapter.ts b/lib/adapters/code-action-adapter.ts index bfbc745b..c6eadb73 100644 --- a/lib/adapters/code-action-adapter.ts +++ b/lib/adapters/code-action-adapter.ts @@ -40,7 +40,7 @@ export default class CodeActionAdapter { range: Range, diagnostics: atomIde.Diagnostic[] ): Promise { - if (linterAdapter == null) { + if (linterAdapter === undefined) { return [] } assert(serverCapabilities.codeActionProvider, "Must have the textDocument/codeAction capability") @@ -100,9 +100,9 @@ export default class CodeActionAdapter { // Until the Linter API provides a place to store the code, // there's no real way for the code actions API to give it back to us. const converted = Convert.atomIdeDiagnosticToLSDiagnostic(diagnostic) - if (diagnostic.range != null && diagnostic.text != null) { + if (diagnostic.text !== undefined) { const code = linterAdapter.getDiagnosticCode(editor, diagnostic.range, diagnostic.text) - if (code != null) { + if (code !== null) { converted.code = code } } diff --git a/lib/adapters/command-execution-adapter.ts b/lib/adapters/command-execution-adapter.ts index b6b895f7..3bca6fe9 100644 --- a/lib/adapters/command-execution-adapter.ts +++ b/lib/adapters/command-execution-adapter.ts @@ -7,7 +7,7 @@ export default class CommandExecutionAdapter { private static commandsCustomCallbacks = new Map() public static canAdapt(serverCapabilities: ServerCapabilities): boolean { - return serverCapabilities.executeCommandProvider != null + return serverCapabilities.executeCommandProvider !== undefined } public static registerCustomCallbackForCommand(command: string, callback: CommandCustomCallbackFunction): void { diff --git a/lib/adapters/datatip-adapter.ts b/lib/adapters/datatip-adapter.ts index 5563a3b5..7107089d 100644 --- a/lib/adapters/datatip-adapter.ts +++ b/lib/adapters/datatip-adapter.ts @@ -33,11 +33,11 @@ export default class DatatipAdapter { const documentPositionParams = Convert.editorToTextDocumentPositionParams(editor, point) const hover = await connection.hover(documentPositionParams) - if (hover == null || DatatipAdapter.isEmptyHover(hover)) { + if (hover === null || DatatipAdapter.isEmptyHover(hover)) { return null } - const range = hover.range == null ? Utils.getWordAtPosition(editor, point) : Convert.lsRangeToAtomRange(hover.range) + const range = hover.range === undefined ? Utils.getWordAtPosition(editor, point) : Convert.lsRangeToAtomRange(hover.range) const markedStrings = (Array.isArray(hover.contents) ? hover.contents : [hover.contents]).map((str) => DatatipAdapter.convertMarkedString(editor, str) @@ -47,6 +47,7 @@ export default class DatatipAdapter { } private static isEmptyHover(hover: Hover): boolean { + // TODO hover.contents is never null! return ( hover.contents == null || (typeof hover.contents === "string" && hover.contents.length === 0) || diff --git a/lib/adapters/definition-adapter.ts b/lib/adapters/definition-adapter.ts index d1fff442..c0934883 100644 --- a/lib/adapters/definition-adapter.ts +++ b/lib/adapters/definition-adapter.ts @@ -43,14 +43,14 @@ export default class DefinitionAdapter { const definitionLocations = DefinitionAdapter.normalizeLocations( await connection.gotoDefinition(documentPositionParams) ) - if (definitionLocations == null || definitionLocations.length === 0) { + if (definitionLocations === null || definitionLocations.length === 0) { return null } let queryRange if (serverCapabilities.documentHighlightProvider) { const highlights = await connection.documentHighlight(documentPositionParams) - if (highlights != null && highlights.length > 0) { + if (highlights.length > 0) { queryRange = highlights.map((h) => Convert.lsRangeToAtomRange(h.range)) } } diff --git a/lib/adapters/document-sync-adapter.ts b/lib/adapters/document-sync-adapter.ts index ae23eed3..ebd76eef 100644 --- a/lib/adapters/document-sync-adapter.ts +++ b/lib/adapters/document-sync-adapter.ts @@ -103,12 +103,12 @@ export default class DocumentSyncAdapter { private _handleGrammarChange(editor: TextEditor): void { const sync = this._editors.get(editor) - if (sync != null && !this._editorSelector(editor)) { + if (sync !== undefined && !this._editorSelector(editor)) { this._editors.delete(editor) this._disposable.remove(sync) sync.didClose() sync.dispose() - } else if (sync == null && this._editorSelector(editor)) { + } else if (sync === undefined && this._editorSelector(editor)) { this._handleNewEditor(editor) } } @@ -160,10 +160,11 @@ export class TextEditorSyncAdapter { private _versions: Map, private _reportBusyWhile: Utils.ReportBusyWhile ) { + // TODO atom.project.onDidChangeFiles is never null this._fakeDidChangeWatchedFiles = atom.project.onDidChangeFiles == null const changeTracking = this.setupChangeTracking(_documentSync) - if (changeTracking != null) { + if (changeTracking !== null) { this._disposable.add(changeTracking) } @@ -279,7 +280,7 @@ export class TextEditorSyncAdapter { private _bumpVersion(): void { const filePath = this._editor.getPath() - if (filePath == null) { + if (filePath === undefined) { return } this._versions.set(filePath, this._getVersion(filePath) + 1) @@ -291,7 +292,7 @@ export class TextEditorSyncAdapter { */ private didOpen(): void { const filePath = this._editor.getPath() - if (filePath == null) { + if (filePath === undefined) { return } // Not yet saved @@ -315,7 +316,7 @@ export class TextEditorSyncAdapter { /** Called when the {TextEditor} is closed and sends the 'didCloseTextDocument' notification to the connected language server. */ public didClose(): void { - if (this._editor.getPath() == null) { + if (this._editor.getPath() === undefined) { return } // Not yet saved diff --git a/lib/adapters/find-references-adapter.ts b/lib/adapters/find-references-adapter.ts index 9742c090..d162d56f 100644 --- a/lib/adapters/find-references-adapter.ts +++ b/lib/adapters/find-references-adapter.ts @@ -35,10 +35,6 @@ export default class FindReferencesAdapter { projectRoot: string | null ): Promise { const locations = await connection.findReferences(FindReferencesAdapter.createReferenceParams(editor, point)) - if (locations == null) { - return null - } - const references: atomIde.Reference[] = locations.map(FindReferencesAdapter.locationToReference) return { type: "data", diff --git a/lib/adapters/linter-push-v2-adapter.ts b/lib/adapters/linter-push-v2-adapter.ts index bdae8217..f4e12473 100644 --- a/lib/adapters/linter-push-v2-adapter.ts +++ b/lib/adapters/linter-push-v2-adapter.ts @@ -118,9 +118,9 @@ export default class LinterPushV2Adapter { */ public getDiagnosticCode(editor: atom.TextEditor, range: atom.Range, text: string): DiagnosticCode | null { const path = editor.getPath() - if (path != null) { + if (path !== undefined) { const diagnosticCodes = this._diagnosticCodes.get(path) - if (diagnosticCodes != null) { + if (diagnosticCodes !== undefined) { return diagnosticCodes.get(getCodeKey(range, text)) || null } } diff --git a/lib/adapters/notifications-adapter.ts b/lib/adapters/notifications-adapter.ts index 68b4f4e2..d25ee4db 100644 --- a/lib/adapters/notifications-adapter.ts +++ b/lib/adapters/notifications-adapter.ts @@ -42,7 +42,7 @@ export default class NotificationsAdapter { text: a.title, onDidClick: () => { resolve(a) - if (notification != null) { + if (notification !== null) { notification.dismiss() } }, @@ -51,7 +51,7 @@ export default class NotificationsAdapter { const notification = addNotificationForMessage(params.type, params.message, options) - if (notification != null) { + if (notification !== null) { notification.onDidDismiss(() => { resolve(null) }) diff --git a/lib/adapters/outline-view-adapter.ts b/lib/adapters/outline-view-adapter.ts index 5c11a287..889cee21 100644 --- a/lib/adapters/outline-view-adapter.ts +++ b/lib/adapters/outline-view-adapter.ts @@ -86,7 +86,7 @@ export default class OutlineViewAdapter { return symbols.map((symbol) => { const tree = OutlineViewAdapter.hierarchicalSymbolToOutline(symbol) - if (symbol.children != null) { + if (symbol.children !== undefined) { tree.children = OutlineViewAdapter.createHierarchicalOutlineTrees(symbol.children) } @@ -123,16 +123,16 @@ export default class OutlineViewAdapter { // Create a map of containers by name with all items that have that name const containers = allItems.reduce((map, item) => { const name = item.outline.representativeName - if (name != null) { + if (name !== undefined) { const container = map.get(name) - if (container == null) { + if (container === undefined) { map.set(name, [item.outline]) } else { container.push(item.outline) } } return map - }, new Map()) + }, new Map()) const roots: atomIde.OutlineTree[] = [] @@ -140,12 +140,12 @@ export default class OutlineViewAdapter { for (const item of allItems) { const containerName = item.containerName const child = item.outline - if (containerName == null || containerName === "") { + if (containerName === undefined || containerName === "") { roots.push(item.outline) } else { const possibleParents = containers.get(containerName) let closestParent = OutlineViewAdapter._getClosestParent(possibleParents, child) - if (closestParent == null) { + if (closestParent === null) { closestParent = { plainText: containerName, representativeName: containerName, @@ -153,7 +153,7 @@ export default class OutlineViewAdapter { children: [child], } roots.push(closestParent) - if (possibleParents == null) { + if (possibleParents === undefined) { containers.set(containerName, [closestParent]) } else { possibleParents.push(closestParent) @@ -168,10 +168,10 @@ export default class OutlineViewAdapter { } private static _getClosestParent( - candidates: atomIde.OutlineTree[] | null, + candidates: atomIde.OutlineTree[] | undefined, child: atomIde.OutlineTree ): atomIde.OutlineTree | null { - if (candidates == null || candidates.length === 0) { + if (candidates === undefined || candidates.length === 0) { return null } @@ -186,7 +186,7 @@ export default class OutlineViewAdapter { if ( parent === undefined || parent.startPosition.isLessThanOrEqual(candidate.startPosition) || - (parent.endPosition != null && + (parent.endPosition !== undefined && candidate.endPosition && parent.endPosition.isGreaterThanOrEqual(candidate.endPosition)) ) { @@ -215,7 +215,7 @@ export default class OutlineViewAdapter { value: symbol.name, }, ], - icon: icon != null ? icon : undefined, + icon: icon !== null ? icon : undefined, representativeName: symbol.name, startPosition: Convert.positionToPoint(symbol.selectionRange.start), endPosition: Convert.positionToPoint(symbol.selectionRange.end), @@ -238,7 +238,7 @@ export default class OutlineViewAdapter { value: symbol.name, }, ], - icon: icon != null ? icon : undefined, + icon: icon !== null ? icon : undefined, representativeName: symbol.name, startPosition: Convert.positionToPoint(symbol.location.range.start), endPosition: Convert.positionToPoint(symbol.location.range.end), diff --git a/lib/adapters/signature-help-adapter.ts b/lib/adapters/signature-help-adapter.ts index 1c29b404..bfb0cd51 100644 --- a/lib/adapters/signature-help-adapter.ts +++ b/lib/adapters/signature-help-adapter.ts @@ -19,7 +19,7 @@ export default class SignatureHelpAdapter { /** @returns A {Boolean} indicating this adapter can adapt the server based on the given serverCapabilities. */ public static canAdapt(serverCapabilities: ServerCapabilities): boolean { - return serverCapabilities.signatureHelpProvider != null + return serverCapabilities.signatureHelpProvider !== undefined } public dispose(): void { @@ -28,7 +28,7 @@ export default class SignatureHelpAdapter { public attach(register: atomIde.SignatureHelpRegistry): void { const { signatureHelpProvider } = this._capabilities - assert(signatureHelpProvider != null) + assert(signatureHelpProvider !== undefined) let triggerCharacters: Set | undefined if (signatureHelpProvider && Array.isArray(signatureHelpProvider.triggerCharacters)) {