INVALID_FORMAT
}
+
+
// static array of all projects.
private Gee.ArrayList<Project> projects;
public bool projects_loaded = false;
-
+ // used to pass around callbacks with project as a return
+ public class Callback : Object {
+ public signal void call(Project project);
+ }
+
public abstract class Project : Object {
public signal void on_changed ();
private bool is_scanned = false;
public Gee.HashMap<string,Palete.GirObject> gir_cache = null; // used by Gir ??? is this used by Roo?
- public Palete.ValaCompileRequest last_request = null;
+ //public Palete.ValaCompileRequest last_request = null; // depricated?
+ public Gee.HashMap<string,GLib.ListStore>? errorsByType = null;
+
+
+
+ protected Gee.HashMap<string,Palete.LanguageClient> language_servers;
protected Project (string path) {
//XObject.extend(this, cfg);
//this.files = { };
this.path = path;
-
-
+ this.language_servers = new Gee.HashMap<string,Palete.LanguageClient>();
+ this.language_servers.set("dummy", new Palete.LanguageClientDummy(this));
+ this.errorsByType = new Gee.HashMap<string,GLib.ListStore>();
}
try {
dir.make_directory();
} catch(GLib.Error e) {
- GLib.error("could not make builder directory");
+ GLib.error("could not make builder directory %s", e.message);
}
return;
}
public void save()
{
- // fixme..
-
-
-
-
-
- //var dirname = GLib.Environment.get_home_dir() + "/.Builder";
-
+
var s = this.toJSON();
GLib.debug("Save Project %s\n%s", this.name, s);
try {
} catch (GLib.Error e) {
GLib.error("failed to save file %s", e.message);
}
+ this.onSave();
}
}
GLib.debug("load is_scanned = false");
+
+ // used to load paths..
+ this.sub_paths = new Gee.ArrayList<JsRender.JsRender>();
+ this.files = new Gee.HashMap<string,JsRender.JsRender>();
+ this.loadSubDirectories("", 0); // must happend before loadJson! (as compile groups checks if file exists.
+
+
+
if (FileUtils.test(this.path + "/.roobuilder.jcfg", FileTest.EXISTS)) {
var pa = new Json.Parser();
this.loadJson(obj);
}
- // used to load paths..
- this.sub_paths = new Gee.ArrayList<JsRender.JsRender>();
- this.files = new Gee.HashMap<string,JsRender.JsRender>();
- this.loadSubDirectories("", 0);
-
- this.initDatabase();
+ this.initDatabase();
this.is_scanned = true; // loaded.. dont need to do it again..
GLib.debug("load is_scanned = true");
}
- public abstract void loadJson(Json.Object obj);
- public abstract void saveJson(Json.Object obj);
/*
- public JsRender.JsRender? getByName(string name)
+ public JsRender.JsRender? getByRelPath(string relpath)
{
foreach(var f in this.files.values) {
- if (f.name == name) {
+ if (f.relpath == relpath || f.relTargetName() == relpath) {
return f;
}
};
// keys are not paths...
foreach(var f in this.files.values) {
+ //GLib.debug("check %s = %s ? %s", path, f.path, f.targetName());
if (f.path == path || f.targetName() == path) {
return f;
}
subs.add(dir + "/" + fn);
continue;
}
- if (Regex.match_simple("\\.(o|cache|gif|jpg|png|gif|out|stamp|~)$", fn)) { // object..
+ if (Regex.match_simple("\\.(o|cache|out|stamp|~)$", fn)) { // object..
continue;
}
if (Regex.match_simple("^(config1.builder|a.out|stamp-h1|depcomp|config.log|config.status)$", fn)) { // object..
}
// calle dfrom new file dialog
- // add files to dires
+ // add files to dires (and main file list)
// update
}
var sp = this.findDir(pfile.dir);
sp.childfiles.append(pfile);
-
-
+ this.files.set(pfile.path, pfile);
+
this.on_changed();
}
file.remove();
+ this.save();
+
// remove it from
return false;
}
- public void loadDirsToStringList( global::Gtk.StringList sl)
+
+ public void loadDirsToStringList( global::Gtk.StringList sl, string prefix)
{
while (sl.get_n_items() > 0) {
}
foreach(var sp in this.sub_paths) {
-
- sl.append( sp.path == this.path ? "/" : sp.path.substring(this.path.length));
+ var add = sp.path == this.path ? "/" : sp.path.substring(this.path.length);
+ if (prefix.length > 0 && !add.has_prefix(prefix)) {
+ continue;
+ }
+ sl.append(add);
}
}
return ret;
}
-
- public abstract void initDatabase();
- public abstract void initialize(); // for new projects (make dirs?);
+ public void updateErrorsforFile(JsRender.JsRender? f)
+ {
+ if (f != null) {
+ var n = this.updateErrorsByType(f, "WARN");
+ n += this.updateErrorsByType(f, "ERR");
+ n += this.updateErrorsByType(f, "DEPR");
+ }
+
+ BuilderApplication.updateCompileResults();
+
+
+ }
+ public int updateErrorsByType(JsRender.JsRender f, string n)
+ {
+ var ls = this.getErrors(n);
+
+ // remove thie file from the list.
+ for(var i =0; i < ls.get_n_items(); i++) {
+ var ce = ls.get_item(i) as Palete.CompileError;
+ if (ce.file.path == f.path) {
+ ls.remove(i);
+ break;
+ }
+ }
+ var add = new Palete.CompileError.new_from_file(f, n);
+ if (add.hasErrors()) {
+ ls.append(add);
+ return 1;
+ }
+ return 0;
+ }
+ public GLib.ListStore getErrors(string n)
+ {
+ var ls = this.errorsByType.get(n);
+ if (ls == null) {
+ ls = new GLib.ListStore(typeof(Palete.CompileError));
+ this.errorsByType.set(n, ls );
+ }
+ return ls;
+ }
+
+
+ public abstract Palete.LanguageClient getLanguageServer(string lang);
+
+
+ public abstract void onSave(); // write meson?
+ public abstract void initDatabase();
+ public abstract void initialize(); // for new projects (make dirs?);
+ public abstract void loadJson(Json.Object obj);
+ public abstract void saveJson(Json.Object obj);
}
}