Skip to content
This repository was archived by the owner on Jul 3, 2024. It is now read-only.

Commit 7eb1837

Browse files
merge: PR #219 from bug/218-windows-platform-support-staging
218 - Windows platform support
2 parents 296afcc + d57292e commit 7eb1837

File tree

11 files changed

+644
-742
lines changed

11 files changed

+644
-742
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
6464
restore-keys: |
6565
${{ runner.os }}-yarn-
66-
- run: yarn install --frozen-lockfile
66+
- run: yarn install --immutable
6767
if: steps.yarn-cache.outputs.cache-hit != 'true'
6868

6969
- run: yarn workspace ${{ matrix.workspace.name }} run lint
@@ -99,7 +99,7 @@ jobs:
9999
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
100100
restore-keys: |
101101
${{ runner.os }}-yarn-
102-
- run: yarn install --frozen-lockfile
102+
- run: yarn install --immutable
103103
if: steps.yarn-cache.outputs.cache-hit != 'true'
104104

105105
- run: yarn workspace ${{ matrix.workspace.name }} run format

.github/workflows/execute-yarn-workspace-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
${{ runner.os }}-yarn-
105105
106106
- name: Install dependencies
107-
run: yarn install --frozen-lockfile
107+
run: yarn install --immutable
108108
if: steps.yarn-cache.outputs.cache-hit != 'true'
109109

110110
- name: Run command (with target)

.github/workflows/publish-extension-manual.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
101101
- name: Install
102102
run: |
103-
yarn install --frozen-lockfile
103+
yarn install --immutable
104104
105105
- name: Get tag prefix
106106
id: get-tag-prefix

.github/workflows/publish-targeted-extension.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ jobs:
115115
${{ runner.os }}-yarn-
116116
117117
- name: Install dependencies
118-
run: yarn install --frozen-lockfile
118+
run: yarn install --immutable
119119
if: steps.yarn-cache.outputs.cache-hit != 'true'
120120

121121
- name: Build

.pnp.cjs

Lines changed: 292 additions & 367 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.pnp.loader.mjs

Lines changed: 63 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

toolchains/solidity/core/scripts/copy-core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fs.readdir('target', { withFileTypes: true }, (err, dirs) => {
1818
return;
1919
}
2020
const files = entries.filter(file => file.isFile()).map(file => file.name);
21-
const serverBinaries = files.filter(file => file.endsWith('-server'));
21+
const serverBinaries = files.filter(file => file.endsWith('-server') || file.endsWith('-server.exe'));
2222
serverBinaries.forEach(binary => {
2323
fs.copyFile(`target/${dir}/${binary}`, `${outputFolder}/${binary}`, (err) => {
2424
if (err) {

toolchains/solidity/extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "osmium-solidity-extension",
33
"displayName": "Osmium Solidity",
44
"description": "",
5-
"version": "0.2.1",
5+
"version": "0.1.3",
66
"publisher": "OsmiumToolchains",
77
"repository": {
88
"type": "git",

toolchains/solidity/extension/src/extension.ts

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* ------------------------------------------------------------------------------------------ */
55

66
import * as path from 'path';
7-
import { workspace, ExtensionContext, Uri } from 'vscode';
7+
import { workspace, ExtensionContext } from 'vscode';
88
import { TextDecoder } from 'util';
99

1010
import {
@@ -13,53 +13,18 @@ import {
1313
ServerOptions,
1414
TransportKind
1515
} from 'vscode-languageclient/node';
16+
import { createLinterClient } from './linter';
1617

17-
let client: LanguageClient;
1818

19-
export async function activate(context: ExtensionContext) {
20-
// The server is implemented in node
21-
const serverBinary = context.asAbsolutePath(
22-
path.join('dist', 'linter-server')
23-
);
24-
25-
// If the extension is launched in debug mode then the debug server options are used
26-
// Otherwise the run options are used
27-
const serverOptions: ServerOptions = {
28-
run: { command: serverBinary, transport: TransportKind.stdio },
29-
debug: {
30-
command: serverBinary,
31-
transport: TransportKind.stdio,
32-
}
33-
};
34-
35-
// Options to control the language client
36-
const clientOptions: LanguageClientOptions = {
37-
// Register the server for plain text documents
38-
documentSelector: [{ scheme: 'file', language: 'solidity' }],
39-
synchronize: {
40-
// Notify the server about file changes to '.clientrc files contained in the workspace
41-
fileEvents: workspace.createFileSystemWatcher('**/.solidhunter.json')
42-
}
43-
};
44-
45-
// Create the language client and start the client.
46-
client = new LanguageClient(
47-
'osmium-solidity',
48-
'Osmium Solidity Language Server',
49-
serverOptions,
50-
clientOptions
51-
);
19+
let linterClient: LanguageClient;
5220

53-
client.onRequest('osmium/getContent', async (params) => {
54-
const contentUint8 = await workspace.fs.readFile(Uri.parse(params.uri));
55-
const content = new TextDecoder().decode(contentUint8);
56-
return {
57-
content,
58-
};
59-
});
21+
export async function activate(context: ExtensionContext) {
22+
linterClient = createLinterClient(context);
6023

61-
// Start the client. This will also launch the server
62-
client.start();
24+
// Push the disposable to the context's subscriptions so that the
25+
// client can be deactivated on extension deactivation
26+
context.subscriptions.push(linterClient);
27+
6328

6429
const folders = workspace.workspaceFolders;
6530
if (folders) {
@@ -70,10 +35,3 @@ export async function activate(context: ExtensionContext) {
7035
}
7136

7237
}
73-
74-
export function deactivate(): Thenable<void> | undefined {
75-
if (!client) {
76-
return undefined;
77-
}
78-
return client.stop();
79-
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import * as path from 'path';
2+
import * as os from 'os';
3+
import { workspace, ExtensionContext, Uri } from "vscode";
4+
import {
5+
LanguageClient,
6+
LanguageClientOptions,
7+
ServerOptions,
8+
TransportKind
9+
} from 'vscode-languageclient/node';
10+
import { TextDecoder } from 'util';
11+
12+
export function createLinterClient(context: ExtensionContext): LanguageClient {
13+
// The server is implemented in node
14+
const serverBinary = context.asAbsolutePath(
15+
path.join(
16+
'dist',
17+
os.platform().startsWith("win") ? 'linter-server.exe' : 'linter-server'
18+
)
19+
);
20+
21+
// If the extension is launched in debug mode then the debug server options are used
22+
// Otherwise the run options are used
23+
const serverOptions: ServerOptions = {
24+
run: { command: serverBinary, transport: TransportKind.stdio },
25+
debug: {
26+
command: serverBinary,
27+
transport: TransportKind.stdio,
28+
}
29+
};
30+
31+
// Options to control the language client
32+
const clientOptions: LanguageClientOptions = {
33+
// Register the server for plain text documents
34+
documentSelector: [{ scheme: 'file', language: 'solidity' }],
35+
synchronize: {
36+
// Notify the server about file changes to '.clientrc files contained in the workspace
37+
fileEvents: workspace.createFileSystemWatcher('**/.solidhunter.json')
38+
}
39+
};
40+
41+
// Create the language client and start the client.
42+
const client = new LanguageClient(
43+
'osmium-solidity-linter',
44+
'Osmium Solidity Linter Language Server',
45+
serverOptions,
46+
clientOptions
47+
);
48+
49+
client.onRequest('osmium/getContent', async (params: { uri: string}) => {
50+
const contentUint8 = await workspace.fs.readFile(Uri.parse(params.uri));
51+
const content = new TextDecoder().decode(contentUint8);
52+
return {
53+
content,
54+
};
55+
});
56+
57+
// Start the client. This will also launch the server
58+
client.start();
59+
60+
return client;
61+
}

0 commit comments

Comments
 (0)