Skip to content

Commit 4c9ac43

Browse files
committed
chore: format
1 parent 388219b commit 4c9ac43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3028
-3046
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- uses: UziTech/action-setup-atom@v1
6767
- uses: actions/[email protected]
6868
with:
69-
node-version: '*'
69+
node-version: "*"
7070
- name: NPM install
7171
run: npm install
7272
# - name: Build and Commit

.github/workflows/bump_deps.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Bump_Dependencies
22

33
on:
44
schedule:
5-
- cron: '5 8 * * Sun' # 8:05 every Sunday
5+
- cron: "5 8 * * Sun" # 8:05 every Sunday
66

77
jobs:
88
Bump_Dependencies:
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v2
1212
- uses: actions/setup-node@v2
1313
with:
14-
node-version: '12'
14+
node-version: "12"
1515
- name: Setup PNPM
1616
uses: pnpm/[email protected]
1717
with:
@@ -32,18 +32,18 @@ jobs:
3232
- uses: peter-evans/create-pull-request@v3
3333
with:
3434
token: ${{ steps.generate-token.outputs.token }}
35-
commit-message: 'chore: Update Dependencies'
36-
title: 'fix: Update Dependencies'
35+
commit-message: "chore: Update Dependencies"
36+
title: "fix: Update Dependencies"
3737
labels: Dependencies
38-
branch: 'Bump_Dependencies'
38+
branch: "Bump_Dependencies"
3939

4040
Bump_devDependencies:
4141
runs-on: ubuntu-latest
4242
steps:
4343
- uses: actions/checkout@v2
4444
- uses: actions/setup-node@v2
4545
with:
46-
node-version: '12'
46+
node-version: "12"
4747
- name: Setup PNPM
4848
uses: pnpm/[email protected]
4949
with:
@@ -64,7 +64,7 @@ jobs:
6464
- uses: peter-evans/create-pull-request@v3
6565
with:
6666
token: ${{ steps.generate-token.outputs.token }}
67-
commit-message: 'chore: Update devDependencies'
68-
title: 'chore: Update devDependencies'
67+
commit-message: "chore: Update devDependencies"
68+
title: "chore: Update devDependencies"
6969
labels: Dependencies
70-
branch: 'Bump_devDependencies'
70+
branch: "Bump_devDependencies"

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# You may wish to alter this file to override the set of languages analyzed,
55
# or to provide custom queries or build logic.
6-
name: 'CodeQL'
6+
name: "CodeQL"
77

88
on:
99
push:
@@ -12,7 +12,7 @@ on:
1212
# The branches below must be a subset of the branches above
1313
branches: [master]
1414
schedule:
15-
- cron: '0 9 * * 3'
15+
- cron: "0 9 * * 3"
1616

1717
jobs:
1818
analyze:
@@ -24,7 +24,7 @@ jobs:
2424
matrix:
2525
# Override automatic language detection by changing the below list
2626
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
27-
language: ['javascript']
27+
language: ["javascript"]
2828
# Learn more...
2929
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
3030

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,25 @@ The underlying JSON-RPC communication is handled by the [vscode-jsonrpc npm modu
6464
A minimal implementation can be illustrated by the Omnisharp package here which has only npm-managed dependencies, and the LSP is a JavaScript file. You simply provide the scope name, language name and server name as well as start your process and `AutoLanguageClient` takes care of interrogating your language server capabilities and wiring up the appropriate services within Atom to expose them.
6565

6666
```javascript
67-
const { AutoLanguageClient } = require('atom-languageclient');
67+
const { AutoLanguageClient } = require("atom-languageclient")
6868

6969
class CSharpLanguageClient extends AutoLanguageClient {
7070
getGrammarScopes() {
71-
return ['source.cs'];
71+
return ["source.cs"]
7272
}
7373
getLanguageName() {
74-
return 'C#';
74+
return "C#"
7575
}
7676
getServerName() {
77-
return 'OmniSharp';
77+
return "OmniSharp"
7878
}
7979

8080
startServerProcess() {
81-
return super.spawnChildNode([require.resolve('omnisharp-client/languageserver/server')]);
81+
return super.spawnChildNode([require.resolve("omnisharp-client/languageserver/server")])
8282
}
8383
}
8484

85-
module.exports = new CSharpLanguageClient();
85+
module.exports = new CSharpLanguageClient()
8686
```
8787

8888
You can get this code packaged up with the necessary package.json etc. from the [ide-csharp](https://github.com/atom/ide-csharp) provides C# support via [Omnisharp (node-omnisharp)](https://github.com/OmniSharp/omnisharp-node-client) repo.
@@ -94,30 +94,30 @@ Note that you will also need to add various entries to the `providedServices` an
9494
If the LSP is a general executable (not a JavaScript file), you should use `spawn` inside `startServerProcess`.
9595

9696
```javascript
97-
const { AutoLanguageClient } = require('atom-languageclient');
97+
const { AutoLanguageClient } = require("atom-languageclient")
9898

9999
class DLanguageClient extends AutoLanguageClient {
100100
getGrammarScopes() {
101-
return ['source.d'];
101+
return ["source.d"]
102102
}
103103
getLanguageName() {
104-
return 'D';
104+
return "D"
105105
}
106106
getServerName() {
107-
return 'serve-d';
107+
return "serve-d"
108108
}
109109

110110
startServerProcess(projectPath) {
111111
return super.spawn(
112-
'serve-d', // the `name` or `path` of the executable
112+
"serve-d", // the `name` or `path` of the executable
113113
// if the `name` is provided it checks `bin/platform-arch/exeName` by default, and if doesn't exists uses the `exeName` on the PATH
114114
[], // args passed to spawn the exe
115115
{ cwd: projectPath } // child process spawn options
116-
);
116+
)
117117
}
118118
}
119119

120-
module.exports = new DLanguageClient();
120+
module.exports = new DLanguageClient()
121121
```
122122

123123
### Using other connection types
@@ -131,24 +131,24 @@ To use ipc simply return _ipc_ from getConnectionType(), e.g.
131131
```javascript
132132
class ExampleLanguageClient extends AutoLanguageClient {
133133
getGrammarScopes() {
134-
return ['source.js', 'javascript'];
134+
return ["source.js", "javascript"]
135135
}
136136
getLanguageName() {
137-
return 'JavaScript';
137+
return "JavaScript"
138138
}
139139
getServerName() {
140-
return 'JavaScript Language Server';
140+
return "JavaScript Language Server"
141141
}
142142

143143
getConnectionType() {
144-
return 'ipc';
144+
return "ipc"
145145
}
146146

147147
startServerProcess() {
148-
const startServer = require.resolve('@example/js-language-server');
149-
return super.spawnChildNode([startServer, '--node-ipc'], {
150-
stdio: [null, null, null, 'ipc'],
151-
});
148+
const startServer = require.resolve("@example/js-language-server")
149+
return super.spawnChildNode([startServer, "--node-ipc"], {
150+
stdio: [null, null, null, "ipc"],
151+
})
152152
}
153153
}
154154
```

lib/adapters/apply-edit-adapter.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,97 @@
1-
import type * as atomIde from 'atom-ide-base';
2-
import Convert from '../convert';
3-
import { LanguageClientConnection, ApplyWorkspaceEditParams, ApplyWorkspaceEditResponse } from '../languageclient';
4-
import { TextBuffer, TextEditor } from 'atom';
1+
import type * as atomIde from "atom-ide-base"
2+
import Convert from "../convert"
3+
import { LanguageClientConnection, ApplyWorkspaceEditParams, ApplyWorkspaceEditResponse } from "../languageclient"
4+
import { TextBuffer, TextEditor } from "atom"
55

66
/** Public: Adapts workspace/applyEdit commands to editors. */
77
export default class ApplyEditAdapter {
88
/** Public: Attach to a {LanguageClientConnection} to receive edit events. */
99
public static attach(connection: LanguageClientConnection): void {
10-
connection.onApplyEdit((m) => ApplyEditAdapter.onApplyEdit(m));
10+
connection.onApplyEdit((m) => ApplyEditAdapter.onApplyEdit(m))
1111
}
1212

1313
/**
1414
* Tries to apply edits and reverts if anything goes wrong.
1515
* Returns the checkpoint, so the caller can revert changes if needed.
1616
*/
1717
public static applyEdits(buffer: TextBuffer, edits: atomIde.TextEdit[]): number {
18-
const checkpoint = buffer.createCheckpoint();
18+
const checkpoint = buffer.createCheckpoint()
1919
try {
2020
// Sort edits in reverse order to prevent edit conflicts.
21-
edits.sort((edit1, edit2) => -edit1.oldRange.compare(edit2.oldRange));
21+
edits.sort((edit1, edit2) => -edit1.oldRange.compare(edit2.oldRange))
2222
edits.reduce((previous: atomIde.TextEdit | null, current) => {
23-
ApplyEditAdapter.validateEdit(buffer, current, previous);
24-
buffer.setTextInRange(current.oldRange, current.newText);
25-
return current;
26-
}, null);
27-
buffer.groupChangesSinceCheckpoint(checkpoint);
28-
return checkpoint;
23+
ApplyEditAdapter.validateEdit(buffer, current, previous)
24+
buffer.setTextInRange(current.oldRange, current.newText)
25+
return current
26+
}, null)
27+
buffer.groupChangesSinceCheckpoint(checkpoint)
28+
return checkpoint
2929
} catch (err) {
30-
buffer.revertToCheckpoint(checkpoint);
31-
throw err;
30+
buffer.revertToCheckpoint(checkpoint)
31+
throw err
3232
}
3333
}
3434

3535
public static async onApplyEdit(params: ApplyWorkspaceEditParams): Promise<ApplyWorkspaceEditResponse> {
36-
let changes = params.edit.changes || {};
36+
let changes = params.edit.changes || {}
3737

3838
if (params.edit.documentChanges) {
39-
changes = {};
39+
changes = {}
4040
params.edit.documentChanges.forEach((change) => {
41-
if (change && 'textDocument' in change && change.textDocument) {
42-
changes[change.textDocument.uri] = change.edits;
41+
if (change && "textDocument" in change && change.textDocument) {
42+
changes[change.textDocument.uri] = change.edits
4343
}
44-
});
44+
})
4545
}
4646

47-
const uris = Object.keys(changes);
47+
const uris = Object.keys(changes)
4848

4949
// Keep checkpoints from all successful buffer edits
50-
const checkpoints: Array<{ buffer: TextBuffer; checkpoint: number }> = [];
50+
const checkpoints: Array<{ buffer: TextBuffer; checkpoint: number }> = []
5151

5252
const promises = uris.map(async (uri) => {
53-
const path = Convert.uriToPath(uri);
53+
const path = Convert.uriToPath(uri)
5454
const editor = (await atom.workspace.open(path, {
5555
searchAllPanes: true,
5656
// Open new editors in the background.
5757
activatePane: false,
5858
activateItem: false,
59-
})) as TextEditor;
60-
const buffer = editor.getBuffer();
59+
})) as TextEditor
60+
const buffer = editor.getBuffer()
6161
// Get an existing editor for the file, or open a new one if it doesn't exist.
62-
const edits = Convert.convertLsTextEdits(changes[uri]);
63-
const checkpoint = ApplyEditAdapter.applyEdits(buffer, edits);
64-
checkpoints.push({ buffer, checkpoint });
65-
});
62+
const edits = Convert.convertLsTextEdits(changes[uri])
63+
const checkpoint = ApplyEditAdapter.applyEdits(buffer, edits)
64+
checkpoints.push({ buffer, checkpoint })
65+
})
6666

6767
// Apply all edits or fail and revert everything
6868
const applied = await Promise.all(promises)
6969
.then(() => true)
7070
.catch((err) => {
71-
atom.notifications.addError('workspace/applyEdits failed', {
72-
description: 'Failed to apply edits.',
71+
atom.notifications.addError("workspace/applyEdits failed", {
72+
description: "Failed to apply edits.",
7373
detail: err.message,
74-
});
74+
})
7575
checkpoints.forEach(({ buffer, checkpoint }) => {
76-
buffer.revertToCheckpoint(checkpoint);
77-
});
78-
return false;
79-
});
76+
buffer.revertToCheckpoint(checkpoint)
77+
})
78+
return false
79+
})
8080

81-
return { applied };
81+
return { applied }
8282
}
8383

8484
/** Private: Do some basic sanity checking on the edit ranges. */
8585
private static validateEdit(buffer: TextBuffer, edit: atomIde.TextEdit, prevEdit: atomIde.TextEdit | null): void {
86-
const path = buffer.getPath() || '';
86+
const path = buffer.getPath() || ""
8787
if (prevEdit && edit.oldRange.end.compare(prevEdit.oldRange.start) > 0) {
88-
throw Error(`Found overlapping edit ranges in ${path}`);
88+
throw Error(`Found overlapping edit ranges in ${path}`)
8989
}
90-
const startRow = edit.oldRange.start.row;
91-
const startCol = edit.oldRange.start.column;
92-
const lineLength = buffer.lineLengthForRow(startRow);
90+
const startRow = edit.oldRange.start.row
91+
const startCol = edit.oldRange.start.column
92+
const lineLength = buffer.lineLengthForRow(startRow)
9393
if (lineLength == null || startCol > lineLength) {
94-
throw Error(`Out of range edit on ${path}:${startRow + 1}:${startCol + 1}`);
94+
throw Error(`Out of range edit on ${path}:${startRow + 1}:${startCol + 1}`)
9595
}
9696
}
9797
}

0 commit comments

Comments
 (0)