Skip to content

Commit a67f1bb

Browse files
author
cheikhshift
committed
Add initial frontend support for parsing govet and golint logs
1 parent 347f56a commit a67f1bb

File tree

4 files changed

+106
-39
lines changed

4 files changed

+106
-39
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Just a Go IDE. It features :
1616
- Build docker images (Must have docker running on host) .
1717
- Breakpoints and debugging with Delve.
1818
- Regex directory search.
19+
- Automatically lints your code in the background, and suggests code fixes.
1920
## Requirements
2021
- Go v1.15+.
2122
- Git. Git present as a command on your system.

api/assets/bindata.go

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

tmpl/js.tmpl

Lines changed: 99 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</button>
1111
</div>
1212
<div class="modal-body">
13-
<p>Welcome to the Strukture! To get started enter a username that will be with chat.</p>
13+
<p>Welcome to the Strukture! To get started enter a username that will be used for chat.</p>
1414
<hr>
1515
<p><input type="text" class="form-control username-input" name="" placeholder="username"></p>
1616
</div>
@@ -61,7 +61,7 @@
6161
}
6262

6363
if(!window.localStorage["struktureid"]){
64-
window.localStorage.struktureid = `makeid()-makeid()-(new Date()).getTime()`;
64+
window.localStorage.struktureid = `${makeid()}-${makeid()}-${(new Date()).getTime()}`;
6565
}
6666

6767
} catch(e) {
@@ -362,6 +362,99 @@
362362
}
363363
langTools.addCompleter(autoCompleter);
364364

365+
function vetAndLint(id,pkg, path){
366+
resetVetter(id)
367+
let file = path
368+
let lineArr = {}
369+
$.ajax({type : "POST", data : {
370+
pkg
371+
} ,url: "/api/govet", success:function(html){
372+
373+
let cText = html.Text.split("\n")
374+
375+
for(var i = 1; i < cText.length;i++){
376+
377+
let line = cText[i]
378+
379+
if ( line.includes(file) ){
380+
let lineParts = line.split(":")
381+
if( lineParts[2] ){
382+
let lastBit = lineParts[ lineParts.length - 1]
383+
console.log(lineParts[2], lastBit)
384+
if(!lineArr[lineParts[2]]){
385+
lineArr[ lineParts[2] ] = []
386+
}
387+
388+
lineArr[ lineParts[2] ].push(lastBit)
389+
390+
}
391+
}
392+
}
393+
394+
$(".ace_gutter-cell", "#" + id).each(function(e,i){
395+
let key = $(this).text().trim()
396+
397+
if (lineArr[key] && !$("i", this).length ){
398+
$(this).attr("style", "height:12px;background:yellow;")
399+
$(this).attr("title", lineArr[key].join("\n"))
400+
401+
}
402+
})
403+
404+
} });
405+
406+
407+
$.ajax({type : "POST", data : {
408+
pkg,
409+
path
410+
},url: "/api/golint", success:function(html){
411+
412+
let cText = html.Text.split("\n")
413+
414+
for(var i = 0; i < cText.length;i++){
415+
416+
let line = cText[i]
417+
418+
if ( line.includes(file) ){
419+
let lineParts = line.split(":")
420+
if( lineParts[1] ){
421+
let lastBit = lineParts[ lineParts.length - 1]
422+
console.log(lineParts[1], lastBit)
423+
if(!lineArr[lineParts[1]]){
424+
lineArr[ lineParts[1] ] = []
425+
}
426+
427+
lineArr[ lineParts[1] ].push(lastBit)
428+
429+
}
430+
}
431+
}
432+
console.log(lineArr)
433+
$(".ace_gutter-cell", "#" + id).each(function(e,i){
434+
let key = $(this).text().trim()
435+
436+
if (lineArr[key] && !$("i", this).length ){
437+
$(this).attr("style", "height:12px;background:yellow;")
438+
$(this).attr("title", lineArr[key].join("\n"))
439+
440+
}
441+
})
442+
443+
} });
444+
}
445+
446+
function resetVetter(id){
447+
$(".ace_gutter-cell", "#" + id).each(function(e,i){
448+
449+
if ( $("i", this).length )
450+
return
451+
452+
let el = $(this)
453+
el.attr("style", "height:12px")
454+
el.attr("title", null)
455+
})
456+
}
457+
365458

366459
function ClearSideBay(){
367460
$(".side-bay").html("");
@@ -708,9 +801,13 @@
708801

709802
if(!custom_data)
710803
$(".side-bay").html(html);
804+
805+
vetAndLint(editor, pkv, link)
711806
},error:function(e){
712807
if(!custom_data)
713808
$(".side-bay").html(e.responseText);
809+
810+
vetAndLint(editor, pkv, link)
714811
}
715812
});
716813
}

tmpl/ui/user/panel/webtwo.tmpl

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -130,42 +130,11 @@
130130

131131
editorPaths['{{.PKG}} - {{.SavesTo}}'.replace("\\", "/")] = editors["{{.ID}}"];
132132

133-
function vetAndLint(){
134-
let file = {{ .SavesTo }}
135-
$.ajax({type : "POST", data : {
136-
pkg : {{ .PKG }}
137-
} ,url: "/api/govet", success:function(html){
138-
139-
let cText = html.Text.split("\n")
140-
141-
for(var i = 1; i < cText.length;i++){
142-
143-
let line = cText[i]
144-
145-
if ( line.includes(file) ){
146-
let lineParts = line.split(":")
147-
if( lineParts[2] ){
148-
let lastBit = lineParts[ lineParts.length - 1]
149-
console.log(lineParts[2], lastBit)
150-
151-
}
152-
}
153-
}
154-
} });
155-
156-
157-
$.ajax({type : "POST", data : {
158-
pkg : {{ .PKG }},
159-
path : {{ .SavesTo }}
160-
},url: "/api/golint", success:function(html){
161-
console.log(html)
162-
} });
163-
}
164-
133+
165134
setTimeout(function(){
166135

167136

168-
vetAndLint()
137+
vetAndLint('{{ .ID }}', '{{ .PKG }}','{{ .SavesTo }}')
169138

170139

171140
$.ajax({url: "/api/pkg-bugs?pkg=" + {{.PKG}}, success:function(html){

0 commit comments

Comments
 (0)