Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 6acfa42

Browse files
committed
Format TS sources with ide-typescript defaults
1 parent a22157d commit 6acfa42

31 files changed

+234
-211
lines changed

lib/adapters/apply-edit-adapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default class ApplyEditAdapter {
7474
// Get an existing editor for the file, or open a new one if it doesn't exist.
7575
const edits = Convert.convertLsTextEdits(changes[uri]);
7676
const checkpoint = ApplyEditAdapter.applyEdits(buffer, edits);
77-
checkpoints.push({buffer, checkpoint});
77+
checkpoints.push({ buffer, checkpoint });
7878
});
7979

8080
// Apply all edits or fail and revert everything
@@ -85,13 +85,13 @@ export default class ApplyEditAdapter {
8585
description: 'Failed to apply edits.',
8686
detail: err.message,
8787
});
88-
checkpoints.forEach(({buffer, checkpoint}) => {
88+
checkpoints.forEach(({ buffer, checkpoint }) => {
8989
buffer.revertToCheckpoint(checkpoint);
9090
});
9191
return false;
9292
});
9393

94-
return {applied};
94+
return { applied };
9595
}
9696

9797
// Private: Do some basic sanity checking on the edit ranges.

lib/adapters/autocomplete-adapter.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default class AutocompleteAdapter {
9393
}
9494

9595
const filtered = !(request.prefix === "" || (triggerChar !== '' && triggerOnly));
96-
return filtered ? filter(suggestions, request.prefix, {key: 'text'}) : suggestions;
96+
return filtered ? filter(suggestions, request.prefix, { key: 'text' }) : suggestions;
9797
}
9898

9999
private shouldTrigger(
@@ -102,9 +102,9 @@ export default class AutocompleteAdapter {
102102
minWordLength: number,
103103
): boolean {
104104
return request.activatedManually
105-
|| triggerChar !== ''
106-
|| minWordLength <= 0
107-
|| request.prefix.length >= minWordLength;
105+
|| triggerChar !== ''
106+
|| minWordLength <= 0
107+
|| request.prefix.length >= minWordLength;
108108
}
109109

110110
private async getOrBuildSuggestions(
@@ -129,14 +129,14 @@ export default class AutocompleteAdapter {
129129

130130
// Our cached suggestions can't be used so obtain new ones from the language server
131131
const completions = await Utils.doWithCancellationToken(server.connection, this._cancellationTokens,
132-
(cancellationToken) => server.connection.completion(
133-
AutocompleteAdapter.createCompletionParams(request, triggerChar, triggerOnly), cancellationToken),
132+
(cancellationToken) => server.connection.completion(
133+
AutocompleteAdapter.createCompletionParams(request, triggerChar, triggerOnly), cancellationToken),
134134
);
135135

136136
// Setup the cache for subsequent filtered results
137137
const isComplete = Array.isArray(completions) || completions.isIncomplete === false;
138138
const suggestionMap = this.completionItemsToSuggestions(completions, request, onDidConvertCompletionItem);
139-
this._suggestionCache.set(server, {isIncomplete: !isComplete, triggerChar, triggerPoint, suggestionMap});
139+
this._suggestionCache.set(server, { isIncomplete: !isComplete, triggerChar, triggerPoint, suggestionMap });
140140

141141
return Array.from(suggestionMap.keys());
142142
}
@@ -259,11 +259,11 @@ export default class AutocompleteAdapter {
259259
// if there is one.
260260
public static createCompletionContext(triggerCharacter: string, triggerOnly: boolean): CompletionContext {
261261
if (triggerCharacter === '') {
262-
return {triggerKind: CompletionTriggerKind.Invoked};
262+
return { triggerKind: CompletionTriggerKind.Invoked };
263263
} else {
264264
return triggerOnly
265-
? {triggerKind: CompletionTriggerKind.TriggerCharacter, triggerCharacter}
266-
: {triggerKind: CompletionTriggerKind.TriggerForIncompleteCompletions, triggerCharacter};
265+
? { triggerKind: CompletionTriggerKind.TriggerCharacter, triggerCharacter }
266+
: { triggerKind: CompletionTriggerKind.TriggerForIncompleteCompletions, triggerCharacter };
267267
}
268268
}
269269

@@ -288,7 +288,7 @@ export default class AutocompleteAdapter {
288288
(s) => [
289289
AutocompleteAdapter.completionItemToSuggestion(
290290
s, {} as ac.AnySuggestion, request, onDidConvertCompletionItem),
291-
new PossiblyResolvedCompletionItem(s, false)]));
291+
new PossiblyResolvedCompletionItem(s, false)]));
292292
}
293293

294294
// Public: Convert a language server protocol CompletionItem to an AutoComplete+ suggestion.
@@ -332,12 +332,12 @@ export default class AutocompleteAdapter {
332332
suggestion.rightLabel = item.detail;
333333

334334
// Older format, can't know what it is so assign to both and hope for best
335-
if (typeof(item.documentation) === 'string') {
335+
if (typeof (item.documentation) === 'string') {
336336
suggestion.descriptionMarkdown = item.documentation;
337337
suggestion.description = item.documentation;
338338
}
339339

340-
if (item.documentation != null && typeof(item.documentation) === 'object') {
340+
if (item.documentation != null && typeof (item.documentation) === 'object') {
341341
// Newer format specifies the kind of documentation, assign appropriately
342342
if (item.documentation.kind === 'markdown') {
343343
suggestion.descriptionMarkdown = item.documentation.value;

lib/adapters/code-action-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default class CodeActionAdapter {
6969
return Promise.resolve(action.title);
7070
},
7171
// tslint:disable-next-line:no-empty
72-
dispose(): void {},
72+
dispose(): void { },
7373
};
7474
}
7575

lib/adapters/datatip-adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ export default class DatatipAdapter {
8383
// Must check as <{language: string}> to disambiguate between
8484
// string and the more explicit object type because MarkedString
8585
// is a union of the two types
86-
if ((markedString as {language: string}).language) {
86+
if ((markedString as { language: string }).language) {
8787
return {
8888
type: 'snippet',
8989
// TODO: find a better mapping from language -> grammar
9090
grammar:
9191
atom.grammars.grammarForScopeName(
92-
`source.${(markedString as {language: string}).language}`) || editor.getGrammar(),
92+
`source.${(markedString as { language: string }).language}`) || editor.getGrammar(),
9393
value: markedString.value,
9494
};
9595
}

lib/adapters/document-sync-adapter.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export class TextEditorSyncAdapter {
229229
this._bumpVersion();
230230
this._connection.didChangeTextDocument({
231231
textDocument: this.getVersionedTextDocumentIdentifier(),
232-
contentChanges: [{text: this._editor.getText()}],
232+
contentChanges: [{ text: this._editor.getText() }],
233233
});
234234
}
235235

@@ -315,7 +315,7 @@ export class TextEditorSyncAdapter {
315315
return; // Other windows or editors still have this file open
316316
}
317317

318-
this._connection.didCloseTextDocument({textDocument: {uri: this.getEditorUri()}});
318+
this._connection.didCloseTextDocument({ textDocument: { uri: this.getEditorUri() } });
319319
}
320320

321321
// Called just before the {TextEditor} saves and sends the 'willSaveTextDocument' notification to
@@ -325,7 +325,7 @@ export class TextEditorSyncAdapter {
325325

326326
const uri = this.getEditorUri();
327327
this._connection.willSaveTextDocument({
328-
textDocument: {uri},
328+
textDocument: { uri },
329329
reason: TextDocumentSaveReason.Manual,
330330
});
331331
}
@@ -342,7 +342,7 @@ export class TextEditorSyncAdapter {
342342
const applyEditsOrTimeout = Utils.promiseWithTimeout(
343343
2500, // 2.5 seconds timeout
344344
this._connection.willSaveWaitUntilTextDocument({
345-
textDocument: {uri},
345+
textDocument: { uri },
346346
reason: TextDocumentSaveReason.Manual,
347347
}),
348348
).then((edits) => {
@@ -374,15 +374,15 @@ export class TextEditorSyncAdapter {
374374

375375
const uri = this.getEditorUri();
376376
const didSaveNotification = {
377-
textDocument: {uri, version: this._getVersion((uri))},
377+
textDocument: { uri, version: this._getVersion((uri)) },
378378
} as DidSaveTextDocumentParams;
379379
if (this._documentSync.save && this._documentSync.save.includeText) {
380380
didSaveNotification.text = this._editor.getText();
381381
}
382382
this._connection.didSaveTextDocument(didSaveNotification);
383383
if (this._fakeDidChangeWatchedFiles) {
384384
this._connection.didChangeWatchedFiles({
385-
changes: [{uri, type: FileChangeType.Changed}],
385+
changes: [{ uri, type: FileChangeType.Changed }],
386386
});
387387
}
388388
}
@@ -397,12 +397,15 @@ export class TextEditorSyncAdapter {
397397
}
398398

399399
if (this._documentSync.openClose !== false) {
400-
this._connection.didCloseTextDocument({textDocument: {uri: oldUri}});
400+
this._connection.didCloseTextDocument({ textDocument: { uri: oldUri } });
401401
}
402402

403403
if (this._fakeDidChangeWatchedFiles) {
404404
this._connection.didChangeWatchedFiles({
405-
changes: [{uri: oldUri, type: FileChangeType.Deleted}, {uri: this._currentUri, type: FileChangeType.Created}],
405+
changes: [
406+
{ uri: oldUri, type: FileChangeType.Deleted },
407+
{ uri: this._currentUri, type: FileChangeType.Created },
408+
],
406409
});
407410
}
408411

lib/adapters/find-references-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default class FindReferencesAdapter {
6767
return {
6868
textDocument: Convert.editorToTextDocumentIdentifier(editor),
6969
position: Convert.pointToPosition(point),
70-
context: {includeDeclaration: true},
70+
context: { includeDeclaration: true },
7171
};
7272
}
7373

lib/adapters/outline-view-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default class OutlineViewAdapter {
4141
// Returns a {Promise} containing the {Outline} of this document.
4242
public async getOutline(connection: LanguageClientConnection, editor: TextEditor): Promise<atomIde.Outline | null> {
4343
const results = await Utils.doWithCancellationToken(connection, this._cancellationTokens, (cancellationToken) =>
44-
connection.documentSymbol({textDocument: Convert.editorToTextDocumentIdentifier(editor)}, cancellationToken),
44+
connection.documentSymbol({ textDocument: Convert.editorToTextDocumentIdentifier(editor) }, cancellationToken),
4545
);
4646

4747
if (results.length === 0) {

lib/adapters/signature-help-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class SignatureHelpAdapter {
3636
}
3737

3838
public attach(register: atomIde.SignatureHelpRegistry): void {
39-
const {signatureHelpProvider} = this._capabilities;
39+
const { signatureHelpProvider } = this._capabilities;
4040
assert(signatureHelpProvider != null);
4141

4242
let triggerCharacters: Set<string> | undefined;

lib/auto-languageclient.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ export default class AutoLanguageClient {
207207
}
208208

209209
// Early wire-up of listeners before initialize method is sent
210-
protected preInitialization(connection: LanguageClientConnection): void {}
210+
protected preInitialization(connection: LanguageClientConnection): void { }
211211

212212
// Late wire-up of listeners after initialize method has been sent
213-
protected postInitialization(server: ActiveServer): void {}
213+
protected postInitialization(server: ActiveServer): void { }
214214

215215
// Determine whether to use ipc, stdio or socket to connect to the server
216216
protected getConnectionType(): ConnectionType {
@@ -396,9 +396,9 @@ export default class AutoLanguageClient {
396396
}
397397

398398
return rpc.createMessageConnection(reader, writer, {
399-
log: (...args: any[]) => {},
400-
warn: (...args: any[]) => {},
401-
info: (...args: any[]) => {},
399+
log: (...args: any[]) => { },
400+
warn: (...args: any[]) => { },
401+
info: (...args: any[]) => { },
402402
error: (...args: any[]) => {
403403
this.logger.error(args);
404404
},
@@ -504,7 +504,7 @@ export default class AutoLanguageClient {
504504
): void {
505505
}
506506

507-
protected onDidInsertSuggestion(arg: ac.SuggestionInsertedEvent): void {}
507+
protected onDidInsertSuggestion(arg: ac.SuggestionInsertedEvent): void { }
508508

509509
// Definitions via LS documentHighlight and gotoDefinition------------
510510
public provideDefinitions(): atomIde.DefinitionProvider {
@@ -553,8 +553,8 @@ export default class AutoLanguageClient {
553553
}
554554

555555
// Linter push v2 API via LS publishDiagnostics
556-
public consumeLinterV2(registerIndie: (params: {name: string}) => linter.IndieDelegate): void {
557-
this._linterDelegate = registerIndie({name: this.name});
556+
public consumeLinterV2(registerIndie: (params: { name: string }) => linter.IndieDelegate): void {
557+
this._linterDelegate = registerIndie({ name: this.name });
558558
if (this._linterDelegate == null) {
559559
return;
560560
}

lib/convert.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default class Convert {
5959
//
6060
// Returns the {Position} representation of the Atom {PointObject}.
6161
public static pointToPosition(point: Point): ls.Position {
62-
return {line: point.row, character: point.column};
62+
return { line: point.row, character: point.column };
6363
}
6464

6565
// Public: Convert a language server {Position} into an Atom {PointObject}.
@@ -99,7 +99,7 @@ export default class Convert {
9999
// Returns a {TextDocumentIdentifier} that has a `uri` property with the Uri for the
100100
// given editor's path.
101101
public static editorToTextDocumentIdentifier(editor: TextEditor): ls.TextDocumentIdentifier {
102-
return {uri: Convert.pathToUri(editor.getPath() || '')};
102+
return { uri: Convert.pathToUri(editor.getPath() || '') };
103103
}
104104

105105
// Public: Create a {TextDocumentPositionParams} from a {TextEditor} and optional {Point}.
@@ -162,18 +162,18 @@ export default class Convert {
162162
public static atomFileEventToLSFileEvents(fileEvent: FilesystemChange): ls.FileEvent[] {
163163
switch (fileEvent.action) {
164164
case 'created':
165-
return [{uri: Convert.pathToUri(fileEvent.path), type: ls.FileChangeType.Created}];
165+
return [{ uri: Convert.pathToUri(fileEvent.path), type: ls.FileChangeType.Created }];
166166
case 'modified':
167-
return [{uri: Convert.pathToUri(fileEvent.path), type: ls.FileChangeType.Changed}];
167+
return [{ uri: Convert.pathToUri(fileEvent.path), type: ls.FileChangeType.Changed }];
168168
case 'deleted':
169-
return [{uri: Convert.pathToUri(fileEvent.path), type: ls.FileChangeType.Deleted}];
169+
return [{ uri: Convert.pathToUri(fileEvent.path), type: ls.FileChangeType.Deleted }];
170170
case 'renamed': {
171171
const results: Array<{ uri: string, type: ls.FileChangeType }> = [];
172172
if (fileEvent.oldPath) {
173-
results.push({uri: Convert.pathToUri(fileEvent.oldPath), type: ls.FileChangeType.Deleted});
173+
results.push({ uri: Convert.pathToUri(fileEvent.oldPath), type: ls.FileChangeType.Deleted });
174174
}
175175
if (fileEvent.path) {
176-
results.push({uri: Convert.pathToUri(fileEvent.path), type: ls.FileChangeType.Created});
176+
results.push({ uri: Convert.pathToUri(fileEvent.path), type: ls.FileChangeType.Created });
177177
}
178178
return results;
179179
}

0 commit comments

Comments
 (0)