Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed May 1, 2021
1 parent 4f1c5ca commit 5556080
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 43 deletions.
4 changes: 2 additions & 2 deletions lib/adapters/code-action-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default class CodeActionAdapter {
* @param serverCapabilities The {ServerCapabilities} of the language server that will be used.
* @param editor The Atom {TextEditor} containing the diagnostics.
* @param range The Atom {Range} to fetch code actions for.
* @param linterMessages An {Array<linter$Message>} to fetch code actions for.
* This is typically a list of messages intersecting `range`.
* @param linterMessages An {Array<linter$Message>} to fetch code actions for. This is typically a list of messages
* intersecting `range`.
* @returns A {Promise} of an {Array} of {atomIde$CodeAction}s to display.
*/
public static async getCodeActions(
Expand Down
39 changes: 21 additions & 18 deletions lib/adapters/diagnostic-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import * as ls from "../languageclient"
import Convert from "../convert"
import LinterPushV2Adapter from "./linter-push-v2-adapter"

/** @deprecated use Linter V2 service */
/** @deprecated Use Linter V2 service */
export type DiagnosticCode = number | string

/** @deprecated use Linter V2 service */
/** @deprecated Use Linter V2 service */
export default class IdeDiagnosticAdapter extends LinterPushV2Adapter {
private _diagnosticCodes: Map<string, Map<string, DiagnosticCode | null>> = new Map()

/**
* Public: Capture the diagnostics sent from a langguage server, convert them to the
* Linter V2 format and forward them on to any attached {V2IndieDelegate}s.
* @deprecated use Linter V2 service
* @param params The {PublishDiagnosticsParams} received from the language server that should
* be captured and forwarded on to any attached {V2IndieDelegate}s.
* Public: Capture the diagnostics sent from a langguage server, convert them to the Linter V2 format and forward them
* on to any attached {V2IndieDelegate}s.
*
* @deprecated Use Linter V2 service
* @param params The {PublishDiagnosticsParams} received from the language server that should be captured and
* forwarded on to any attached {V2IndieDelegate}s.
*/
public captureDiagnostics(params: ls.PublishDiagnosticsParams): void {
const path = Convert.uriToPath(params.uri)
Expand All @@ -31,11 +32,13 @@ export default class IdeDiagnosticAdapter extends LinterPushV2Adapter {
this._indies.forEach((i) => i.setMessages(path, messages))
}

/** Public: get diagnostics for the given linter messages
* @deprecated use Linter V2 service
* @param linterMessages an array of linter {V2Message}
/**
* Public: get diagnostics for the given linter messages
*
* @deprecated Use Linter V2 service
* @param linterMessages An array of linter {V2Message}
* @param editor
* @returns an array of LS {Diagnostic[]}
* @returns An array of LS {Diagnostic[]}
*/
public getLSDiagnosticsForIdeDiagnostics(
diagnostics: atomIde.Diagnostic[],
Expand All @@ -46,7 +49,8 @@ export default class IdeDiagnosticAdapter extends LinterPushV2Adapter {

/**
* Public: Get the {Diagnostic} that is associated with the given {atomIde.Diagnostic}.
* @deprecated use Linter V2 service
*
* @deprecated Use Linter V2 service
* @param diagnostic The {atomIde.Diagnostic} object to fetch the {Diagnostic} for.
* @param editor
* @returns The associated {Diagnostic}.
Expand All @@ -66,10 +70,9 @@ export default class IdeDiagnosticAdapter extends LinterPushV2Adapter {
}

/**
* Private: Get the recorded diagnostic code for a range/message.
* Diagnostic codes are tricky because there's no suitable place in the Linter API for them.
* For now, we'll record the original code for each range/message combination and retrieve it
* when needed (e.g. for passing back into code actions)
* Private: Get the recorded diagnostic code for a range/message. Diagnostic codes are tricky because there's no
* suitable place in the Linter API for them. For now, we'll record the original code for each range/message
* combination and retrieve it when needed (e.g. for passing back into code actions)
*/
private getDiagnosticCode(editor: atom.TextEditor, range: atom.Range, text: string): DiagnosticCode | null {
const path = editor.getPath()
Expand All @@ -83,7 +86,7 @@ export default class IdeDiagnosticAdapter extends LinterPushV2Adapter {
}
}

/** @deprecated use Linter V2 service */
/** @deprecated Use Linter V2 service */
export function atomIdeDiagnosticToLSDiagnostic(diagnostic: atomIde.Diagnostic): ls.Diagnostic {
// TODO: support diagnostic codes and codeDescriptions
// TODO!: support data
Expand All @@ -95,7 +98,7 @@ export function atomIdeDiagnosticToLSDiagnostic(diagnostic: atomIde.Diagnostic):
}
}

/** @deprecated use Linter V2 service */
/** @deprecated Use Linter V2 service */
export function diagnosticTypeToLSSeverity(type: atomIde.DiagnosticType): ls.DiagnosticSeverity {
switch (type) {
case "Error":
Expand Down
34 changes: 18 additions & 16 deletions lib/adapters/linter-push-v2-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import {
} from "../languageclient"

/**
* Public: Listen to diagnostics messages from the language server and publish them
* to the user by way of the Linter Push (Indie) v2 API provided by the Base Linter package.
* Public: Listen to diagnostics messages from the language server and publish them to the user by way of the Linter
* Push (Indie) v2 API provided by the Base Linter package.
*/
export default class LinterPushV2Adapter {
/*
* A map from file path calculated using the LS diagnostic uri to an array of linter messages {linter.Message[]}
*/
protected _diagnosticMap: Map<string, linter.Message[]> = new Map()
/**
* A map from file path {linter.Message["location"]["file"]} to a Map of all Message keys to Diagnostics ${Map<linter.Message["key"], Diagnostic>}
* It has to be stored separately because a {Message} object cannot hold all of the information
* that a {Diagnostic} provides, thus we store the original {Diagnostic} object.
* A map from file path {linter.Message["location"]["file"]} to a Map of all Message keys to Diagnostics
* ${Map<linter.Message["key"], Diagnostic>} It has to be stored separately because a {Message} object cannot hold all
* of the information that a {Diagnostic} provides, thus we store the original {Diagnostic} object.
*/
protected _lsDiagnosticMap: Map<
linter.Message["location"]["file"],
Expand Down Expand Up @@ -101,9 +101,11 @@ export default class LinterPushV2Adapter {
}
}

/** Public: get diagnostics for the given linter messages
* @param linterMessages an array of linter {V2Message}
* @returns an array of LS {Diagnostic[]}
/**
* Public: get diagnostics for the given linter messages
*
* @param linterMessages An array of linter {V2Message}
* @returns An array of LS {Diagnostic[]}
*/
public getLSDiagnosticsForMessages(linterMessages: linter.Message[]): Diagnostic[] {
return (
Expand All @@ -125,8 +127,8 @@ export default class LinterPushV2Adapter {
}

/**
* Public: Convert a diagnostic severity number obtained from the language server into
* the textual equivalent for a Linter {V2Message}.
* Public: Convert a diagnostic severity number obtained from the language server into the textual equivalent for a
* Linter {V2Message}.
*
* @param severity A number representing the severity of the diagnostic.
* @returns A string of 'error', 'warning' or 'info' depending on the severity.
Expand All @@ -146,8 +148,7 @@ export default class LinterPushV2Adapter {
}

/**
* Public: Convert a single {Diagnostic} received from a language server into a single
* {Message} expected by the Linter V2 API.
* Public: Convert a single {Diagnostic} received from a language server into a single {Message} expected by the Linter V2 API.
*
* @param path A string representing the path of the file the diagnostic belongs to.
* @param diagnostics A {Diagnostic} object received from the language server.
Expand All @@ -171,8 +172,8 @@ function lsDiagnosticToV2Message(path: string, diagnostic: Diagnostic): linter.M
}

/**
* Convert a severity level of an LSP {Diagnostic} to that of a Base Linter v2 {Message}.
* Note: this conversion is lossy due to the v2 Message not being able to represent hints.
* Convert a severity level of an LSP {Diagnostic} to that of a Base Linter v2 {Message}. Note: this conversion is lossy
* due to the v2 Message not being able to represent hints.
*
* @param severity A severity level of of an LSP {Diagnostic} to be converted.
* @returns A severity level a Base Linter v2 {Message}.
Expand Down Expand Up @@ -213,8 +214,7 @@ function iconForLSSeverity(severity: DiagnosticSeverity): string | undefined {
}

/**
* Convert the related information from a diagnostic into
* a reference point for a Linter {V2Message}.
* Convert the related information from a diagnostic into a reference point for a Linter {V2Message}.
*
* @param relatedInfo Several related information objects (only the first is used).
* @returns A value that is suitable for using as {V2Message}.reference.
Expand All @@ -235,6 +235,7 @@ function relatedInformationToReference(

/**
* Get a unique key for a Linter v2 Message
*
* @param message A {Message} object
* @returns ${string} a unique key
*/
Expand All @@ -247,6 +248,7 @@ function getMessageKey(message: linter.Message): string {

/**
* Construct an unique key for a Linter v2 Message and store it in `Message.key`
*
* @param message A {Message} object to serialize.
* @returns ${string} a unique key
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ export default class Convert {
}
}

/** @deprecated use Linter V2 service */
/** @deprecated Use Linter V2 service */
public static atomIdeDiagnosticToLSDiagnostic(diagnostic: atomIde.Diagnostic): ls.Diagnostic {
// eslint-disable-next-line import/no-deprecated
return atomIdeDiagnosticToLSDiagnostic(diagnostic)
}

/** @deprecated use Linter V2 service */
/** @deprecated Use Linter V2 service */
public static diagnosticTypeToLSSeverity(type: atomIde.DiagnosticType): ls.DiagnosticSeverity {
// eslint-disable-next-line import/no-deprecated
return diagnosticTypeToLSSeverity(type)
Expand Down
8 changes: 3 additions & 5 deletions lib/languageclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ export class LanguageClientConnection extends EventEmitter {
* Public: Send a `textDocument/codeAction` request.
*
* @param params The {CodeActionParams} identifying the document, range and context for the code action.
* @returns A {Promise} containing an {Array} of {Command}s or {CodeAction}s that can be performed
* against the given documents range.
* @returns A {Promise} containing an {Array} of {Command}s or {CodeAction}s that can be performed against the given
* documents range.
*/
public codeAction(params: lsp.CodeActionParams): Promise<Array<lsp.Command | lsp.CodeAction> | null> {
return this._sendRequest(lsp.CodeActionRequest.type, params)
Expand Down Expand Up @@ -576,9 +576,7 @@ export class LanguageClientConnection extends EventEmitter {
}
}

/**
* Contains additional information about the context in which a completion request is triggered.
*/
/** Contains additional information about the context in which a completion request is triggered. */
export interface CompletionContext {
/** How the completion was triggered. */
triggerKind: lsp.CompletionTriggerKind
Expand Down

0 comments on commit 5556080

Please sign in to comment.