typeprof 0.20.2 → 0.20.3

Sign up to get free protection for your applications and to get access to all the features.
data/vscode/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "ruby-typeprof",
3
3
  "displayName": "Ruby TypeProf",
4
- "version": "0.20.0",
4
+ "version": "0.20.1",
5
5
  "publisher": "mame",
6
6
  "author": {
7
7
  "name": "Yusuke Endoh"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/mame/vscode-typeprof"
11
+ "url": "https://github.com/ruby/typeprof/tree/master/vscode"
12
12
  },
13
13
  "license": "MIT",
14
14
  "categories": [
@@ -62,7 +62,7 @@
62
62
  "devDependencies": {
63
63
  "@types/node": "^14.14.37",
64
64
  "typescript": "^4.2.3",
65
- "vsce": "^1.96.1",
65
+ "vsce": "^1.103.1",
66
66
  "vscode": "^1.1.37"
67
67
  },
68
68
  "dependencies": {
@@ -95,20 +95,30 @@ function executeTypeProf(folder: vscode.WorkspaceFolder, arg: String): child_pro
95
95
  return typeprof;
96
96
  }
97
97
 
98
- function getTypeProfVersion(folder: vscode.WorkspaceFolder, callback: (version: string) => void): child_process.ChildProcessWithoutNullStreams {
98
+ function getTypeProfVersion(folder: vscode.WorkspaceFolder, outputChannel: vscode.OutputChannel, callback: (version: string) => void): child_process.ChildProcessWithoutNullStreams {
99
99
  const typeprof = executeTypeProf(folder, "--version");
100
100
  let output = "";
101
101
 
102
+ const log = (msg: string) => {
103
+ outputChannel.appendLine("[vscode] " + msg);
104
+ console.info(msg);
105
+ };
106
+
102
107
  typeprof.stdout?.on("data", out => { output += out; });
103
- typeprof.stderr?.on("data", out => { console.log(out); });
108
+ typeprof.stderr?.on("data", (out: Buffer) => {
109
+ const str = ("" + out).trim();
110
+ for (const line of str.split("\n")) {
111
+ log("stderr: " + line);
112
+ }
113
+ });
104
114
  typeprof.on("error", e => {
105
- console.info(`typeprof is not supported for this folder: ${folder}`);
106
- console.info(`because: ${e}`);
115
+ log(`typeprof is not supported for this folder: ${folder}`);
116
+ log(`because: ${e}`);
107
117
  });
108
118
  typeprof.on("exit", (code) => {
109
119
  if (code == 0) {
110
- console.info(`typeprof version: ${output}`)
111
120
  const str = output.trim();
121
+ log(`typeprof version: ${str}`)
112
122
  const version = /^typeprof (\d+).(\d+).(\d+)$/.exec(str);
113
123
  if (version) {
114
124
  const major = Number(version[1]);
@@ -118,15 +128,15 @@ function getTypeProfVersion(folder: vscode.WorkspaceFolder, callback: (version:
118
128
  callback(str);
119
129
  }
120
130
  else {
121
- console.info(`typeprof version ${str} is too old; please use 0.20.0 or later for IDE feature`);
131
+ log(`typeprof version ${str} is too old; please use 0.20.0 or later for IDE feature`);
122
132
  }
123
133
  }
124
134
  else {
125
- console.info(`typeprof --version showed unknown message`);
135
+ log(`typeprof --version showed unknown message`);
126
136
  }
127
137
  }
128
138
  else {
129
- console.info(`failed to invoke typeprof: error code ${code}`);
139
+ log(`failed to invoke typeprof: error code ${code}`);
130
140
  }
131
141
  typeprof.kill()
132
142
  });
@@ -164,7 +174,7 @@ function getTypeProfStream(folder: vscode.WorkspaceFolder, error: (msg: string)
164
174
  });
165
175
  }
166
176
 
167
- function invokeTypeProf(folder: vscode.WorkspaceFolder): LanguageClient {
177
+ function invokeTypeProf(folder: vscode.WorkspaceFolder, outputChannel: vscode.OutputChannel): LanguageClient {
168
178
  let client: LanguageClient;
169
179
 
170
180
  const reportError = (msg: string) => client.info(msg);
@@ -185,6 +195,7 @@ function invokeTypeProf(folder: vscode.WorkspaceFolder): LanguageClient {
185
195
  { scheme: "file", language: "ruby" },
186
196
  { scheme: "file", language: "rbs" },
187
197
  ],
198
+ outputChannel,
188
199
  synchronize: {
189
200
  fileEvents:
190
201
  vscode.workspace.createFileSystemWatcher("{**/*.rb,**/*.rbs}"),
@@ -199,17 +210,21 @@ function invokeTypeProf(folder: vscode.WorkspaceFolder): LanguageClient {
199
210
  const clientSessions: Map<vscode.WorkspaceFolder, State> = new Map();
200
211
 
201
212
  function startTypeProf(folder: vscode.WorkspaceFolder) {
202
- const showStatus = (msg: string) => vscode.window.setStatusBarMessage(msg, 3000);
203
- console.log(`start: ${folder}`);
213
+ const outputChannel = vscode.window.createOutputChannel("Ruby TypeProf");
214
+ const showStatus = (msg: string) => {
215
+ outputChannel.appendLine("[vscode] " + msg);
216
+ vscode.window.setStatusBarMessage(msg, 3000);
217
+ }
218
+ outputChannel.appendLine("[vscode] Try to start TypeProf for IDE");
204
219
 
205
- const typeprof = getTypeProfVersion(folder, (version) => {
220
+ const typeprof = getTypeProfVersion(folder, outputChannel, (version) => {
206
221
  if (!version) {
207
222
  showStatus(`Ruby TypeProf is not configured; Try to add "gem 'typeprof'" to Gemfile`);
208
223
  clientSessions.delete(folder);
209
224
  return;
210
225
  }
211
226
  showStatus(`Starting Ruby TypeProf (${version})...`);
212
- const client = invokeTypeProf(folder);
227
+ const client = invokeTypeProf(folder, outputChannel);
213
228
  client.onReady()
214
229
  .then(() => {
215
230
  showStatus("Ruby TypeProf is running");
@@ -225,7 +240,6 @@ function startTypeProf(folder: vscode.WorkspaceFolder) {
225
240
  }
226
241
 
227
242
  function stopTypeProf(state: State) {
228
- console.log(`stop: ${state.workspaceFolder}`);
229
243
  switch (state.kind) {
230
244
  case "invoking":
231
245
  state.process.kill();
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typeprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.2
4
+ version: 0.20.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Endoh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs