Skip to content

Commit b208b27

Browse files
committed
fix misused promises
prepare 0.0.8
1 parent fc23501 commit b208b27

File tree

6 files changed

+62
-72
lines changed

6 files changed

+62
-72
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change Log
22

3+
## 0.0.8
4+
- fix misused promises
5+
36
## 0.0.7
47
- updated grammar
58
- fixed mythX issue due to API change

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ Note: Active features can be disabled by setting `Settings` → `Vyper` → `Mod
9090

9191
see [CHANGELOG](./CHANGELOG.md)
9292

93+
## 0.0.8
94+
- fix misused promises
95+
9396
## 0.0.7
9497
- updated grammar
9598
- fixed mythX issue due to API change

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-vyper",
33
"displayName": "Vyper",
44
"description": "Ethereum Vyper language support for Visual Studio Code",
5-
"version": "0.0.7",
5+
"version": "0.0.8",
66
"keywords": [
77
"vyper",
88
"ethereum",

Diff for: src/extension.js

+9-24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict'
12
/**
23
* @author github.com/tintinweb
34
* @license MIT
@@ -28,30 +29,22 @@ var activeEditor;
2829

2930
/** event funcs */
3031
async function onDidSave(document){
31-
return new Promise((reject,resolve) =>{
32-
33-
if(document.languageId!=VYPER_ID){
34-
console.log("langid mismatch")
35-
reject("langid_mismatch")
36-
return;
37-
}
32+
if(document.languageId!=VYPER_ID){
33+
console.log("langid mismatch")
34+
return;
35+
}
3836

39-
//always run on save
40-
41-
if(vyperConfig.compile.onSave){
42-
resolve(mod_compile.compileContractCommand(document.uri))
43-
}
44-
})
37+
//always run on save
38+
if(vyperConfig.compile.onSave){
39+
mod_compile.compileContractCommand(document.uri)
40+
}
4541
}
4642

4743
async function onDidChange(event) {
48-
return new Promise((reject,resolve) => {
4944
if(vscode.window.activeTextEditor.document.languageId!=VYPER_ID){
50-
reject("langid_mismatch")
5145
return;
5246
}
5347

54-
console.log("onDidChange ...")
5548
if(vyperConfig.decoration.enable){
5649
mod_deco.decorateWords(activeEditor, [
5750
{
@@ -99,11 +92,6 @@ async function onDidChange(event) {
9992
},
10093
], mod_deco.styles.boldUnderline);
10194
}
102-
103-
104-
console.log("✓ onDidChange")
105-
resolve()
106-
});
10795
}
10896
function onInitModules(context, type) {
10997
mod_hover.init(context, type, vyperConfig)
@@ -117,8 +105,6 @@ function onActivate(context) {
117105
if (!active || !active.document) return;
118106
activeEditor = active;
119107

120-
console.log(" activate extension: vyper ...")
121-
122108
registerDocType(VYPER_ID);
123109

124110
function registerDocType(type) {
@@ -186,7 +172,6 @@ function onActivate(context) {
186172

187173

188174
}
189-
console.log("✓ activate extension: vyper")
190175
}
191176

192177
/* exports */

Diff for: src/features/compile.js

+44-46
Original file line numberDiff line numberDiff line change
@@ -167,51 +167,6 @@ compileVyper.necessary = function(options, callback) {
167167
function compileActiveFileCommand(contractFile) {
168168
compileActiveFile(contractFile)
169169
.then(
170-
(errormsg) => {
171-
diagnosticCollections.compiler.delete(contractFile);
172-
diagnosticCollections.mythx.delete(contractFile);
173-
vscode.window.showErrorMessage('[Compiler Error] ' + errormsg);
174-
let lineNr = 1; // add default errors to line 0 if not known
175-
let matches = /(?:line\s+(\d+))/gm.exec(errormsg)
176-
if (matches && matches.length==2){
177-
//only one line ref
178-
lineNr = parseInt(matches[1])
179-
}
180-
181-
let lines = errormsg.split(/\r?\n/)
182-
console.log(errormsg)
183-
let shortmsg = lines[0]
184-
185-
// IndexError
186-
if (lines.indexOf("SyntaxError: invalid syntax") > -1) {
187-
let matches = /line (\d+)/gm.exec(errormsg)
188-
if (matches.length >= 2) {
189-
lineNr = parseInt(matches[1])
190-
}
191-
shortmsg = "SyntaxError: invalid syntax";
192-
} else {
193-
//match generic vyper exceptions
194-
let matches = /vyper\.exceptions\.\w+Exception:\s+(?:line\s+(\d+)).*$/gm.exec(errormsg)
195-
if (matches && matches.length > 0) {
196-
shortmsg = matches[0]
197-
if (matches.length >= 2) {
198-
lineNr = parseInt(matches[1])
199-
}
200-
}
201-
202-
203-
}
204-
if (errormsg) {
205-
diagnosticCollections.compiler.set(contractFile, [{
206-
code: '',
207-
message: shortmsg,
208-
range: new vscode.Range(new vscode.Position(lineNr - 1, 0), new vscode.Position(lineNr - 1, 255)),
209-
severity: vscode.DiagnosticSeverity.Error,
210-
source: errormsg,
211-
relatedInformation: []
212-
}]);
213-
}
214-
},
215170
(success) => {
216171
diagnosticCollections.compiler.delete(contractFile);
217172
diagnosticCollections.mythx.delete(contractFile);
@@ -283,6 +238,49 @@ function compileActiveFileCommand(contractFile) {
283238
})
284239
}
285240
}
241+
},
242+
(errormsg) => {
243+
diagnosticCollections.compiler.delete(contractFile);
244+
diagnosticCollections.mythx.delete(contractFile);
245+
vscode.window.showErrorMessage('[Compiler Error] ' + errormsg);
246+
let lineNr = 1; // add default errors to line 0 if not known
247+
let matches = /(?:line\s+(\d+))/gm.exec(errormsg)
248+
if (matches && matches.length==2){
249+
//only one line ref
250+
lineNr = parseInt(matches[1])
251+
}
252+
253+
let lines = errormsg.split(/\r?\n/)
254+
console.log(errormsg)
255+
let shortmsg = lines[0]
256+
257+
// IndexError
258+
if (lines.indexOf("SyntaxError: invalid syntax") > -1) {
259+
let matches = /line (\d+)/gm.exec(errormsg)
260+
if (matches.length >= 2) {
261+
lineNr = parseInt(matches[1])
262+
}
263+
shortmsg = "SyntaxError: invalid syntax";
264+
} else {
265+
//match generic vyper exceptions
266+
let matches = /vyper\.exceptions\.\w+Exception:\s+(?:line\s+(\d+)).*$/gm.exec(errormsg)
267+
if (matches && matches.length > 0) {
268+
shortmsg = matches[0]
269+
if (matches.length >= 2) {
270+
lineNr = parseInt(matches[1])
271+
}
272+
}
273+
}
274+
if (errormsg) {
275+
diagnosticCollections.compiler.set(contractFile, [{
276+
code: '',
277+
message: shortmsg,
278+
range: new vscode.Range(new vscode.Position(lineNr - 1, 0), new vscode.Position(lineNr - 1, 255)),
279+
severity: vscode.DiagnosticSeverity.Error,
280+
source: errormsg,
281+
relatedInformation: []
282+
}]);
283+
}
286284
}
287285
)
288286
.catch(ex => {
@@ -292,7 +290,7 @@ function compileActiveFileCommand(contractFile) {
292290
}
293291

294292
function compileActiveFile(contractFile) {
295-
return new Promise((reject, resolve) => {
293+
return new Promise((resolve, reject) => {
296294
if (!contractFile && vscode.window.activeTextEditor.document.languageId !== VYPER_ID) {
297295
reject("Not a vyper source file")
298296
return;

Diff for: src/features/signatures.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
'use strict'
12
/**
23
* @author github.com/tintinweb
34
* @license MIT
45
*
56
* */
67

7-
class VyperSignatureHelpProvider{
8+
class VyperSignatureHelpProvider {
89
provideSignatureHelp(document, position, token, context){
910
return new Promise((resolve, reject) => {
1011
position = position.translate(0, -1)

0 commit comments

Comments
 (0)