Gee.ArrayList<string> top_classes;
public static Gee.HashMap<string,GirObject>? classes_cache = null;
-
+ public static Gee.ArrayList<string>? top_classes_cache = null;
+
public Roo(Project.Project project)
{
aconstruct(project);
this.name = "Roo";
this.top_classes = new Gee.ArrayList<string>();
+
+
this.load(); // ? initialize the roodata?
+
}
Gee.HashMap<string,GirObject> propsFromJSONArray(string type, Json.Array ar, GirObject cls)
}
if (Roo.classes_cache != null) {
this.classes = Roo.classes_cache;
+ this.top_classes = Roo.top_classes_cache ;
return;
}
- // this.loadUsageFile(BuilderApplication.configDirectory() + "/resources/RooUsage.txt");
+
this.classes = new Gee.HashMap<string,GirObject>();
var add_to = new Gee.HashMap<string,Gee.ArrayList<string>>();
-
+
+ var f = GLib. File.new_for_path(BuilderApplication.configDirectory() + "/resources/roodata.json");
+ if (!f.query_exists(null)) {
+ f = GLib. File.new_for_uri("resources:///data/roodata.json");
+ }
+
+
+
var pa = new Json.Parser();
- pa.load_from_file(BuilderApplication.configDirectory() + "/resources/roodata.json");
+ try {
+ uint8[] data;
+ f.load_contents( null, out data, null );
+ pa.load_from_data((string) data);
+ } catch(GLib.Error e) {
+ GLib.error("Could not load %s",f.get_uri());
+ }
var node = pa.get_root();
var clist = node.get_object(); /// was in data... .get_object_member("data");
cls.can_drop_onto = add_to.get(cls.name);
}
}
- Roo.classes_cache = classes;
+ Roo.classes_cache = this.classes;
+ Roo.top_classes_cache = this.top_classes;
}
}
+
+
public override Gee.HashMap<string,GirObject> getPropertiesFor(string ename, JsRender.NodePropType ptype)
{
//print("Loading for " + ename);
case JsRender.NodePropType.CTOR:
return ret;
default:
- throw new Error.INVALID_VALUE( "getPropertiesFor called with: " + ptype.to_string());
+ GLib.error( "getPropertiesFor called with: " + ptype.to_string());
//var ret = new Gee.HashMap<string,GirObject>();
//return ret;
}
+ // removes all the properties where the type contains '.' ?? << disabled now..
public Gee.HashMap<string,GirObject> filterProps(Gee.HashMap<string,GirObject> props)
{
}
- if (!val.type.contains(".")) {
+ //if (!val.type.contains(".")) {
outprops.set(k,val);
continue;
- }
+ //}
}
-
- public override void on_child_added(JsRender.Node? parent,JsRender.Node child)
- {
-
- return;
- }
+
/*
* Pulldown options for type
*/
return true;
}
- public override List<SourceCompletionItem> suggestComplete(
- JsRender.JsRender file,
- JsRender.Node? node,
- JsRender.NodeProp? xxprop,
- string complete_string
- ) {
-
- var ret = new List<SourceCompletionItem>();
- // completion rules??
-
- // Roo......
-
- // this. (based on the node type)
- // this.xxx // Node and any determination...
-
- if (complete_string.index_of(".",0) < 0) {
- // string does not have a '.'
- // offer up this / Roo / javascript keywords... / look for var string = .. in the code..
- for(var i = 0; i < JsRender.Lang.match_strings.size ; i++) {
- var str = JsRender.Lang.match_strings.get(i);
- if (complete_string != str && str.index_of(complete_string,0) == 0 ) { // should we ignore exact matches... ???
- ret.append(new SourceCompletionItem (str, str, null, "javascript : " + str));
- }
-
-
- }
- if (complete_string != "Roo" && "Roo".index_of(complete_string,0) == 0 ) { // should we ignore exact matches... ???
- ret.append(new SourceCompletionItem ("Roo - A Roo class", "Roo", null, "Roo library"));
- }
- if (complete_string != "_this" && "_this".index_of(complete_string,0) == 0 ) { // should we ignore exact matches... ???
- ret.append(new SourceCompletionItem ("_this - the top level element", "_this", null, "Top level element"));
- }
- return ret;
- }
- // got at least one ".".
- var parts = complete_string.split(".");
- var curtype = "";
- var cur_instance = false;
- if (parts[0] == "this") {
- // work out from the node, what the type is...
- if (node == null) {
- print("node is empty - no return\n");
- return ret; // no idea..
- }
- curtype = node.fqn();
- cur_instance = true;
- }
- if (parts[0] == "Roo") {
- curtype = "Roo";
- cur_instance = false;
- }
-
- var prevbits = parts[0] + ".";
- for(var i =1; i < parts.length; i++) {
- print("matching %d/%d\n", i, parts.length);
- var is_last = i == parts.length -1;
-
- // look up all the properties of the type...
- var cls = this.getClass(curtype);
- if (cls == null) {
- print("could not get class of curtype %s\n", curtype);
- return ret;
- }
-
- if (!is_last) {
-
- // only exact matches from here on...
- if (cur_instance) {
- if (cls.props.has_key(parts[i])) {
- var prop = cls.props.get(parts[i]);
- if (prop.type.index_of(".",0) > -1) {
- // type is another roo object..
- curtype = prop.type;
- prevbits += parts[i] + ".";
- continue;
- }
- return ret;
- }
-
-
-
- // check methods?? - we do not export that at present..
- return ret; //no idea...
- }
-
- // not a instance..
- //look for child classes.
- var citer = this.classes.map_iterator();
- var foundit = false;
- while (citer.next()) {
- var scls = citer.get_key();
- var look = prevbits + parts[i];
- if (scls.index_of(look,0) != 0) {
- continue;
- }
- // got a starting match..
- curtype = look;
- cur_instance = false;
- foundit =true;
- break;
- }
- if (!foundit) {
- return ret;
- }
- prevbits += parts[i] + ".";
- continue;
- }
- // got to the last element..
- print("Got last element\n");
- if (curtype == "") { // should not happen.. we would have returned already..
- return ret;
- }
- print("Got last element type %s\n",curtype);
- if (!cur_instance) {
- print("matching instance");
- // it's a static reference..
- var citer = this.classes.map_iterator();
- while (citer.next()) {
- var scls = citer.get_key();
- var look = prevbits + parts[i];
- if (parts[i].length > 0 && scls.index_of(look,0) != 0) {
- continue;
- }
- // got a starting match..
- ret.append(new SourceCompletionItem (
- scls,
- scls,
- null,
- scls));
- }
- return ret;
- }
- print("matching property");
-
-
-
- var citer = cls.methods.map_iterator();
- while (citer.next()) {
- var prop = citer.get_value();
- // does the name start with ...
- if (parts[i].length > 0 && prop.name.index_of(parts[i],0) != 0) {
- continue;
- }
- // got a matching property...
- // return type?
- ret.append(new SourceCompletionItem (
- prop.name + prop.sig + " : ("+ prop.propertyof + ")",
- prevbits + prop.name + "(",
- null,
- prop.doctxt));
- }
-
- // get the properties / methods and subclasses.. of cls..
- // we have cls.. - see if the string matches any of the properties..
- citer = cls.props.map_iterator();
- while (citer.next()) {
- var prop = citer.get_value();
- // does the name start with ...
- if (parts[i].length > 0 && prop.name.index_of(parts[i],0) != 0) {
- continue;
- }
- // got a matching property...
-
- ret.append(new SourceCompletionItem (
- prop.name + " : " + prop.type + " ("+ prop.propertyof + ")",
- prevbits + prop.name,
- null,
- prop.doctxt));
- }
-
-
- return ret;
-
-
-
-
-
- }
-
-
-
-
-
-
- return ret;
- }
- public override string[] getChildList(string in_rval)
+
+
+
+ public override Gee.ArrayList<string> getChildList(string in_rval, bool with_prop)
{
if (this.top_classes.size < 1) {
this.load();
}
-
-
- string[] ret = {};
+
+
+
var ar = this.top_classes;
if (in_rval != "*top") {
if (this.classes.has_key(in_rval)) {
}
}
- foreach(var str in ar) {
- ret += str;
- }
- GLib.debug("getChildList for %s returns %s", in_rval, string.joinv(", ", ret));
- return ret;
+ if (!with_prop) {
+ var ret = new Gee.ArrayList<string>();
+ foreach(var v in ar) {
+ if (v.contains(":")) {
+ continue;
+ }
+ ret.add(v);
+ }
+ return ret;
+ }
+
+ GLib.debug("getChildList for %s returns %d items", in_rval, ar.size);
+ return ar;
//return this.original_getChildList( in_rval);
}
- public override string[] getDropList(string rval)
+
+
+
+ public override Gee.ArrayList<string> getDropList(string rval)
{
+
+ if (this.dropCache.has_key(rval)) {
+ return this.dropCache.get(rval);
+ }
// we might be dragging Roo.bootstrap.layout.Region:center
// in which case we need to lookup Roo.bootstrap.layout.Region
// and see if it's has can_drop_onto
- string[] ret = {};
+ var ret = new Gee.ArrayList<string>();
var cls = this.classes.get(rval);
// cls can be null.
if (cls == null && rval.contains(":")) {
}
foreach(var str in cls.can_drop_onto) {
-
- ret += str;
+ ret.add(str);
+ }
+ if (this.top_classes.contains(rval)) {
+ ret.add("*top");
}
- GLib.debug("getDropList for %s return[] %s", rval, string.joinv(", ", ret));
+ //GLib.debug("getDropList for %s return[] %s", rval, string.joinv(", ", ret));
+ this.dropCache.set(rval,ret);
return ret;
//return this.default_getDropList(rval);
}
+ public override JsRender.Node fqnToNode(string fqn)
+ {
+ var ret = new JsRender.Node();
+ ret.setFqn(fqn);
+ // any default requred proerties?
+
+ return ret;
+
+
+
+ }
+
}
+
+
+
+
+
}