mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-16 17:30:27 +00:00
ui: click on errors to go to line; fixed mainpath -> mainPath
This commit is contained in:
parent
502ee5de0f
commit
17f99b34d4
@ -168,6 +168,9 @@ div.has-errors {
|
||||
div.is-busy-unused {
|
||||
background-color: #8888bb !important;
|
||||
}
|
||||
#error_alert_msg {
|
||||
margin-right: 2em;
|
||||
}
|
||||
div.menu_div {
|
||||
position: absolute;
|
||||
width: 200px;
|
||||
|
@ -16,8 +16,6 @@ export class CodeProject {
|
||||
filedata : {[path:string]:FileData} = {};
|
||||
listings : CodeListingMap;
|
||||
segments : Segment[];
|
||||
// TODO: mainpath and mainPath !??!!?
|
||||
mainpath : string;
|
||||
mainPath : string;
|
||||
pendingWorkerMessages = 0;
|
||||
tools_preloaded = {};
|
||||
@ -72,7 +70,7 @@ export class CodeProject {
|
||||
// look for local and preset files
|
||||
files.push(fn);
|
||||
// look for files in current (main file) folder
|
||||
var dir = getFolderForPath(this.mainpath);
|
||||
var dir = getFolderForPath(this.mainPath);
|
||||
if (dir.length > 0 && dir != 'local') // TODO
|
||||
files.push(dir + '/' + fn);
|
||||
}
|
||||
@ -161,14 +159,14 @@ export class CodeProject {
|
||||
|
||||
// TODO: test duplicate files, local paths mixed with presets
|
||||
buildWorkerMessage(depends:Dependency[]) {
|
||||
this.preloadWorker(this.mainpath);
|
||||
this.preloadWorker(this.mainPath);
|
||||
var msg = {updates:[], buildsteps:[]};
|
||||
// TODO: add preproc directive for __MAINFILE__
|
||||
var mainfilename = this.stripLocalPath(this.mainpath);
|
||||
var maintext = this.getFile(this.mainpath);
|
||||
var mainfilename = this.stripLocalPath(this.mainPath);
|
||||
var maintext = this.getFile(this.mainPath);
|
||||
var depfiles = [];
|
||||
msg.updates.push({path:mainfilename, data:maintext});
|
||||
this.filename2path[mainfilename] = this.mainpath;
|
||||
this.filename2path[mainfilename] = this.mainPath;
|
||||
for (var dep of depends) {
|
||||
if (!dep.link) {
|
||||
msg.updates.push({path:dep.filename, data:dep.data});
|
||||
@ -176,12 +174,21 @@ export class CodeProject {
|
||||
}
|
||||
this.filename2path[dep.filename] = dep.path;
|
||||
}
|
||||
msg.buildsteps.push({path:mainfilename, files:[mainfilename].concat(depfiles), platform:this.platform_id, tool:this.platform.getToolForFilename(this.mainpath), mainfile:true});
|
||||
msg.buildsteps.push({
|
||||
path:mainfilename,
|
||||
files:[mainfilename].concat(depfiles),
|
||||
platform:this.platform_id,
|
||||
tool:this.platform.getToolForFilename(this.mainPath),
|
||||
mainfile:true});
|
||||
for (var dep of depends) {
|
||||
if (dep.data && dep.link) {
|
||||
this.preloadWorker(dep.filename);
|
||||
msg.updates.push({path:dep.filename, data:dep.data});
|
||||
msg.buildsteps.push({path:dep.filename, files:[dep.filename].concat(depfiles), platform:this.platform_id, tool:this.platform.getToolForFilename(dep.path)});
|
||||
msg.buildsteps.push({
|
||||
path:dep.filename,
|
||||
files:[dep.filename].concat(depfiles),
|
||||
platform:this.platform_id,
|
||||
tool:this.platform.getToolForFilename(dep.path)});
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
@ -260,8 +267,8 @@ export class CodeProject {
|
||||
}
|
||||
|
||||
sendBuild() {
|
||||
if (!this.mainpath) throw Error("need to call setMainFile first");
|
||||
var maindata = this.getFile(this.mainpath);
|
||||
if (!this.mainPath) throw Error("need to call setMainFile first");
|
||||
var maindata = this.getFile(this.mainPath);
|
||||
// if binary blob, just return it as ROM
|
||||
if (maindata instanceof Uint8Array) {
|
||||
this.isCompiling = true;
|
||||
@ -288,14 +295,14 @@ export class CodeProject {
|
||||
updateFile(path:string, text:FileData) {
|
||||
this.updateFileInStore(path, text); // TODO: isBinary
|
||||
this.filedata[path] = text;
|
||||
if (this.okToSend() && this.mainpath) {
|
||||
if (this.okToSend() && this.mainPath) {
|
||||
if (this.callbackBuildStatus) this.callbackBuildStatus(true);
|
||||
this.sendBuild();
|
||||
}
|
||||
};
|
||||
|
||||
setMainFile(path:string) {
|
||||
this.mainpath = path;
|
||||
this.mainPath = path;
|
||||
if (this.callbackBuildStatus) this.callbackBuildStatus(true);
|
||||
this.sendBuild();
|
||||
}
|
||||
|
@ -1066,14 +1066,34 @@ async function updateSelector() {
|
||||
});
|
||||
}
|
||||
|
||||
function getErrorElement(err : WorkerError) {
|
||||
var span = $('<p/>');
|
||||
if (err.path != null) {
|
||||
var s = err.line ? `(${err.path}:${err.line})` : `(${err.path})`
|
||||
var link = $('<a/>').text(s);
|
||||
var path = err.path;
|
||||
// TODO: hack because examples/foo.a only gets listed as foo.a
|
||||
if (path == getCurrentMainFilename()) path = current_project.mainPath;
|
||||
// click link to open file, if it's available...
|
||||
if (projectWindows.isWindow(path)) {
|
||||
link.click((ev) => {
|
||||
var wnd = projectWindows.createOrShow(path);
|
||||
if (wnd instanceof Views.SourceEditor) {
|
||||
wnd.setCurrentLine(err.line, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
span.append(link);
|
||||
span.append(' ');
|
||||
}
|
||||
span.append($('<span/>').text(err.msg));
|
||||
return span;
|
||||
}
|
||||
|
||||
function showErrorAlert(errors : WorkerError[]) {
|
||||
var div = $("#error_alert_msg").empty();
|
||||
for (var err of errors.slice(0,10)) {
|
||||
var s = '';
|
||||
if (err.path) s += err.path + ":";
|
||||
if (err.line) s += err.line + ":";
|
||||
s += err.msg;
|
||||
div.append($("<p>").text(s));
|
||||
div.append(getErrorElement(err));
|
||||
}
|
||||
$("#error_alert").show();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user