aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/golang.js
diff options
context:
space:
mode:
authorRabsRincon <rubrinbla@gmail.com>2017-12-19 17:12:43 +0100
committerRabsRincon <rubrinbla@gmail.com>2017-12-19 17:13:10 +0100
commitbe42a844d03fb33ebed390d57dbc107d5fc6cf6e (patch)
tree72008d3ab2536e68064f35877eae32136c5fa77c /lib/compilers/golang.js
parentbffba4e90c89d5e8ec5d93c5eaf09788416d33b2 (diff)
downloadcompiler-explorer-be42a844d03fb33ebed390d57dbc107d5fc6cf6e.tar.gz
compiler-explorer-be42a844d03fb33ebed390d57dbc107d5fc6cf6e.zip
Fix Go line highlight
Diffstat (limited to 'lib/compilers/golang.js')
-rw-r--r--lib/compilers/golang.js29
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/compilers/golang.js b/lib/compilers/golang.js
index a60920892..4afb4dfbf 100644
--- a/lib/compilers/golang.js
+++ b/lib/compilers/golang.js
@@ -22,34 +22,33 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
-var Compile = require('../base-compiler');
-var _ = require('underscore-node');
+const Compile = require('../base-compiler'),
+ _ = require('underscore-node');
function compilenewgol(info, env) {
- var compiler = new Compile(info, env);
+ const compiler = new Compile(info, env);
compiler.originalGetDefaultExecOptions = compiler.getDefaultExecOptions;
function convertNewGoL(code) {
- var re = /^\s+(0[xX]?[0-9A-Za-z]+)?\s?[0-9]+\s*\(([^:]+):([0-9]+)\)\s*([A-Z]+)(.*)/;
- var prevLine = null;
- var file = null;
- var fileCount = 1;
+ const re = /^\s+(0[xX]?[0-9A-Za-z]+)?\s?[0-9]+\s*\(([^:]+):([0-9]+)\)\s*([A-Z]+)(.*)/;
+ let prevLine = null;
+ let file = null;
+ let fileCount = 0;
return code.map(function (obj) {
- var line = obj.text;
- var match = line.match(re);
+ const line = obj.text;
+ const match = line.match(re);
if (match) {
- var res = "";
+ let res = "";
if (file !== match[2]) {
+ fileCount++;
res += "\t.file " + fileCount + ' "' + match[2] + '"\n';
file = match[2];
- fileCount++;
}
if (prevLine !== match[3]) {
res += "\t.loc " + fileCount + " " + match[3] + " 0\n";
prevLine = match[3];
}
- var ret = res + "\t" + match[4].toLowerCase() + match[5];
- return ret;
+ return res + "\t" + match[4].toLowerCase() + match[5];
} else
return null;
}).filter(_.identity).join("\n");
@@ -70,8 +69,8 @@ function compilenewgol(info, env) {
};
compiler.getDefaultExecOptions = function () {
- var execOptions = this.originalGetDefaultExecOptions();
- var goroot = this.env.compilerProps("compiler." + this.compiler.id + ".goroot");
+ const execOptions = this.originalGetDefaultExecOptions();
+ const goroot = this.env.compilerProps("compiler." + this.compiler.id + ".goroot");
if (goroot) {
execOptions.env.GOROOT = goroot;
}